\(H = \sum_i^{L-1} S_i\cdot S_{i+1}\)
And my code as follow:
Python: Select all
import numpy as np
import matplotlib.pyplot as plt
from tenpy.networks.mps import MPS
from tenpy.models.spins import SpinModel
from tenpy.algorithms import dmrg
model_params = dict(
L =32,
S =1, # spin 1
Jx =1,
Jy =1,
Jz =1, # couplings
bc_MPS ='finite', #boundary condition
conserve ='best',
) # conserved quantum qualities
dmrg_params = {
"max_sweeps" : 800,
'mixer' : True, # setting this to True helps to escape local minima.
'trunc_params' :
{ 'chi_max' : 1600,
'svd_min' : 1.e-13,},
'max_E_err' : 1.e-13,
}
def DMRG_heisenberg( model_params,dmrg_params ):
print("DMRG")
M = SpinModel(model_params) #类实例化
L = int(model_params['L'])
product_state = [0,1,-1,0]*(L//4) # initial state
psi = MPS.from_product_state(M.lat.mps_sites(), product_state, bc=M.lat.bc_MPS) #initial MPS
info = dmrg.run(psi, M, dmrg_params) # main work....
E = info['E']
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!
return E, psi
#执行DMRG算法
if __name__ == "__main__":
import logging
logging.basicConfig(level=logging.INFO)
E,psi = DMRG_heisenberg(model_params,dmrg_params)
questions:
the energy is
Code: Select all
-37.4230420434121598/31 = -1.2....
Code: Select all
−1.401484039….