Code: Select all
def example_DMRG_SSH_infinite_S_xi_scaling():
L = 50 # or whatever you like...
t1, t2 = 0.5, 1.5
t_array = np.array([(t1 if i % 2 == 0 else t2) for i in range(L-1)])
model_params = {
'L': L,
't': t_array,
'V': 0., 'mu': 0., # just free fermions, but you can generalize...
'conserve': 'best'
}
M = FermionChain(model_params)
product_state = ["up"] * int(M.lat.N_sites/2)+["down"]*(M.lat.N_sites-int(M.lat.N_sites/2))
psi = MPS.from_product_state(M.lat.mps_sites(), product_state, bc=M.lat.bc_MPS)
dmrg_params = {
'start_env': 10,
'mixer': None,
# 'mixer_params': {'amplitude': 1.e-3, 'decay': 5., 'disable_after': 50},
'trunc_params': {
'chi_max': 50,
#Dimension of the system
'svd_min': 1.e-10
},
'update_env': 20,
'start_env': 20,
'max_E_err': 1.e-9,
'max_S_err': 1.e-6,
'update_env': 0,
}
#chi_list = np.arange(7, 31, 2)
s_list = []
xi_list = []
eng = dmrg.TwoSiteDMRGEngine(psi, M, dmrg_params)
# necessary if you for example have a fixed numer of sweeps, if you don't set this you option your simulation stops after initial number of sweeps!
## DMRG Calculation ##
print("Start IDMRG CALCULATION")
result=eng.run()
eng.options['mixer'] = None
psi.canonical_form()
Sx=[]
Sm=psi.expectation_value("Sm")
Sp=psi.expectation_value("Sp")
Sz=psi.expectation_value("Sz")
for (item1, item2) in zip(Sm, Sp):
Sx.append(item1+item2)
## Calculating bond entropy and correlation length ##
s_list=psi.entanglement_entropy()
# the bond 0 is between MPS unit cells and hence sensible even for 2D lattices.
#xi_list.append(psi.correlation_length())
#print(result)
E_list.append(result[0])
print(
#np.mean(psi.expectation_value(M.H_bond)),
s_list[-1],
E_list[-1],
#xi_list[-1],
flush=True)
tenpy.tools.optimization.optimize(3) # quite some speedup for small chi
print("SETTING NEW BOND DIMENSION")
return s_list, xi_list, E_list,Sz