0 votes
asked by (590 points)

Hi Miles,

I want to calculate the Sx^2 for a spin 2 system and the operator is defined in the header file spintwo.h. For the simple code shown below, the compile was successful but when I ran the code, I got the error message:

"From line 161, file itdata/qdense.cc

Setting IQTensor element non-zero would violate its symmetry.

Setting IQTensor element non-zero would violate its symmetry.
Aborted (core dumped)"

include "itensor/all.h"

include ".../itensor/itensor/mps/sites/spintwo.h"

using namespace itensor;

int main()
{
auto sites = SpinTwo(4);
ITensor op = sites.op("Sx2",2);
PrintData(op);
return 0;
}

I got the same error message for operators Sy^2 and S^2 but the code worked perfectly for Sz^2. Could you please help me resolve this issue?

P.S. A year ago, an ITensor user named alesa ran into a similar problem for spin 1 system and you mentioned that there was a bug associated with spin 1 siteset which you later fixed: http://itensor.org/support/678/get-error-message-for-using-sx2

1 Answer

+1 vote
answered by (27.6k points)
selected by
 
Best answer

Hi, thanks for the question. So the issue is a rather technical one and has to do with a tricky design issue we have with using a single site set type for both ITensor and IQTensor tensor types. We have a plan to fix this more deeply in the library, but for now you have to do the following steps:

  1. when defining an operator such as Sx^2 inside your site set, add the line
    Op = mixedIQTensor(dag(s),sP);
    before setting the elements of your operator. See the file itensor/mps/sites/spinhalf.h and where the "Sx" operator is defined for an example.

  2. when retrieving your operator from the sites.op("Sx2",j) method, make sure to convert it to an ITensor

You will need to use ITensors, and not IQTensors, to work with operators such as Sx^2 in your own code since such an operator does not conserve the total Sz quantum number.

Best regards,
Miles

commented by (590 points)
Hi Miles,

I did exactly what you suggested and the code works perfectly. Thanks for your help.

Regards,
Niraj
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

...