0 votes
asked by (120 points)
edited by


I am trying to implement a $Z4$ symmetry in the electron site, similar to the $Z3$ symmetry in the Z3 site. I created a new site in which I have a $Z_4$ QN, and all operators are equal to the electron site.

Z4pSite(Args const& args = Args::global())
    auto ts = TagSet("Site,Z4p");
    if( args.defined("SiteNumber") )
      s = Index(QN({0,4}),1,
      s = Index(4,ts);

When I use this Z4 site, I can measure the totalQN of an MPS that I define

auto sites = Z4p(N,{"ConserveQNs",true});
auto state = InitState(sites);
for(int i = N; i >= 1; --i)
 auto psi = MPS(state);

and it gives me the expected QN. However when I try to make an Hamiltonian that conserves $Z_4$ QN , I aways get the error "From line 173, file itdata/qdense.cc
Setting Tensor element non-zero would violate its symmetry.
Setting Tensor element non-zero would violate its symmetry.
Aborted (core dumped)", no matter how simple the Hamiltonian is, even if it is just a nearest neighbour hopping:

#include "itensor/all.h"
using namespace itensor;
int main()
   int N = 16;
   auto J1=1;
   auto sites = Z4p(N,{"ConserveQNs",true});
   auto ampo = AutoMPO(sites);
   for(int b = 1; b < N; ++b)
            ampo += -J1,"Cdagup",b,"Cup",b+1;
            ampo += -J1,"Cdagup",b+1,"Cup",b;
            ampo += -J1,"Cdagdn",b,"Cdn",b+1;
            ampo += -J1,"Cdagdn",b+1,"Cdn",b;
   auto H = toMPO(ampo);
   return 0;

I'm wondering that could be the problem, as I tried to implement the $Z_3$ symmetry in the tJ siteset and it worked without any problems.

Raphael L R C Teixeira

commented by (70.1k points)
Hi, could you please post how you defined the Cdagup, Cup, etc operators in detail? It may well be that the Hamiltonian you are making out of those operators, the way they are defined, does not conserve the Z4 quantum number.
commented by (70.1k points)
Relatedly, how are you wanting to define those operators ideally? It's a little confusing to me what is meant by "C dagger" and "C" in this context since these degrees of freedom are not electrons. (So what is spin "up" and "down" and what do those mean for these kind of sites?)
commented by (120 points)
Hello Miles,

I was trying to define a QN such that empty state has QN - 0, up  QN - 1, UpDn - QN=2 and Dn - Qn 3, and I defined the same way the electron site with a phase:

    op(std::string const& opname,
       Args const& args) const
        auto sP = prime(s);

        IndexVal Em(s(1)),

        ITensor Op(dag(s),sP);

    if(opname == "Cup")
        if(opname == "Cdagup")
        if(opname == "Cdn")
        if(opname == "Cdagdn")

I was trying to implement the basis from arXiv:1802.06061 (Eq. A4). I also tried without the phase, literally the same from electron site, and it didn`t work.
commented by (70.1k points)
I see, thanks. But from what I can see in that paper, the definition of the fermion operators such as Cdagup are related to the Z4 basis in a rather complicated way, as shown by Equation (2) which relates the d operator to a linear combination of C operators with both spin types (up and down). Is your definition equivalent to that one?
commented by (120 points)
edited by
Yes it should be the same. Ok, now I see it. Even though it is a rather complicated way to define  the C operators in terms of this Z4 D operators (A7), if I were to implement this way, it should work, right? I will be trying this. Thank you!
commented by (70.1k points)
Yes, I wanted to point that out more from the physics side to make sure you had thought about those mappings the same way I was reading them.

But I'm puzzled by one thing: the way you defined Cup, Cdagup, etc. in the code looks to me like it might still respect the Z4 symmetry. So in parallel to you I will do a few tests to check whether I'm right about that and see exactly what part is leading to the error message. I'll let you know -

1 Answer

0 votes
answered by (70.1k points)

Hi, so to answer your question more definitively, I ran your code and the more technical (ITensor specific) reason for the error is that the way you have defined the operators does not lead to operators with a well-defined quantum number "flux" (i.e. the operators do not change a state by a definite QN amount, which is required of QN ITensors).

One case where this error is occurring is in your definition of the "Cdagup" operator. If you work through the fluxes of the two elements you are setting, they are different. One element is in a block of flux QN({3,4}) whereas the other is in a block of flux QN({1,4}). I note that you switched around the definition of the "UD" state and the "Dn" state from that of the Electron site set so that "UD" is state 3 and "Dn" is state 4. I imagine you had a good reason to try this, but I just wanted to point it out to emphasize this is important to notice when doing the flux calculation.

For more information on how the flux of operator blocks are defined, here is a page in the ITensor book (which I just added back to the v3 version of the book):

Please let me know if you have any questions about the above -


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.