16 #include <bitcalc.hpp> 17 #include "mltplyCommon.hpp" 18 #include "mltplySpinCore.hpp" 19 #include "wrapperMPI.hpp" 20 #include "mltplyMPISpin.hpp" 21 #include "mltplyMPISpinCore.hpp" 22 #include "expec_totalspin.hpp" 48 std::complex<double> **vec
51 long int irght, ilft, ihfbit;
52 long int isite1, isite2;
53 long int is1_up, is2_up, is1_down, is2_down;
55 int num1_up, num2_up, istate;
56 int num1_down, num2_down;
57 long int ibit1_up, ibit2_up, ibit1_down, ibit2_down;
58 std::complex<double> tmp_spn_z;
63 for (istate = 0; istate < nstate; istate++) {
67 for (isite1 = 1; isite1 <= X->
Def.
NsiteMPI; isite1++) {
68 is1_up = X->
Def.
Tpow[2 * isite1 - 2];
69 is1_down = X->
Def.
Tpow[2 * isite1 - 1];
71 for (isite2 = 1; isite2 <= X->
Def.
NsiteMPI; isite2++) {
72 is2_up = X->
Def.
Tpow[2 * isite2 - 2];
73 is2_down = X->
Def.
Tpow[2 * isite2 - 1];
75 for (j = 1; j <= i_max; j++) {
77 ibit1_up =
list_1[j] & is1_up;
78 num1_up = ibit1_up / is1_up;
79 ibit2_up =
list_1[j] & is2_up;
80 num2_up = ibit2_up / is2_up;
82 ibit2_down =
list_1[j] & is2_down;
83 num2_down = ibit2_down / is2_down;
84 ibit1_down =
list_1[j] & is1_down;
85 num1_down = ibit1_down / is1_down;
87 tmp_spn_z = (num1_up - num1_down) * (num2_up - num2_down);
88 for (istate = 0; istate < nstate; istate++)
89 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate] * tmp_spn_z / 4.0);
90 if (isite1 == isite2) {
91 for (istate = 0; istate < nstate; istate++) {
92 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate]) * (num1_up + num1_down - 2 * num1_up * num1_down) / 2.0;
93 X->
Phys.
Sz[istate] += real(conj(vec[j][istate]) * vec[j][istate]) * (num1_up - num1_down) / 2.0;
97 if (ibit1_up != 0 && ibit1_down == 0 && ibit2_up == 0 && ibit2_down != 0) {
98 iexchg =
list_1[j] - (is1_up + is2_down);
99 iexchg += (is2_up + is1_down);
101 for (istate = 0; istate < nstate; istate++)
102 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[off][istate]) / 2.0;
104 else if (ibit1_up == 0 && ibit1_down != 0 && ibit2_up != 0 && ibit2_down == 0) {
105 iexchg =
list_1[j] - (is1_down + is2_up);
106 iexchg += (is2_down + is1_up);
108 for (istate = 0; istate < nstate; istate++)
109 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[off][istate]) / 2.0;
130 std::complex<double> **vec
133 long int isite1, isite2;
134 long int is1_up, is2_up, is1_down, is2_down;
135 long int iexchg, off;
136 int num1_up, num2_up, istate;
137 int num1_down, num2_down;
138 long int ibit1_up, ibit2_up, ibit1_down, ibit2_down, list_1_j;
139 std::complex<double> tmp_spn_z;
144 for (istate = 0; istate < nstate; istate++) {
148 for (isite1 = 1; isite1 <= X->
Def.
NsiteMPI; isite1++) {
149 for (isite2 = 1; isite2 <= X->
Def.
NsiteMPI; isite2++) {
150 is1_up = X->
Def.
Tpow[2 * isite1 - 2];
151 is1_down = X->
Def.
Tpow[2 * isite1 - 1];
152 is2_up = X->
Def.
Tpow[2 * isite2 - 2];
153 is2_down = X->
Def.
Tpow[2 * isite2 - 1];
155 for (j = 1; j <= i_max; j++) {
157 ibit1_up = list_1_j & is1_up;
158 num1_up = ibit1_up / is1_up;
159 ibit2_up = list_1_j & is2_up;
160 num2_up = ibit2_up / is2_up;
162 ibit1_down = list_1_j & is1_down;
163 num1_down = ibit1_down / is1_down;
164 ibit2_down = list_1_j & is2_down;
165 num2_down = ibit2_down / is2_down;
167 tmp_spn_z = (num1_up - num1_down) * (num2_up - num2_down);
168 for (istate = 0; istate < nstate; istate++)
169 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate] * tmp_spn_z / 4.0);
170 if (isite1 == isite2) {
171 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate]) * (num1_up + num1_down - 2 * num1_up * num1_down) / 2.0;
172 X->
Phys.
Sz[istate] += real(conj(vec[j][istate]) * vec[j][istate]) * (num1_up - num1_down) / 2.0;
175 if (ibit1_up != 0 && ibit1_down == 0 && ibit2_up == 0 && ibit2_down != 0) {
176 iexchg = list_1_j - (is1_up + is2_down);
177 iexchg += (is2_up + is1_down);
179 for (istate = 0; istate < nstate; istate++)
180 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[off][istate] / 2.0);
182 else if (ibit1_up == 0 && ibit1_down != 0 && ibit2_up != 0 && ibit2_down == 0) {
183 iexchg = list_1_j - (is1_down + is2_up);
184 iexchg += (is2_down + is1_up);
186 for (istate = 0; istate < nstate; istate++)
187 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[off][istate] / 2.0);
210 std::complex<double> **vec
213 long int irght, ilft, ihfbit;
214 long int isite1, isite2;
215 long int tmp_isite1, tmp_isite2;
217 long int is1_up, is2_up;
218 long int iexchg, off, off_2;
220 int num1_up, num2_up;
221 int num1_down, num2_down;
222 int sigma_1, sigma_2, istate;
223 long int ibit1_up, ibit2_up, ibit_tmp, is_up;
224 std::complex<double> spn_z1, spn_z2;
229 for (istate = 0; istate < nstate; istate++) {
235 for (isite1 = 1; isite1 <= X->
Def.
NsiteMPI; isite1++) {
236 for (isite2 = 1; isite2 <= X->
Def.
NsiteMPI; isite2++) {
240 is1_up = X->
Def.
Tpow[isite1 - 1];
241 is2_up = X->
Def.
Tpow[isite2 - 1];
242 is_up = is1_up + is2_up;
244 num1_down = 1 - num1_up;
246 num2_down = 1 - num2_up;
247 spn_z = (num1_up - num1_down) * (num2_up - num2_down);
249 for (j = 1; j <= i_max; j++) {
250 for (istate = 0; istate < nstate; istate++)
251 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate] * spn_z) / 4.0;
253 if (isite1 == isite2) {
254 for (j = 1; j <= i_max; j++) {
255 for (istate = 0; istate < nstate; istate++)
256 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate]) / 2.0;
266 if (isite1 < isite2) {
275 is1_up = X->
Def.
Tpow[tmp_isite1 - 1];
276 is2_up = X->
Def.
Tpow[tmp_isite2 - 1];
278 num2_down = 1 - num2_up;
281 for (j = 1; j <= i_max; j++) {
282 ibit1_up =
list_1[j] & is1_up;
283 num1_up = ibit1_up / is1_up;
284 num1_down = 1 - num1_up;
285 spn_z = (num1_up - num1_down) * (num2_up - num2_down);
286 for (istate = 0; istate < nstate; istate++)
287 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate] * spn_z) / 4.0;
289 if (isite1 < isite2) {
298 is1_up = X->
Def.
Tpow[isite1 - 1];
299 is2_up = X->
Def.
Tpow[isite2 - 1];
300 is_up = is1_up + is2_up;
302 for (j = 1; j <= i_max; j++) {
303 ibit1_up =
list_1[j] & is1_up;
304 num1_up = ibit1_up / is1_up;
305 num1_down = 1 - num1_up;
306 ibit2_up =
list_1[j] & is2_up;
307 num2_up = ibit2_up / is2_up;
308 num2_down = 1 - num2_up;
310 spn_z = (num1_up - num1_down) * (num2_up - num2_down);
311 for (istate = 0; istate < nstate; istate++)
312 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate] * spn_z) / 4.0;
314 if (isite1 == isite2) {
315 for (istate = 0; istate < nstate; istate++)
316 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate]) / 2.0;
319 ibit_tmp = (num1_up) ^ (num2_up);
321 iexchg =
list_1[j] ^ (is_up);
323 for (istate = 0; istate < nstate; istate++)
324 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[off][istate]) / 2.0;
335 for (isite1 = 1; isite1 <= X->
Def.
NsiteMPI; isite1++) {
336 for (isite2 = 1; isite2 <= X->
Def.
NsiteMPI; isite2++) {
339 if (isite1 == isite2) {
340 for (j = 1; j <= i_max; j++) {
342 for (istate = 0; istate < nstate; istate++) {
343 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate]) * S1 * (S1 + 1.0);
344 X->
Phys.
Sz[istate] += real(conj(vec[j][istate]) * vec[j][istate] * spn_z1);
349 for (j = 1; j <= i_max; j++) {
352 for (istate = 0; istate < nstate; istate++)
353 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[j][istate] * spn_z1 * spn_z2);
360 if (ibit_tmp == TRUE) {
363 if (ibit_tmp == TRUE) {
365 for (istate = 0; istate < nstate; istate++)
366 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[off][istate])
367 * sqrt(S2 * (S2 + 1) - real(spn_z2) * (real(spn_z2) + 1))
368 * sqrt(S1 * (S1 + 1) - real(spn_z1) * (real(spn_z1) - 1)) / 2.0;
374 if (ibit_tmp == TRUE) {
377 if (ibit_tmp == TRUE) {
379 for (istate = 0; istate < nstate; istate++)
380 X->
Phys.
s2[istate] += real(conj(vec[j][istate]) * vec[off][istate])
381 * sqrt(S2 * (S2 + 1) - real(spn_z2) * (real(spn_z2) - 1.0))
382 * sqrt(S1 * (S1 + 1) - real(spn_z1) * (real(spn_z1) + 1)) / 2.0;
408 std::complex<double> **vec
411 long int isite1, isite2, tmp_isite1, tmp_isite2;
412 long int is1_up, is2_up;
413 long int iexchg, off, off_2;
414 int num1_up, num2_up, istate;
415 int num1_down, num2_down;
416 int sigma_1, sigma_2;
417 long int ibit1_up, ibit2_up, ibit_tmp, is_up;
418 std::complex<double> spn_z1, spn_z2;
424 for (istate = 0; istate < nstate; istate++) {
429 for (isite1 = 1; isite1 <= X->
Def.
NsiteMPI; isite1++) {
431 is1_up = X->
Def.
Tpow[isite1 - 1];
432 ibit1_up =
myrank & is1_up;
433 num1_up = ibit1_up / is1_up;
434 num1_down = 1 - num1_up;
435 for (j = 1; j <= i_max; j++) {
436 for (istate = 0; istate < nstate; istate++)
437 X->
Phys.
Sz[istate] += real(conj(vec[j][istate])*vec[j][istate]) * (num1_up - num1_down) / 2.0;
441 is1_up = X->
Def.
Tpow[isite1 - 1];
442 for (j = 1; j <= i_max; j++) {
444 ibit1_up = list_1_j & is1_up;
445 num1_up = ibit1_up / is1_up;
446 num1_down = 1 - num1_up;
447 for (istate = 0; istate < nstate; istate++)
448 X->
Phys.
Sz[istate] += real(conj(vec[j][istate])*vec[j][istate]) * (num1_up - num1_down) / 2.0;
451 for (isite2 = 1; isite2 <= X->
Def.
NsiteMPI; isite2++) {
454 is1_up = X->
Def.
Tpow[isite1 - 1];
455 is2_up = X->
Def.
Tpow[isite2 - 1];
457 num1_down = 1 - num1_up;
459 num2_down = 1 - num2_up;
460 spn_z2 = (num1_up - num1_down)*(num2_up - num2_down) / 4.0;
461 for (j = 1; j <= i_max; j++) {
462 for (istate = 0; istate < nstate; istate++)
463 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[j][istate] * spn_z2);
465 if (isite1 == isite2) {
466 for (j = 1; j <= i_max; j++) {
467 for (istate = 0; istate < nstate; istate++)
468 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[j][istate]) / 2.0;
477 if (isite1 < isite2) {
485 is1_up = X->
Def.
Tpow[tmp_isite1 - 1];
486 is2_up = X->
Def.
Tpow[tmp_isite2 - 1];
488 num2_down = 1 - num2_up;
490 for (j = 1; j <= i_max; j++) {
492 ibit1_up = list_1_j & is1_up;
493 num1_up = ibit1_up / is1_up;
494 num1_down = 1 - num1_up;
495 spn_z2 = (num1_up - num1_down)*(num2_up - num2_down);
496 for (istate = 0; istate < nstate; istate++)
497 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[j][istate] * spn_z2) / 4.0;
499 if (isite1 < isite2) {
507 is2_up = X->
Def.
Tpow[isite2 - 1];
508 is_up = is1_up + is2_up;
509 for (j = 1; j <= i_max; j++) {
511 ibit1_up = list_1_j & is1_up;
512 num1_up = ibit1_up / is1_up;
513 num1_down = 1 - num1_up;
514 ibit2_up = list_1_j & is2_up;
515 num2_up = ibit2_up / is2_up;
516 num2_down = 1 - num2_up;
518 spn_z2 = (num1_up - num1_down)*(num2_up - num2_down);
519 for (istate = 0; istate < nstate; istate++)
520 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[j][istate] * spn_z2) / 4.0;
522 if (isite1 == isite2) {
523 for (istate = 0; istate < nstate; istate++)
524 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[j][istate]) / 2.0;
527 ibit_tmp = (num1_up) ^ (num2_up);
529 iexchg = list_1_j ^ (is_up);
531 for (istate = 0; istate < nstate; istate++)
532 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[off][istate]) / 2.0;
543 for (isite1 = 1; isite1 <= X->
Def.
NsiteMPI; isite1++) {
547 for (j = 1; j <= i_max; j++) {
548 for (istate = 0; istate < nstate; istate++) {
549 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[j][istate]) * S1*(S1 + 1.0);
550 X->
Phys.
Sz[istate] += real(conj(vec[j][istate])*vec[j][istate] * spn_z1);
555 for (j = 1; j <= i_max; j++) {
557 for (istate = 0; istate < nstate; istate++) {
558 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[j][istate]) * S1*(S1 + 1.0);
559 X->
Phys.
Sz[istate] += real(conj(vec[j][istate])*vec[j][istate] * spn_z1);
563 for (isite2 = 1; isite2 <= X->
Def.
NsiteMPI; isite2++) {
564 if (isite1 == isite2)
continue;
571 for (j = 1; j <= i_max; j++) {
574 for (istate = 0; istate < nstate; istate++)
575 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[j][istate] * spn_z1*spn_z2);
584 for (istate = 0; istate < nstate; istate++)
585 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[off_2 + 1][istate])
586 * sqrt(S2*(S2 + 1) - real(spn_z2) * (real(spn_z2) + 1))
587 * sqrt(S1*(S1 + 1) - real(spn_z1) * (real(spn_z1) - 1)) / 2.0;
594 for (istate = 0; istate < nstate; istate++)
595 X->
Phys.
s2[istate] += real(conj(vec[j][istate])*vec[off_2 + 1][istate])
596 * sqrt(S2*(S2 + 1) - real(spn_z2) * (real(spn_z2) - 1.0))
597 * sqrt(S1*(S1 + 1) - real(spn_z1) * (real(spn_z1) + 1)) / 2.0;
622 std::complex<double> **vec
631 for (istate = 0; istate < nstate; istate++)
646 for (istate = 0; istate < nstate; istate++) {
struct DefineList Def
Definision of system (Hamiltonian) etc.
int GetSplitBitByModel(const int Nsite, const int iCalcModel, long int *irght, long int *ilft, long int *ihfbit)
function of splitting original bit into right and left spaces.
void totalspin_Hubbard(struct BindStruct *X, int nstate, std::complex< double > **vec)
function of calculating totalspin for Hubbard model
double * s2
Expectation value of the square of the total S.
int Nsite
Number of sites in the INTRA process region.
void totalspin_Spin(struct BindStruct *X, int nstate, std::complex< double > **vec)
function of calculating totalspin for spin model
int X_SpinGC_CisAis(long int j, long int is1_spin, long int sigma1)
Compute the grandcanonical spin state with bit mask is1_spin.
struct LargeList Large
Variables for Matrix-Vector product.
int ConvertToList1GeneralSpin(const long int org_ibit, const long int ihlfbit, long int *_ilist1Comp)
function of converting component to list_1
struct PhysList Phys
Physical quantities.
int mode
multiply or expectation value.
double * Sz
Expectation value of the Total Sz.
int NsiteMPI
Total number of sites, differ from DefineList::Nsite.
int GetOffCompGeneralSpin(const long int org_ibit, const int org_isite, const int org_ispin, const int off_ispin, long int *_ioffComp, const long int *SiteToBit, const long int *Tpow)
function of getting off-diagonal component for general spin
int GetOffComp(long int *_list_2_1, long int *_list_2_2, long int _ibit, const long int _irght, const long int _ilft, const long int _ihfbit, long int *_ioffComp)
function of getting off-diagonal component
int expec_totalspin(struct BindStruct *X, int nstate, std::complex< double > **vec)
Parent function of calculation of total spin.
int myrank
Process ID, defined in InitializeMPI()
int GetLocal2Sz(const int isite, const long int org_bit, const long int *SiteToBit, const long int *Tpow)
get 2sz at a site for general spin
int iFlgGeneralSpin
Flag for the general (Sz/=1/2) spin.
void totalspin_HubbardGC(struct BindStruct *X, int nstate, std::complex< double > **vec)
function of calculating totalspin for Hubbard model in grand canonical ensemble
void SumMPI_dv(int nnorm, double *norm)
MPI wrapper function to obtain sum of Double array across processes.
void totalspin_SpinGC(struct BindStruct *X, int nstate, std::complex< double > **vec)
function of calculating totalspin for spin model in grand canonical ensemble
long int * SiteToBit
[DefineList::NsiteMPI] Similar to DefineList::Tpow. For general spin.
long int * Tpow
[2 * DefineList::NsiteMPI] malloc in setmem_def().
int iCalcModel
Switch for model. 0:Hubbard, 1:Spin, 2:Kondo, 3:HubbardGC, 4:SpinGC, 5:KondoGC, 6:HubbardNConserved.
struct CheckList Check
Size of the Hilbert space.
long int sdim
Dimension for Ogata-Lin ???
long int idim_max
The dimension of the Hilbert space of this process.
int GetBitGeneral(const int isite, const long int org_bit, const long int *SiteToBit, const long int *Tpow)
get bit at a site for general spin
int Total2SzMPI
Total across processes.