def example_DMRG_heisenberg_xxz_finite(L, Jz, chi, conserve='best', verbose=True): print("finite DMRG, Heisenberg XXZ chain") print("L={L:d}, Jz={Jz:.2f}".format(L=L, Jz=Jz)) model_params = dict(L=L, S=0.5, Jx=1., Jy=1., Jz=Jz, bc_MPS='finite', conserve=conserve, verbose=verbose) M = SpinModel(model_params) product_state = ["up", "down"] * (M.lat.N_sites // 2) psi = MPS.from_product_state(M.lat.mps_sites(), product_state, bc=M.lat.bc_MPS) dmrg_params = { 'mixer': True, # setting this to True helps to escape local minima 'max_E_err': 1.e-16, 'trunc_params': { 'chi_max': chi, 'svd_min': 1.e-16 }, 'verbose': verbose, } info = dmrg.run(psi, M, dmrg_params) # the main work... E = info['E'] E = E * 4 print("E = {E:.13f}".format(E=E)) print("final bond dimensions: ", psi.chi) Sz = psi.expectation_value("Sz") # Sz instead of Sigma z: spin-1/2 operators! mag_z = np.mean(Sz) print("<S_z> = [{Sz0:.5f}, {Sz1:.5f}]; mean ={mag_z:.5f}".format(Sz0=Sz[0], Sz1=Sz[1], mag_z=mag_z)) # note: it's clear that mean(<Sz>) is 0: the model has Sz conservation! corrs = psi.correlation_function("Sz", "Sz", sites1=range(10)) print("correlations <Sz_i Sz_j> =") print(corrs) return E, psi, M
def example_DMRG_heisenberg_xxz_infinite(Jx=1, Jy=1, Jz=1, hx=0, hy=0, hz=0, conserve='best', verbose=False, chi_max=100, S=0.5): if verbose: print("infinite DMRG, Heisenberg XXZ chain") print("Jz={Jz:.2f}, conserve={conserve!r}".format( Jz=Jz, conserve=conserve)) model_params = dict( L=2, S=S, # spin 1/2 Jx=Jx, Jy=Jy, Jz=Jz, # couplings hx=hx, hy=hy, hz=hz, bc_MPS='infinite', conserve=conserve, verbose=verbose) M = SpinModel(model_params) product_state = ["up", "up"] # initial Neel state psi = MPS.from_product_state(M.lat.mps_sites(), product_state, bc=M.lat.bc_MPS) dmrg_params = { 'mixer': True, # setting this to True helps to escape local minima 'trunc_params': { 'chi_max': chi_max, 'svd_min': 1.e-10, }, 'max_E_err': 1.e-10, 'verbose': verbose, } info = dmrg.run(psi, M, dmrg_params) E = info['E'] if verbose: print("E = {E:.13f}".format(E=E)) print("final bond dimensions: ", psi.chi) Sz = psi.expectation_value( "Sz") # Sz instead of Sigma z: spin-1/2 operators! mag_z = np.mean(Sz) if verbose: print("<S_z> = [{Sz0:.5f}, {Sz1:.5f}]; mean ={mag_z:.5f}".format( Sz0=Sz[0], Sz1=Sz[1], mag_z=mag_z)) # note: it's clear that mean(<Sz>) is 0: the model has Sz conservation! if verbose: print("correlation length:", psi.correlation_length()) corrs = psi.correlation_function("Sz", "Sz", sites1=range(10)) if verbose: print("correlations <Sz_i Sz_j> =") print(corrs) return E, psi, M
"""Initialization of the Heisenberg model on a kagome lattice.""" # Copyright 2019 TeNPy Developers, GNU GPLv3 from tenpy.models.spins import SpinModel model_params = { "S": 0.5, # Spin 1/2 "lattice": "Kagome", "bc_MPS": "infinite", "bc_y": "cylinder", "Ly": 2, # defines cylinder circumference "conserve": "Sz", # use Sz conservation "Jx": 1., "Jy": 1., "Jz": 1. # Heisenberg coupling } model = SpinModel(model_params)