HPhi++  3.1.0
mltplySpin.cpp
Go to the documentation of this file.
1 /* HPhi - Quantum Lattice Model Simulator */
2 /* Copyright (C) 2015 The University of Tokyo */
3 /* This program is free software: you can redistribute it and/or modify */
4 /* it under the terms of the GNU General Public License as published by */
5 /* the Free Software Foundation, either version 3 of the License, or */
6 /* (at your option) any later version. */
7 
8 /* This program is distributed in the hope that it will be useful, */
9 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
10 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
11 /* GNU General Public License for more details. */
12 
13 /* You should have received a copy of the GNU General Public License */
14 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
159 #include <bitcalc.hpp>
160 #include "common/setmemory.hpp"
161 #include "mltplyCommon.hpp"
162 #include "mltplySpin.hpp"
163 #include "CalcTime.hpp"
164 #include "mltplySpinCore.hpp"
165 #include "mltplyHubbardCore.hpp"
166 #include "mltplyMPISpin.hpp"
167 #include "mltplyMPISpinCore.hpp"
174  struct BindStruct *X,
175  int nstate, std::complex<double> **tmp_v0,
176  std::complex<double> **tmp_v1
177 ) {
178  int iret=0;
179  if (X->Def.iFlgGeneralSpin == FALSE)
180  iret = mltplyHalfSpin(X, nstate, tmp_v0, tmp_v1);
181  else
182  iret = mltplyGeneralSpin(X, nstate, tmp_v0, tmp_v1);
183  return iret;
184 }/*int mltplySpin*/
191  struct BindStruct *X,
192  int nstate, std::complex<double> **tmp_v0,
193  std::complex<double> **tmp_v1
194 ) {
195  long int i;
196  long int isite1, isite2, sigma1, sigma2;
197  long int sigma3, sigma4;
198 
199  /*[s] For InterAll */
200  std::complex<double> tmp_V;
201  /*[e] For InterAll */
202  int ihermite=0;
203  int idx=0;
204 
205  StartTimer(400);
210  StartTimer(410);
211  for (i = 0; i < X->Def.NInterAll_OffDiagonal; i+=2) {
212  if (X->Def.InterAll_OffDiagonal[i][0] + 1 > X->Def.Nsite &&
213  X->Def.InterAll_OffDiagonal[i][4] + 1 > X->Def.Nsite) {
214  StartTimer(411);
215  child_general_int_spin_MPIdouble(i, X, nstate, tmp_v0, tmp_v1);
216  StopTimer(411);
217  }
218  else if (X->Def.InterAll_OffDiagonal[i][4] + 1 > X->Def.Nsite) {
219  StartTimer(412);
220  child_general_int_spin_MPIsingle(i, X, nstate, tmp_v0, tmp_v1);
221  StopTimer(412);
222  }
223  else if (X->Def.InterAll_OffDiagonal[i][0] + 1 > X->Def.Nsite) {
224  StartTimer(413);
225  child_general_int_spin_MPIsingle(i + 1, X, nstate, tmp_v0, tmp_v1);
226  StopTimer(413);
227  }
228  else {
229  StartTimer(414);
230  for (ihermite = 0; ihermite<2; ihermite++) {
231  idx = i + ihermite;
232  isite1 = X->Def.InterAll_OffDiagonal[idx][0] + 1;
233  isite2 = X->Def.InterAll_OffDiagonal[idx][4] + 1;
234  sigma1 = X->Def.InterAll_OffDiagonal[idx][1];
235  sigma2 = X->Def.InterAll_OffDiagonal[idx][3];
236  sigma3 = X->Def.InterAll_OffDiagonal[idx][5];
237  sigma4 = X->Def.InterAll_OffDiagonal[idx][7];
238  tmp_V = X->Def.ParaInterAll_OffDiagonal[idx];
239  child_general_int_spin_GetInfo(X, isite1, isite2, sigma1, sigma2, sigma3, sigma4, tmp_V);
240  child_general_int_spin(nstate, tmp_v0, tmp_v1, X);
241  }/*for (ihermite = 0; ihermite<2; ihermite++)*/
242  StopTimer(414);
243  }
244  }/*for (i = 0; i < X->Def.NInterAll_OffDiagonal; i+=2)*/
245  StopTimer(410);
249  StartTimer(420);
250  for (i = 0; i < X->Def.NExchangeCoupling; i++) {
251  sigma1=0; sigma2=1;
252  if (X->Def.ExchangeCoupling[i][0] + 1 > X->Def.Nsite &&
253  X->Def.ExchangeCoupling[i][1] + 1 > X->Def.Nsite) {
254  StartTimer(421);
256  X->Def.ExchangeCoupling[i][0], sigma1, sigma2,
257  X->Def.ExchangeCoupling[i][1], sigma2, sigma1,
258  X->Def.ParaExchangeCoupling[i], X, nstate, tmp_v0, tmp_v1);
259  StopTimer(421);
260  }
261  else if (X->Def.ExchangeCoupling[i][1] + 1 > X->Def.Nsite) {
262  StartTimer(422);
264  X->Def.ExchangeCoupling[i][0], sigma1, sigma2,
265  X->Def.ExchangeCoupling[i][1], sigma2, sigma1,
266  X->Def.ParaExchangeCoupling[i], X, nstate, tmp_v0, tmp_v1);
267  StopTimer(422);
268  }
269  else if (X->Def.ExchangeCoupling[i][0] + 1 > X->Def.Nsite) {
270  StartTimer(423);
272  X->Def.ExchangeCoupling[i][1], sigma2, sigma1,
273  X->Def.ExchangeCoupling[i][0], sigma1, sigma2,
274  X->Def.ParaExchangeCoupling[i], X, nstate, tmp_v0, tmp_v1);
275  StopTimer(423);
276  }
277  else {
278  StartTimer(424);
280  child_exchange_spin(nstate, tmp_v0, tmp_v1, X);
281  StopTimer(424);
282  }
283  }/*for (i = 0; i < X->Def.NExchangeCoupling; i += 2)*/
284  StopTimer(420);
285 
286  StopTimer(400);
287  return 0;
288 }/*int mltplyHalfSpin*/
295  struct BindStruct *X,
296  int nstate, std::complex<double> **tmp_v0,
297  std::complex<double> **tmp_v1
298 ){
299  long int j;
300  long int i;
301  long int off = 0;
302  long int tmp_off = 0;
303  long int tmp_off2 = 0;
304  long int ihfbit=0;
305  long int isite1, isite2, sigma1, sigma2;
306  long int sigma3, sigma4;
307 
308  long int tmp_sgn;
309  /*[s] For InterAll */
310  std::complex<double> tmp_V;
311  int one = 1;
312  /*[e] For InterAll */
313 
314  long int i_max;
315  i_max = X->Check.idim_max;
316  int ihermite=0;
317  int idx=0;
318 
319  StartTimer(400);
324  StartTimer(410);
325  ihfbit =X->Check.sdim;
326  for (i = 0; i < X->Def.NInterAll_OffDiagonal; i += 2) {
327  if (X->Def.InterAll_OffDiagonal[i][0] + 1 > X->Def.Nsite &&
328  X->Def.InterAll_OffDiagonal[i][4] + 1 > X->Def.Nsite) {
329  StartTimer(411);
330  child_general_int_GeneralSpin_MPIdouble(i, X, nstate, tmp_v0, tmp_v1);
331  StopTimer(411);
332  }
333  else if (X->Def.InterAll_OffDiagonal[i][4] + 1 > X->Def.Nsite) {
334  StartTimer(412);
335  child_general_int_GeneralSpin_MPIsingle(i, X, nstate, tmp_v0, tmp_v1);
336  StopTimer(412);
337  }
338  else if (X->Def.InterAll_OffDiagonal[i][0] + 1 > X->Def.Nsite) {
339  StartTimer(412);
340  child_general_int_GeneralSpin_MPIsingle(i + 1, X, nstate, tmp_v0, tmp_v1);
341  StopTimer(412);
342  }
343  else {
344  StartTimer(413);
345  for (ihermite = 0; ihermite < 2; ihermite++) {
346  idx = i + ihermite;
347  isite1 = X->Def.InterAll_OffDiagonal[idx][0] + 1;
348  isite2 = X->Def.InterAll_OffDiagonal[idx][4] + 1;
349  sigma1 = X->Def.InterAll_OffDiagonal[idx][1];
350  sigma2 = X->Def.InterAll_OffDiagonal[idx][3];
351  sigma3 = X->Def.InterAll_OffDiagonal[idx][5];
352  sigma4 = X->Def.InterAll_OffDiagonal[idx][7];
353  tmp_V = X->Def.ParaInterAll_OffDiagonal[idx];
354 #pragma omp parallel for default(none) \
355 private(j,tmp_sgn,off,tmp_off,tmp_off2) \
356 firstprivate(i_max,isite1,isite2,sigma1,sigma2,sigma3,sigma4,X,tmp_V,ihfbit) \
357 shared(tmp_v0,tmp_v1,list_1,list_2_1,list_2_2,one,nstate)
358  for (j = 1; j <= i_max; j++) {
359  tmp_sgn = GetOffCompGeneralSpin(list_1[j], isite2, sigma4, sigma3, &tmp_off, X->Def.SiteToBit, X->Def.Tpow);
360  if (tmp_sgn == TRUE) {
361  tmp_sgn = GetOffCompGeneralSpin(tmp_off, isite1, sigma2, sigma1, &tmp_off2, X->Def.SiteToBit, X->Def.Tpow);
362  if (tmp_sgn == TRUE) {
363  ConvertToList1GeneralSpin(tmp_off2, ihfbit, &off);
364  zaxpy_(&nstate, &tmp_V, &tmp_v1[j][0], &one, &tmp_v0[off][0], &one);
365  }
366  }/*if (tmp_sgn == TRUE)*/
367  }/*for (j = 1; j <= i_max; j++)*/
368  }/*for (ihermite = 0; ihermite < 2; ihermite++)*/
369  StopTimer(413);
370  }
371  }/*for (i = 0; i < X->Def.NInterAll_OffDiagonal; i += 2)*/
372  StopTimer(410);
373  StopTimer(400);
374  return 0;
375 }/*int mltplyGeneralSpin*/
382  struct BindStruct *X,
383  int nstate, std::complex<double> **tmp_v0,
384  std::complex<double> **tmp_v1
385 ) {
386  int iret=0;
387  if (X->Def.iFlgGeneralSpin == FALSE)
388  iret = mltplyHalfSpinGC(X, nstate, tmp_v0, tmp_v1);
389  else
390  iret = mltplyGeneralSpinGC(X, nstate, tmp_v0, tmp_v1);
391 
392  if(iret != 0) return iret;
393 
394  return iret;
395 }/*int mltplySpinGC*/
402  struct BindStruct *X,
403  int nstate, std::complex<double> **tmp_v0,
404  std::complex<double> **tmp_v1
405 ) {
406  long int j;
407  long int i;
408  long int off = 0;
409  long int is1_spin = 0;
410  long int isite1, isite2, sigma1, sigma2;
411  long int sigma3, sigma4;
412  std::complex<double> tmp_trans;
413  long int tmp_sgn;
414  /*[s] For InterAll */
415  std::complex<double> tmp_V;
416  int one = 1;
417  /*[e] For InterAll */
418 
419  long int i_max;
420  i_max = X->Check.idim_max;
421 
422  int ihermite=0;
423  int idx=0;
424 
425  StartTimer(500);
426 
427  StartTimer(510);
428  for (i = 0; i < X->Def.EDNTransfer; i+=2 ) {
429  if(X->Def.EDGeneralTransfer[i][0]+1 > X->Def.Nsite){
430  if(X->Def.EDGeneralTransfer[i][1]==X->Def.EDGeneralTransfer[i][3]){
431  fprintf(stderr, "Transverse_OffDiagonal component is illegal.\n");
432  }
433  else{
434  StartTimer(511);
436  X->Def.EDGeneralTransfer[i][0], X->Def.EDGeneralTransfer[i][1],
438  X, nstate, tmp_v0, tmp_v1);
439  StopTimer(511);
440  }
441  }/*if(X->Def.EDGeneralTransfer[i][0]+1 > X->Def.Nsite)*/
442  else{
443  StartTimer(512);
444  for(ihermite=0; ihermite<2; ihermite++){
445  idx=i+ihermite;
446  isite1 = X->Def.EDGeneralTransfer[idx][0] + 1;
447  isite2 = X->Def.EDGeneralTransfer[idx][2] + 1;
448  sigma1 = X->Def.EDGeneralTransfer[idx][1];
449  sigma2 = X->Def.EDGeneralTransfer[idx][3];
450  tmp_trans = -X->Def.EDParaGeneralTransfer[idx];
451  if (child_general_hopp_GetInfo(X, isite1, isite2, sigma1, sigma2) != 0) {
452  return -1;
453  }
454 
455  if(sigma1==sigma2){
456  fprintf(stderr, "Transverse_OffDiagonal component is illegal.\n");
457  }
458  else{
459  // longitudinal magnetic field (considerd in diagonalcalc.cpp)
460  // transverse magnetic field
461  is1_spin = X->Def.Tpow[isite1 - 1];
462 #pragma omp parallel for default(none) \
463 private(j, tmp_sgn) firstprivate(i_max, is1_spin, sigma2, X,off, tmp_trans) \
464 shared(tmp_v0, tmp_v1,one,nstate)
465  for (j = 1; j <= i_max; j++) {
466  tmp_sgn = X_SpinGC_CisAit(j, is1_spin, sigma2, &off);
467  if(tmp_sgn !=0){
468  zaxpy_(&nstate, &tmp_trans, &tmp_v1[j][0], &one, &tmp_v0[off + 1][0], &one);
469  }/*if(tmp_sgn !=0)*/
470  }/*for (j = 1; j <= i_max; j++)*/
471  }//sigma1 != sigma2
472  }/*for(ihermite=0; ihermite<2; ihermite++)*/
473  StopTimer(512);
474  }
475  }/*for (i = 0; i < X->Def.EDNTransfer; i+=2 )*/
476  StopTimer(510);
480  StartTimer(520);
481  for (i = 0; i < X->Def.NInterAll_OffDiagonal; i += 2) {
482  if (X->Def.InterAll_OffDiagonal[i][0] + 1 > X->Def.Nsite &&
483  X->Def.InterAll_OffDiagonal[i][4] + 1 > X->Def.Nsite) {
484  StartTimer(521);
485  GC_child_general_int_spin_MPIdouble(i, X, nstate, tmp_v0, tmp_v1);
486  StopTimer(521);
487  }
488  else if (X->Def.InterAll_OffDiagonal[i][4] + 1 > X->Def.Nsite) {
489  StartTimer(522);
490  GC_child_general_int_spin_MPIsingle(i, X, nstate, tmp_v0, tmp_v1);
491  StopTimer(522);
492  }
493  else if (X->Def.InterAll_OffDiagonal[i][0] + 1 > X->Def.Nsite) {
494  StartTimer(522);
495  GC_child_general_int_spin_MPIsingle(i + 1, X, nstate, tmp_v0, tmp_v1);
496  StopTimer(522);
497  }
498  else {
499  StartTimer(523);
500  for (ihermite = 0; ihermite < 2; ihermite++) {
501  idx = i + ihermite;
502  isite1 = X->Def.InterAll_OffDiagonal[idx][0] + 1;
503  isite2 = X->Def.InterAll_OffDiagonal[idx][4] + 1;
504  sigma1 = X->Def.InterAll_OffDiagonal[idx][1];
505  sigma2 = X->Def.InterAll_OffDiagonal[idx][3];
506  sigma3 = X->Def.InterAll_OffDiagonal[idx][5];
507  sigma4 = X->Def.InterAll_OffDiagonal[idx][7];
508  tmp_V = X->Def.ParaInterAll_OffDiagonal[idx];
509  child_general_int_spin_GetInfo(X, isite1, isite2, sigma1, sigma2, sigma3, sigma4, tmp_V);
510  GC_child_general_int_spin(nstate, tmp_v0, tmp_v1, X);
511  }
512  StopTimer(523);
513  }
514  }/*for (i = 0; i < X->Def.NInterAll_OffDiagonal; i += 2)*/
515  StopTimer(520);
519  StartTimer(530);
520  for (i = 0; i < X->Def.NExchangeCoupling; i++) {
521  sigma1=0; sigma2=1;
522  if (X->Def.ExchangeCoupling[i][0] + 1 > X->Def.Nsite &&
523  X->Def.ExchangeCoupling[i][1] + 1 > X->Def.Nsite){
524  StartTimer(531);
526  X->Def.ExchangeCoupling[i][0], sigma1, sigma2,
527  X->Def.ExchangeCoupling[i][1], sigma2, sigma1,
528  X->Def.ParaExchangeCoupling[i], X, nstate, tmp_v0, tmp_v1);
529  StopTimer(531);
530  }
531  else if (X->Def.ExchangeCoupling[i][1] + 1 > X->Def.Nsite) {
532  StartTimer(532);
534  X->Def.ExchangeCoupling[i][0], sigma1, sigma2,
535  X->Def.ExchangeCoupling[i][1], sigma2, sigma1,
536  X->Def.ParaExchangeCoupling[i], X, nstate, tmp_v0, tmp_v1);
537  StopTimer(532);
538  }
539  else if (X->Def.ExchangeCoupling[i][0] + 1 > X->Def.Nsite) {
540  StartTimer(532);
542  X->Def.ExchangeCoupling[i][1], sigma2, sigma1,
543  X->Def.ExchangeCoupling[i][0], sigma1, sigma2,
544  X->Def.ParaExchangeCoupling[i], X, nstate, tmp_v0, tmp_v1);
545  StopTimer(532);
546  }
547  else {
548  StartTimer(533);
550  GC_child_exchange_spin(nstate, tmp_v0, tmp_v1, X);
551  StopTimer(533);
552  }
553  }/* for (i = 0; i < X->Def.NExchangeCoupling; i ++) */
554  StopTimer(530);
558  StartTimer(540);
559  for (i = 0; i < X->Def.NPairLiftCoupling; i++) {
560  sigma1 =0; sigma2=1;
561  if (X->Def.PairLiftCoupling[i][0] + 1 > X->Def.Nsite &&
562  X->Def.PairLiftCoupling[i][1] + 1 > X->Def.Nsite) {
563  StartTimer(541);
565  X->Def.PairLiftCoupling[i][0], sigma1, sigma2,
566  X->Def.PairLiftCoupling[i][1], sigma1, sigma2,
567  X->Def.ParaPairLiftCoupling[i], X, nstate, tmp_v0, tmp_v1);
568  StopTimer(541);
569  }
570  else if (X->Def.PairLiftCoupling[i][1] + 1 > X->Def.Nsite) {
571  StartTimer(542);
573  X->Def.PairLiftCoupling[i][0], sigma1, sigma2,
574  X->Def.PairLiftCoupling[i][1], sigma1, sigma2,
575  X->Def.ParaPairLiftCoupling[i], X, nstate, tmp_v0, tmp_v1);
576  StopTimer(542);
577  }
578  else if (X->Def.PairLiftCoupling[i][0] + 1 > X->Def.Nsite) {
579  StartTimer(542);
581  X->Def.PairLiftCoupling[i][1], sigma1, sigma2,
582  X->Def.PairLiftCoupling[i][0], sigma1, sigma2,
583  X->Def.ParaPairLiftCoupling[i], X, nstate, tmp_v0, tmp_v1);
584  StopTimer(542);
585  }
586  else {
587  StartTimer(543);
589  GC_child_pairlift_spin(nstate, tmp_v0, tmp_v1, X);
590  StopTimer(543);
591  }
592  }/*for (i = 0; i < X->Def.NPairLiftCoupling; i += 2)*/
593  StopTimer(540);
594 
595  StopTimer(500);
596  return 0;
597 }/*int mltplyHalfSpinGC*/
604  struct BindStruct *X,
605  int nstate, std::complex<double> **tmp_v0,
606  std::complex<double> **tmp_v1
607 ) {
608  long int j;
609  long int i;
610  long int off = 0;
611  long int tmp_off = 0;
612  long int isite1, isite2, sigma1, sigma2;
613  long int sigma3, sigma4;
614  std::complex<double> tmp_trans;
615  long int tmp_sgn;
616  double num1 = 0;
617  /*[s] For InterAll */
618  std::complex<double> tmp_V;
619  int one = 1;
620  /*[e] For InterAll */
621 
622  long int i_max;
623  i_max = X->Check.idim_max;
624 
625  int ihermite=0;
626  int idx=0;
627 
628  StartTimer(500);
629 
630  StartTimer(510);
631  for (i = 0; i < X->Def.EDNTransfer; i += 2) {
632  isite1 = X->Def.EDGeneralTransfer[i][0] + 1;
633  isite2 = X->Def.EDGeneralTransfer[i][2] + 1;
634  sigma1 = X->Def.EDGeneralTransfer[i][1];
635  sigma2 = X->Def.EDGeneralTransfer[i][3];
636  tmp_trans = -X->Def.EDParaGeneralTransfer[idx];
637  if (isite1 == isite2) {
638  if (sigma1 != sigma2) {
639  if (isite1 > X->Def.Nsite) {
641  isite1 - 1, sigma1, sigma2, tmp_trans, X, nstate, tmp_v0, tmp_v1);
642  }/*if (isite1 > X->Def.Nsite)*/
643  else {
644  for (ihermite = 0; ihermite<2; ihermite++) {
645  idx = i + ihermite;
646  isite1 = X->Def.EDGeneralTransfer[idx][0] + 1;
647  isite2 = X->Def.EDGeneralTransfer[idx][2] + 1;
648  sigma1 = X->Def.EDGeneralTransfer[idx][1];
649  sigma2 = X->Def.EDGeneralTransfer[idx][3];
650  tmp_trans = -X->Def.EDParaGeneralTransfer[idx];
651 
652  // transverse magnetic field
653 #pragma omp parallel for default(none) \
654 private(j, tmp_sgn, num1) firstprivate(i_max, isite1, sigma1, sigma2, X, off, tmp_trans) \
655 shared(tmp_v0, tmp_v1,one,nstate)
656  for (j = 1; j <= i_max; j++) {
657  num1 = GetOffCompGeneralSpin(
658  j - 1, isite1, sigma2, sigma1, &off, X->Def.SiteToBit, X->Def.Tpow);
659  if (num1 != 0) { // for multply
660  zaxpy_(&nstate, &tmp_trans, &tmp_v1[j][0], &one, &tmp_v0[off + 1][0], &one);
661  }/*if (num1 != 0)*/
662  }/*for (j = 1; j <= i_max; j++)*/
663  }/*for (ihermite = 0; ihermite<2; ihermite++)*/
664  }
665  }// sigma1 != sigma2
666  else{ // sigma1 = sigma2
667  fprintf(stderr, "Error: Transverse_Diagonal component must be absorbed !");
668  }
669  }//isite1 = isite2
670  else { // isite1 != isite2
671  // hopping is not allowed in localized spin system
672  return -1;
673  }
674  }/*for (i = 0; i < X->Def.EDNTransfer; i += 2)*/
675  StopTimer(510);
679  StartTimer(520);
680  for (i = 0; i< X->Def.NInterAll_OffDiagonal; i += 2) {
681  if (X->Def.InterAll_OffDiagonal[i][0] + 1 > X->Def.Nsite &&
682  X->Def.InterAll_OffDiagonal[i][4] + 1 > X->Def.Nsite) {
683  StartTimer(521);
684  GC_child_general_int_GeneralSpin_MPIdouble(i, X, nstate, tmp_v0, tmp_v1);
685  StopTimer(521);
686  }
687  else if (X->Def.InterAll_OffDiagonal[i][4] + 1 > X->Def.Nsite) {
688  StartTimer(522);
689  GC_child_general_int_GeneralSpin_MPIsingle(i, X, nstate, tmp_v0, tmp_v1);
690  StopTimer(522);
691  }
692  else if (X->Def.InterAll_OffDiagonal[i][0] + 1 > X->Def.Nsite) {
693  StartTimer(522);
694  GC_child_general_int_GeneralSpin_MPIsingle(i + 1, X, nstate, tmp_v0, tmp_v1);
695  StopTimer(522);
696  }
697  else {
698  StartTimer(523);
699  for (ihermite = 0; ihermite < 2; ihermite++) {
700  idx = i + ihermite;
701  isite1 = X->Def.InterAll_OffDiagonal[idx][0] + 1;
702  isite2 = X->Def.InterAll_OffDiagonal[idx][4] + 1;
703  sigma1 = X->Def.InterAll_OffDiagonal[idx][1];
704  sigma2 = X->Def.InterAll_OffDiagonal[idx][3];
705  sigma3 = X->Def.InterAll_OffDiagonal[idx][5];
706  sigma4 = X->Def.InterAll_OffDiagonal[idx][7];
707  tmp_V = X->Def.ParaInterAll_OffDiagonal[idx];
708 
709  if (sigma1 == sigma2) {
710  if (sigma3 == sigma4) {
711  fprintf(stderr, "InterAll_OffDiagonal component is illegal.\n");
712  return -1;
713  }/*if (sigma3 == sigma4)*/
714  else {
715  //sigma3=sigma4 term is considerd as a diagonal term.
716 #pragma omp parallel for default(none) \
717  private(j, tmp_sgn, off) \
718  firstprivate(i_max, isite1, isite2, sigma1, sigma3, sigma4, X, tmp_V) \
719  shared(tmp_v0, tmp_v1,one,nstate)
720  for (j = 1; j <= i_max; j++) {
721  tmp_sgn = GetOffCompGeneralSpin(
722  j - 1, isite2, sigma4, sigma3, &off, X->Def.SiteToBit, X->Def.Tpow);
723  if (tmp_sgn == TRUE) {
724  tmp_sgn = BitCheckGeneral(off, isite1, sigma1, X->Def.SiteToBit, X->Def.Tpow);
725  if (tmp_sgn == TRUE) {
726  zaxpy_(&nstate, &tmp_V, &tmp_v1[j][0], &one, &tmp_v0[off + 1][0], &one);
727  }/*if (tmp_sgn == TRUE)*/
728  }/*if (tmp_sgn == TRUE)*/
729  }/*for (j = 1; j <= i_max; j++)*/
730  }
731  }/*if (sigma1 == sigma2)*/
732  else if (sigma3 == sigma4) {
733  //sigma1=sigma2 term is considerd as a diagonal term.
734 #pragma omp parallel for default(none) \
735  private(j, tmp_sgn, off, tmp_off) \
736  firstprivate(i_max, isite1, isite2, sigma1, sigma2, sigma3, sigma4, X, tmp_V) \
737  shared(tmp_v0, tmp_v1,one,nstate)
738  for (j = 1; j <= i_max; j++) {
739  tmp_sgn = BitCheckGeneral(j - 1, isite2, sigma3, X->Def.SiteToBit, X->Def.Tpow);
740  if (tmp_sgn == TRUE) {
741  tmp_sgn = GetOffCompGeneralSpin(
742  j - 1, isite1, sigma2, sigma1, &off, X->Def.SiteToBit, X->Def.Tpow);
743  if (tmp_sgn == TRUE) {
744  zaxpy_(&nstate, &tmp_V, &tmp_v1[j][0], &one, &tmp_v0[off + 1][0], &one);
745  }/*if (tmp_sgn == TRUE)*/
746  }/*if (tmp_sgn == TRUE)*/
747  }/*for (j = 1; j <= i_max; j++)*/
748  }/*else if (sigma3 == sigma4)*/
749  else {
750 #pragma omp parallel for default(none) \
751  private(j, tmp_sgn, off, tmp_off) \
752  firstprivate(i_max, isite1, isite2, sigma1, sigma2, sigma3, sigma4, X, tmp_V) \
753  shared(tmp_v0, tmp_v1,one,nstate)
754  for (j = 1; j <= i_max; j++) {
755  tmp_sgn = GetOffCompGeneralSpin(
756  j - 1, isite2, sigma4, sigma3, &tmp_off, X->Def.SiteToBit, X->Def.Tpow);
757  if (tmp_sgn == TRUE) {
758  tmp_sgn = GetOffCompGeneralSpin(
759  tmp_off, isite1, sigma2, sigma1, &off, X->Def.SiteToBit, X->Def.Tpow);
760  if (tmp_sgn == TRUE) {
761  zaxpy_(&nstate, &tmp_V, &tmp_v1[j][0], &one, &tmp_v0[off + 1][0], &one);
762  }/*if (tmp_sgn == TRUE)*/
763  }/*if (tmp_sgn == TRUE)*/
764  }/*for (j = 1; j <= i_max; j++)*/
765  }
766  }
767  StopTimer(523);
768  }
769  }/*for (i = 0; i< X->Def.NInterAll_OffDiagonal; i += 2)*/
770  StopTimer(520);
771 
772  StopTimer(500);
773  return 0;
774 }/*int mltplyGeneralSpinGC*/
775 
776 /******************************************************************************/
777 //[s] child functions
778 /******************************************************************************/
779 
786  int nstate, std::complex<double> **tmp_v0,
787  std::complex<double> **tmp_v1,
788  struct BindStruct *X
789 ) {
790  long int j;
791  long int i_max = X->Large.i_max;
792  long int off = 0;
793 
794 #pragma omp parallel for default(none) \
795  firstprivate(i_max, X,off) private(j) shared(tmp_v0, tmp_v1,nstate)
796  for (j = 1; j <= i_max; j++)
797  child_exchange_spin_element(j, nstate, tmp_v0, tmp_v1, X, &off);
798 }/*std::complex<double> child_exchange_spin*/
805  int nstate, std::complex<double> **tmp_v0,
806  std::complex<double> **tmp_v1,
807  struct BindStruct *X
808 ) {
809  long int j;
810  long int i_max = X->Large.i_max;
811  long int off = 0;
812 
813 #pragma omp parallel for default(none) \
814  firstprivate(i_max, X,off) private(j) shared(tmp_v0, tmp_v1,nstate)
815  for (j = 1; j <= i_max; j++)
816  GC_child_exchange_spin_element(j, nstate, tmp_v0, tmp_v1, X, &off);
817 }/*std::complex<double> GC_child_exchange_spin*/
824  int nstate, std::complex<double> **tmp_v0,
825  std::complex<double> **tmp_v1,
826  struct BindStruct *X
827 ) {
828  long int j;
829  long int i_max = X->Large.i_max;
830  long int off = 0;
831 
832 #pragma omp parallel for default(none) \
833  firstprivate(i_max, X,off) private(j) shared(tmp_v0, tmp_v1,nstate)
834  for (j = 1; j <= i_max; j++)
835  GC_child_pairlift_spin_element(j, nstate, tmp_v0, tmp_v1, X, &off);
836 }/*std::complex<double> GC_child_pairlift_spin*/
843  int nstate, std::complex<double> **tmp_v0,
844  std::complex<double> **tmp_v1,
845  struct BindStruct *X
846 ) {
847  std::complex<double> tmp_V, dmv;
848  long int j, i_max;
849  long int org_sigma2, org_sigma4;
850  long int isA_up, isB_up;
851  long int tmp_off = 0;
852  int tmp_sgn;
853  int one = 1;
854 
855  i_max = X->Large.i_max;
856  org_sigma2 = X->Large.is2_spin;
857  org_sigma4 = X->Large.is4_spin;
858  tmp_V = X->Large.tmp_V;
859  isA_up = X->Large.is1_up;
860  isB_up = X->Large.is2_up;
861 
862 #pragma omp parallel for default(none) private(j, tmp_sgn, dmv) \
863 firstprivate(i_max,X,isA_up,isB_up,org_sigma2,org_sigma4,tmp_off,tmp_V) \
864 shared(tmp_v1, tmp_v0,one,nstate)
865  for (j = 1; j <= i_max; j++) {
866  tmp_sgn = X_child_exchange_spin_element(j, X, isA_up, isB_up, org_sigma2, org_sigma4, &tmp_off);
867  if (tmp_sgn != 0) {
868  dmv = (std::complex<double>)tmp_sgn * tmp_V;
869  zaxpy_(&nstate, &dmv, &tmp_v1[j][0], &one, &tmp_v0[tmp_off][0], &one);
870  }/*if (tmp_sgn != 0)*/
871  }/*for (j = 1; j <= i_max; j++)*/
872 }/*std::complex<double> child_general_int_spin*/
879  int nstate, std::complex<double> **tmp_v0,
880  std::complex<double> **tmp_v1,
881  struct BindStruct *X
882 ) {
883  std::complex<double> tmp_V;
884  long int j, i_max;
885  long int org_isite1, org_isite2;
886  long int org_sigma1, org_sigma2, org_sigma3, org_sigma4;
887  long int isA_up, isB_up;
888  long int tmp_off = 0;
889 
890  i_max = X->Large.i_max;
891  org_isite1 = X->Large.isite1;
892  org_isite2 = X->Large.isite2;
893  org_sigma1 = X->Large.is1_spin;
894  org_sigma2 = X->Large.is2_spin;
895  org_sigma3 = X->Large.is3_spin;
896  org_sigma4 = X->Large.is4_spin;
897  tmp_V = X->Large.tmp_V;
898  isA_up = X->Def.Tpow[org_isite1 - 1];
899  isB_up = X->Def.Tpow[org_isite2 - 1];
900 
901 #pragma omp parallel default(none) \
902 private(j) shared(tmp_v0,tmp_v1,nstate) \
903 firstprivate(i_max,X,isA_up,isB_up,org_sigma1,org_sigma2,org_sigma3,org_sigma4,tmp_off,tmp_V)
904  {
905  if (org_sigma1 == org_sigma2 && org_sigma3 == org_sigma4) { //diagonal
906 #pragma omp for
907  for (j = 1; j <= i_max; j++)
909  j, isA_up, isB_up, org_sigma2, org_sigma4, tmp_V, nstate, tmp_v0, tmp_v1);
910  }
911  else if (org_sigma1 == org_sigma2 && org_sigma3 != org_sigma4) {
912 #pragma omp for
913  for (j = 1; j <= i_max; j++)
915  j, org_sigma2, org_sigma4, isA_up, isB_up, tmp_V, nstate, tmp_v0, tmp_v1, &tmp_off);
916  }
917  else if (org_sigma1 != org_sigma2 && org_sigma3 == org_sigma4) {
918 #pragma omp for
919  for (j = 1; j <= i_max; j++)
921  j, org_sigma2, org_sigma4, isA_up, isB_up, tmp_V, nstate, tmp_v0, tmp_v1, &tmp_off);
922  }
923  else if (org_sigma1 != org_sigma2 && org_sigma3 != org_sigma4) {
924 #pragma omp for
925  for (j = 1; j <= i_max; j++)
927  j, org_sigma2, org_sigma4, isA_up, isB_up, tmp_V, nstate, tmp_v0, tmp_v1, &tmp_off);
928  }
929  }/*End of parallel region*/
930 }/*std::complex<double> GC_child_general_int_spin*/
931 /******************************************************************************/
932 //[e] child functions
933 /******************************************************************************/
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.hpp:395
int mltplyGeneralSpin(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Driver function for General Spin hamiltonian.
Definition: mltplySpin.cpp:294
std::complex< double > * EDParaGeneralTransfer
Value of general transfer integrals by a def file. malloc in setmem_def(). Data Format [DefineList::N...
Definition: struct.hpp:116
void GC_child_pairlift_spin(int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X)
Compute pair-lift term of spin Hamiltonian (grandcanonical)
Definition: mltplySpin.cpp:823
int BitCheckGeneral(const long int org_bit, const int org_isite, const int target_ispin, const long int *SiteToBit, const long int *Tpow)
bit check function for general spin
Definition: bitcalc.cpp:392
void GC_child_CisAisCisAis_spin_element(long int j, long int isA_up, long int isB_up, long int org_sigma2, long int org_sigma4, std::complex< double > tmp_V, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Compute term of grandcanonical spsin system.
long int is2_spin
Mask used in the bit oeration.
Definition: struct.hpp:334
void GC_child_pairlift_spin_element(long int j, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X, long int *tmp_off)
Multiply Hamiltonian of pairlift term of grandcanonical spin system.
void child_general_int_spin_MPIdouble(long int i_int, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Exchange term in Spin model When both site1 and site2 are in the inter process region.
void GC_child_CisAisCitAiu_spin_element(long int j, long int org_sigma2, long int org_sigma4, long int isA_up, long int isB_up, std::complex< double > tmp_V, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int *tmp_off)
Compute term of grandcanonical spsin system.
int ** ExchangeCoupling
[DefineList::NExchangeCoupling][2] Index of exchange term. malloc in setmem_def().
Definition: struct.hpp:146
int NPairLiftCoupling
Number of pair-lift term.
Definition: struct.hpp:153
int X_child_exchange_spin_element(long int j, struct BindStruct *X, long int isA_up, long int isB_up, long int sigmaA, long int sigmaB, long int *tmp_off)
Compute index of final wavefunction associated to spin-exchange term.
int Nsite
Number of sites in the INTRA process region.
Definition: struct.hpp:56
void GC_child_general_int_spin_MPIdouble(long int i_int, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
General interaction term in the Spin model + GC When both site1 and site2 are in the inter process re...
int child_general_int_spin_GetInfo(struct BindStruct *X, long int isite1, long int isite2, long int sigma1, long int sigma2, long int sigma3, long int sigma4, std::complex< double > tmp_V)
Set parameters for the bit operation of spin-general interaction term.
long int is1_up
Mask used in the bit oeration.
Definition: struct.hpp:326
int mltplySpinGC(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Driver function for Spin hamiltonian.
Definition: mltplySpin.cpp:381
struct LargeList Large
Variables for Matrix-Vector product.
Definition: struct.hpp:397
void child_exchange_spin(int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X)
Compute exchange term of spin Hamiltonian (canonical)
Definition: mltplySpin.cpp:785
void X_GC_child_CisAitCiuAiv_spin_MPIsingle(int org_isite1, int org_ispin1, int org_ispin2, int org_isite3, int org_ispin3, int org_ispin4, std::complex< double > tmp_J, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Exchange and Pairlifting term in Spin model + GC When only site2 is in the inter process region...
int ** EDGeneralTransfer
Index of transfer integrals for calculation. malloc in setmem_def(). Data Format [DefineList::NTransf...
Definition: struct.hpp:110
void GC_child_general_int_spin(int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X)
Compute Inter-All term of spin Hamiltonian (grandcanonical)
Definition: mltplySpin.cpp:878
int ConvertToList1GeneralSpin(const long int org_ibit, const long int ihlfbit, long int *_ilist1Comp)
function of converting component to list_1
Definition: bitcalc.cpp:285
int isite2
Is it realy used ???
Definition: struct.hpp:338
void child_general_int_GeneralSpin_MPIsingle(long int i_int, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
General interaction term in the Spin model + GC When both site1 and site2 are in the inter process re...
long int is4_spin
Mask used in the bit oeration.
Definition: struct.hpp:336
void X_GC_child_CisAit_GeneralSpin_MPIdouble(int org_isite1, int org_ispin1, int org_ispin2, std::complex< double > tmp_trans, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Compute term in the grandcanonical general spin system when both site is in the inter process region...
void GC_child_general_int_GeneralSpin_MPIsingle(long int i_int, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
General interaction term in the Spin model + GC When both site1 and site2 are in the inter process re...
int mltplyHalfSpin(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Driver function for Spin 1/2 hamiltonian.
Definition: mltplySpin.cpp:190
void X_child_general_int_spin_MPIsingle(int org_isite1, int org_ispin1, int org_ispin2, int org_isite3, int org_ispin3, int org_ispin4, std::complex< double > tmp_J, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
int ** InterAll_OffDiagonal
[DefineList::NinterAll_OffDiagonal][8] Interacted quartet
Definition: struct.hpp:161
void child_general_int_GeneralSpin_MPIdouble(long int i_int, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
General interaction term in the Spin model + GC When both site1 and site2 are in the inter process re...
int ** PairLiftCoupling
[DefineList::NPairHopping][2] Index of pair-lift term. malloc in setmem_def().
Definition: struct.hpp:154
int EDNTransfer
Number of transfer integrals for calculation.
Definition: struct.hpp:105
Bind.
Definition: struct.hpp:394
int mltplySpin(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Driver function for Spin hamiltonian.
Definition: mltplySpin.cpp:173
double * ParaExchangeCoupling
[DefineList::NExchangeCoupling] Coupling constant of exchange term. malloc in setmem_def().
Definition: struct.hpp:148
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
Definition: bitcalc.cpp:243
double * ParaPairLiftCoupling
[DefineList::NPairHopping] Coupling constant of pair-lift term. malloc in setmem_def().
Definition: struct.hpp:156
void GC_child_general_int_GeneralSpin_MPIdouble(long int i_int, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
General interaction term in the Spin model + GC When both site1 and site2 are in the inter process re...
void X_GC_child_CisAitCiuAiv_spin_MPIdouble(int org_isite1, int org_ispin1, int org_ispin2, int org_isite3, int org_ispin3, int org_ispin4, std::complex< double > tmp_J, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
term in Spin model + GC. When both site1 and site2 are in the inter process region.
int child_exchange_spin_GetInfo(int iExchange, struct BindStruct *X)
Set parameters for the bit operation of spin-exchange term.
long int i_max
Length of eigenvector.
Definition: struct.hpp:318
int mltplyGeneralSpinGC(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Driver function for General Spin hamiltonian (grandcanonical)
Definition: mltplySpin.cpp:603
int NExchangeCoupling
Number of exchange term.
Definition: struct.hpp:145
std::complex< double > * ParaInterAll_OffDiagonal
[DefineList::NInterAll_OffDiagonal] Coupling constant of off-diagonal inter-all term. malloc in setmem_def().
Definition: struct.hpp:170
int iFlgGeneralSpin
Flag for the general (Sz/=1/2) spin.
Definition: struct.hpp:86
int mltplyHalfSpinGC(struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Driver function for Spin 1/2 Hamiltonian (grandcanonical)
Definition: mltplySpin.cpp:401
int child_pairlift_spin_GetInfo(int iPairLift, struct BindStruct *X)
Set parameters for the bit operation of spin-pairlift term.
void StopTimer(int n)
function for calculating elapse time [elapse time=StartTimer-StopTimer]
Definition: time.cpp:83
int NInterAll_OffDiagonal
Number of interall term (off-diagonal)
Definition: struct.hpp:165
void GC_child_exchange_spin_element(long int j, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X, long int *tmp_off)
Multiply Hamiltonian of exchange term of grandcanonical spin system.
void child_exchange_spin_element(long int j, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X, long int *tmp_off)
Multiply Hamiltonian of exchange term of canonical spin system.
void X_GC_child_CisAit_spin_MPIdouble(int org_isite1, int org_ispin1, int org_ispin2, std::complex< double > tmp_trans, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Hopping term in Spin + GC When both site1 and site2 are in the inter process region.
long int * SiteToBit
[DefineList::NsiteMPI] Similar to DefineList::Tpow. For general spin.
Definition: struct.hpp:94
long int * Tpow
[2 * DefineList::NsiteMPI] malloc in setmem_def().
Definition: struct.hpp:90
void child_general_int_spin_MPIsingle(long int i_int, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Exchange term in Spin model When only site2 is in the inter process region.
int child_general_hopp_GetInfo(struct BindStruct *X, long int isite1, long int isite2, long int sigma1, long int sigma2)
Compute mask for bit operation of hopping term.
int X_SpinGC_CisAit(long int j, long int is1_spin, long int sigma2, long int *tmp_off)
Compute index of final wavefunction by term (grandcanonical).
void GC_child_general_int_spin_MPIsingle(long int i_int, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
General interaction term in the Spin model + GC When both site1 and site2 are in the inter process re...
long int is3_spin
Mask used in the bit oeration.
Definition: struct.hpp:335
long int is1_spin
Mask used in the bit oeration.
Definition: struct.hpp:333
void child_general_int_spin(int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X)
Compute Inter-All term of spin Hamiltonian (canonical)
Definition: mltplySpin.cpp:842
void X_child_general_int_spin_MPIdouble(int org_isite1, int org_ispin1, int org_ispin2, int org_isite3, int org_ispin3, int org_ispin4, std::complex< double > tmp_J, struct BindStruct *X, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1)
Exchange term in Spin model When both site1 and site2 are in the inter process region.
void GC_child_CisAitCiuAiu_spin_element(long int j, long int org_sigma2, long int org_sigma4, long int isA_up, long int isB_up, std::complex< double > tmp_V, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int *tmp_off)
Compute term of grandcanonical spsin system.
struct CheckList Check
Size of the Hilbert space.
Definition: struct.hpp:396
int isite1
Is it realy used ???
Definition: struct.hpp:337
long int sdim
Dimension for Ogata-Lin ???
Definition: struct.hpp:309
void GC_child_exchange_spin(int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, struct BindStruct *X)
Compute exchange term of spin Hamiltonian (grandcanonical)
Definition: mltplySpin.cpp:804
long int * list_1
Definition: global.cpp:25
long int idim_max
The dimension of the Hilbert space of this process.
Definition: struct.hpp:305
long int is2_up
Mask used in the bit oeration.
Definition: struct.hpp:328
void GC_child_CisAitCiuAiv_spin_element(long int j, long int org_sigma2, long int org_sigma4, long int isA_up, long int isB_up, std::complex< double > tmp_V, int nstate, std::complex< double > **tmp_v0, std::complex< double > **tmp_v1, long int *tmp_off_2)
Compute term of grandcanonical spsin system.
void StartTimer(int n)
function for initializing elapse time [start]
Definition: time.cpp:71
std::complex< double > tmp_V
Coupling constant.
Definition: struct.hpp:349