17 #include "PairExSpin.h" 19 #include "wrapperMPI.h" 20 #include "mltplyMPISpinCore.h" 21 #include "mltplySpinCore.h" 37 double complex *tmp_v0,
38 double complex *tmp_v1
43 if (
X->Def.iFlgGeneralSpin ==
FALSE) {
64 double complex *tmp_v0,
65 double complex *tmp_v1
68 long unsigned int i,j;
69 long unsigned int isite1;
70 long unsigned int org_isite1,org_isite2,org_sigma1,org_sigma2;
71 long unsigned int tmp_off=0;
73 double complex tmp_trans=0;
76 i_max =
X->Check.idim_maxOrg;
78 for(i=0;i<
X->Def.NPairExcitationOperator;i++){
79 org_isite1 =
X->Def.PairExcitationOperator[i][0]+1;
80 org_isite2 =
X->Def.PairExcitationOperator[i][2]+1;
81 org_sigma1 =
X->Def.PairExcitationOperator[i][1];
82 org_sigma2 =
X->Def.PairExcitationOperator[i][3];
83 tmp_trans =
X->Def.ParaPairExcitationOperator[i];
84 if(org_isite1 == org_isite2){
85 if(org_isite1 >
X->Def.Nsite){
86 if(org_sigma1==org_sigma2){
87 if(
X->Def.PairExcitationOperator[i][4]==0) {
99 isite1 =
X->Def.Tpow[org_isite1-1];
100 if(org_sigma1==org_sigma2) {
101 if (
X->Def.PairExcitationOperator[i][4] == 1) {
103 #pragma omp parallel for default(none) private(j, tmp_sgn) firstprivate(i_max, isite1, org_sigma1, X,tmp_trans) shared(tmp_v0, tmp_v1) 104 for (j = 1; j <= i_max; j++) {
105 tmp_v0[j] += (1.0-
X_SpinGC_CisAis(j,
X, isite1, org_sigma1)) * tmp_v1[j] * (-tmp_trans);
110 #pragma omp parallel for default(none) private(j, tmp_sgn) firstprivate(i_max, isite1, org_sigma1, X,tmp_trans) shared(tmp_v0, tmp_v1) 111 for (j = 1; j <= i_max; j++) {
112 tmp_v0[j] +=
X_SpinGC_CisAis(j,
X, isite1, org_sigma1) * tmp_v1[j] * tmp_trans;
118 #pragma omp parallel for default(none) private(j, tmp_sgn, tmp_off) firstprivate(i_max, isite1, org_sigma2, X, tmp_trans) shared(tmp_v0, tmp_v1) 119 for(j=1;j<=i_max;j++){
122 tmp_v0[tmp_off+1]+= tmp_sgn*tmp_v1[j]*tmp_trans;
128 fprintf(
stdoutMPI,
"ERROR: hopping is not allowed in localized spin system\n");
146 double complex *tmp_v0,
147 double complex *tmp_v1
150 long unsigned int i, j;
152 long unsigned int org_isite1, org_isite2, org_sigma1, org_sigma2;
153 long unsigned int tmp_off = 0;
155 double complex tmp_trans = 0;
157 i_max =
X->Check.idim_maxOrg;
159 for(i=0;i<
X->Def.NPairExcitationOperator;i++){
160 org_isite1 =
X->Def.PairExcitationOperator[i][0]+1;
161 org_isite2 =
X->Def.PairExcitationOperator[i][2]+1;
162 org_sigma1 =
X->Def.PairExcitationOperator[i][1];
163 org_sigma2 =
X->Def.PairExcitationOperator[i][3];
164 tmp_trans =
X->Def.ParaPairExcitationOperator[i];
165 if(org_isite1 == org_isite2){
166 if(org_isite1 >
X->Def.Nsite){
167 if(org_sigma1==org_sigma2){
168 if(
X->Def.PairExcitationOperator[i][4]==0) {
181 if(org_sigma1==org_sigma2){
182 if(
X->Def.PairExcitationOperator[i][4]==0) {
184 #pragma omp parallel for default(none) private(j, num1) firstprivate(i_max, org_isite1, org_sigma1, X, tmp_trans) shared(tmp_v0, tmp_v1) 185 for (j = 1; j <= i_max; j++) {
186 num1 =
BitCheckGeneral(j - 1, org_isite1, org_sigma1,
X->Def.SiteToBit,
X->Def.Tpow);
187 tmp_v0[j] += tmp_trans * tmp_v1[j] * num1;
192 #pragma omp parallel for default(none) private(j, num1) firstprivate(i_max, org_isite1, org_sigma1, X, tmp_trans) shared(tmp_v0, tmp_v1) 193 for (j = 1; j <= i_max; j++) {
194 num1 =
BitCheckGeneral(j - 1, org_isite1, org_sigma1,
X->Def.SiteToBit,
X->Def.Tpow);
195 tmp_v0[j] += -tmp_trans * tmp_v1[j] * (1.0-num1);
200 #pragma omp parallel for default(none) private(j, num1) firstprivate(i_max, org_isite1, org_sigma1, org_sigma2, X,tmp_off, tmp_trans) shared(tmp_v0, tmp_v1) 201 for(j=1;j<=i_max;j++){
202 num1 =
GetOffCompGeneralSpin(j-1, org_isite1, org_sigma2, org_sigma1, &tmp_off,
X->Def.SiteToBit,
X->Def.Tpow);
204 tmp_v0[tmp_off+1] += tmp_trans*tmp_v1[j]*num1;
210 fprintf(
stdoutMPI,
"ERROR: hopping is not allowed in localized spin system\n");
228 double complex *tmp_v0,
229 double complex *tmp_v1
233 if (
X->Def.iFlgGeneralSpin ==
FALSE) {
253 double complex *tmp_v0,
254 double complex *tmp_v1
258 long unsigned int i,j, idim_maxMPI;
259 long unsigned int isite1;
260 long unsigned int org_isite1,org_isite2,org_sigma1,org_sigma2;
261 long unsigned int tmp_off=0;
263 double complex tmp_trans=0;
267 long unsigned int is1_up;
269 i_max =
X->Check.idim_maxOrg;
271 double complex *tmp_v1bufOrg;
274 idim_maxMPI =
MaxMPI_li(
X->Check.idim_maxOrg);
275 c_malloc1(tmp_v1bufOrg, idim_maxMPI + 1);
278 for (i = 0; i <
X->Def.NPairExcitationOperator; i++) {
279 org_isite1 =
X->Def.PairExcitationOperator[i][0] + 1;
280 org_isite2 =
X->Def.PairExcitationOperator[i][2] + 1;
281 org_sigma1 =
X->Def.PairExcitationOperator[i][1];
282 org_sigma2 =
X->Def.PairExcitationOperator[i][3];
283 tmp_trans =
X->Def.ParaPairExcitationOperator[i];
284 if (org_sigma1 == org_sigma2) {
285 if (org_isite1 == org_isite2) {
286 if (org_isite1 >
X->Def.Nsite) {
287 is1_up =
X->Def.Tpow[org_isite1 - 1];
289 if (
X->Def.PairExcitationOperator[i][4] == 0) {
291 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1) \ 292 firstprivate(i_max, tmp_trans) private(j) 293 for (j = 1; j <= i_max; j++) tmp_v0[j] += tmp_trans * tmp_v1[j];
297 #pragma omp parallel for default(none) shared(tmp_v0, tmp_v1) \ 298 firstprivate(i_max, tmp_trans) private(j) 299 for (j = 1; j <= i_max; j++) tmp_v0[j] += tmp_trans * tmp_v1[j];
304 isite1 =
X->Def.Tpow[org_isite1 - 1];
305 if (org_isite1 == org_isite2 && org_sigma1 == org_sigma2 &&
306 X->Def.PairExcitationOperator[i][4] == 1) {
307 #pragma omp parallel for default(none) private(j) firstprivate(i_max, isite1, org_sigma1, X, tmp_trans) shared(tmp_v0, tmp_v1) 308 for (j = 1; j <= i_max; j++) {
309 tmp_v0[j] += (1.0 -
X_Spin_CisAis(j,
X, isite1, org_sigma1)) * tmp_v1[j] * (-tmp_trans);
312 #pragma omp parallel for default(none) private(j) firstprivate(i_max, isite1, org_sigma1, X, tmp_trans) shared(tmp_v0, tmp_v1) 313 for (j = 1; j <= i_max; j++) {
314 tmp_v0[j] +=
X_Spin_CisAis(j,
X, isite1, org_sigma1) * tmp_v1[j] * tmp_trans;
319 fprintf(
stdoutMPI,
"Error: isite1 must be equal to isite2 for Spin system. \n");
323 if (org_isite1 >
X->Def.Nsite) {
324 X_child_CisAit_spin_MPIdouble(org_isite1-1, org_sigma2, tmp_trans,
X, tmp_v0, tmp_v1, tmp_v1bufOrg, i_max,
X->Def.Tpow,
list_1_org,
list_1buf_org,
list_2_1,
list_2_2,
X->Large.irght,
X->Large.ilft,
X->Large.ihfbit);
327 isite1 =
X->Def.Tpow[org_isite1 - 1];
328 #pragma omp parallel for default(none) private(j, tmp_off, num1) \ 329 firstprivate(i_max, isite1, org_sigma2, X, tmp_trans, list_1_org, list_1, list_2_1, list_2_2) shared(tmp_v0, tmp_v1) 330 for (j = 1; j <= i_max; j++) {
332 if (num1 != 0) tmp_v0[tmp_off] += tmp_v1[j] * tmp_trans*(double)num1;
352 double complex *tmp_v0,
353 double complex *tmp_v1
357 long unsigned int i,j, idim_maxMPI;
358 long unsigned int org_isite1,org_isite2,org_sigma1,org_sigma2;
359 long unsigned int tmp_off=0;
360 long unsigned int off=0;
362 double complex tmp_trans=0;
365 i_max =
X->Check.idim_maxOrg;
367 double complex *tmp_v1bufOrg;
370 idim_maxMPI =
MaxMPI_li(
X->Check.idim_maxOrg);
371 c_malloc1(tmp_v1bufOrg, idim_maxMPI + 1);
374 for(i=0;i<
X->Def.NPairExcitationOperator;i++){
375 org_isite1 =
X->Def.PairExcitationOperator[i][0]+1;
376 org_isite2 =
X->Def.PairExcitationOperator[i][2]+1;
377 org_sigma1 =
X->Def.PairExcitationOperator[i][1];
378 org_sigma2 =
X->Def.PairExcitationOperator[i][3];
379 tmp_trans =
X->Def.ParaPairExcitationOperator[i];
380 if(org_isite1 == org_isite2){
381 if(org_isite1 >
X->Def.Nsite){
382 if(org_sigma1==org_sigma2){
385 org_isite1, org_sigma1,
X->Def.SiteToBit,
X->Def.Tpow);
386 if(
X->Def.PairExcitationOperator[i][4]==0) {
388 #pragma omp parallel for default(none) private(j) firstprivate(i_max, tmp_trans) shared(tmp_v0,tmp_v1) 389 for (j = 1; j <= i_max; j++) {
390 tmp_v0[j] += tmp_trans * tmp_v1[j];
396 #pragma omp parallel for default(none) private(j) firstprivate(i_max, tmp_trans) shared(tmp_v0,tmp_v1) 397 for (j = 1; j <= i_max; j++) {
398 tmp_v0[j] += -tmp_trans * tmp_v1[j];
404 X_child_CisAit_GeneralSpin_MPIdouble(org_isite1-1, org_sigma1, org_sigma2, tmp_trans,
X, tmp_v0, tmp_v1, tmp_v1bufOrg, i_max,
list_1_org,
list_1buf_org,
X->Large.ihfbit);
408 if(org_sigma1==org_sigma2) {
410 if (
X->Def.PairExcitationOperator[i][4] == 0) {
411 #pragma omp parallel for default(none) private(j, num1) firstprivate(i_max, org_isite1, org_sigma1, X, tmp_trans) shared(tmp_v0,tmp_v1, list_1) 412 for (j = 1; j <= i_max; j++) {
414 tmp_v0[j] += tmp_trans * tmp_v1[j] * num1;
417 #pragma omp parallel for default(none) private(j, num1) firstprivate(i_max, org_isite1, org_sigma1, X, tmp_trans) shared(tmp_v0,tmp_v1, list_1) 418 for (j = 1; j <= i_max; j++) {
420 tmp_v0[j] += -tmp_trans * tmp_v1[j] * (1.0 - num1);
425 #pragma omp parallel for default(none) private(j, tmp_sgn,tmp_off) \ 426 firstprivate(i_max, org_isite1, org_sigma1, org_sigma2, X, off, tmp_trans, myrank) \ 427 shared(tmp_v0, tmp_v1, list_1_org, list_1) 428 for (j = 1; j <= i_max; j++) {
433 printf(
"rank=%d, org=%ld, tmp_off=%ld, list_1=%ld, ihfbit=%ld\n",
myrank,
list_1_org[j], off,
list_1[tmp_off],
X->Large.ihfbit);
435 tmp_v0[tmp_off] += tmp_v1[j]*tmp_trans;
442 fprintf(
stdoutMPI,
"ERROR: hopping is not allowed in localized spin system\n");
double complex X_GC_child_CisAis_GeneralSpin_MPIdouble(int org_isite1, int org_ispin1, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Compute term in the grandcanonical general spin system when both site is in the inter process region...
double complex X_GC_child_CisAis_spin_MPIdouble(int org_isite1, int org_ispin1, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Spin + GC When both site1 and site2 are in the inter process region.
int GetPairExcitedStateHalfSpinGC(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
double complex X_GC_child_CisAit_spin_MPIdouble(int org_isite1, int org_ispin1, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Spin + GC When both site1 and site2 are in the inter process region.
int X_SpinGC_CisAis(long unsigned int j, struct BindStruct *X, long unsigned int is1_spin, long unsigned int sigma1)
Compute the grandcanonical spin state with bit mask is1_spin.
int ConvertToList1GeneralSpin(const long unsigned int org_ibit, const long unsigned int ihlfbit, long unsigned int *_ilist1Comp)
function of converting component to list_1
int X_Spin_CisAis(long unsigned int j, struct BindStruct *X, long unsigned int is1_spin, long unsigned int sigma1)
Compute the spin state with bit mask is1_spin.
int GetPairExcitedStateSpinGC(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Calculation of pair excited state for Spin Grand canonical system.
long unsigned int * list_1buf_org
double complex X_GC_child_CisAit_GeneralSpin_MPIdouble(int org_isite1, int org_ispin1, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Compute term in the grandcanonical general spin system when both site is in the inter process region...
double complex X_child_CisAit_spin_MPIdouble(int org_isite1, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1, double complex *tmp_v1buf, unsigned long int idim_max, long unsigned int *Tpow, long unsigned int *list_1_org, long unsigned int *list_1buf_org, long unsigned int *list_2_1_target, long unsigned int *list_2_2_target, long unsigned int _irght, long unsigned int _ilft, long unsigned int _ihfbit)
Hopping term in Spin + Canonical for CalcSpectrum When both site1 and site2 are in the inter process ...
int GetPairExcitedStateSpin(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
long unsigned int * list_1_org
unsigned long int MaxMPI_li(unsigned long int idim)
MPI wrapper function to obtain maximum unsigned long integer across processes.
long unsigned int * list_2_1
int X_Spin_CisAit(long unsigned int j, struct BindStruct *X, long unsigned int is1_spin, long unsigned int sigma2, long unsigned int *list_1_Org_, long unsigned int *list_2_1_, long unsigned int *list_2_2_, long unsigned int *tmp_off)
Compute index of final wavefunction by term.
long unsigned int * list_1
double complex X_GC_child_AisCis_GeneralSpin_MPIdouble(int org_isite1, int org_ispin1, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Compute term in the grandcanonical general spin system when both site is in the inter process region...
long unsigned int * list_2_2
int BitCheckGeneral(const long unsigned int org_bit, const unsigned int org_isite, const unsigned int target_ispin, const long int *SiteToBit, const long unsigned int *Tpow)
bit check function for general spin
double complex X_GC_child_AisCis_spin_MPIdouble(int org_isite1, int org_ispin1, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
Hopping term in Spin + GC When both site1 and site2 are in the inter process region.
int GetPairExcitedStateGeneralSpin(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
int GetPairExcitedStateHalfSpin(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
double complex X_child_CisAit_GeneralSpin_MPIdouble(int org_isite1, int org_ispin1, int org_ispin2, double complex tmp_trans, struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1, double complex *tmp_v1buf, unsigned long int idim_max, long unsigned int *list_1_org, long unsigned int *list_1buf_org, long unsigned int _ihfbit)
Compute term in the canonical general spin system when both site is in the inter process region...
int GetOffCompGeneralSpin(const long unsigned int org_ibit, const int org_isite, const int org_ispin, const int off_ispin, long unsigned int *_ioffComp, const long int *SiteToBit, const long unsigned int *Tpow)
function of getting off-diagonal component for general spin
int X_SpinGC_CisAit(long unsigned int j, struct BindStruct *X, long unsigned int is1_spin, long unsigned int sigma2, long unsigned int *tmp_off)
Compute index of final wavefunction by term (grandcanonical).
int myrank
Process ID, defined in InitializeMPI()
int GetPairExcitedStateGeneralSpinGC(struct BindStruct *X, double complex *tmp_v0, double complex *tmp_v1)
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()