n2.init_lt(state) n1.init_lt(state) flips = np.array(np.random.choice(np.arange(n1.nv), 2)) lv_match = np.all(np.isclose(n1.log_val(state), n2.log_val(state))) lp_match = np.all(np.isclose(n1.log_pop(state, flips), n2.log_pop(state, flips))) print("Log_val matches: {}".format(lv_match)) print("Log_pop matches: {}".format(lp_match)) if not (lv_match and lp_match): exit() nruns = 1000 h = ising1d.Ising1d(40, 0.5) print("Sampling n1 ...") start_time = time.time() s1 = sampler.Sampler(n1, h) s1.run(nruns) print("time elapsed: {:.2f}s".format(time.time() - start_time)) print("Sampling n2 ...") start_time = time.time() s2 = sampler.Sampler(n2, h) s2.run(nruns) print("time elapsed: {:.2f}s".format(time.time() - start_time))
alpha = 2 m = True wf = nqs.NqsTI(nspins, alpha) # A translation invariant NQS instance wf.Wreduced = 0.1 * np.random.uniform( -1, 1, wf.Wreduced.shape) + 0j # Fill in with starting values if type(wf.a) == int: wf.a = 0.1 * np.random.uniform(-1, 1) + 0j else: wf.a = 0.1 * np.random.uniform(-1, 1) * np.ones(wf.a.shape) + 0j wf.breduced = 0.1 * np.random.uniform(-1, 1, wf.breduced.shape) + 0j #wf.load_parameters('../Outputs/'+str(nspins)+'_alpha='+str(alpha)+'_Ising10_ti_100.npz') h = ising1d.Ising1d(nspins, 1.0) #h = heisenberg1d.Heisenberg1d(10,1) #h = xyz.XYZ(10,(-1,-1,0)) #h = fermionhop1d.FermionHop(nspins,-2) base_array = -1 * np.ones(nspins) base_array[0:nspins // 2] *= -1 state = np.random.permutation( base_array) # return a random permutation of the half 1, half-1 array wf.init_lt(state) s = sampler.Sampler(wf, h, mag0=m) s.run(nruns, init_state=state) state = s.state wf.init_lt(state)
import nqs import numpy as np import sampler import observables import time import matplotlib.pyplot as plt import distances import ising1d #Script to generate the data -- sigmax(t) for all our time-evolved wave functions nsteps = 400 data_rate = 5 nruns = 1000 talk_rate = 25 h = ising1d.Ising1d(10, 1.0) ## Now that we have all the wavefunctions generated, find the <sigma(x)> at each one #Fully connected translation-invariant print("Fully connected ANNQS") sxnonloc = [] nonlocerr = [] wf = nqs.NqsTI(10, 1) start_time = time.time() for t in np.arange(0, nsteps, data_rate): if t % talk_rate == 0: print('t = {}'.format(t)) wf.load_parameters('../Outputs/10SpinEvolve/evolution_ti_' + str(t) + '.npz') s = sampler.Sampler(wf, observables.Sigmax(10, 1),
import ising1d import fermionhop1d import nqs import trainer import sampler import numpy as np import matplotlib.pyplot as plt import time start = time.time() nruns = 1000 k = 2 gam = .01 nspins = 10 #h = heisenberg1d.Heisenberg1d(nspins,1) h = ising1d.Ising1d(10, 0.5) #h = fermionhop1d.FermionHop(nspins,1) wf = nqs.NqsLocal(nspins, 1, k) # A local NQS instance wf.W = 0.1 * np.random.random(wf.W.shape) + 0j # Fill in with starting values wf.a = 0.1 * np.random.random(wf.a.shape) + 0j wf.b = 0.1 * np.random.random(wf.b.shape) + 0j base_array = np.concatenate( (np.ones(int(1)), -1 * np.ones(int(nspins - 1)))) # make an array of half 1, half -1 state = np.random.permutation( base_array) # return a random permutation of the half 1, half-1 array wf.init_lt(state)