+1 vote
asked by (140 points)

Hello,

I've made a SiteSet named DP that is similar to the one provided by the CustomSpin class, and I want to use DMRG to find the ground state of the Hamiltonian
$$
p \sum S{-}S{+} + q \sum S{+}S{-}
$$.

The code in C++ is:

#include "itensor/all.h"
#include "DP.h"

using namespace itensor;

int main() {

// lattice parameters 
double p = 0.2;
double q = 0.7;
int capacity = 1;
int num_sites = 3;
auto args = Args("capacity=", capacity);
auto lattice = DP(num_sites, args)

// Hamiltonian
auto ampo = AutoMPO(lattice);
for (int i = 1; i <= lattice.length()-1; ++i) {
    ampo += p, "S-", i, "S+", i+1;
    ampo += q, "S+", i, "S-", i+1;
}
auto H = toMPO(ampo);

// MPS 
auto state = InitState(lattice);
auto psi0 = randomMPS(state);


print("MPS \n");
print(psi0);
print("MPO \n");
print(H);

// DMRG
auto sweeps = Sweeps(5);
sweeps.maxdim() = 10, 20, 100, 100, 200;
sweeps.cutoff() = 0.0001;
auto [energy, psi] = dmrg(H, psi0, sweeps);

return 0;
}

I receive an error "davidson: size of initial vector should match linear matrix size". However, the printout of the MPS and MPO (if I'm not misunderstanding them) say that they match:

MPS:

ITensor ord=2: (dim=2|id=672) (dim=1|id=834|"l=1,Link")
{norm=0.89 (Dense Real)}

ITensor ord=3: (dim=1|id=834|"l=1,Link") (dim=2|id=67) (dim=1|id=475|"l=2,Link")
{norm=1.01 (Dense Real)}

ITensor ord=2: (dim=1|id=475|"l=2,Link") (dim=2|id=393) 
{norm=0.91 (Dense Real)} 

MPO:

ITensor ord=3: (dim=4|id=436|"l=1,Link") (dim=2|id=672) (dim=2|id=672)'
{norm=1.59 (Dense Real)}

ITensor ord=4: (dim=4|id=436|"l=1,Link") (dim=4|id=372|"l=2,Link") (dim=2|id=67) (dim=2|id=67)'
{norm=2.56 (Dense Real)}

ITensor ord=3: (dim=4|id=372|"l=2,Link") (dim=2|id=393) (dim=2|id=393)' 
{norm=2.00 (Dense Real)}

How should I properly construct the MPO/MPS?

commented by (70k points)
Hi, thanks for the question. So looking over your code and the error message, the error is not referring to the length of your MPO or MPS. It is referring instead to a numerical problem that occurred inside of the innermost loop of the DMRG algorithm. Based on the information provided, it's not clear what really led to this error.

Here are two things that would help:
- showing how the DP sites are defined, because there may be a mistake in some of the operator definitions that is e.g. leading to the Hamiltonian not being Hermitian
- trying a system of length 4 or greater, because the 3-site case may have some slight issue as it is an unusually small system & we don't often test the code on such small sizes

If those two approaches don't pinpoint the issue, then the thing to do is to run it in a debugger and/or print out some intermediate quantities to see what's going on inside the code. It could be a bug in ITensor even.

Let's keep discussing –

Miles
commented by (140 points)
Hi Miles,

Thanks for the clear advice. The operators on the DP sites are defined so that the Hamiltonian is non-Hermitian, like you pointed out. I will try your suggestions for adapting DMRG to use the Arnoldi algorithm (http://itensor.org/support/2367/non-hermitian-dmrg-in-julia).

Thanks very much for your help!
commented by (70k points)
I see - so you were intentionally studying a non-Hermitian Hamiltonian? If so, yes you would need to adapt the DMRG algorithm which by default requires a Hermitian Hamiltonian.
commented by (14.1k points)
Note that in the Julia version it would be easy to try out non-Hermitian DMRG.

1 Answer

0 votes
answered by (70k points)

(See answer in discussion above.)

Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...