## Why does my SSH model not working

How do I use this algorithm? What does that parameter do?
yhang
Posts: 2
Joined: 15 Jul 2022, 18:58

### Why does my SSH model not working

I am trying to code the SSH model using tenpy, but it looks like the product state got some problems, which I am confused about, here are my codes and the error

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

Attachments
Screen Shot 2022-08-30 at 21.23.02.png (113.65 KiB) Viewed 247 times
Johannes
Posts: 357
Joined: 21 Jul 2018, 12:52
Location: TU Munich

### Re: Why does my SSH model not working

You're using a FermionChain. As the name suggests, the FermionChain has as local sites the tenpy.networks.site.FermionSite. This site doesn't define "up" or "down" states, but only "full" and "empty" states.

Try to adjust the initial product state to be e.g. a half-filled

Code: Select all

	product_state = ["full", "empty"] * int(M.lat.N_sites/2)

Note that DMRG will also need much less iterations if you distribute the particles evenly instead of all on one side.