+1 vote
asked by (340 points)

I've defined a custom SiteSet that is a mixture of SpinHalfSite and HubbardSite, and now I want to define a Hamiltonian on these sites using AutoMPO. This works just fine when I convert AutoMPO to an MPO. However, when I convert AutoMPO to an IQMPO, and try to apply it to an IQMPS, I get a segmentation fault.

I've defined my custom SiteSet in siteset.h as

template<typename SiteType1,typename SiteType2>
class BasicSiteSet2 : public SiteSet
{
public:

BasicSiteSet2() { }

BasicSiteSet2(int N,
             Args const& args = Args::global()){
    assert (N%2==0);
    auto sites = SiteStore(N);
    for(int j = 1; j <= N; ++j){
        if (j%2==1){
            sites.set(j,SiteType1(j,args));
        }
        else{
            sites.set(j,SiteType2(j,args));
        }
    }
    SiteSet::init(std::move(sites));
}

BasicSiteSet2(std::vector<IQIndex> const& inds)
    {
    int N = inds.size();
    auto sites = SiteStore(N);
    for(int j = 1, i = 0; j <= N; ++j, ++i)
        {
        auto& Ii = inds.at(i);
        if (j%2==1){
           sites.set(j,SiteType1(Ii));
        }
        else{
           sites.set(j,SiteType2(Ii));
        }
        }
    SiteSet::init(std::move(sites));
    }

void
read(std::istream& s)
    {
    SiteSet::readType2<SiteType1,SiteType2>(s);
    }

};

Then my code is:

auto sites = BasicSiteSet2<HubbardSite,SpinHalfSite>(2)
auto ampo=AutoMPO(sites);
ampo += 1,"Sz",1,"Sz",2;
auto H = IQMPO(ampo);

auto state = InitState(sites,"Up");

auto psi = IQMPS(state);
auto psi1 = exactApplyMPO(H,psi);

My Hamiltonian conserves spin and overall fermion number. Is there some adjustment to the quantum numbers I need to make in order to have this work? If so, what?

Thank you for your help!

1 Answer

0 votes
answered by (70.1k points)

Hi, so this is a good idea, however you are running into some of the deeper levels of AutoMPO which are not as ideal as they should be. I'm specifically planning to make handling of fermions more consistent throughout the library to help with some of these issues.

So my main guess as to what's going on is that AutoMPO is seeing that some of your operators are fermionic and then trying to make Jordan-Wigner string over all the sites in between your fermionic sites. However, the SpinHalfSite class does not provide a Jordan-Wigner string "F" operator.

So it may be as simple as defining an "F" operator for SpinHalfSite

But I can't really be sure that's the problem. Did you or can you try running your code in debug mode? That way you might get a more helpful error message instead of just a segfault.

Let's chat about it and I can try out your code myself if it's still not clear what's causing the issue.

Miles

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

...