def main(): l = 15 h = 0.1 j = 1 n_configs = 250 n_usable_configs = 200 temps = linspace(10,.5,20) energy = zeros((len(temps), 1)) initial_energy = ones((l, l)) last_lattice = initial_energy for iTemp, temp in enumerate(temps): lattice = generate_configs(l, h, j, last_lattice, n_configs, n_usable_configs, temp) lattice_pad = zeros((l+2, l+2, n_usable_configs)) for config in range(n_usable_configs): lattice_pad[:,:,config] = pad(lattice[:,:,config]) north = lattice_pad[0:-2, 1:-1, :] south = lattice_pad[2:, 1:-1, :] east = lattice_pad[1:-1, 2:, :] west = lattice_pad[1:-1, 0:-2, :] f = -1 * h * sum(lattice) s = -1 * 0.5*j * sum(lattice * (north + south + east + west)) energy_temp = (f+s)/float(n_usable_configs) energy[iTemp] = energy_temp #print('energy for ', temp, ' = ', energy_temp) last_lattice = lattice[:,:,-1] #print(energy) print size(temps) print size(energy) plotxy(temps, energy)
def main(): l = 15 h = 0.1 j = 1 n_configs = 250 n_usable_configs = 200 temps = linspace(10, .5, 20) energy = zeros((len(temps), 1)) initial_energy = ones((l, l)) last_lattice = initial_energy for iTemp, temp in enumerate(temps): lattice = generate_configs(l, h, j, last_lattice, n_configs, n_usable_configs, temp) lattice_pad = zeros((l + 2, l + 2, n_usable_configs)) for config in range(n_usable_configs): lattice_pad[:, :, config] = pad(lattice[:, :, config]) north = lattice_pad[0:-2, 1:-1, :] south = lattice_pad[2:, 1:-1, :] east = lattice_pad[1:-1, 2:, :] west = lattice_pad[1:-1, 0:-2, :] f = -1 * h * sum(lattice) s = -1 * 0.5 * j * sum(lattice * (north + south + east + west)) energy_temp = (f + s) / float(n_usable_configs) energy[iTemp] = energy_temp #print('energy for ', temp, ' = ', energy_temp) last_lattice = lattice[:, :, -1] #print(energy) print size(temps) print size(energy) plotxy(temps, energy)
def operation(): l, H, J = 15, 0.1, 1 nbr_configs, nbr_configs2use = 250, 200 tt_list = [x / float(10) for x in range(100, 0, -5)] #print tt_list expg_sigma = zeros([size(tt_list), 1]) m0 = around(random.rand(l, l), 0) * 2 - 1 last_latt = m0 for tt in range(size(tt_list)): latt3D = generate_configs(l, H, J, last_latt, nbr_configs, nbr_configs2use, tt_list[tt]) #print latt3D.shape latt3D_pad = zeros(([l + 2, l + 2, nbr_configs2use])) #print latt3D_pad.shape for cind in range(nbr_configs2use): latt3D_pad[:, :, cind] = pad(latt3D[:, :, cind]) north = latt3D_pad[0:-2, 1:-1, :] south = latt3D_pad[2:, 1:-1, :] east = latt3D_pad[1:-1, 2:, :] west = latt3D_pad[1:-1, 0:-2, :] #print latt3D==north #print latt3D_pad.shape #print north.shape #print north.shape stable_spins3D = (latt3D == north) & (latt3D == south) & ( latt3D == east) & (latt3D == west) #print stable_spins3D[:,:,0] #print latt3D #print north #print sum(latt3D==east) #print sum(latt3D==west) g_sigma = sum(stable_spins3D) print g_sigma #print g_sigma #print south.shape #print east.shape #print west.shape expg_sigma[tt] = g_sigma / float(nbr_configs2use) last_latt = latt3D[:, :, -1] plotxy(tt_list, expg_sigma)
def operation(): l,H,J=15,0.1,1 nbr_configs, nbr_configs2use = 250,200 tt_list = [x/float(10) for x in range(100,0,-5)] #print tt_list expg_sigma = zeros([size(tt_list),1]) m0 = around(random.rand(l,l),0)*2 -1 last_latt = m0 for tt in range(size(tt_list)): latt3D = generate_configs(l, H, J, last_latt, nbr_configs, nbr_configs2use, tt_list[tt]) #print latt3D.shape latt3D_pad = zeros(([l+2, l+2, nbr_configs2use])) #print latt3D_pad.shape for cind in range(nbr_configs2use): latt3D_pad[:,:,cind] = pad(latt3D[:,:,cind]) north = latt3D_pad[0:-2, 1:-1, :] south = latt3D_pad[2:, 1:-1, :] east = latt3D_pad[1:-1, 2:, :] west = latt3D_pad[1:-1, 0:-2, :] #print latt3D==north #print latt3D_pad.shape #print north.shape #print north.shape stable_spins3D = (latt3D==north) & (latt3D==south) & (latt3D==east) & (latt3D==west) #print stable_spins3D[:,:,0] #print latt3D #print north #print sum(latt3D==east) #print sum(latt3D==west) g_sigma = sum(stable_spins3D) print g_sigma #print g_sigma #print south.shape #print east.shape #print west.shape expg_sigma[tt] = g_sigma/float(nbr_configs2use) last_latt = latt3D[:,:,-1] plotxy(tt_list, expg_sigma)