In [1]:
import pyhmc
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import time
import subprocess
import os
In [2]:
J = 1.
H = 0
kb = 1.
T = 1.0
dims = np.array([10, 10, 10])
Nsamp = 10000
eps = 0.01
In [3]:
start = time.time()
res = pyhmc.simulate(J, H, kb, T, dims, Nsamp, eps)
end = time.time()
print(end - start)
In [4]:
plt.plot(res['magnetisation'])
Out[4]:
In [5]:
plt.plot(res['energy'])
Out[5]:
In [6]:
start = time.time()
with open('testin.txt', 'w') as f:
f.write(str(Nsamp) + "\n")
f.write(str(dims[0]) + "\n")
f.write(str(dims[1]) + "\n")
f.write(str(dims[2]) + "\n")
f.write(str(H) + "\n")
f.write(str(J) + "\n")
f.write(str(1/(kb*T)) + "\n")
f.write(str(eps) + "\n")
subprocess.call("../main")
res2 = np.loadtxt("testout.txt")
end = time.time()
print(end - start)
In [7]:
plt.plot(res2[:, 1])
Out[7]:
In [8]:
plt.plot(res2[:,0])
Out[8]:
In [ ]: