temperature approaches T_c = 2.269. """ from numpy import vstack, linspace, array from pylab import plot, legend, show from latgas import lattice from latgas.lattice import Lattice, Potential, System M_t = None E_t = None sizes = [1000, 500, 200, 100] for sz in sizes: inter = lambda r: -4 lattice = Lattice(sz, dim = 2) potential = Potential(inter, 1.0, 5) sys = System(lattice, potential) sys.set_mu(8.0) E = [] N = [] temp = linspace(2.5, 2.0, 26) for i in temp: print i sys.set_T(i) ee, nn = sys.run(1000) ee, nn = sys.run(1000) E.append(ee) N.append(nn) E = array(E) N = array(N) M = -(2*N - sz**2)/(sz**2)
in python). We can eventually add an "autocorrelation" measure to compare times. """ #!/usr/bin/env python from latgas import lattice from latgas.lattice import Lattice, Potential, System from time import time from pylab import plot, legend, xlabel, ylabel, show from numpy import array sz = 30 inter = lambda r: -4 lattice = Lattice(sz, dim = 2) potential = Potential(inter, 1.0, 5) sys = System(lattice, potential) sys.set_mu(8.0) sys.set_T(20.0) steps = range(1, 201) Trun = [] Tpy = [] Tc = [] for i in steps: print i t1 = time() for j in xrange(i): sys.whole_lattice() t2 = time() Tpy.append(1000*(t2-t1))
in python). We can eventually add an "autocorrelation" measure to compare times. """ #!/usr/bin/env python from latgas import lattice from latgas.lattice import Lattice, Potential, System from time import time from pylab import plot, legend, xlabel, ylabel, show from numpy import array sz = 30 inter = lambda r: -4 lattice = Lattice(sz, dim=2) potential = Potential(inter, 1.0, 5) sys = System(lattice, potential) sys.set_mu(8.0) sys.set_T(20.0) steps = range(1, 201) Trun = [] Tpy = [] Tc = [] for i in steps: print i t1 = time() for j in xrange(i): sys.whole_lattice() t2 = time() Tpy.append(1000 * (t2 - t1)) t1 = time()
#!/usr/bin/env python """ test that everything works This should be superseeded by an eventual unittesting """ from latgas import lattice from latgas.lattice import Lattice, Potential, System sz = 30 def inter(r): if r <= 1.0: return -4 if r <= 3.0: return 1 lattice = Lattice(sz, dim = 2) potential = Potential(inter, 3.0, 20) sys = System(lattice, potential) sys.lattice.random(1) sys.set_mu(8.0) sys.set_T(20.0) sys.N = sys.tot_population() sys.E = sys.tot_energy() sys.run(3000) print "E = {0}, N = {1}".format(sys.E, sys.N)
temperature approaches T_c = 2.269. """ from numpy import vstack, linspace, array from pylab import plot, legend, show from latgas import lattice from latgas.lattice import Lattice, Potential, System M_t = None E_t = None sizes = [1000, 500, 200, 100] for sz in sizes: inter = lambda r: -4 lattice = Lattice(sz, dim=2) potential = Potential(inter, 1.0, 5) sys = System(lattice, potential) sys.set_mu(8.0) E = [] N = [] temp = linspace(2.5, 2.0, 26) for i in temp: print i sys.set_T(i) ee, nn = sys.run(1000) ee, nn = sys.run(1000) E.append(ee) N.append(nn) E = array(E) N = array(N) M = -(2 * N - sz ** 2) / (sz ** 2)