Qn about iDMRG

How do I use this algorithm? What does that parameter do?
Post Reply
nervxxx
Posts: 5
Joined: 20 Aug 2020, 04:16

Qn about iDMRG

Post by nervxxx »

Hi, I am new to TeNPY and trying to use it.
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())
Note I am running iDMRG. If I understand correctly what the code is doing, I am solving for the ground state of the XXZ Hamiltonian on an infinite chain with specific anisotropy Delta = -1.7, in the Sz = 0 sector. Would this be accurate?

However I am very puzzled by the result I am getting. The energy density should be negative, yet I get this:
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
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.

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:
================================================================================
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 the energy density per sweep which fluctuates really wildly. What is happening here?


Note everything works fine for open BC and finite MPSes -- they agree with an independent ED code in MATLAB that I have.
User avatar
Johannes
Site Admin
Posts: 413
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Qn about iDMRG

Post by Johannes »

The model is \( H = J \sum_{i} (0.5 (S^+_i S^-_{i+1} + h.c.) + \Delta S^z_I S^z_{i+1} ) - h^z \sum_i S^z_i \), which is in the ferromagnetic phase of the XXZ chain for \(\Delta = -1.7\). In other words, the True ground state is simply all down states (or all up states, if you have a non-zero \(h^z\)).
Indeed, if you start from the fully FM state,

Code: Select all

psi = MPS.from_product_state(sites,["up","up"],"infinite")
you'll just get the expected energy of -1.7 *0.5*0.5 = -0.425. This is a very trivial product state for which you don't need to run DMRG, you can caluclate the energy by hand!

Fixing the half-filling will not be well defined in the thermodynamic limit; on the finite system it will try to make domains of (say) upspins left and down-spins right, but this will fail when growing the system - obviously, this is not a translation invariant state (that iDMRG looks for).
I guess that's also the issue for convergence for the \(\Delta=-1.67\) case. You can try to confirm this by measuring the Sz profile during the sweeps.
nervxxx
Posts: 5
Joined: 20 Aug 2020, 04:16

Re: Qn about iDMRG

Post by nervxxx »

Thank you for the response.

I see, so if I understand correctly what you are saying, there is no way to fix a magnetization density sector at least within iDMRG, even though total magnetization *is* a symmetry of the system and it *is* therefore meaningful to talk about GSes in the different magnetization sectors (i.e. QM 101 -- mutually commuting operators can be simultaneously diagonalized). After all there is no issue in principle of extracting a well-defined GS energy density in the magnetization density sector sz in thermodynamic limit by solving for the GS energy for various finite size systems, say in ED, with total Sz=sz*L sector, and extrapolating to the infinite system size limit.

So therefore the failure is not theoretical (because it would entail a failure of linear algebra, clearly not) but rather technical due to the way iDMRG works -- by growing the system -- that there is no way to preserve total magnetization density. Would that be right?
Post Reply