def test_dmrg2(self): mpiprint(0,'\n'+'='*20+'\nTesting one-site dmrg\n'+\ '-Davidson\n-Fixed BD\n-not orthonormalized\n-calc left\n-Multiple BD\n'+'='*20) # Use the TASEP MPO from cyclomps.algs.dmrg1 import dmrg from numpy import complex_ from cyclomps.mpo.tasep import return_mpo mpo = return_mpo(10,(0.5,0.5,1.)) E1 = dmrg(mpo, alg='davidson', dtype=complex_, tol=1e-5, mbd=[10,20], min_iter=3, nStates=2, fixed_bd=True, left=False) mpiprint(0,'Passed\n'+'='*20)
def test_dmrg1(self): mpiprint(0,'\n'+'='*20+'\nTesting one-site dmrg\n'+\ '-Exact Diagonalization\n-not fixed\n-not orthonormalized\n-calc left\n'+'='*20) # Use the TASEP MPO from cyclomps.algs.dmrg1 import dmrg from numpy import complex_ from cyclomps.mpo.tasep import return_mpo mpo = return_mpo(10,(0.5,0.5,1.)) E0 = dmrg(mpo, alg='exact', dtype=complex_, tol=1e-3, max_iter=[4,2], min_iter=[2,0], mbd = [10,20], mps_subdir='test_mps', env_subdir='test_env', nStates=1, fixed_bd=False, orthonormalize=False, left=True, end_gauge=5) mpiprint(0,'Passed\n'+'='*20)
# Initial Hamiltonian Parameters Omega_0 = 1. Delta_0 = 0.5 V_0 = 1. # Final Hamiltonian Parameters Omega_f = 1.e-3 Delta_f = 0.5 V_f = 1. # Get the MPO hamParams = (Omega_0, Delta_0, V_0) mpo = return_mpo(N, hamParams, D=Dmpo) # Create an initial state energy_gs, mps = dmrg(mpo, mbd=10, left=False, nStates=1, return_state=True) print('Initial Energy = {}'.format(energy_gs)) # Create an MPO with Energy subtracted hamParams = (Omega_f, Delta_f, V_f) mpo = return_mpo(N, hamParams, D=Dmpo) # Run DMRG again energy_gs, _ = dmrg(mpo, mbd=10, left=False, nStates=1, return_state=True) # Create an MPO with Energy subtracted hamParams = (Omega_f, Delta_f, V_f) mpo = return_mpo(N, hamParams, D=Dmpo, const=real(energy_gs)) mpo = return_mpo(N, hamParams, D=Dmpo) # Run time evolution
# Calculate Settings left = False # Set up MPO periodicy = False periodicx = False hamParams = array([jr, jl, ju, jd, cr, cl, cu, cd, dr, dl, du, dd, sx, sy]) mpo = return_mpo((Nx, Ny), hamParams, periodicy=periodicy, periodicx=periodicx) # Run diagonalization E0, vl, vr = ed(mpo, left=True) print(E0[0], E0[-1]) # Run dmrg E, mps = dmrg(mpo, mbd=20, nStates=1, return_state=True) # Evaluate Local Energies # vertical interactions print('\nVertical Energies') for y in ['bottom'] + [i for i in range(Ny - 1)] + ['top']: for x in range(Nx): mpo_tmp = single_bond_energy((Nx, Ny), hamParams, x, y, 'vert') Etmp = contract(mps=mps, mpo=mpo_tmp) print('E_vert({},{}) = {}'.format(x, y, Etmp)) # Horizontal interactions print('\nHorizontal Energies') print(['left'] + [i for i in range(Nx - 1)] + ['right']) for x in ['left'] + [i for i in range(Nx - 1)] + ['right']: for y in range(Ny): mpo_tmp = single_bond_energy((Nx, Ny), hamParams, x, y, 'horz')
# Set up mpo hamParams = array([c, s]) mpo = return_mpo(N, hamParams, hermitian=hermitian) # Run diagonalization E0, mps, env = dmrg(mpo, alg=alg, mps=mps, env=env, return_state=True, return_env=True, dtype=complex_, mbd=mbd, tol=tol, max_iter=max_iter, min_iter=min_iter, mps_subdir=mps_dir, env_subdir=env_dir, nStates=nStates, fixed_bd=fixed_bd, state_avg=state_avg, orthonormalize=orthonormalize, end_gauge=end_gauge, left=left) E0_vec.append(real(E0[0])) E1_vec.append(real(E0[1])) for sind2 in range(len(E0_vec)): mpiprint( 0, '{}\t{}\t{}'.format(sVec[sind2], E0_vec[sind2], E1_vec[sind2])) try:
state_avg = False orthonormalize = False end_gauge = 0 left = False #s = sVec[0] hamParams = (Omega, Delta, V) mpo = return_mpo(N, hamParams) if False: # Run exact diagonalization u, v = ed(mpo) print(u) # Run diagonalization E0 = dmrg(mpo, alg=alg, dtype=float_, mbd=mbd, tol=tol, max_iter=max_iter, min_iter=min_iter, mps_subdir=mps_dir, env_subdir=env_dir, nStates=nStates, fixed_bd=fixed_bd, state_avg=state_avg, orthonormalize=orthonormalize, end_gauge=end_gauge, left=left)
jl = 0.1 ju = 0.9 jd = 0.1 cr = 0.5 cl = 0.5 cu = 0.5 cd = 0.5 dr = 0.5 dl = 0.5 du = 0.5 dd = 0.5 sx = sxvec[i] sy = -0.5 # Set up MPO periodicy = False periodicx = False hamParams = array([jr,jl,ju,jd,cr,cl,cu,cd,dr,dl,du,dd,sx,sy]) mpo = return_mpo((Nx,Ny),hamParams,periodicy=periodicy,periodicx=periodicx) # Run dmrg E,mps = dmrg(mpo, mbd=mbd, nStates=2, return_state=True, left=False, max_iter=5, fixed_bd=True, state_avg=True) print('results,{},{},{},{}'.format(sx,E[0].real,E[1].real,(E[0]-E[1]).real))
if __name__ == "__main__": from cyclomps.mpo.tasep import return_mpo, return_tebd_ops from cyclomps.algs.dmrg1 import dmrg N = 30 a = 0.5 b = 0.5 D = 10 sVec = [ -1., -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, -0.05, -0.01, 0., 0.01, 0.01, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 ] for sind, s in enumerate(sVec): # Get operators ops = return_tebd_ops(N, (a, b, s)) ham = return_mpo(N, (a, b, s)) # Start by trying DMRG E0, mps = dmrg(ham, mbd=D, max_iter=5, nStates=1, fixed_bd=True, return_state=True) # Try again with TEBD E = tebd(ops, H=ham, D=[D, D, D, D, D, D, D, D, D], step_size=[1., 0.9, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1], n_step=[10, 10, 10, 10, 10, 10, 10, 10, 10], conv_tol=1e-8) print(s, E)
from cyclomps.tools.utils import * mpiprint(0, '\n' + '=' * 20 + '\nTesting one-site dmrg\n' + '=' * 20) # Use the TASEP MPO from cyclomps.algs.dmrg1 import dmrg from numpy import complex_ from cyclomps.mpo.asep import return_mpo mpo = return_mpo(10, (0.5, 0.5, 0.1, 0.9, 0.5, 0.5, -0.5)) E0, mps = dmrg(mpo, alg='davidson', dtype=complex_, tol=1e-3, mbd=10, max_iter=20, min_iter=10, mps_subdir='test_mps', env_subdir='test_env', nStates=3, fixed_bd=True, orthonormalize=False, return_state=True, state_avg=True) E0 = dmrg(mpo, mps=mps, alg='davidson', dtype=complex_, tol=1e-3, mbd=[10, 20, 30], max_iter=2, min_iter=0,