25 #include "MPIchemps2.h" 28 void CheMPS2::Heff::addDiagram5A(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorL ** Lright,
double * temp,
double * temp2)
const{
30 #ifdef CHEMPS2_MPI_COMPILATION 34 int NL = denS->gNL(ikappa);
35 int TwoSL = denS->gTwoSL(ikappa);
36 int IL = denS->gIL(ikappa);
38 int NR = denS->gNR(ikappa);
39 int TwoSR = denS->gTwoSR(ikappa);
40 int IR = denS->gIR(ikappa);
42 int N1 = denS->gN1(ikappa);
43 int N2 = denS->gN2(ikappa);
44 int TwoJ = denS->gTwoJ(ikappa);
46 int theindex = denS->gIndex();
47 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
48 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
57 #ifdef CHEMPS2_MPI_COMPILATION 58 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5A1 ) == MPIRANK ) && (N1==0) && (N2==0)){
60 if ((N1==0) && (N2==0)){
63 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
64 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
65 for (
int TwoJdown=0; TwoJdown<=2; TwoJdown+=2){
66 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
68 int fase =
phase(TwoSLdown+TwoSRdown+2);
69 const double factor = fase * sqrt((TwoJdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j( 1, 1, TwoJdown, TwoSLdown, TwoSRdown, TwoSR );
76 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
77 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
80 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
81 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
84 if ((leftOK) && (rightOK)){
86 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
87 if (denBK->
gIrrep(l_alpha) == Irrep){
92 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
93 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
95 if ((dimLdown>0) && (dimRdown>0)){
97 int size = dimRup * dimRdown;
98 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
100 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
101 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
102 double prefac = factor * ( Prob->
gMxElement(l_alpha, l_beta, theindex, theindex+1)
103 + ((TwoJdown==0)?1:-1) * Prob->
gMxElement(l_alpha, l_beta, theindex+1, theindex) );
104 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
105 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
111 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 1, 1, TwoJdown, NR+1, TwoSRdown, IRdown);
113 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
116 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
117 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
131 #ifdef CHEMPS2_MPI_COMPILATION 132 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5A2 ) == MPIRANK ) && (N1==1) && (N2==0)){
134 if ((N1==1) && (N2==0)){
137 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
138 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
140 if (((TwoSL == TwoSRdown) || (TwoSLdown == TwoSR)) && (abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
142 double factor1 = 0.0;
143 double factor2 = 0.0;
145 if (TwoSL == TwoSRdown){ factor2 =
phase(TwoSRdown + 1 - TwoSR); }
146 if (TwoSLdown == TwoSR){
147 int fase =
phase(TwoSLdown + 1 - TwoSL);
148 factor1 = fase * sqrt(((TwoSRdown+1)*(TwoSL+1.0))/((TwoSR+1)*(TwoSLdown+1.0)));
156 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
157 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
159 bool rightOK =
false;
160 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
161 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
164 if ((leftOK) && (rightOK)){
166 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
167 if (denBK->
gIrrep(l_alpha) == Irrep){
172 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
173 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
175 if ((dimLdown>0) && (dimRdown>0)){
177 int size = dimRup * dimRdown;
178 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
180 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
181 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
182 double prefac = factor1 * Prob->
gMxElement(l_alpha, l_beta, theindex, theindex+1)
183 + factor2 * Prob->
gMxElement(l_alpha, l_beta, theindex+1, theindex);
184 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
185 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
191 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 2, 1, 1, NR+1, TwoSRdown, IRdown);
193 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
196 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
197 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
210 #ifdef CHEMPS2_MPI_COMPILATION 211 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5A3 ) == MPIRANK ) && (N1==0) && (N2==1)){
213 if ((N1==0) && (N2==1)){
216 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
217 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
219 if (((TwoSL == TwoSRdown) || (TwoSLdown == TwoSR)) && (abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
221 double factor1 = 0.0;
222 double factor2 = 0.0;
224 if (TwoSL == TwoSRdown){ factor1 =
phase(TwoSRdown + 1 - TwoSR); }
225 if (TwoSLdown == TwoSR){
226 int fase =
phase(TwoSLdown + 1 - TwoSL);
227 factor2 = fase * sqrt(((TwoSRdown+1)*(TwoSL+1.0))/((TwoSR+1)*(TwoSLdown+1.0)));
235 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
236 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
238 bool rightOK =
false;
239 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
240 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
243 if ((leftOK) && (rightOK)){
245 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
246 if (denBK->
gIrrep(l_alpha) == Irrep){
251 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
252 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
254 if ((dimLdown>0) && (dimRdown>0)){
256 int size = dimRup * dimRdown;
257 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
259 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
260 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
261 double prefac = factor1 * Prob->
gMxElement(l_alpha, l_beta, theindex, theindex+1)
262 + factor2 * Prob->
gMxElement(l_alpha, l_beta, theindex+1, theindex);
263 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
264 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
270 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 1, 2, 1, NR+1, TwoSRdown, IRdown);
272 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
275 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
276 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
289 #ifdef CHEMPS2_MPI_COMPILATION 290 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5A4 ) == MPIRANK ) && (N1==1) && (N2==1)){
292 if ((N1==1) && (N2==1)){
295 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
296 if ((TwoSLdown>=0) && (abs(TwoSR-TwoSLdown)<=1)){
297 int TwoSRdown = TwoSLdown;
299 int fase = (((TwoSL+1)%2)!=0)?-1:1;
300 const double factor = fase * sqrt((TwoJ+1)*(TwoSL+1.0)) *
Wigner::wigner6j( 1, 1, TwoJ, TwoSL, TwoSR, TwoSRdown );
307 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
308 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
310 bool rightOK =
false;
311 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
312 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
315 if ((leftOK) && (rightOK)){
317 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
318 if (denBK->
gIrrep(l_alpha) == Irrep){
323 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
324 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
326 if ((dimLdown>0) && (dimRdown>0)){
328 int size = dimRup * dimRdown;
329 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
331 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
332 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
333 double prefac = factor * ( Prob->
gMxElement(l_alpha, l_beta, theindex, theindex+1)
334 + ((TwoJ==0)?1:-1) * Prob->
gMxElement(l_alpha, l_beta, theindex+1, theindex) );
335 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
336 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
342 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 2, 2, 0, NR+1, TwoSRdown, IRdown);
344 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
347 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
348 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
360 void CheMPS2::Heff::addDiagram5B(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorL ** Lright,
double * temp,
double * temp2)
const{
362 #ifdef CHEMPS2_MPI_COMPILATION 366 int NL = denS->gNL(ikappa);
367 int TwoSL = denS->gTwoSL(ikappa);
368 int IL = denS->gIL(ikappa);
370 int NR = denS->gNR(ikappa);
371 int TwoSR = denS->gTwoSR(ikappa);
372 int IR = denS->gIR(ikappa);
374 int N1 = denS->gN1(ikappa);
375 int N2 = denS->gN2(ikappa);
376 int TwoJ = denS->gTwoJ(ikappa);
378 int theindex = denS->gIndex();
379 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
380 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
388 #ifdef CHEMPS2_MPI_COMPILATION 389 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5B1 ) == MPIRANK ) && (N1==1) && (N2==1)){
391 if ((N1==1) && (N2==1)){
394 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
395 if ((TwoSLdown>=0) && (abs(TwoSR-TwoSLdown)<=1)){
396 int TwoSRdown = TwoSLdown;
398 int fase =
phase(TwoSL+TwoSR+2);
399 const double factor = fase * sqrt((TwoJ+1)*(TwoSR+1.0)) *
Wigner::wigner6j( 1, 1, TwoJ, TwoSL, TwoSR, TwoSRdown );
406 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
407 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
409 bool rightOK =
false;
410 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
411 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
414 if ((leftOK) && (rightOK)){
416 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
417 if (denBK->
gIrrep(l_alpha) == Irrep){
422 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
423 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
425 if ((dimLdown>0) && (dimRdown>0)){
427 int size = dimRup * dimRdown;
428 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
430 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
431 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
432 double prefac = factor * ( Prob->
gMxElement(l_alpha, l_beta, theindex, theindex+1)
433 + ((TwoJ==0)?1:-1) * Prob->
gMxElement(l_alpha, l_beta, theindex+1, theindex) );
434 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
435 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
441 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 0, 0, 0, NR-1, TwoSRdown, IRdown);
443 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
446 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
447 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
458 #ifdef CHEMPS2_MPI_COMPILATION 459 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5B2 ) == MPIRANK ) && (N1==2) && (N2==1)){
461 if ((N1==2) && (N2==1)){
464 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
465 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
467 if (((TwoSL == TwoSRdown) || (TwoSLdown == TwoSR)) && (abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
469 double factor1 = 0.0;
470 double factor2 = 0.0;
472 if (TwoSLdown == TwoSR){ factor2 =
phase(TwoSR + 1 - TwoSRdown); }
473 if (TwoSL == TwoSRdown){
474 int fase =
phase(TwoSL + 1 - TwoSLdown);
475 factor1 = fase * sqrt(((TwoSR+1)*(TwoSLdown+1.0))/((TwoSRdown+1)*(TwoSL+1.0)));
483 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
484 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
486 bool rightOK =
false;
487 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
488 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
491 if ((leftOK) && (rightOK)){
493 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
494 if (denBK->
gIrrep(l_alpha) == Irrep){
499 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
500 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
502 if ((dimLdown>0) && (dimRdown>0)){
504 int size = dimRup * dimRdown;
505 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
507 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
508 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
509 double prefac = factor1 * Prob->
gMxElement(l_alpha, l_beta, theindex, theindex+1)
510 + factor2 * Prob->
gMxElement(l_alpha, l_beta, theindex+1, theindex);
511 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
512 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
518 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 1, 0, 1, NR-1, TwoSRdown, IRdown);
520 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
523 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
524 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
537 #ifdef CHEMPS2_MPI_COMPILATION 538 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5B3 ) == MPIRANK ) && (N1==1) && (N2==2)){
540 if ((N1==1) && (N2==2)){
543 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
544 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
546 if (((TwoSL == TwoSRdown) || (TwoSLdown == TwoSR)) && (abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
548 double factor1 = 0.0;
549 double factor2 = 0.0;
551 if (TwoSLdown == TwoSR){ factor1 =
phase(TwoSR + 1 - TwoSRdown); }
552 if (TwoSL == TwoSRdown){
553 factor2 =
phase(TwoSL + 1 - TwoSLdown) * sqrt(((TwoSR+1)*(TwoSLdown+1.0))/((TwoSRdown+1)*(TwoSL+1.0)));
561 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
562 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
564 bool rightOK =
false;
565 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
566 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
569 if ((leftOK) && (rightOK)){
571 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
572 if (denBK->
gIrrep(l_alpha) == Irrep){
577 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
578 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
580 if ((dimLdown>0) && (dimRdown>0)){
582 int size = dimRup * dimRdown;
583 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
585 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
586 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
587 double prefac = factor1 * Prob->
gMxElement(l_alpha, l_beta, theindex, theindex+1)
588 + factor2 * Prob->
gMxElement(l_alpha, l_beta, theindex+1, theindex);
589 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
590 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
596 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 0, 1, 1, NR-1, TwoSRdown, IRdown);
598 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
601 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
602 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
615 #ifdef CHEMPS2_MPI_COMPILATION 616 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5B4 ) == MPIRANK ) && (N1==2) && (N2==2)){
618 if ((N1==2) && (N2==2)){
621 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
622 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
623 for (
int TwoJdown=0; TwoJdown<=2; TwoJdown+=2){
624 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
626 int fase = (((TwoSLdown+1)%2)!=0)?-1:1;
627 const double factor = fase * sqrt((TwoJdown+1)*(TwoSLdown+1.0)) *
Wigner::wigner6j( 1, 1, TwoJdown, TwoSLdown, TwoSRdown, TwoSR );
634 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
635 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
637 bool rightOK =
false;
638 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
639 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
642 if ((leftOK) && (rightOK)){
644 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
645 if (denBK->
gIrrep(l_alpha) == Irrep){
650 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
651 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
653 if ((dimLdown>0) && (dimRdown>0)){
655 int size = dimRup * dimRdown;
656 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
658 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
659 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
660 double prefac = factor * ( Prob->
gMxElement(l_alpha, l_beta, theindex, theindex+1)
661 + ((TwoJdown==0)?1:-1) * Prob->
gMxElement(l_alpha, l_beta, theindex+1, theindex) );
662 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
663 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
669 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 1, 1, TwoJdown, NR-1, TwoSRdown, IRdown);
671 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
674 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
675 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
689 void CheMPS2::Heff::addDiagram5C(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorL ** Lright,
double * temp,
double * temp2)
const{
691 #ifdef CHEMPS2_MPI_COMPILATION 695 int NL = denS->gNL(ikappa);
696 int TwoSL = denS->gTwoSL(ikappa);
697 int IL = denS->gIL(ikappa);
699 int NR = denS->gNR(ikappa);
700 int TwoSR = denS->gTwoSR(ikappa);
701 int IR = denS->gIR(ikappa);
703 int N1 = denS->gN1(ikappa);
704 int N2 = denS->gN2(ikappa);
705 int TwoJ = denS->gTwoJ(ikappa);
707 int theindex = denS->gIndex();
708 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
709 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
718 #ifdef CHEMPS2_MPI_COMPILATION 719 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5C1 ) == MPIRANK ) && (N1==1) && (N2==0)){
721 if ((N1==1) && (N2==0)){
724 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
725 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
726 if ((abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
728 int fase =
phase(TwoSL+TwoSRdown);
729 const double factor2 = fase * sqrt((TwoSL+1)*(TwoSR+1.0)) *
Wigner::wigner6j( TwoSLdown, TwoSRdown, 1, TwoSR, TwoSL, 1 );
730 const double factor1 = (TwoSL==TwoSRdown)?sqrt((TwoSR+1.0)/(TwoSRdown+1.0)):0.0;
737 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
738 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
740 bool rightOK =
false;
741 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
742 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
745 if ((leftOK) && (rightOK)){
747 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
748 if (denBK->
gIrrep(l_alpha) == Irrep){
753 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
754 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
756 if ((dimLdown>0) && (dimRdown>0)){
758 int size = dimRup * dimRdown;
759 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
761 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
762 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
763 double prefac = factor1 * Prob->
gMxElement(l_alpha,theindex,theindex+1,l_beta)
764 + factor2 * Prob->
gMxElement(l_alpha,theindex,l_beta,theindex+1);
765 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
766 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
772 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 0, 1, 1, NR-1, TwoSRdown, IRdown);
774 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
777 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
778 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
790 #ifdef CHEMPS2_MPI_COMPILATION 791 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5C2 ) == MPIRANK ) && (N1==2) && (N2==0)){
793 if ((N1==2) && (N2==0)){
796 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
797 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
798 for (
int TwoJdown=0; TwoJdown<=2; TwoJdown+=2){
799 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
801 int fase =
phase(TwoSR + TwoSLdown + 3 + TwoJdown);
802 const double factor1 = fase * sqrt((TwoSR+1)*(TwoJdown+1.0)) *
Wigner::wigner6j( 1, 1, TwoJdown, TwoSLdown, TwoSRdown, TwoSR );
803 const double factor2 = (TwoJdown==0)?sqrt(2.0*(TwoSR+1.0)/(TwoSRdown+1.0)):0.0;
810 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
811 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
813 bool rightOK =
false;
814 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
815 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
818 if ((leftOK) && (rightOK)){
820 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
821 if (denBK->
gIrrep(l_alpha) == Irrep){
826 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
827 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
829 if ((dimLdown>0) && (dimRdown>0)){
831 int size = dimRup * dimRdown;
832 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
834 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
835 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
836 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex, theindex+1, l_beta)
837 + factor2 * Prob->
gMxElement(l_alpha, theindex, l_beta, theindex+1);
838 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
839 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
845 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 1, 1, TwoJdown, NR-1, TwoSRdown, IRdown);
847 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
850 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
851 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
864 #ifdef CHEMPS2_MPI_COMPILATION 865 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5C3 ) == MPIRANK ) && (N1==1) && (N2==1)){
867 if ((N1==1) && (N2==1)){
870 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
871 if ((TwoSLdown>=0) && (abs(TwoSR-TwoSLdown)<=1)){
872 int TwoSRdown = TwoSLdown;
874 int fase =
phase(TwoSR + TwoSRdown + 3 + TwoJ);
875 double factor1 = fase * sqrt((TwoSL+1.0)*(TwoJ+1.0)*(TwoSR+1.0)/(TwoSRdown+1.0)) *
Wigner::wigner6j( 1, 1, TwoJ, TwoSL, TwoSR, TwoSRdown );
876 double factor2 = (TwoJ==0)?sqrt(2.0*(TwoSR+1.0)/(TwoSRdown+1.0)):0.0;
883 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
884 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
886 bool rightOK =
false;
887 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
888 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
891 if ((leftOK) && (rightOK)){
893 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
894 if (denBK->
gIrrep(l_alpha) == Irrep){
899 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
900 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
902 if ((dimLdown>0) && (dimRdown>0)){
904 int size = dimRup * dimRdown;
905 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
907 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
908 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
909 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex, theindex+1, l_beta)
910 + factor2 * Prob->
gMxElement(l_alpha, theindex, l_beta, theindex+1);
911 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
912 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
918 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 0, 2, 0, NR-1, TwoSRdown, IRdown);
920 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
923 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
924 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
935 #ifdef CHEMPS2_MPI_COMPILATION 936 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5C4 ) == MPIRANK ) && (N1==2) && (N2==1)){
938 if ((N1==2) && (N2==1)){
941 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
942 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
943 if ((abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
945 const double factor1 = (TwoSLdown==TwoSR) ?
phase(TwoSL-TwoSRdown) * sqrt((TwoSL+1.0)/(TwoSLdown+1.0)) : 0.0;
946 const double factor2 =
phase(TwoSL+TwoSRdown+2) * sqrt((TwoSL+1)*(TwoSR+1.0)) *
Wigner::wigner6j( TwoSLdown, TwoSRdown, 1, TwoSR, TwoSL, 1 );
953 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
954 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
956 bool rightOK =
false;
957 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
958 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
961 if ((leftOK) && (rightOK)){
963 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
964 if (denBK->
gIrrep(l_alpha) == Irrep){
969 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
970 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
972 if ((dimLdown>0) && (dimRdown>0)){
974 int size = dimRup * dimRdown;
975 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
977 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
978 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
979 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex, theindex+1, l_beta)
980 + factor2 * Prob->
gMxElement(l_alpha, theindex, l_beta, theindex+1);
981 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
982 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
988 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 1, 2, 1, NR-1, TwoSRdown, IRdown);
990 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
993 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
994 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1007 void CheMPS2::Heff::addDiagram5D(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorL ** Lright,
double * temp,
double * temp2)
const{
1009 #ifdef CHEMPS2_MPI_COMPILATION 1013 int NL = denS->gNL(ikappa);
1014 int TwoSL = denS->gTwoSL(ikappa);
1015 int IL = denS->gIL(ikappa);
1017 int NR = denS->gNR(ikappa);
1018 int TwoSR = denS->gTwoSR(ikappa);
1019 int IR = denS->gIR(ikappa);
1021 int N1 = denS->gN1(ikappa);
1022 int N2 = denS->gN2(ikappa);
1023 int TwoJ = denS->gTwoJ(ikappa);
1025 int theindex = denS->gIndex();
1026 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
1027 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1036 #ifdef CHEMPS2_MPI_COMPILATION 1037 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5D1 ) == MPIRANK ) && (N1==0) && (N2==1)){
1039 if ((N1==0) && (N2==1)){
1042 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1043 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1044 if ((abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1046 int fase =
phase(TwoSLdown+TwoSR);
1047 const double factor2 = fase * sqrt((TwoSLdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j( TwoSL, TwoSR, 1, TwoSRdown, TwoSLdown, 1 );
1048 const double factor1 = (TwoSLdown==TwoSR)?sqrt((TwoSRdown+1.0)/(TwoSR+1.0)):0.0;
1054 bool leftOK =
false;
1055 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1056 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1058 bool rightOK =
false;
1059 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1060 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1063 if ((leftOK) && (rightOK)){
1065 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1066 if (denBK->
gIrrep(l_alpha) == Irrep){
1071 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
1072 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1074 if ((dimLdown>0) && (dimRdown>0)){
1076 int size = dimRup * dimRdown;
1077 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1079 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1080 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1081 double prefac = factor1 * Prob->
gMxElement(l_alpha,theindex,theindex+1,l_beta)
1082 + factor2 * Prob->
gMxElement(l_alpha,theindex,l_beta,theindex+1);
1083 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1084 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1090 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 1, 0, 1, NR+1, TwoSRdown, IRdown);
1092 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
1095 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
1096 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1109 #ifdef CHEMPS2_MPI_COMPILATION 1110 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5D2 ) == MPIRANK ) && (N1==1) && (N2==1)){
1112 if ((N1==1) && (N2==1)){
1115 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1116 if ((TwoSLdown>=0) && (abs(TwoSR-TwoSLdown)<=1)){
1117 int TwoSRdown = TwoSLdown;
1119 int fase =
phase(TwoSRdown + TwoSL + 3 + TwoJ);
1120 const double factor1 = fase * sqrt((TwoSRdown+1)*(TwoJ+1.0)) *
Wigner::wigner6j( 1, 1, TwoJ, TwoSL, TwoSR, TwoSRdown );
1121 const double factor2 = (TwoJ==0)?sqrt(2.0*(TwoSRdown+1.0)/(TwoSR+1.0)):0.0;
1127 bool leftOK =
false;
1128 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1129 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1131 bool rightOK =
false;
1132 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1133 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1136 if ((leftOK) && (rightOK)){
1138 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1139 if (denBK->
gIrrep(l_alpha) == Irrep){
1144 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
1145 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1147 if ((dimLdown>0) && (dimRdown>0)){
1149 int size = dimRup * dimRdown;
1150 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1152 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1153 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1154 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex, theindex+1, l_beta)
1155 + factor2 * Prob->
gMxElement(l_alpha, theindex, l_beta, theindex+1);
1156 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1157 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1163 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 2, 0, 0, NR+1, TwoSRdown, IRdown);
1165 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
1168 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
1169 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1180 #ifdef CHEMPS2_MPI_COMPILATION 1181 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5D3 ) == MPIRANK ) && (N1==0) && (N2==2)){
1183 if ((N1==0) && (N2==2)){
1186 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1187 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1188 for (
int TwoJdown=0; TwoJdown<=2; TwoJdown+=2){
1189 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1191 int fase =
phase(TwoSR + TwoSRdown + 3 + TwoJdown);
1192 double factor1 = fase * sqrt((TwoSLdown+1.0)*(TwoJdown+1.0)*(TwoSRdown+1.0)/(TwoSR+1.0)) *
Wigner::wigner6j( 1, 1, TwoJdown, TwoSLdown, TwoSRdown, TwoSR );
1193 double factor2 = (TwoJdown==0)?sqrt(2.0*(TwoSRdown+1.0)/(TwoSR+1.0)):0.0;
1199 bool leftOK =
false;
1200 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1201 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1203 bool rightOK =
false;
1204 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1205 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1208 if ((leftOK) && (rightOK)){
1210 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1211 if (denBK->
gIrrep(l_alpha) == Irrep){
1216 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
1217 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1219 if ((dimLdown>0) && (dimRdown>0)){
1221 int size = dimRup * dimRdown;
1222 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1224 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1225 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1226 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex, theindex+1, l_beta)
1227 + factor2 * Prob->
gMxElement(l_alpha, theindex, l_beta, theindex+1);
1228 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1229 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1235 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 1, 1, TwoJdown, NR+1, TwoSRdown, IRdown);
1237 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
1240 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
1241 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1254 #ifdef CHEMPS2_MPI_COMPILATION 1255 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5D4 ) == MPIRANK ) && (N1==1) && (N2==2)){
1257 if ((N1==1) && (N2==2)){
1260 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1261 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1262 if ((abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1264 const double factor1 = (TwoSL==TwoSRdown) ?
phase(TwoSLdown-TwoSR) * sqrt((TwoSLdown+1.0)/(TwoSL+1.0)) : 0.0;
1265 const double factor2 =
phase(TwoSLdown+TwoSR+2) * sqrt((TwoSLdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j( TwoSL, TwoSR, 1, TwoSRdown, TwoSLdown, 1 );
1271 bool leftOK =
false;
1272 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1273 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1275 bool rightOK =
false;
1276 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1277 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1280 if ((leftOK) && (rightOK)){
1282 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1283 if (denBK->
gIrrep(l_alpha) == Irrep){
1288 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
1289 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1291 if ((dimLdown>0) && (dimRdown>0)){
1293 int size = dimRup * dimRdown;
1294 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1296 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1297 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1298 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex, theindex+1, l_beta)
1299 + factor2 * Prob->
gMxElement(l_alpha, theindex, l_beta, theindex+1);
1300 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1301 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1307 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 2, 1, 1, NR+1, TwoSRdown, IRdown);
1309 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
1312 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
1313 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1326 void CheMPS2::Heff::addDiagram5E(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorL ** Lright,
double * temp,
double * temp2)
const{
1328 #ifdef CHEMPS2_MPI_COMPILATION 1332 int NL = denS->gNL(ikappa);
1333 int TwoSL = denS->gTwoSL(ikappa);
1334 int IL = denS->gIL(ikappa);
1336 int NR = denS->gNR(ikappa);
1337 int TwoSR = denS->gTwoSR(ikappa);
1338 int IR = denS->gIR(ikappa);
1340 int N1 = denS->gN1(ikappa);
1341 int N2 = denS->gN2(ikappa);
1342 int TwoJ = denS->gTwoJ(ikappa);
1344 int theindex = denS->gIndex();
1345 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
1346 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1355 #ifdef CHEMPS2_MPI_COMPILATION 1356 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5E1 ) == MPIRANK ) && (N1==0) && (N2==1)){
1358 if ((N1==0) && (N2==1)){
1361 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1362 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1363 if ((abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1365 const double factor2 =
phase(TwoSL+TwoSRdown) * sqrt((TwoSL+1)*(TwoSR+1.0)) *
Wigner::wigner6j( TwoSLdown, TwoSRdown, 1, TwoSR, TwoSL, 1 );
1366 const double factor1 = (TwoSL==TwoSRdown)?sqrt((TwoSR+1.0)/(TwoSRdown+1.0)):0.0;
1372 bool leftOK =
false;
1373 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1374 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1376 bool rightOK =
false;
1377 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1378 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1381 if ((leftOK) && (rightOK)){
1383 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1384 if (denBK->
gIrrep(l_alpha) == Irrep){
1389 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
1390 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1392 if ((dimLdown>0) && (dimRdown>0)){
1394 int size = dimRup * dimRdown;
1395 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1397 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1398 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1399 double prefac = factor1 * Prob->
gMxElement(l_alpha,theindex+1,theindex,l_beta)
1400 + factor2 * Prob->
gMxElement(l_alpha,theindex+1,l_beta,theindex);
1401 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1402 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1408 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 1, 0, 1, NR-1, TwoSRdown, IRdown);
1410 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
1413 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
1414 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1426 #ifdef CHEMPS2_MPI_COMPILATION 1427 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5E2 ) == MPIRANK ) && (N1==0) && (N2==2)){
1429 if ((N1==0) && (N2==2)){
1432 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1433 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1434 for (
int TwoJdown=0; TwoJdown<=2; TwoJdown+=2){
1435 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1437 int fase =
phase(TwoSR + TwoSLdown + 3);
1438 const double factor1 = fase * sqrt((TwoSR+1)*(TwoJdown+1.0)) *
Wigner::wigner6j( 1, 1, TwoJdown, TwoSLdown, TwoSRdown, TwoSR );
1439 const double factor2 = (TwoJdown==0)?sqrt(2.0*(TwoSR+1.0)/(TwoSRdown+1.0)):0.0;
1445 bool leftOK =
false;
1446 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1447 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1449 bool rightOK =
false;
1450 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1451 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1454 if ((leftOK) && (rightOK)){
1456 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1457 if (denBK->
gIrrep(l_alpha) == Irrep){
1462 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
1463 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1465 if ((dimLdown>0) && (dimRdown>0)){
1467 int size = dimRup * dimRdown;
1468 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1470 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1471 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1472 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex+1, theindex, l_beta)
1473 + factor2 * Prob->
gMxElement(l_alpha, theindex+1, l_beta, theindex);
1474 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1475 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1481 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 1, 1, TwoJdown, NR-1, TwoSRdown, IRdown);
1483 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
1486 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
1487 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1500 #ifdef CHEMPS2_MPI_COMPILATION 1501 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5E3 ) == MPIRANK ) && (N1==1) && (N2==1)){
1503 if ((N1==1) && (N2==1)){
1506 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1507 if ((TwoSLdown>=0) && (abs(TwoSR-TwoSLdown)<=1)){
1508 int TwoSRdown = TwoSLdown;
1510 int fase =
phase(TwoSR + TwoSRdown + 3);
1511 double factor1 = fase * sqrt((TwoSL+1.0)*(TwoJ+1.0)*(TwoSR+1.0)/(TwoSRdown+1.0)) *
Wigner::wigner6j( 1, 1, TwoJ, TwoSL, TwoSR, TwoSRdown );
1512 double factor2 = (TwoJ==0)?sqrt(2.0*(TwoSR+1.0)/(TwoSRdown+1.0)):0.0;
1518 bool leftOK =
false;
1519 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1520 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1522 bool rightOK =
false;
1523 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1524 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1527 if ((leftOK) && (rightOK)){
1529 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1530 if (denBK->
gIrrep(l_alpha) == Irrep){
1535 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
1536 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1538 if ((dimLdown>0) && (dimRdown>0)){
1540 int size = dimRup * dimRdown;
1541 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1543 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1544 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1545 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex+1, theindex, l_beta)
1546 + factor2 * Prob->
gMxElement(l_alpha, theindex+1, l_beta, theindex);
1547 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1548 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1554 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 2, 0, 0, NR-1, TwoSRdown, IRdown);
1556 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
1559 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
1560 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1571 #ifdef CHEMPS2_MPI_COMPILATION 1572 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5E4 ) == MPIRANK ) && (N1==1) && (N2==2)){
1574 if ((N1==1) && (N2==2)){
1577 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1578 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1579 if ((abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1581 const double factor1 = (TwoSLdown==TwoSR) ?
phase(TwoSL-TwoSRdown) * sqrt((TwoSL+1.0)/(TwoSLdown+1.0)) : 0.0;
1582 const double factor2 =
phase(TwoSL+TwoSRdown+2) * sqrt((TwoSL+1)*(TwoSR+1.0)) *
Wigner::wigner6j( TwoSLdown, TwoSRdown, 1, TwoSR, TwoSL, 1 );
1588 bool leftOK =
false;
1589 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1590 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1592 bool rightOK =
false;
1593 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1594 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1597 if ((leftOK) && (rightOK)){
1599 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1600 if (denBK->
gIrrep(l_alpha) == Irrep){
1605 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
1606 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1608 if ((dimLdown>0) && (dimRdown>0)){
1610 int size = dimRup * dimRdown;
1611 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1613 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1614 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1615 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex+1, theindex, l_beta)
1616 + factor2 * Prob->
gMxElement(l_alpha, theindex+1, l_beta, theindex);
1617 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1618 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1624 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, 2, 1, 1, NR-1, TwoSRdown, IRdown);
1626 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
1629 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
1630 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1643 void CheMPS2::Heff::addDiagram5F(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorL ** Lright,
double * temp,
double * temp2)
const{
1645 #ifdef CHEMPS2_MPI_COMPILATION 1649 int NL = denS->gNL(ikappa);
1650 int TwoSL = denS->gTwoSL(ikappa);
1651 int IL = denS->gIL(ikappa);
1653 int NR = denS->gNR(ikappa);
1654 int TwoSR = denS->gTwoSR(ikappa);
1655 int IR = denS->gIR(ikappa);
1657 int N1 = denS->gN1(ikappa);
1658 int N2 = denS->gN2(ikappa);
1659 int TwoJ = denS->gTwoJ(ikappa);
1661 int theindex = denS->gIndex();
1662 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
1663 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1672 #ifdef CHEMPS2_MPI_COMPILATION 1673 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5F1 ) == MPIRANK ) && (N1==1) && (N2==0)){
1675 if ((N1==1) && (N2==0)){
1678 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1679 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1680 if ((abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1682 const double factor2 =
phase(TwoSLdown+TwoSR) * sqrt((TwoSLdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j( TwoSL, TwoSR, 1, TwoSRdown, TwoSLdown, 1 );
1683 const double factor1 = (TwoSLdown==TwoSR)?sqrt((TwoSRdown+1.0)/(TwoSR+1.0)):0.0;
1689 bool leftOK =
false;
1690 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1691 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1693 bool rightOK =
false;
1694 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1695 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1698 if ((leftOK) && (rightOK)){
1700 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1701 if (denBK->
gIrrep(l_alpha) == Irrep){
1706 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
1707 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1709 if ((dimLdown>0) && (dimRdown>0)){
1711 int size = dimRup * dimRdown;
1712 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1714 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1715 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1716 double prefac = factor1 * Prob->
gMxElement(l_alpha,theindex+1,theindex,l_beta)
1717 + factor2 * Prob->
gMxElement(l_alpha,theindex+1,l_beta,theindex);
1718 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1719 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1725 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 0, 1, 1, NR+1, TwoSRdown, IRdown);
1727 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
1730 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
1731 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1743 #ifdef CHEMPS2_MPI_COMPILATION 1744 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5F2 ) == MPIRANK ) && (N1==1) && (N2==1)){
1746 if ((N1==1) && (N2==1)){
1749 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1750 if ((TwoSLdown>=0) && (abs(TwoSR-TwoSLdown)<=1)){
1751 int TwoSRdown = TwoSLdown;
1753 const double factor1 =
phase(TwoSRdown + TwoSL + 3) * sqrt((TwoSRdown+1)*(TwoJ+1.0)) *
Wigner::wigner6j( 1, 1, TwoJ, TwoSL, TwoSR, TwoSRdown );
1754 const double factor2 = (TwoJ==0)?sqrt(2.0*(TwoSRdown+1.0)/(TwoSR+1.0)):0.0;
1760 bool leftOK =
false;
1761 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1762 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1764 bool rightOK =
false;
1765 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1766 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1769 if ((leftOK) && (rightOK)){
1771 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1772 if (denBK->
gIrrep(l_alpha) == Irrep){
1777 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
1778 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1780 if ((dimLdown>0) && (dimRdown>0)){
1782 int size = dimRup * dimRdown;
1783 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1785 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1786 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1787 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex+1, theindex, l_beta)
1788 + factor2 * Prob->
gMxElement(l_alpha, theindex+1, l_beta, theindex);
1789 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1790 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1796 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 0, 2, 0, NR+1, TwoSRdown, IRdown);
1798 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
1801 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
1802 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1813 #ifdef CHEMPS2_MPI_COMPILATION 1814 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5F3 ) == MPIRANK ) && (N1==2) && (N2==0)){
1816 if ((N1==2) && (N2==0)){
1819 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1820 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1821 for (
int TwoJdown=0; TwoJdown<=2; TwoJdown+=2){
1822 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1824 double factor1 =
phase(TwoSR + TwoSRdown + 3) * sqrt((TwoSLdown+1.0)*(TwoJdown+1.0)*(TwoSRdown+1.0)/(TwoSR+1.0)) *
Wigner::wigner6j( 1, 1, TwoJdown, TwoSLdown, TwoSRdown, TwoSR );
1825 double factor2 = (TwoJdown==0)?sqrt(2.0*(TwoSRdown+1.0)/(TwoSR+1.0)):0.0;
1831 bool leftOK =
false;
1832 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1833 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1835 bool rightOK =
false;
1836 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1837 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1840 if ((leftOK) && (rightOK)){
1842 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1843 if (denBK->
gIrrep(l_alpha) == Irrep){
1848 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
1849 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1851 if ((dimLdown>0) && (dimRdown>0)){
1853 int size = dimRup * dimRdown;
1854 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1856 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1857 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1858 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex+1, theindex, l_beta)
1859 + factor2 * Prob->
gMxElement(l_alpha, theindex+1, l_beta, theindex);
1860 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1861 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1867 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 1, 1, TwoJdown, NR+1, TwoSRdown, IRdown);
1869 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
1872 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
1873 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1886 #ifdef CHEMPS2_MPI_COMPILATION 1887 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_5F4 ) == MPIRANK ) && (N1==2) && (N2==1)){
1889 if ((N1==2) && (N2==1)){
1892 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
1893 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1894 if ((abs(TwoSLdown-TwoSRdown)<=1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1896 const double factor1 = (TwoSL==TwoSRdown) ?
phase(TwoSLdown-TwoSR) * sqrt((TwoSLdown+1.0)/(TwoSL+1.0)) : 0.0;
1897 const double factor2 =
phase(TwoSLdown+TwoSR+2) * sqrt((TwoSLdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j( TwoSL, TwoSR, 1, TwoSRdown, TwoSLdown, 1 );
1903 bool leftOK =
false;
1904 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1905 if (denBK->
gIrrep(l_alpha) == Irrep){ leftOK =
true; }
1907 bool rightOK =
false;
1908 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1909 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){ rightOK =
true; }
1912 if ((leftOK) && (rightOK)){
1914 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
1915 if (denBK->
gIrrep(l_alpha) == Irrep){
1920 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
1921 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1923 if ((dimLdown>0) && (dimRdown>0)){
1925 int size = dimRup * dimRdown;
1926 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
1928 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
1929 if (denBK->
gIrrep(l_beta) == IrrepTimesMid){
1930 double prefac = factor1 * Prob->
gMxElement(l_alpha, theindex+1, theindex, l_beta)
1931 + factor2 * Prob->
gMxElement(l_alpha, theindex+1, l_beta, theindex);
1932 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1933 daxpy_(&size,&prefac,LblockR,&inc,temp,&inc);
1939 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, 1, 2, 1, NR+1, TwoSRdown, IRdown);
1941 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
1944 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
1945 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
static double wigner6j(const int two_ja, const int two_jb, const int two_jc, const int two_jd, const int two_je, const int two_jf)
Wigner-6j symbol (gsl api)
int gCurrentDim(const int boundary, const int N, const int TwoS, const int irrep) const
Get the current virtual dimensions.
static int mpi_rank()
Get the rank of this MPI process.
double gMxElement(const int alpha, const int beta, const int gamma, const int delta) const
Get a specific interaction matrix element.
static int directProd(const int Irrep1, const int Irrep2)
Get the direct product of the irreps with numbers Irrep1 and Irrep2: a bitwise XOR for psi4's convent...
int gL() const
Get the number of orbitals.
int getNumberOfIrreps() const
Get the total number of irreps.
static int phase(const int TwoTimesPower)
Phase function.
int gIrrep(const int orbital) const
Get an orbital irrep.