Hi there!
I am trying to implement conserved parity in ITensor C++ version. I consider one dimensional Ising chain with periodic boundary condition. The Hamiltonian is H = -g\sum_j \sigma_j^z- J\sum_j \sigma_j^x \sigma_{j+1}^x. This hamiltonian commutes with the operator \mathcal{F} = \prod_j \sigma_j^z. My goal is to compute ground state energy in each parity sector, i.e., \mathcal{F}=1 and \mathcal{F}=-1. My code is as follows:
#include "itensor/all.h"
#include "itensor/util/print_macro.h"
using namespace itensor;
int main(int argc, char *argv[])
{
int N;
double J, g;
N = atoi (argv[1]);
J = 2*atof (argv[2]);
g = 2*atof (argv[3]);
auto sites = SpinOne(N,{"ConserveParity=",true});
auto ampo = AutoMPO(sites);
for(int j = 1; j <=N; ++j){
ampo += -g,"Sz",j;
int jp1 = (j % N)+1; // Periodic boundary condition
ampo += -J,"Sx",j,"Sx",jp1;
}
auto H = toMPO(ampo);
auto sweeps = Sweeps(10);
sweeps.maxdim() = 10,20,100,200,400;
sweeps.cutoff() = 1E-10;
auto psi0 = randomMPS(sites);
auto [en0, psi_opt] = dmrg(H, psi0, sweeps,{"Quite=",true});
printfln("\nGround State Energy =",en0);
return 0;
}
This gives me following error:
`
Trying to set element:
Index: (dim=3|id=706|“S=1,n=1,Site”)
1: 1 QN({“Sz”,2})
2: 1 QN({“Sz”,0})
3: 1 QN({“Sz”,-2}), Val: 2
Index: (dim=3|id=706|“S=1,n=1,Site”)’
1: 1 QN({“Sz”,2})
2: 1 QN({“Sz”,0})
3: 1 QN({“Sz”,-2}), Val: 1
Element flux is: QN({“Sz”,2})
ITensor flux is: QN({“Sz”,-2})
From line 327, file /Users/itensor/itensor/itensor_impl.h
In .set, cannot set element with flux different from ITensor flux
In .set, cannot set element with flux different from ITensor flux
zsh: abort
`
Could you please point out what I am doing wrong. Also how do I specify value of \mathcal{F} to be +1 or -1?
Thanks!