def opt_func(x, *args): mps = mps_opt.MPS_OPT(N=N, maxBondDim=100, add_noise=False, hamType="sep", hamParams=(rho_l, 1 - rho_l, p[i], 1 - p[i], 1 - rho_r, rho_r, x), verbose=1) return mps.kernel()
#----------------------------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=1000) plt.style.use('fivethirtyeight') #'fivethirtyeight') #'ggplot' #----------------------------------------------------------------------------- # 1D SEP #----------------------------------------------------------------------------- N = 6 x = mps_opt.MPS_OPT(N=N, hamType="tasep", hamParams=(0.35, -1, 2 / 3)) #hamParams = (np.random.rand(),np.random.rand(),np.random.rand(),np.random.rand(),np.random.rand(),np.random.rand(),np.random.rand())) x.initialize_containers() x.generate_mpo() full_ham = x.mpo.return_full_ham() E_ed, _ = np.linalg.eig(full_ham) print('Energy via Exact Diagonalization:\n{}'.format(np.sort(E_ed)[-1])) print('Full Energy Spectrum:\n{}'.format(np.sort(E_ed)[::-1])) plt.figure(1) plt.subplot(221) plt.spy(full_ham) plt.title('1D SEP') plt.figure(2) plt.subplot(221) plt.imshow(full_ham) plt.colorbar()
import numpy as np import time import mps_opt import matplotlib.pyplot as plt #----------------------------------------------------------------------------- # A simple calculation using the general sep instead of the tasep. This # is initially set up to run the case identical to the one done in the # 01_simple_tasep.py example. #----------------------------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' N = 4 x = mps_opt.MPS_OPT(N=N, maxBondDim=200, hamType="sep", plotExpVals=True, plotConv=True, add_noise=False, hamParams=(2 / 3, 0, 1, 0, 0, 0.35, -1)) E = x.kernel()
np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' N = 50 npts = 100 betaVec = np.linspace(0,1,npts) alphaVec = np.linspace(0,1,npts) J_mat = np.zeros((len(betaVec),len(alphaVec))) J_mat_inf = np.zeros((len(betaVec),len(alphaVec))) for i in range(len(betaVec)): for j in range(len(alphaVec)): print('-'*20+'\nalpha = {}%, beta = {}%\n'.format(j/len(alphaVec),i/len(betaVec))) x = mps_opt.MPS_OPT(N=int(N), maxBondDim = 8, tol = 1e-1, verbose = 0, hamParams = (alphaVec[j],-0.001,betaVec[i])) E1 = x.kernel() x = mps_opt.MPS_OPT(N=int(N), maxBondDim = 8, tol = 1e-1, verbose = 0, hamParams = (alphaVec[j],0.001,betaVec[i])) E2 = x.kernel() J_mat[i,j] = (E1-E2)/(0.002)/N # Determine infinite limit current if alphaVec[j] > 0.5 and betaVec[i] > 0.5: J_mat_inf[i,j] = 1/4 elif alphaVec[j] < 0.5 and betaVec[i] > alphaVec[j]: J_mat_inf[i,j] = alphaVec[j]*(1-alphaVec[j])
import cProfile import mps_opt import pstats x = mps_opt.MPS_OPT(N=[4, 4], hamType='sep_2d', maxBondDim=20, maxIter=1, hamParams=(0.5, 0.5, 0.9, 0.2, 0.2, 0.8, 0.5, 0.5, 0.9, 0.2, 0.2, 0.8, -1)) cProfile.run('x.kernel()', 'mps_stats') #x.kernel() p = pstats.Stats('mps_stats') p.sort_stats('cumulative').print_stats(20)
# A simple script to run a calculation for the tasep # at a single point in phase space. #---------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=3) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' # Create MPS object x = mps_opt.MPS_OPT(N=10, hamType='tasep', target_state=0, hamParams=(0.35, -1, 2 / 3)) # Run optimization x.kernel() # Create MPS object x = mps_opt.MPS_OPT(N=10, hamType='tasep', target_state=1, hamParams=(0.35, -1, 2 / 3)) # Run optimization x.kernel() # Create MPS object x = mps_opt.MPS_OPT(N=10, hamType='tasep',
np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' N = 10 a = 2 / 3 g = 0 p = 1 q = 0 b = 0 d = 0.35 s = -1 # Check non periodic case x = mps_opt.MPS_OPT(N=N, maxBondDim=20, hamType="sep", plotExpVals=True, plotConv=True, add_noise=False, hamParams=(a, g, p, q, b, d, s)) E = x.kernel() # Start playing with vector input a_vec = np.zeros(N) a_vec[0] = a g_vec = np.zeros(N) p_vec = np.ones(N) q_vec = np.zeros(N) b_vec = np.zeros(N) d_vec = np.zeros(N) d_vec[-1] = d x = mps_opt.MPS_OPT( N=N,
import numpy as np import time import mps_opt import matplotlib.pyplot as plt #----------------------------------------------------------------------------- # Using the Ising Hamiltonian, perform a simple steady state calculation #----------------------------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' N = 50 x = mps_opt.MPS_OPT(N=N, hamType="ising", plotExpVals=True, plotConv=True, periodic_x=True, hamParams=(1, 0)) E = x.kernel()
N = 10 npts = 50 ds = 0.01 betaVec = np.linspace(0.01, 0.99, npts)[::-1] alphaVec = np.linspace(0.01, 0.99, npts)[::-1] J_mat = np.zeros((len(betaVec), len(alphaVec))) J_mat_inf = np.zeros((len(betaVec), len(alphaVec))) J_mat_ed = np.zeros((len(betaVec), len(alphaVec))) J_mat_mf = np.zeros((len(betaVec), len(alphaVec))) for i in range(len(betaVec)): for j in range(len(alphaVec)): print(('-' * 20 + '\nalpha = {}\nbeta = {}\n{}% Complete\n' + '-' * 20).format(alphaVec[j], betaVec[i], i / len(betaVec) * 100)) x = mps_opt.MPS_OPT(N=int(N), hamParams=(alphaVec[j], -ds, betaVec[i])) E1 = x.kernel() E1_ed = x.exact_diag() E1_mf = x.mean_field() x = mps_opt.MPS_OPT(N=int(N), hamParams=(alphaVec[j], ds, betaVec[i])) E2 = x.kernel() E2_ed = x.exact_diag() E2_mf = x.mean_field() # Calculate Current J_mat[i, j] = (E1 - E2) / (2 * ds) / N J_mat_ed[i, j] = (E1_ed - E2_ed) / (2 * ds) / N J_mat_mf[i, j] = (E1_mf - E2_mf) / (2 * ds) / N # Determine infinite limit current if alphaVec[j] > 0.5 and betaVec[i] > 0.5: J_mat_inf[i, j] = 1 / 4 elif alphaVec[j] < 0.5 and betaVec[i] > alphaVec[j]:
plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' Nx = 8 Ny = 8 s = -1 a = 0.35 b = 2 / 3 x = mps_opt.MPS_OPT(N=Nx, hamType="tasep", plotConv=True, plotExpVals=True, periodic_x=True, add_noise=False, hamParams=(a, s, b)) x.kernel() x1 = mps_opt.MPS_OPT(N=[Nx, Ny], hamType="sep_2d", periodic_x=True, add_noise=False, hamParams=(0, 1, a, 0, 0, b, 0, 0, 0, 0, 0, 0, s)) E1 = x1.kernel() x2 = mps_opt.MPS_OPT(N=[Nx, Ny], hamType="sep_2d", periodic_x=True, add_noise=False, hamParams=(1, 0, 0, a, b, 0, 0, 0, 0, 0, 0, 0, -s))
#N = int(argv[1]) #bondDimVec = int(argv[2]) N = 6 bondDimVec = 100 #[100,200,300,400,500,600,700,800,900,1000] tol = 1e-10 maxIter = 5 maxEigIter = 5 #tol = [1e-1]*(len(bondDimVec)-1) #tol.insert(-1,1e-10) #maxIter = [2]*(len(bondDimVec)-1) #maxIter.insert(-1,10) # Run 1D Calculation for comparison x = mps_opt.MPS_OPT(N=N, maxBondDim=bondDimVec, hamType="sep", hamParams=(0.9, 0.1, 0.5, 0.5, 0.1, 0.9, -1)) x.kernel() Evec_1d = x.bondDimEnergies E_ed = x.exact_diag() E_mf = x.mean_field() # Run 2D in opposite direction print('\nRun 2D - Not Aligned\n') x = mps_opt.MPS_OPT(N=[N, N], maxBondDim=bondDimVec, hamType="sep_2d", maxIter=maxIter, max_eig_iter=maxEigIter, add_noise=True, verbose=4,
x = mps_opt.MPS_OPT(N=N, maxBondDim = bondDimVec, hamType = "sep", hamParams = (0.9,0.1,0.5,0.5,0.1,0.9,-1)) x.kernel() Evec_1d = x.bondDimEnergies E_ed = x.exact_diag() E_mf = x.mean_field() """ # Run 2D in opposite direction print('\nRun 2D - Not Aligned\n') x = mps_opt.MPS_OPT(N=N**2, maxBondDim=bondDimVec, hamType="sep_2d", maxIter=maxIter, max_eig_iter=20, verbose=4, tol=tol, hamParams=(0, 0, 0, 0, 0, 0, 0.5, 0.5, 0.9, 0.1, 0.1, 0.9, -1)) x.kernel() Evec_2d_notaligned = x.bondDimEnergies / N """ # Run 2D in aligned direction print('\nRun 2D - Aligned\n') x = mps_opt.MPS_OPT(N=N**2, maxBondDim = bondDimVec, hamType = "sep_2d", verbose = 3, maxIter = maxIter, tol = tol,
density = np.zeros((len(p), len(s), N), dtype=np.complex128) CGF_ed = np.zeros((len(p), len(s)), dtype=np.complex128) # Entanglement Entropy nPart_ed = np.zeros((len(p), len(s)), dtype=np.complex128) # Entanglement Entropy density_ed = np.zeros((len(p), len(s), N), dtype=np.complex128) for i in range(len(p)): for j in range(len(s)): print('s = {}'.format(s[j])) print('p = {}'.format(p[i])) x = mps_opt.MPS_OPT( N=N, maxBondDim=200, add_noise=False, hamType="sep", verbose=2, #plotExpVals = True, #plotConv = True, hamParams=(rho_l, 1 - rho_l, p[i], 1 - p[i], 1 - rho_r, rho_r, s[j])) x.kernel() CGF_ed[i, j] = x.exact_diag() nPart_ed[i, j] = np.sum(x.ed.nv) CGF[i, j] = x.finalEnergy EE[i, j] = x.entanglement_entropy[int(x.N / 2)] nPart[i, j] = np.sum(x.calc_occ) density[i, j, :] = x.calc_occ density_ed[i, j, :] = x.ed.nv np.savez(filename, CGF=CGF, CGF_ed=CGF_ed,
#----------------------------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode']=False np.set_printoptions(suppress=True) np.set_printoptions(precision=3) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' Nx = 4 Ny = 4 x = mps_opt.MPS_OPT(N=Nx, hamType="tasep", # plotExpVals=True, # plotConv=True, add_noise=False, hamParams=(0.35,-1,2/3)) x.kernel() x1 = mps_opt.MPS_OPT(N=[Nx,Ny], hamType="sep_2d", # plotExpVals=True, # plotConv=True, add_noise = False, hamParams = (0,1,0.35,0,0,2/3,0,0,0,0,0,0,-1)) E1 = x1.kernel() x2 = mps_opt.MPS_OPT(N=[Nx,Ny], hamType="sep_2d", # plotExpVals=True, # plotConv=True, add_noise = False,
npts = 30 betaVec = np.linspace(0, 1, npts) alphaVec = np.linspace(0, 1, npts) s_vec = np.array([-0.1, 0.1]) J_mat = np.zeros((npts, npts)) for i in range(len(betaVec)): for j in range(len(alphaVec)): print('-' * 20 + '\nalpha = {}%, beta = {}%\n'.format(j / len(alphaVec) * 100, i / len(betaVec) * 100)) print('alpha = {}, beta = {}\n'.format(alphaVec[j], betaVec[i]) + '-' * 20) x = mps_opt.MPS_OPT(N=[N, N], maxBondDim=[10, 30, 50], hamType="sep_2d", verbose=2, hamParams=(0.25, 0.25, 0, 0, 0, 0, 0.25, 0.25, alphaVec[j], betaVec[i], betaVec[i], alphaVec[j], s_vec[0])) E1 = x.kernel() x = mps_opt.MPS_OPT(N=[N, N], maxBondDim=[10, 30, 50], hamType="sep_2d", verbose=2, hamParams=(0.25, 0.25, 0, 0, 0, 0, 0.25, 0.25, alphaVec[j], betaVec[i], betaVec[i], alphaVec[j], s_vec[1])) E2 = x.kernel() J_mat[i, j] = np.abs((E1 - E2) / (s_vec[1] - s_vec[0]) / N) x, y = np.meshgrid(betaVec, alphaVec) f = plt.figure()
import numpy as np import time import mps_opt import matplotlib.pyplot as plt #----------------------------------------------------------------------------- # Run a simple calculation for a 2D Heisenberg Model # DOESN'T WORK CORRECTLY!!! #----------------------------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' x = mps_opt.MPS_OPT(N=[3, 12], hamType="heis_2d", verbose=4, plotExpVals=True, plotConv=True, periodic_x=True, periodic_y=False, maxBondDim=50, hamParams=(1, 0)) E = x.kernel()
#----------------------------------------------------------------------------- # Here, I am going to calcualte some of the properties of the MPSs that we get # and make sure that they are in agreement with those given by LDT. #----------------------------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=10) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' N = 10 rho_r = 0.5 rho_l = 0.5 p = 0.2 s = 0. x = mps_opt.MPS_OPT(N=N, maxBondDim=100, add_noise=False, hamType="sep", hamParams=(rho_l, 1 - rho_l, p, 1 - p, 1 - rho_r, rho_r, s)) x.kernel() for i in range(len(x.rpsi)): print(x.rpsi[i]) print(np.sum(x.rpsi)) print(np.sum(x.rpsi * x.rpsi))
# General Settings maxBondDim = 500 maxIter = 3 max_eig_iter = 5 tol = 1e-16 verbose = 3 # Calculate scaling for 1D system N = np.array([10,20,30,40,50,60,70,80,90,100,110,120,130,140],dtype=np.int) t_vec = np.zeros(N.shape) for i in range(len(N)): print('1D System: Size = {}'.format(N[i])) x = mps_opt.MPS_OPT(N=N[i], maxBondDim = maxBondDim, maxIter = maxIter, max_eig_iter = max_eig_iter, tol = tol, verbose = verbose, hamType = 'sep', hamParams = (0.3,0.8,0.4,0.7,0.1,0.2,-1)) t1 = time.clock() x.kernel() t2 = time.clock() t_vec[i] = t2-t1 print('Computational Time = {}'.format(t_vec[i])) # Calculate scaling for 2D system N_vec_2d = np.array([2,4,6,8,10,12])#,14,16,18,20]) t_vec_2d = np.zeros(N_vec_2d.shape) for i in range(len(N_vec_2d)): print('2D System: Size = {}'.format(N_vec_2d[i]**2)) x = mps_opt.MPS_OPT(N=[N_vec_2d[i],N_vec_2d[i]],
# Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode']=False np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' N = 100 bondDimVec = np.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,30,40,50]) Evec = np.zeros(len(bondDimVec)) diffVec = np.zeros(len(bondDimVec)) for i in range(len(bondDimVec)): print('\tRunning Calcs for M = {}'.format(bondDimVec[i])) x = mps_opt.MPS_OPT(N=int(N), maxBondDim = bondDimVec[i], tol = 1e-1, hamParams = (0.35,-1,2/3)) Evec[i] = x.kernel() diffVec = np.abs(Evec-Evec[-1]) fig = plt.figure() plt.semilogy(bondDimVec,diffVec,'b-',linewidth=5) plt.semilogy(bondDimVec,diffVec,'ro',markersize=10) plt.xticks(fontsize=14) plt.yticks(fontsize=14) plt.xlabel('Bond Dimension',fontsize=20) plt.ylabel('$E-E_{exact}$',fontsize=20) fig.savefig('varyMaxBondDim.pdf')
import numpy as np import time import mps_opt import matplotlib.pyplot as plt #----------------------------------------------------------------------------- # A simple calculation for the 1D heisenberg model. #----------------------------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode']=False np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' N = 50 x = mps_opt.MPS_OPT(N=int(N), hamType = "heis", plotExpVals = True, plotConv = True, periodic_x = True, hamParams = (1,0)) E = x.kernel()
import numpy as np import matplotlib.pyplot as plt #----------------------------------------------------------------------------- # Run a check to ensure PBC are working, by setting up staggered # SEPs on a 2D lattice in both directions. #----------------------------------------------------------------------------- # Run 1D for comparison N = 4 a = 2/3 b = 0.35 s = -1 dividing_point = 3 x = mps_opt.MPS_OPT(N=N, hamType = "sep", plotExpVals = True, hamParams = (a,0,1,0,0,b,s)) E = x.kernel() print('Expected Energy Result = {}'.format(E*N)) # Run 2D in x-direction Nx = N Ny = N jl = np.zeros((Nx,Ny)) jr = np.ones((Nx,Ny)) jr[:,dividing_point-1] = 0 ju = np.zeros((Nx,Ny)) jd = np.zeros((Nx,Ny)) cr = np.zeros((Nx,Ny)) cr[:,dividing_point] = a cl = np.zeros((Nx,Ny)) cu = np.zeros((Nx,Ny))
import numpy as np import time import mps_opt import matplotlib.pyplot as plt #----------------------------------------------------------------------------- # This calculation is identical to the one done in example 07, with the # exception that the current is now flowing in the opposite direction. #----------------------------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' N = 10 x = mps_opt.MPS_OPT(N=N, hamType="sep", plotExpVals=True, plotConv=True, periodic_x=True, hamParams=(0, 0.35, 0, 1, 2 / 3, 0, 1)) E = x.kernel()
plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=2) np.set_printoptions(linewidth=100) plt.style.use('fivethirtyeight') #'fivethirtyeight') #'ggplot' #----------------------------------------------------------------------------- # 2D WASEP #----------------------------------------------------------------------------- N = 3 n_points = 10 E = 10 px = 1 / 2 * np.exp(-E / N) qx = 1 / 2 * np.exp(E / N) s = np.array([-29.1919191919, -18.6868686869, -10]) CGF_dmrg = np.zeros(s.shape) for i in range(len(s)): x = mps_opt.MPS_OPT( N=[N, N], hamType="sep_2d", #periodic_x = True, periodic_y=True, verbose=3, maxBondDim=2, maxIter=2, hamParams=(1 / 2, 1 / 2, qx, px, 1 / 2, 1 / 2, 0, 0, 1 / 2, 1 / 2, 0, 0, [0, s[i] / N])) CGF_dmrg[i] = x.kernel()
#----------------------------------------------------------------------------- # For the default TASEP calculation, we compare the results of slowly # increasing the bond dimension to if we simply initially choose the # largest bond dimension, to determine if it has any effect on final # outcomes. And to compare time savings. #----------------------------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' t1 = time.time() N = 20 x = mps_opt.MPS_OPT(N=int(N), verbose=2, maxBondDim=[10, 50, 100]) x.kernel() t2 = time.time() # Provide some comparison for if we don't slowly increase bond dim x = mps_opt.MPS_OPT(N=int(N), verbose=2, maxBondDim=100) x.kernel() t3 = time.time() # Print Results print('#' * 50 + '\nIncremented case total time: {}\nDirect case total time: {}\n'.format( t2 - t1, t3 - t2) + '#' * 50)
#---------------------------------------------------------- # A simple script to run a calculation for the tasep # at a single point in phase space. #---------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=3) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' # Create MPS object x = mps_opt.MPS_OPT( N=500, hamType='tasep', maxBondDim=100, tol=1e-5, maxIter=10, verbose=4, periodic_x=False, #plotConv = True, #plotExpVals = True, add_noise=False, hamParams=(0.35, 0, 2 / 3)) # Run optimization x.kernel() print(x.calc_occ)
#----------------------------------------------------------------------------- # Here, we calculate the current and CGF as a function of s using both # DMR and Mean Field Methods. We then compare the results and plot these. #----------------------------------------------------------------------------- # Set Plotting parameters plt.rc('text', usetex=True) plt.rcParams['text.latex.preamble'] = [r'\boldmath'] plt.rc('font', family='serif') plt.rcParams['text.latex.unicode'] = False np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' # Recreate Ushnish plot N = 8 s_vec = np.linspace(-2, 2, 20) # E_dmrg = np.zeros(s_vec.shape) E = np.zeros(s_vec.shape) for i in range(len(s_vec)): x = mps_opt.MPS_OPT(N=N, hamType="sep", hamParams=(0.9, 0.1, 0.5, 0.5, 0.9, 0.1, s_vec[i]), usePyscf=False) E[i] = x.mean_field() fig1 = plt.figure() plt.plot(s_vec, E, '-') # plt.plot(s_vec,E_dmrg,':') plt.grid(True) fig1.savefig('vary_s_mf.pdf')
np.set_printoptions(suppress=True) np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' N = 12 bondDimVec = [ 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200 ] # Run 1D Calculation for comparison Evec_1d = np.zeros(len(bondDimVec)) diffVec = np.zeros(len(bondDimVec)) print('Running 1D Calculations') x = mps_opt.MPS_OPT(N=N, maxBondDim=bondDimVec, hamParams=(0.35, -1, 2 / 3), verbose=2, hamType='tasep') x.kernel() Evec_1d = x.bondDimEnergies print(Evec_1d) # Run exact Diagonalization for 1D print('Running Exact Diagonalization (1D)') E_ed = x.exact_diag() # Run mean field 1d print('Running mean field (1D)') E_mf = x.mean_field() # Run 2D in opposite direction Evec_2d_notaligned = np.zeros(len(bondDimVec)) print('Running misaligned 2D calculations') x = mps_opt.MPS_OPT(N=N**2,
N = 4 n_points = 10 E = 10 px = 1 / 2 * np.exp(-E / N) qx = 1 / 2 * np.exp(E / N) s = np.array([-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1]) CGF_ed = np.zeros(s.shape) CGF_dmrg = np.zeros(s.shape) all_energies = np.zeros((2**(N**2), len(s))) for i in range(len(s)): if s[i] > -20 and s[i] < 0: target_state = 3 else: target_state = 0 x = mps_opt.MPS_OPT(N=[N, N], hamType="sep_2d", periodic_x=True, periodic_y=True, target_state=target_state, hamParams=(qx, px, 1 / 2, 1 / 2, 0, 0, 0, 0, 0, 0, 0, 0, [s[i] / N, 0])) x.initialize_containers() x.generate_mpo() for i in range(N**2): block_ham = x.mpo.return_single_block_ham(i) #print(block_ham) E_block, _ = np.linalg.eig(block_ham) print('Energies for Occupation Level {}'.format(i)) print(np.sort(E_block)) CGF_dmrg[i] = x.kernel()
fig1 = plt.figure() fig2 = plt.figure() fig3 = plt.figure() fig4 = plt.figure() fig5 = plt.figure() col_vec = ['r','r','y','g','b','c','k','m'] for j in range(len(N_vec)): N = N_vec[j] print('Running Calcs for N={}'.format(N)) Evec = np.zeros(s_vec.shape) Evec_adj = np.zeros(s_vec.shape) EE = np.zeros(s_vec.shape) for i in range(len(s_vec)): print('\tRunning Calcs for s={}'.format(s_vec[i])) x = mps_opt.MPS_OPT(N =int(N), hamType = "tasep", #plotExpVals = True, hamParams = (0.35,s_vec[i],2/3)) Evec[i] = x.kernel() Evec_adj[i] = Evec[i]/(N+1) EE[i] = x.entanglement_entropy[int(N/2)] Ediff = Evec[1:]-Evec[:len(Evec)-1] Sdiff = s_vec[1:]-s_vec[:len(s_vec)-1] slope = -Ediff/(Sdiff) plt.figure(fig1.number) plt.plot(s_vec,Evec,col_vec[j]+'-',linewidth=3) plt.xlabel('$s$',fontsize=20) plt.ylabel('$\mu$',fontsize=20) plt.figure(fig2.number) plt.plot(s_vec,Evec_adj,col_vec[j]+'-',linewidth=3) plt.xlabel('$s$',fontsize=20) plt.ylabel('$\mu/(N+1)$',fontsize=20)
np.set_printoptions(precision=100) plt.style.use('ggplot') #'fivethirtyeight') #'ggplot' N = 10 npts = 50 betaVec = np.linspace(0,1,npts) alphaVec = np.linspace(0,1,npts) s_vec = np.array([-0.1,0.1]) J_mat = np.zeros((npts,npts)) for i in range(len(betaVec)): for j in range(len(alphaVec)): print('-'*20+'\nalpha = {}%, beta = {}%\n'.format(j/len(alphaVec)*100,i/len(betaVec)*100)) print('alpha = {}, beta = {}\n'.format(alphaVec[j],betaVec[i])+'-'*20) x = mps_opt.MPS_OPT(N=N, maxBondDim = [10,20,30], hamType = "sep", verbose = 0, hamParams = (alphaVec[j],betaVec[i],0.5,0.5,betaVec[i],alphaVec[j],s_vec[0])) E1 = x.kernel() x = mps_opt.MPS_OPT(N=N, maxBondDim = [10,20,30], hamType = "sep", verbose = 0, hamParams = (alphaVec[j],betaVec[i],0.5,0.5,betaVec[i],alphaVec[j],s_vec[1])) E2 = x.kernel() J_mat[i,j] = np.abs((E1-E2)/(s_vec[1]-s_vec[0])/N) x,y = np.meshgrid(betaVec,alphaVec) f = plt.figure() plt.pcolor(x,y,J_mat) plt.colorbar() plt.xticks(fontsize=14)