I tried running the following test script, which is more or less the XXZ example given in the documentation:

Code: Select all

```
from tenpy.networks.site import SpinSite
from tenpy.models.lattice import Chain
from tenpy.models.model import CouplingModel, NearestNeighborModel, MPOModel
from tenpy.networks.mps import MPS
from tenpy.algorithms import dmrg
class XXZChain(CouplingModel, NearestNeighborModel, MPOModel):
def __init__(self, L=2, S=0.5, J=1., Delta=-1.7, hz=0.):
spin = SpinSite(S=S, conserve='Sz')
# the lattice defines the geometry
lat = Chain(L, spin, bc="periodic", bc_MPS="infinite")
CouplingModel.__init__(self, lat)
# add terms of the Hamiltonian
self.add_coupling(J * 0.5, 0, "Sp", 0, "Sm", 1) # Sp_i Sm_{i+1}
self.add_coupling(J * 0.5, 0, "Sp", 0, "Sm", -1) # Sp_i Sm_{i-1}
self.add_coupling(J * Delta, 0, "Sz", 0, "Sz", 1)
# (for site dependent prefactors, the strength can be an array)
self.add_onsite(-hz, 0, "Sz")
# finish initialization
# generate MPO for DMRG
MPOModel.__init__(self, lat, self.calc_H_MPO())
# generate H_bond for TEBD
NearestNeighborModel.__init__(self, lat, self.calc_H_bond())
model = XXZChain()
sites = model.lat.mps_sites()
psi = MPS.from_product_state(sites,["up","down"]*1,"infinite")
dmrg_params = {"trunc_params": {"chi_max": 100, "svd_min": 1.e-10}, "mixer": True}
info = dmrg.run(psi, model, dmrg_params)
print("E = ",info['E'])
print("max. bond dimension = ",max(psi.chi))
print("corre. length =",psi.correlation_length())
```

However I am very puzzled by the result I am getting. The energy density should be negative, yet I get this:

I mean, I say it should be negative because I obtained the GS energy/system size on periodic chains in ED and found it was always negative; thus in the TDL it should also be negative.sweep 30, age = 368

Energy = 0.2018209781181106, S = 0.1636146174328617, norm_err = 4.7e-16

Current memory usage 46008.0 MB, time elapsed: 2.6 s

Delta E = 8.8818e-17, Delta S = 9.4369e-17 (per sweep)

max_trunc_err = 4.6061e-25, max_E_trunc = 1.4211e-14

MPS bond dimensions: [4, 3]

================================================================================

DMRG finished after 30 sweeps.

total size = 368, maximum chi = 4

================================================================================

E = 0.20182097811811062

max. bond dimension = 4

corre. length = 0.4362827657246735

So why is it positive?

Then there is something odd. If I change Delta to -1.67, still in the gapped ferromagnetic phase of the XXZ model where the ground state should be relatively simple, the iDMRG doesn't seem like it wants to converge:

Note the energy density per sweep which fluctuates really wildly. What is happening here?================================================================================

sweep 10, age = 128

Energy = 0.1900958110857189, S = nan, norm_err = 2.6e-16

Current memory usage 45844.0 MB, time elapsed: 1.3 s

Delta E = nan, Delta S = 0.0000e+00 (per sweep)

max_trunc_err = 5.1968e-21, max_E_trunc = 7.1054e-15

MPS bond dimensions: [5, 3]

disable mixer after 15 sweeps, final amplitude 3.05e-10

Updating environment

.....

================================================================================

sweep 20, age = 248

Energy = 0.1900958110857118, S = 0.1686131567831038, norm_err = 3.9e-17

Current memory usage 46628.0 MB, time elapsed: 2.0 s

Delta E = -7.1054e-16, Delta S = nan (per sweep)

max_trunc_err = 1.4014e-24, max_E_trunc = 1.4211e-14

MPS bond dimensions: [4, 3]

Updating environment

.....

================================================================================

sweep 30, age = 368

Energy = 0.4915880947474696, S = 0.0776768967601684, norm_err = 2.2e-11

Current memory usage 59124.0 MB, time elapsed: 5.6 s

Delta E = 3.0149e-02, Delta S = -9.0936e-03 (per sweep)

max_trunc_err = 1.4882e-07, max_E_trunc = -2.0647e-06

MPS bond dimensions: [14, 14]

Updating environment

.....

================================================================================

sweep 40, age = 488

Energy = 0.1819779374852555, S = 0.6361349382587411, norm_err = 1.8e-04

Current memory usage 60292.0 MB, time elapsed: 9.2 s

Delta E = -3.0961e-02, Delta S = 5.5846e-02 (per sweep)

max_trunc_err = 1.8969e-06, max_E_trunc = -2.2694e-05

MPS bond dimensions: [33, 35]

Updating environment

.....

================================================================================

sweep 50, age = 608

Energy = 1.1514287417030786, S = 0.9826144092191988, norm_err = 1.1e-01

Current memory usage 63828.0 MB, time elapsed: 13.2 s

Delta E = 9.6945e-02, Delta S = 3.4648e-02 (per sweep)

max_trunc_err = 1.5756e-07, max_E_trunc = -8.7012e-07

MPS bond dimensions: [100, 100]

Updating environment

.....

Note everything works fine for open BC and finite MPSes -- they agree with an independent ED code in MATLAB that I have.