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)


114.47310853004456

In [4]:
plt.plot(res['magnetisation'])


Out[4]:
[<matplotlib.lines.Line2D at 0x7f1181fa3470>]

In [5]:
plt.plot(res['energy'])


Out[5]:
[<matplotlib.lines.Line2D at 0x7f1181ed8080>]

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)


109.81287050247192

In [7]:
plt.plot(res2[:, 1])


Out[7]:
[<matplotlib.lines.Line2D at 0x7f1181d2c048>]

In [8]:
plt.plot(res2[:,0])


Out[8]:
[<matplotlib.lines.Line2D at 0x7f1181e5ffd0>]

In [ ]: