Dear Jakub,
So I guess from examples .. but I cannot guess everything. To be specific. I run QMC codes for Bose-Hubbard. I know how to get occupation at different sides (for inhomogenous model, e.g. with harmonic trap and/or disorder), call them <n_i>. But I am interested in second moment <n_i^2>
There is a solution which looks ugly, but works :
patch the definition of the site basis of the model you're working with. In your example, Bose-Hubbard Hamiltonian uses the basis called "boson". Go to models.xml file and then add a line to the SITEBASIS definition:
<SITEBASIS name="boson"> <PARAMETER name="Nmax" default="infinity"/> <QUANTUMNUMBER name="N" min="0" max="Nmax"/> <OPERATOR name="bdag" matrixelement="sqrt(N+1)"> <CHANGE quantumnumber="N" change="1"/> </OPERATOR> <OPERATOR name="b" matrixelement="sqrt(N)"> <CHANGE quantumnumber="N" change="-1"/> </OPERATOR> <OPERATOR name="n" matrixelement="N"/> <OPERATOR name="n2" matrixelement="N*N"/> <!-- added --> </SITEBASIS>
Like I said, it's ugly, but it works. And, like you, I'd be very much interested in learning how to add measurements properly, without dirty tricks :).
Best,
Zhenya