# Mismatch Between MPS and MPO sizes

+1 vote

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:

{norm=0.89 (Dense Real)}

{norm=1.01 (Dense Real)}

{norm=0.91 (Dense Real)}

MPO:

{norm=1.59 (Dense Real)}

{norm=2.56 (Dense Real)}

{norm=2.00 (Dense Real)}

How should I properly construct the MPO/MPS?

commented by (70.1k 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 (70.1k 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.