Error when calling function toExpH

For SpinHalfSite, the toExpH function runs correctly.
For FermionSite,which is:


    int N=4;
    auto sites = Fermion(N); 
    
    auto ampo = AutoMPO(sites);
    for(auto j : range1(N-1))
        {
        ampo +=     "Cdag",j,"C",j+1;
        ampo +=     "C",j,"Cdag",j+1;
        ampo +=     "Cdag",j,"C",j;
        }
    ampo +=     "Cdag",N,"C",N;

The toExpH function reports the following error:

From line 885, file itensor.cc

div(T1)=QN({“Nf”,0,-1}) must equal div(T2)=QN({“Nf”,1,-1}) when adding T1+T2

looking forward to your reply.

Thanks for the question. I think I see two issues here:

  1. the main issue is that your operator, as written, is not Hermitian. Our toExpH system assumes a Hermitian operator, currently. (Plus I think you intended to write a Hermitian Hamiltonian.) The operator "C",j,"Cdag",j+1 is not the Hermitian conjugate of the operator "Cdag",j,"C",j+1. Instead you need to use the rule (c^\dag_j c_{j+1})^\dagger = c^\dagger_{j+1} c_j where one uses the fact that the \dagger operation reverses the ordering of the operators also.
  2. the other issue is not your fault, but is apparently a limitation of the AutoMPO system which is that I find the code for toExpH works only when you combine operators on a single site, so writing "N",j instead of "Cdag",j,"C",j even though they are mathematically equivalent.

Here is a corrected code that worked for me:

    auto ampo = AutoMPO(sites);
    for(auto j : range1(N-1))
        {
        ampo +=     "Cdag",j,"C",j+1;
        ampo +=     "Cdag",j+1,"C",j;
        ampo +=     "N",j;
        }
    ampo += "N",N;
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.