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!