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?