25 #include "MPIchemps2.h" 28 void CheMPS2::Heff::addDiagram2a1spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator **** Atensors, TensorS0 **** S0tensors,
double * workspace)
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 dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
48 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
50 const bool leftSum = ( theindex < Prob->
gL()*0.5 )?
true:
false;
54 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
55 for (
int l_beta=l_alpha; l_beta<theindex; l_beta++){
57 #ifdef CHEMPS2_MPI_COMPILATION 58 if ( MPIchemps2::owner_absigma( l_alpha, l_beta ) == MPIRANK )
61 int ILdown =
Irreps::directProd(IL,S0tensors[theindex-1][l_beta-l_alpha][theindex-1-l_beta]->get_irrep());
62 int IRdown =
Irreps::directProd(IR,Atensors[theindex+1][l_beta-l_alpha][theindex+1-l_beta]->get_irrep());
63 int memSkappa = denS->gKappa(NL-2,TwoSL,ILdown,N1,N2,TwoJ,NR-2,TwoSR,IRdown);
67 int dimLdown = denBK->
gCurrentDim(theindex ,NL-2,TwoSL,ILdown);
68 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSR,IRdown);
70 double * BlockS0 = S0tensors[theindex-1][l_beta-l_alpha][theindex-1-l_beta]->gStorage(NL-2,TwoSL,ILdown,NL,TwoSL,IL);
71 double * BlockA = Atensors[theindex+1][l_beta-l_alpha][theindex+1-l_beta]->gStorage(NR-2,TwoSR,IRdown,NR,TwoSR,IR);
78 dgemm_(&trans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,BlockS0,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
82 dgemm_(¬rans,¬rans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,BlockA,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
91 for (
int l_gamma=theindex+2; l_gamma<Prob->
gL(); l_gamma++){
92 for (
int l_delta=l_gamma; l_delta<Prob->
gL(); l_delta++){
94 #ifdef CHEMPS2_MPI_COMPILATION 95 if ( MPIchemps2::owner_absigma( l_gamma, l_delta ) == MPIRANK )
98 int ILdown =
Irreps::directProd(IL,Atensors[theindex-1][l_delta-l_gamma][l_gamma-theindex]->get_irrep());
99 int IRdown =
Irreps::directProd(IR,S0tensors[theindex+1][l_delta-l_gamma][l_gamma-theindex-2]->get_irrep());
100 int memSkappa = denS->gKappa(NL-2,TwoSL,ILdown,N1,N2,TwoJ,NR-2,TwoSR,IRdown);
104 int dimLdown = denBK->
gCurrentDim(theindex ,NL-2,TwoSL,ILdown);
105 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSR,IRdown);
107 double * BlockA = Atensors[theindex-1][l_delta-l_gamma][l_gamma-theindex]->gStorage(NL-2,TwoSL,ILdown,NL,TwoSL,IL);
108 double * BlockS0 = S0tensors[theindex+1][l_delta-l_gamma][l_gamma-theindex-2]->gStorage(NR-2,TwoSR,IRdown,NR,TwoSR,IR);
115 dgemm_(&trans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,BlockA,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
119 dgemm_(¬rans,¬rans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,BlockS0,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
129 void CheMPS2::Heff::addDiagram2a2spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator **** Atensors, TensorS0 **** S0tensors,
double * workspace)
const{
131 #ifdef CHEMPS2_MPI_COMPILATION 135 int NL = denS->gNL(ikappa);
136 int TwoSL = denS->gTwoSL(ikappa);
137 int IL = denS->gIL(ikappa);
139 int NR = denS->gNR(ikappa);
140 int TwoSR = denS->gTwoSR(ikappa);
141 int IR = denS->gIR(ikappa);
143 int N1 = denS->gN1(ikappa);
144 int N2 = denS->gN2(ikappa);
145 int TwoJ = denS->gTwoJ(ikappa);
147 int theindex = denS->gIndex();
148 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
149 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
151 const bool leftSum = ( theindex < Prob->
gL()*0.5 )?
true:
false;
155 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
156 for (
int l_beta=l_alpha; l_beta<theindex; l_beta++){
158 #ifdef CHEMPS2_MPI_COMPILATION 159 if ( MPIchemps2::owner_absigma( l_alpha, l_beta ) == MPIRANK )
162 int ILdown =
Irreps::directProd(IL,S0tensors[theindex-1][l_beta-l_alpha][theindex-1-l_beta]->get_irrep());
163 int IRdown =
Irreps::directProd(IR,Atensors[theindex+1][l_beta-l_alpha][theindex+1-l_beta]->get_irrep());
164 int memSkappa = denS->gKappa(NL+2,TwoSL,ILdown,N1,N2,TwoJ,NR+2,TwoSR,IRdown);
168 int dimLdown = denBK->
gCurrentDim(theindex ,NL+2,TwoSL,ILdown);
169 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSR,IRdown);
171 double * BlockS0 = S0tensors[theindex-1][l_beta-l_alpha][theindex-1-l_beta]->gStorage(NL,TwoSL,IL,NL+2,TwoSL,ILdown);
172 double * BlockA = Atensors[theindex+1][l_beta-l_alpha][theindex+1-l_beta]->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IRdown);
179 dgemm_(¬rans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,BlockS0,&dimL,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
183 dgemm_(¬rans,&trans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,BlockA,&dimR,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
192 for (
int l_gamma=theindex+2; l_gamma<Prob->
gL(); l_gamma++){
193 for (
int l_delta=l_gamma; l_delta<Prob->
gL(); l_delta++){
195 #ifdef CHEMPS2_MPI_COMPILATION 196 if ( MPIchemps2::owner_absigma( l_gamma, l_delta ) == MPIRANK )
199 int ILdown =
Irreps::directProd(IL,Atensors[theindex-1][l_delta-l_gamma][l_gamma-theindex]->get_irrep());
200 int IRdown =
Irreps::directProd(IR,S0tensors[theindex+1][l_delta-l_gamma][l_gamma-theindex-2]->get_irrep());
201 int memSkappa = denS->gKappa(NL+2,TwoSL,ILdown,N1,N2,TwoJ,NR+2,TwoSR,IRdown);
205 int dimLdown = denBK->
gCurrentDim(theindex ,NL+2,TwoSL,ILdown);
206 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSR,IRdown);
208 double * BlockA = Atensors[theindex-1][l_delta-l_gamma][l_gamma-theindex]->gStorage(NL,TwoSL,IL,NL+2,TwoSL,ILdown);
209 double * BlockS0 = S0tensors[theindex+1][l_delta-l_gamma][l_gamma-theindex-2]->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IRdown);
216 dgemm_(¬rans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,BlockA,&dimL,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
220 dgemm_(¬rans,&trans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,BlockS0,&dimR,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
230 void CheMPS2::Heff::addDiagram2a1spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator **** Btensors, TensorS1 **** S1tensors,
double * workspace)
const{
232 #ifdef CHEMPS2_MPI_COMPILATION 236 int NL = denS->gNL(ikappa);
237 int TwoSL = denS->gTwoSL(ikappa);
238 int IL = denS->gIL(ikappa);
240 int NR = denS->gNR(ikappa);
241 int TwoSR = denS->gTwoSR(ikappa);
242 int IR = denS->gIR(ikappa);
244 int N1 = denS->gN1(ikappa);
245 int N2 = denS->gN2(ikappa);
246 int TwoJ = denS->gTwoJ(ikappa);
248 int theindex = denS->gIndex();
249 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
250 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
252 const bool leftSum = ( theindex < Prob->
gL()*0.5 )?
true:
false;
256 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
257 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
259 if ((TwoSLdown>=0) && (TwoSRdown>=0) && (abs(TwoSLdown-TwoSRdown)<=TwoJ)){
261 int fase =
phase(TwoSRdown+TwoSL+TwoJ+2);
262 const double thefactor = fase * sqrt((TwoSR + 1)*(TwoSL + 1.0)) *
Wigner::wigner6j( TwoSLdown, TwoSRdown, TwoJ, TwoSR, TwoSL, 2 );
264 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
265 for (
int l_beta=l_alpha+1; l_beta<theindex; l_beta++){
267 #ifdef CHEMPS2_MPI_COMPILATION 268 if ( MPIchemps2::owner_absigma( l_alpha, l_beta ) == MPIRANK )
271 int ILdown =
Irreps::directProd(IL,S1tensors[theindex-1][l_beta-l_alpha][theindex-1-l_beta]->get_irrep());
272 int IRdown =
Irreps::directProd(IR,Btensors[theindex+1][l_beta-l_alpha][theindex+1-l_beta]->get_irrep());
273 int memSkappa = denS->gKappa(NL-2,TwoSLdown,ILdown,N1,N2,TwoJ,NR-2,TwoSRdown,IRdown);
277 int dimLdown = denBK->
gCurrentDim(theindex ,NL-2,TwoSLdown,ILdown);
278 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSRdown,IRdown);
280 double * BlockS1 = S1tensors[theindex-1][l_beta-l_alpha][theindex-1-l_beta]->gStorage(NL-2,TwoSLdown,ILdown,NL,TwoSL,IL);
281 double * BlockB = Btensors[theindex+1][l_beta-l_alpha][theindex+1-l_beta]->gStorage(NR-2,TwoSRdown,IRdown,NR,TwoSR,IR);
285 double alpha = thefactor;
288 dgemm_(&trans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,BlockS1,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
292 dgemm_(¬rans,¬rans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,BlockB,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
304 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
305 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
307 if ((TwoSLdown>=0) && (TwoSRdown>=0) && (abs(TwoSLdown-TwoSRdown)<=TwoJ)){
309 int fase =
phase(TwoSRdown+TwoSL+TwoJ+2);
310 const double thefactor = fase * sqrt((TwoSR + 1)*(TwoSL + 1.0)) *
Wigner::wigner6j(TwoSLdown,TwoSRdown,TwoJ,TwoSR,TwoSL,2);
312 for (
int l_gamma=theindex+2; l_gamma<Prob->
gL(); l_gamma++){
313 for (
int l_delta=l_gamma+1; l_delta<Prob->
gL(); l_delta++){
315 #ifdef CHEMPS2_MPI_COMPILATION 316 if ( MPIchemps2::owner_absigma( l_gamma, l_delta ) == MPIRANK )
319 int ILdown =
Irreps::directProd(IL,Btensors[theindex-1][l_delta-l_gamma][l_gamma-theindex]->get_irrep());
320 int IRdown =
Irreps::directProd(IR,S1tensors[theindex+1][l_delta-l_gamma][l_gamma-theindex-2]->get_irrep());
321 int memSkappa = denS->gKappa(NL-2,TwoSLdown,ILdown,N1,N2,TwoJ,NR-2,TwoSRdown,IRdown);
325 int dimLdown = denBK->
gCurrentDim(theindex ,NL-2,TwoSLdown,ILdown);
326 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSRdown,IRdown);
328 double * BlockB = Btensors[theindex-1][l_delta-l_gamma][l_gamma-theindex]->gStorage(NL-2,TwoSLdown,ILdown,NL,TwoSL,IL);
329 double * BlockS1 = S1tensors[theindex+1][l_delta-l_gamma][l_gamma-theindex-2]->gStorage(NR-2,TwoSRdown,IRdown,NR,TwoSR,IR);
333 double alpha = thefactor;
336 dgemm_(&trans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,BlockB,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
340 dgemm_(¬rans,¬rans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,BlockS1,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
353 void CheMPS2::Heff::addDiagram2a2spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator **** Btensors, TensorS1 **** S1tensors,
double * workspace)
const{
355 #ifdef CHEMPS2_MPI_COMPILATION 359 int NL = denS->gNL(ikappa);
360 int TwoSL = denS->gTwoSL(ikappa);
361 int IL = denS->gIL(ikappa);
363 int NR = denS->gNR(ikappa);
364 int TwoSR = denS->gTwoSR(ikappa);
365 int IR = denS->gIR(ikappa);
367 int N1 = denS->gN1(ikappa);
368 int N2 = denS->gN2(ikappa);
369 int TwoJ = denS->gTwoJ(ikappa);
371 int theindex = denS->gIndex();
372 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
373 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
375 const bool leftSum = ( theindex < Prob->
gL()*0.5 )?
true:
false;
379 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
380 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
382 if ((TwoSLdown>=0) && (TwoSRdown>=0) && (abs(TwoSLdown-TwoSRdown)<=TwoJ)){
384 int fase =
phase(TwoSLdown+TwoSR+TwoJ+2);
385 const double thefactor = fase * sqrt((TwoSRdown + 1)*(TwoSLdown + 1.0)) *
Wigner::wigner6j(TwoSLdown,TwoSRdown,TwoJ,TwoSR,TwoSL,2);
387 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
388 for (
int l_beta=l_alpha+1; l_beta<theindex; l_beta++){
390 #ifdef CHEMPS2_MPI_COMPILATION 391 if ( MPIchemps2::owner_absigma( l_alpha, l_beta ) == MPIRANK )
394 int ILdown =
Irreps::directProd(IL,S1tensors[theindex-1][l_beta-l_alpha][theindex-1-l_beta]->get_irrep());
395 int IRdown =
Irreps::directProd(IR,Btensors[theindex+1][l_beta-l_alpha][theindex+1-l_beta]->get_irrep());
396 int memSkappa = denS->gKappa(NL+2,TwoSLdown,ILdown,N1,N2,TwoJ,NR+2,TwoSRdown,IRdown);
400 int dimLdown = denBK->
gCurrentDim(theindex ,NL+2,TwoSLdown,ILdown);
401 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSRdown,IRdown);
403 double * BlockS1 = S1tensors[theindex-1][l_beta-l_alpha][theindex-1-l_beta]->gStorage(NL,TwoSL,IL,NL+2,TwoSLdown,ILdown);
404 double * BlockB = Btensors[ theindex+1][l_beta-l_alpha][theindex+1-l_beta]->gStorage(NR,TwoSR,IR,NR+2,TwoSRdown,IRdown);
408 double alpha = thefactor;
411 dgemm_(¬r,¬r,&dimL,&dimRdown,&dimLdown,&alpha,BlockS1,&dimL,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
415 dgemm_(¬r,&trans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,BlockB,&dimR,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
427 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
428 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
430 if ((TwoSLdown>=0) && (TwoSRdown>=0) && (abs(TwoSLdown-TwoSRdown)<=TwoJ)){
432 int fase =
phase(TwoSLdown+TwoSR+TwoJ+2);
433 const double thefactor = fase * sqrt((TwoSRdown + 1)*(TwoSLdown + 1.0)) *
Wigner::wigner6j(TwoSLdown,TwoSRdown,TwoJ,TwoSR,TwoSL,2);
435 for (
int l_gamma=theindex+2; l_gamma<Prob->
gL(); l_gamma++){
436 for (
int l_delta=l_gamma+1; l_delta<Prob->
gL(); l_delta++){
438 #ifdef CHEMPS2_MPI_COMPILATION 439 if ( MPIchemps2::owner_absigma( l_gamma, l_delta ) == MPIRANK )
442 int ILdown =
Irreps::directProd(IL,Btensors[theindex-1][l_delta-l_gamma][l_gamma-theindex]->get_irrep());
443 int IRdown =
Irreps::directProd(IR,S1tensors[theindex+1][l_delta-l_gamma][l_gamma-theindex-2]->get_irrep());
444 int memSkappa = denS->gKappa(NL+2,TwoSLdown,ILdown,N1,N2,TwoJ,NR+2,TwoSRdown,IRdown);
448 int dimLdown = denBK->
gCurrentDim(theindex ,NL+2,TwoSLdown,ILdown);
449 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSRdown,IRdown);
451 double * BlockB = Btensors[theindex-1][l_delta-l_gamma][l_gamma-theindex]->gStorage(NL,TwoSL,IL,NL+2,TwoSLdown,ILdown);
452 double * BlockS1 = S1tensors[theindex+1][l_delta-l_gamma][l_gamma-theindex-2]->gStorage(NR,TwoSR,IR,NR+2,TwoSRdown,IRdown);
456 double alpha = thefactor;
459 dgemm_(¬rans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,BlockB,&dimL,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
463 dgemm_(¬rans,&trans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,BlockS1,&dimR,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
476 void CheMPS2::Heff::addDiagram2a3spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator **** Ctensors, TensorF0 **** F0tensors,
double * workspace)
const{
478 #ifdef CHEMPS2_MPI_COMPILATION 482 int NL = denS->gNL(ikappa);
483 int TwoSL = denS->gTwoSL(ikappa);
484 int IL = denS->gIL(ikappa);
486 int NR = denS->gNR(ikappa);
487 int TwoSR = denS->gTwoSR(ikappa);
488 int IR = denS->gIR(ikappa);
490 int N1 = denS->gN1(ikappa);
491 int N2 = denS->gN2(ikappa);
492 int TwoJ = denS->gTwoJ(ikappa);
494 int theindex = denS->gIndex();
495 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
496 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
498 const bool leftSum = ( theindex < Prob->
gL()*0.5 )?
true:
false;
502 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
503 for (
int l_alpha=l_gamma+1; l_alpha<theindex; l_alpha++){
505 #ifdef CHEMPS2_MPI_COMPILATION 506 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_gamma, l_alpha ) == MPIRANK )
509 int ILdown =
Irreps::directProd(IL,F0tensors[theindex-1][l_alpha-l_gamma][theindex-1-l_alpha]->get_irrep());
510 int IRdown =
Irreps::directProd(IR,Ctensors[theindex+1][l_alpha-l_gamma][theindex+1-l_alpha]->get_irrep());
511 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,N1,N2,TwoJ,NR,TwoSR,IRdown);
515 int dimLdown = denBK->
gCurrentDim(theindex ,NL,TwoSL,ILdown);
516 int dimRdown = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IRdown);
519 double * ptr = Ctensors[theindex+1][l_alpha-l_gamma][theindex+1-l_alpha]->gStorage(NR,TwoSR,IR,NR,TwoSR,IRdown);
520 double * BlockF0 = F0tensors[theindex-1][l_alpha-l_gamma][theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL,TwoSL,ILdown);
527 dgemm_(¬rans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,BlockF0,&dimL,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
531 dgemm_(¬rans,&trans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,ptr,&dimR,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
538 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
539 for (
int l_gamma=l_alpha; l_gamma<theindex; l_gamma++){
541 #ifdef CHEMPS2_MPI_COMPILATION 542 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_alpha, l_gamma ) == MPIRANK )
545 int ILdown =
Irreps::directProd(IL,F0tensors[theindex-1][l_gamma-l_alpha][theindex-1-l_gamma]->get_irrep());
546 int IRdown =
Irreps::directProd(IR,Ctensors[theindex+1][l_gamma-l_alpha][theindex+1-l_gamma]->get_irrep());
547 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,N1,N2,TwoJ,NR,TwoSR,IRdown);
551 int dimLdown = denBK->
gCurrentDim(theindex ,NL,TwoSL,ILdown);
552 int dimRdown = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IRdown);
555 double * ptr = Ctensors[theindex+1][l_gamma-l_alpha][theindex+1-l_gamma]->gStorage(NR,TwoSR,IRdown,NR,TwoSR,IR);
556 double * BlockF0 = F0tensors[theindex-1][l_gamma-l_alpha][theindex-1-l_gamma]->gStorage(NL,TwoSL,ILdown,NL,TwoSL,IL);
563 dgemm_(&trans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,BlockF0,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
567 dgemm_(¬rans,¬rans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,ptr,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
576 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
577 for (
int l_beta=l_delta+1; l_beta<Prob->
gL(); l_beta++){
579 #ifdef CHEMPS2_MPI_COMPILATION 580 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_delta, l_beta ) == MPIRANK )
583 int ILdown =
Irreps::directProd(IL,Ctensors[theindex-1][l_beta-l_delta][l_delta-theindex]->get_irrep());
584 int IRdown =
Irreps::directProd(IR,F0tensors[theindex+1][l_beta-l_delta][l_delta-theindex-2]->get_irrep());
585 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,N1,N2,TwoJ,NR,TwoSR,IRdown);
589 int dimLdown = denBK->
gCurrentDim(theindex ,NL,TwoSL,ILdown);
590 int dimRdown = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IRdown);
593 double * ptr = Ctensors[theindex-1][l_beta-l_delta][l_delta-theindex]->gStorage(NL,TwoSL,IL,NL,TwoSL,ILdown);
594 double * BlockF0 = F0tensors[theindex+1][l_beta-l_delta][l_delta-theindex-2]->gStorage(NR,TwoSR,IR,NR,TwoSR,IRdown);
601 dgemm_(¬rans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,ptr,&dimL,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
605 dgemm_(¬rans,&trans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,BlockF0,&dimR,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
612 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
613 for (
int l_delta=l_beta; l_delta<Prob->
gL(); l_delta++){
615 #ifdef CHEMPS2_MPI_COMPILATION 616 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_beta, l_delta ) == MPIRANK )
619 int ILdown =
Irreps::directProd(IL,Ctensors[theindex-1][l_delta-l_beta][l_beta-theindex]->get_irrep());
620 int IRdown =
Irreps::directProd(IR,F0tensors[theindex+1][l_delta-l_beta][l_beta-theindex-2]->get_irrep());
621 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,N1,N2,TwoJ,NR,TwoSR,IRdown);
625 int dimLdown = denBK->
gCurrentDim(theindex ,NL,TwoSL,ILdown);
626 int dimRdown = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IRdown);
629 double * ptr = Ctensors[theindex-1][l_delta-l_beta][l_beta-theindex]->gStorage(NL,TwoSL,ILdown,NL,TwoSL,IL);
630 double * BlockF0 = F0tensors[theindex+1][l_delta-l_beta][l_beta-theindex-2]->gStorage(NR,TwoSR,IRdown,NR,TwoSR,IR);
637 dgemm_(&trans,¬rans,&dimL,&dimRdown,&dimLdown,&alpha,ptr,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
641 dgemm_(¬rans,¬rans,&dimL,&dimR,&dimRdown,&alpha,workspace,&dimL,BlockF0,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
651 void CheMPS2::Heff::addDiagram2a3spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator **** Dtensors, TensorF1 **** F1tensors,
double * workspace)
const{
653 #ifdef CHEMPS2_MPI_COMPILATION 657 int NL = denS->gNL(ikappa);
658 int TwoSL = denS->gTwoSL(ikappa);
659 int IL = denS->gIL(ikappa);
661 int NR = denS->gNR(ikappa);
662 int TwoSR = denS->gTwoSR(ikappa);
663 int IR = denS->gIR(ikappa);
665 int N1 = denS->gN1(ikappa);
666 int N2 = denS->gN2(ikappa);
667 int TwoJ = denS->gTwoJ(ikappa);
669 int theindex = denS->gIndex();
670 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
671 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
673 const bool leftSum = ( theindex < Prob->
gL()*0.5 )?
true:
false;
677 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
678 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
680 if ((TwoSLdown>=0) && (TwoSRdown>=0) && (abs(TwoSLdown-TwoSRdown)<=TwoJ)){
682 int fase =
phase(TwoSLdown+TwoSRdown+TwoJ+2);
683 double prefactor = fase * sqrt((TwoSR + 1)*(TwoSLdown + 1.0)) *
Wigner::wigner6j(TwoSLdown,TwoSRdown,TwoJ,TwoSR,TwoSL,2);
685 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
686 for (
int l_alpha=l_gamma+1; l_alpha<theindex; l_alpha++){
688 #ifdef CHEMPS2_MPI_COMPILATION 689 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_gamma, l_alpha ) == MPIRANK )
692 int ILdown =
Irreps::directProd(IL,F1tensors[theindex-1][l_alpha-l_gamma][theindex-1-l_alpha]->get_irrep());
693 int IRdown =
Irreps::directProd(IR,Dtensors[theindex+1][l_alpha-l_gamma][theindex+1-l_alpha]->get_irrep());
694 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,N1,N2,TwoJ,NR,TwoSRdown,IRdown);
698 int dimLdown = denBK->
gCurrentDim(theindex ,NL,TwoSLdown,ILdown);
699 int dimRdown = denBK->
gCurrentDim(theindex+2,NR,TwoSRdown,IRdown);
702 double * ptr = Dtensors[theindex+1][l_alpha-l_gamma][theindex+1-l_alpha]->gStorage(NR,TwoSR,IR,NR,TwoSRdown,IRdown);
703 double * BlockF1 = F1tensors[theindex-1][l_alpha-l_gamma][theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL,TwoSLdown,ILdown);
709 dgemm_(¬r,¬r,&dimL,&dimRdown,&dimLdown,&prefactor,BlockF1,&dimL,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
713 dgemm_(¬r,&trans,&dimL,&dimR,&dimRdown,&beta,workspace,&dimL,ptr,&dimR,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
720 fase =
phase(TwoSL+TwoSR+TwoJ+2);
721 prefactor = fase * sqrt((TwoSRdown + 1)*(TwoSL + 1.0)) *
Wigner::wigner6j(TwoSLdown,TwoSRdown,TwoJ,TwoSR,TwoSL,2);
723 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
724 for (
int l_gamma=l_alpha; l_gamma<theindex; l_gamma++){
726 #ifdef CHEMPS2_MPI_COMPILATION 727 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_alpha, l_gamma ) == MPIRANK )
730 int ILdown =
Irreps::directProd(IL,F1tensors[theindex-1][l_gamma-l_alpha][theindex-1-l_gamma]->get_irrep());
731 int IRdown =
Irreps::directProd(IR,Dtensors[theindex+1][l_gamma-l_alpha][theindex+1-l_gamma]->get_irrep());
732 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,N1,N2,TwoJ,NR,TwoSRdown,IRdown);
736 int dimLdown = denBK->
gCurrentDim(theindex ,NL,TwoSLdown,ILdown);
737 int dimRdown = denBK->
gCurrentDim(theindex+2,NR,TwoSRdown,IRdown);
740 double * ptr = Dtensors[theindex+1][l_gamma-l_alpha][theindex+1-l_gamma]->gStorage(NR,TwoSRdown,IRdown,NR,TwoSR,IR);
741 double * BlockF1 = F1tensors[theindex-1][l_gamma-l_alpha][theindex-1-l_gamma]->gStorage(NL,TwoSLdown,ILdown,NL,TwoSL,IL);
747 dgemm_(&trans,¬r,&dimL,&dimRdown,&dimLdown,&prefactor,BlockF1,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
751 dgemm_(¬r,¬r,&dimL,&dimR,&dimRdown,&beta,workspace,&dimL,ptr,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
763 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
764 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
766 if ((TwoSLdown>=0) && (TwoSRdown>=0) && (abs(TwoSLdown-TwoSRdown)<=TwoJ)){
768 int fase =
phase(TwoSLdown+TwoSRdown+TwoJ+2);
769 double prefactor = fase * sqrt((TwoSR + 1)*(TwoSLdown + 1.0)) *
Wigner::wigner6j(TwoSLdown,TwoSRdown,TwoJ,TwoSR,TwoSL,2);
771 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
772 for (
int l_beta=l_delta+1; l_beta<Prob->
gL(); l_beta++){
774 #ifdef CHEMPS2_MPI_COMPILATION 775 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_delta, l_beta ) == MPIRANK )
778 int ILdown =
Irreps::directProd(IL,Dtensors[theindex-1][l_beta-l_delta][l_delta-theindex]->get_irrep());
779 int IRdown =
Irreps::directProd(IR,F1tensors[theindex+1][l_beta-l_delta][l_delta-theindex-2]->get_irrep());
780 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,N1,N2,TwoJ,NR,TwoSRdown,IRdown);
784 int dimLdown = denBK->
gCurrentDim(theindex ,NL,TwoSLdown,ILdown);
785 int dimRdown = denBK->
gCurrentDim(theindex+2,NR,TwoSRdown,IRdown);
788 double * ptr = Dtensors[theindex-1][l_beta-l_delta][l_delta-theindex]->gStorage(NL,TwoSL,IL,NL,TwoSLdown,ILdown);
789 double * BlockF1 = F1tensors[theindex+1][l_beta-l_delta][l_delta-theindex-2]->gStorage(NR,TwoSR,IR,NR,TwoSRdown,IRdown);
795 dgemm_(¬r,¬r,&dimL,&dimRdown,&dimLdown,&prefactor,ptr,&dimL,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
799 dgemm_(¬r,&trans,&dimL,&dimR,&dimRdown,&beta,workspace,&dimL,BlockF1,&dimR,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
806 fase =
phase(TwoSL+TwoSR+TwoJ+2);
807 prefactor = fase * sqrt((TwoSRdown + 1)*(TwoSL + 1.0)) *
Wigner::wigner6j(TwoSLdown,TwoSRdown,TwoJ,TwoSR,TwoSL,2);
809 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
810 for (
int l_delta=l_beta; l_delta<Prob->
gL(); l_delta++){
812 #ifdef CHEMPS2_MPI_COMPILATION 813 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_beta, l_delta ) == MPIRANK )
816 int ILdown =
Irreps::directProd(IL,Dtensors[theindex-1][l_delta-l_beta][l_beta-theindex]->get_irrep());
817 int IRdown =
Irreps::directProd(IR,F1tensors[theindex+1][l_delta-l_beta][l_beta-theindex-2]->get_irrep());
818 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,N1,N2,TwoJ,NR,TwoSRdown,IRdown);
822 int dimLdown = denBK->
gCurrentDim(theindex ,NL,TwoSLdown,ILdown);
823 int dimRdown = denBK->
gCurrentDim(theindex+2,NR,TwoSRdown,IRdown);
826 double * ptr = Dtensors[theindex-1][l_delta-l_beta][l_beta-theindex]->gStorage(NL,TwoSLdown,ILdown,NL,TwoSL,IL);
827 double * BlockF1 = F1tensors[theindex+1][l_delta-l_beta][l_beta-theindex-2]->gStorage(NR,TwoSRdown,IRdown,NR,TwoSR,IR);
833 dgemm_(&trans,¬r,&dimL,&dimRdown,&dimLdown,&prefactor,ptr,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,workspace,&dimL);
837 dgemm_(¬r,¬r,&dimL,&dimR,&dimRdown,&beta,workspace,&dimL,BlockF1,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
850 void CheMPS2::Heff::addDiagram2b1and2b2(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Atensor)
const{
852 int N1 = denS->gN1(ikappa);
856 int theindex = denS->gIndex();
857 int NL = denS->gNL(ikappa);
858 int TwoSL = denS->gTwoSL(ikappa);
859 int IL = denS->gIL(ikappa);
861 int dimLdown = denBK->
gCurrentDim(theindex,NL-2,TwoSL,IL);
865 int NR = denS->gNR(ikappa);
866 int TwoSR = denS->gTwoSR(ikappa);
867 int IR = denS->gIR(ikappa);
869 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
870 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
872 int memSkappa = denS->gKappa(NL-2,TwoSL,IL,2, denS->gN2(ikappa), denS->gTwoJ(ikappa), NR,TwoSR,IR);
876 double * BlockA = Atensor->gStorage(NL-2,TwoSL,IL,NL,TwoSL,IL);
879 double alpha = sqrt(2.0);
882 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&alpha,BlockA,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
890 int theindex = denS->gIndex();
891 int NL = denS->gNL(ikappa);
892 int TwoSL = denS->gTwoSL(ikappa);
893 int IL = denS->gIL(ikappa);
895 int dimLdown = denBK->
gCurrentDim(theindex,NL+2,TwoSL,IL);
899 int NR = denS->gNR(ikappa);
900 int TwoSR = denS->gTwoSR(ikappa);
901 int IR = denS->gIR(ikappa);
903 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
904 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
906 int memSkappa = denS->gKappa(NL+2,TwoSL,IL,0, denS->gN2(ikappa), denS->gTwoJ(ikappa), NR,TwoSR,IR);
910 double * BlockA = Atensor->gStorage(NL,TwoSL,IL,NL+2,TwoSL,IL);
912 double alpha = sqrt(2.0);
915 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&alpha,BlockA,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
923 void CheMPS2::Heff::addDiagram2c1and2c2(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Atensor)
const{
925 int N2 = denS->gN2(ikappa);
929 int theindex = denS->gIndex();
930 int NL = denS->gNL(ikappa);
931 int TwoSL = denS->gTwoSL(ikappa);
932 int IL = denS->gIL(ikappa);
934 int dimLdown = denBK->
gCurrentDim(theindex,NL-2,TwoSL,IL);
938 int NR = denS->gNR(ikappa);
939 int TwoSR = denS->gTwoSR(ikappa);
940 int IR = denS->gIR(ikappa);
942 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
943 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
945 int memSkappa = denS->gKappa(NL-2,TwoSL,IL, denS->gN1(ikappa), 2, denS->gTwoJ(ikappa), NR,TwoSR,IR);
949 double * BlockA = Atensor->gStorage(NL-2,TwoSL,IL,NL,TwoSL,IL);
952 double alpha = sqrt(2.0);
955 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&alpha,BlockA,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
963 int theindex = denS->gIndex();
964 int NL = denS->gNL(ikappa);
965 int TwoSL = denS->gTwoSL(ikappa);
966 int IL = denS->gIL(ikappa);
968 int dimLdown = denBK->
gCurrentDim(theindex,NL+2,TwoSL,IL);
972 int NR = denS->gNR(ikappa);
973 int TwoSR = denS->gTwoSR(ikappa);
974 int IR = denS->gIR(ikappa);
976 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
977 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
979 int memSkappa = denS->gKappa(NL+2,TwoSL,IL, denS->gN1(ikappa), 0, denS->gTwoJ(ikappa), NR,TwoSR,IR);
983 double * BlockA = Atensor->gStorage(NL,TwoSL,IL,NL+2,TwoSL,IL);
985 double alpha = sqrt(2.0);
988 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&alpha,BlockA,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
996 void CheMPS2::Heff::addDiagram2dall(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS)
const{
998 const int N1 = denS->gN1(ikappa);
999 const int N2 = denS->gN2(ikappa);
1000 const int theindex = denS->gIndex();
1001 int size = denBK->
gCurrentDim(theindex, denS->gNL(ikappa),denS->gTwoSL(ikappa),denS->gIL(ikappa))
1002 * denBK->
gCurrentDim(theindex+2,denS->gNR(ikappa),denS->gTwoSR(ikappa),denS->gIR(ikappa));
1005 if ((N1==2) && (N2==0)){
1007 int memSkappa = denS->gKappa(denS->gNL(ikappa),denS->gTwoSL(ikappa),denS->gIL(ikappa), 0, 2, 0, denS->gNR(ikappa),denS->gTwoSR(ikappa),denS->gIR(ikappa));
1010 double factor = Prob->
gMxElement(theindex, theindex, theindex+1, theindex+1);
1011 daxpy_(&size,&factor,memS+denS->gKappa2index(memSkappa),&inc,memHeff+denS->gKappa2index(ikappa),&inc);
1015 if ((N1==0) && (N2==2)){
1017 int memSkappa = denS->gKappa(denS->gNL(ikappa),denS->gTwoSL(ikappa),denS->gIL(ikappa), 2, 0, 0, denS->gNR(ikappa),denS->gTwoSR(ikappa),denS->gIR(ikappa));
1020 double factor = Prob->
gMxElement(theindex, theindex, theindex+1, theindex+1);
1021 daxpy_(&size,&factor,memS+denS->gKappa2index(memSkappa),&inc,memHeff+denS->gKappa2index(ikappa),&inc);
1025 if ((N1==2) && (N2==2)){
1027 double factor = 4 * Prob->
gMxElement(theindex, theindex+1, theindex, theindex+1)
1028 - 2 * Prob->
gMxElement(theindex, theindex+1, theindex+1, theindex);
1029 daxpy_(&size,&factor,memS+denS->gKappa2index(ikappa),&inc,memHeff+denS->gKappa2index(ikappa),&inc);
1033 if ((N1==1) && (N2==1)){
1035 int fase = (denS->gTwoJ(ikappa) == 0)? 1: -1;
1036 double factor = Prob->
gMxElement(theindex, theindex+1, theindex, theindex+1)
1037 + fase * Prob->
gMxElement(theindex, theindex+1, theindex+1, theindex);
1038 daxpy_(&size,&factor,memS+denS->gKappa2index(ikappa),&inc,memHeff+denS->gKappa2index(ikappa),&inc);
1042 if ((N1==2) && (N2==1)){
1044 double factor = 2 * Prob->
gMxElement(theindex, theindex+1, theindex, theindex+1)
1045 - Prob->
gMxElement(theindex, theindex+1, theindex+1, theindex);
1046 daxpy_(&size,&factor,memS+denS->gKappa2index(ikappa),&inc,memHeff+denS->gKappa2index(ikappa),&inc);
1050 if ((N1==1) && (N2==2)){
1052 double factor = 2 * Prob->
gMxElement(theindex, theindex+1, theindex, theindex+1)
1053 - Prob->
gMxElement(theindex, theindex+1, theindex+1, theindex);
1054 daxpy_(&size,&factor,memS+denS->gKappa2index(ikappa),&inc,memHeff+denS->gKappa2index(ikappa),&inc);
1060 void CheMPS2::Heff::addDiagram2e1and2e2(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Atensor)
const{
1062 int N1 = denS->gN1(ikappa);
1066 int theindex = denS->gIndex();
1067 int NL = denS->gNL(ikappa);
1068 int TwoSL = denS->gTwoSL(ikappa);
1069 int IL = denS->gIL(ikappa);
1070 int NR = denS->gNR(ikappa);
1071 int TwoSR = denS->gTwoSR(ikappa);
1072 int IR = denS->gIR(ikappa);
1074 int dimL = denBK->
gCurrentDim(theindex, NL, TwoSL,IL);
1075 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSR,IR);
1076 int dimRup = denBK->
gCurrentDim(theindex+2,NR, TwoSR,IR);
1078 int memSkappa = denS->gKappa(NL,TwoSL,IL, 0, denS->gN2(ikappa), denS->gTwoJ(ikappa), NR-2,TwoSR,IR);
1082 double * BlockA = Atensor->gStorage(NR-2,TwoSR,IR,NR,TwoSR,IR);
1084 double alpha = sqrt(2.0);
1087 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,BlockA,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
1094 int theindex = denS->gIndex();
1095 int NL = denS->gNL(ikappa);
1096 int TwoSL = denS->gTwoSL(ikappa);
1097 int IL = denS->gIL(ikappa);
1098 int NR = denS->gNR(ikappa);
1099 int TwoSR = denS->gTwoSR(ikappa);
1100 int IR = denS->gIR(ikappa);
1102 int dimL = denBK->
gCurrentDim(theindex, NL, TwoSL,IL);
1103 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSR,IR);
1104 int dimRup = denBK->
gCurrentDim(theindex+2,NR, TwoSR,IR);
1106 int memSkappa = denS->gKappa(NL,TwoSL,IL, 2, denS->gN2(ikappa), denS->gTwoJ(ikappa), NR+2,TwoSR,IR);
1110 double * BlockA = Atensor->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IR);
1113 double alpha = sqrt(2.0);
1116 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,BlockA,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
1123 void CheMPS2::Heff::addDiagram2f1and2f2(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Atensor)
const{
1125 int N2 = denS->gN2(ikappa);
1129 int theindex = denS->gIndex();
1130 int NL = denS->gNL(ikappa);
1131 int TwoSL = denS->gTwoSL(ikappa);
1132 int IL = denS->gIL(ikappa);
1133 int NR = denS->gNR(ikappa);
1134 int TwoSR = denS->gTwoSR(ikappa);
1135 int IR = denS->gIR(ikappa);
1137 int dimL = denBK->
gCurrentDim(theindex, NL, TwoSL,IL);
1138 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSR,IR);
1139 int dimRup = denBK->
gCurrentDim(theindex+2,NR, TwoSR,IR);
1141 int memSkappa = denS->gKappa(NL,TwoSL,IL, denS->gN1(ikappa), 0, denS->gTwoJ(ikappa), NR-2,TwoSR,IR);
1145 double * BlockA = Atensor->gStorage(NR-2,TwoSR,IR,NR,TwoSR,IR);
1147 double alpha = sqrt(2.0);
1150 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,BlockA,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
1157 int theindex = denS->gIndex();
1158 int NL = denS->gNL(ikappa);
1159 int TwoSL = denS->gTwoSL(ikappa);
1160 int IL = denS->gIL(ikappa);
1161 int NR = denS->gNR(ikappa);
1162 int TwoSR = denS->gTwoSR(ikappa);
1163 int IR = denS->gIR(ikappa);
1165 int dimL = denBK->
gCurrentDim(theindex, NL, TwoSL,IL);
1166 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSR,IR);
1167 int dimRup = denBK->
gCurrentDim(theindex+2,NR, TwoSR,IR);
1169 int memSkappa = denS->gKappa(NL,TwoSL,IL, denS->gN1(ikappa), 2, denS->gTwoJ(ikappa), NR+2,TwoSR,IR);
1173 double * BlockA = Atensor->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IR);
1176 double alpha = sqrt(2.0);
1179 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,BlockA,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
1186 void CheMPS2::Heff::addDiagram2b3spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Ctensor)
const{
1188 int N1 = denS->gN1(ikappa);
1192 int theindex = denS->gIndex();
1194 int NL = denS->gNL(ikappa);
1195 int TwoSL = denS->gTwoSL(ikappa);
1196 int IL = denS->gIL(ikappa);
1198 int dimL = denBK->
gCurrentDim(theindex, NL, TwoSL, IL);
1199 int dimR = denBK->
gCurrentDim(theindex+2,denS->gNR(ikappa),denS->gTwoSR(ikappa),denS->gIR(ikappa));
1201 double * Cblock = Ctensor->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
1205 double alpha = ((N1==2)?1.0:0.5)*sqrt(2.0);
1208 dgemm_(&trans,¬rans,&dimL,&dimR,&dimL,&alpha,Cblock,&dimL,memS+denS->gKappa2index(ikappa),&dimL,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
1214 void CheMPS2::Heff::addDiagram2c3spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Ctensor)
const{
1216 int N2 = denS->gN2(ikappa);
1220 int theindex = denS->gIndex();
1222 int NL = denS->gNL(ikappa);
1223 int TwoSL = denS->gTwoSL(ikappa);
1224 int IL = denS->gIL(ikappa);
1226 int dimL = denBK->
gCurrentDim(theindex, NL, TwoSL, IL);
1227 int dimR = denBK->
gCurrentDim(theindex+2,denS->gNR(ikappa),denS->gTwoSR(ikappa),denS->gIR(ikappa));
1229 double * Cblock = Ctensor->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
1233 double alpha = ((N2==2)?1.0:0.5)*sqrt(2.0);
1236 dgemm_(&trans,¬rans,&dimL,&dimR,&dimL,&alpha,Cblock,&dimL,memS+denS->gKappa2index(ikappa),&dimL,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
1242 void CheMPS2::Heff::addDiagram2e3spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Ctensor)
const{
1244 int N1 = denS->gN1(ikappa);
1248 int theindex = denS->gIndex();
1250 int NR = denS->gNR(ikappa);
1251 int TwoSR = denS->gTwoSR(ikappa);
1252 int IR = denS->gIR(ikappa);
1254 int dimR = denBK->
gCurrentDim(theindex+2,NR, TwoSR, IR);
1255 int dimL = denBK->
gCurrentDim(theindex ,denS->gNL(ikappa),denS->gTwoSL(ikappa),denS->gIL(ikappa));
1257 double * Cblock = Ctensor->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
1260 double alpha = ((N1==2)?1.0:0.5)*sqrt(2.0);
1263 dgemm_(¬rans,¬rans,&dimL,&dimR,&dimR,&alpha,memS+denS->gKappa2index(ikappa),&dimL,Cblock,&dimR,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
1269 void CheMPS2::Heff::addDiagram2f3spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Ctensor)
const{
1271 int N2 = denS->gN2(ikappa);
1275 int theindex = denS->gIndex();
1277 int NR = denS->gNR(ikappa);
1278 int TwoSR = denS->gTwoSR(ikappa);
1279 int IR = denS->gIR(ikappa);
1281 int dimR = denBK->
gCurrentDim(theindex+2,NR, TwoSR, IR);
1282 int dimL = denBK->
gCurrentDim(theindex ,denS->gNL(ikappa),denS->gTwoSL(ikappa),denS->gIL(ikappa));
1284 double * Cblock = Ctensor->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
1287 double alpha = ((N2==2)?1.0:0.5)*sqrt(2.0);
1290 dgemm_(¬rans,¬rans,&dimL,&dimR,&dimR,&alpha,memS+denS->gKappa2index(ikappa),&dimL,Cblock,&dimR,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
1296 void CheMPS2::Heff::addDiagram2b3spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Dtensor)
const{
1298 int N1 = denS->gN1(ikappa);
1302 int theindex = denS->gIndex();
1304 int NL = denS->gNL(ikappa);
1305 int TwoSL = denS->gTwoSL(ikappa);
1306 int IL = denS->gIL(ikappa);
1307 int NR = denS->gNR(ikappa);
1308 int TwoSR = denS->gTwoSR(ikappa);
1309 int IR = denS->gIR(ikappa);
1310 int TwoJ = denS->gTwoJ(ikappa);
1311 int N2 = denS->gN2(ikappa);
1313 int dimLup = denBK->
gCurrentDim(theindex, NL,TwoSL,IL);
1314 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1316 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1318 int dimLdown = denBK->
gCurrentDim(theindex, NL, TwoSLdown, IL);
1322 double * Dblock = Dtensor->gStorage(NL,TwoSLdown,IL,NL,TwoSL,IL);
1324 int TwoS2 = (N2==1)?1:0;
1325 int TwoJstart = ((TwoSR!=TwoSLdown) || (TwoS2==0)) ? 1 + TwoS2 : 0;
1326 for (
int TwoJdown=TwoJstart; TwoJdown<=1+TwoS2; TwoJdown+=2){
1327 if (abs(TwoSLdown-TwoSR)<=TwoJdown){
1329 int memSkappa = denS->gKappa(NL, TwoSLdown, IL, N1, N2, TwoJdown, NR, TwoSR, IR);
1333 int fase =
phase(TwoSLdown + TwoSR + TwoJ + TwoS2 + TwoJdown - 1);
1334 double alpha = fase * sqrt(3.0*(TwoJ+1)*(TwoJdown+1)*(TwoSL+1)) *
Wigner::wigner6j(TwoJdown,TwoJ,2,1,1,TwoS2) *
Wigner::wigner6j(TwoJdown,TwoJ,2,TwoSL,TwoSLdown,TwoSR);
1339 dgemm_(&trans,¬ra,&dimLup,&dimR,&dimLdown,&alpha,Dblock,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1350 void CheMPS2::Heff::addDiagram2c3spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Dtensor)
const{
1352 int N2 = denS->gN2(ikappa);
1356 int theindex = denS->gIndex();
1358 int NL = denS->gNL(ikappa);
1359 int TwoSL = denS->gTwoSL(ikappa);
1360 int IL = denS->gIL(ikappa);
1361 int NR = denS->gNR(ikappa);
1362 int TwoSR = denS->gTwoSR(ikappa);
1363 int IR = denS->gIR(ikappa);
1364 int TwoJ = denS->gTwoJ(ikappa);
1365 int N1 = denS->gN1(ikappa);
1367 int dimLup = denBK->
gCurrentDim(theindex, NL,TwoSL,IL);
1368 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1370 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1372 int dimLdown = denBK->
gCurrentDim(theindex, NL, TwoSLdown, IL);
1376 double * Dblock = Dtensor->gStorage(NL,TwoSLdown,IL,NL,TwoSL,IL);
1378 int TwoS1 = (N1==1)?1:0;
1379 int TwoJstart = ((TwoSR!=TwoSLdown) || (TwoS1==0)) ? 1 + TwoS1 : 0;
1380 for (
int TwoJdown=TwoJstart; TwoJdown<=1+TwoS1; TwoJdown+=2){
1381 if (abs(TwoSLdown-TwoSR)<=TwoJdown){
1383 int memSkappa = denS->gKappa(NL, TwoSLdown, IL, N1, N2, TwoJdown, NR, TwoSR, IR);
1387 int fase =
phase(TwoSLdown + TwoSR + 2*TwoJ + TwoS1 - 1);
1388 double alpha = fase * sqrt(3.0*(TwoJ+1)*(TwoJdown+1)*(TwoSL+1)) *
Wigner::wigner6j(TwoJdown,TwoJ,2,1,1,TwoS1) *
Wigner::wigner6j(TwoJdown,TwoJ,2,TwoSL,TwoSLdown,TwoSR);
1393 dgemm_(&trans,¬ra,&dimLup,&dimR,&dimLdown,&alpha,Dblock,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1404 void CheMPS2::Heff::addDiagram2e3spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Dtensor)
const{
1406 int N1 = denS->gN1(ikappa);
1410 int theindex = denS->gIndex();
1412 int NL = denS->gNL(ikappa);
1413 int TwoSL = denS->gTwoSL(ikappa);
1414 int IL = denS->gIL(ikappa);
1415 int NR = denS->gNR(ikappa);
1416 int TwoSR = denS->gTwoSR(ikappa);
1417 int IR = denS->gIR(ikappa);
1418 int TwoJ = denS->gTwoJ(ikappa);
1419 int N2 = denS->gN2(ikappa);
1421 int dimL = denBK->
gCurrentDim(theindex, NL,TwoSL,IL);
1422 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1424 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
1426 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSRdown, IR);
1430 double * Dblock = Dtensor->gStorage(NR,TwoSRdown,IR,NR,TwoSR,IR);
1432 int TwoS2 = (N2==1)?1:0;
1433 int TwoJstart = ((TwoSRdown!=TwoSL) || (TwoS2==0)) ? 1 + TwoS2 : 0;
1434 for (
int TwoJdown=TwoJstart; TwoJdown<=1+TwoS2; TwoJdown+=2){
1435 if (abs(TwoSL-TwoSRdown)<=TwoJdown){
1437 int memSkappa = denS->gKappa(NL, TwoSL, IL, N1, N2, TwoJdown, NR, TwoSRdown, IR);
1441 int fase =
phase(TwoSRdown + TwoSL + 2*TwoJ + TwoS2 + 1);
1442 double alpha = fase * sqrt(3.0*(TwoJ+1)*(TwoJdown+1)*(TwoSRdown+1)) *
Wigner::wigner6j(TwoJdown,TwoJ,2,1,1,TwoS2) *
Wigner::wigner6j(TwoJdown,TwoJ,2,TwoSR,TwoSRdown,TwoSL);
1446 dgemm_(¬r,¬r,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Dblock,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
1457 void CheMPS2::Heff::addDiagram2f3spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Dtensor)
const{
1459 int N2 = denS->gN2(ikappa);
1463 int theindex = denS->gIndex();
1465 int NL = denS->gNL(ikappa);
1466 int TwoSL = denS->gTwoSL(ikappa);
1467 int IL = denS->gIL(ikappa);
1468 int NR = denS->gNR(ikappa);
1469 int TwoSR = denS->gTwoSR(ikappa);
1470 int IR = denS->gIR(ikappa);
1471 int TwoJ = denS->gTwoJ(ikappa);
1472 int N1 = denS->gN1(ikappa);
1474 int dimL = denBK->
gCurrentDim(theindex, NL,TwoSL,IL);
1475 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1477 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
1479 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSRdown, IR);
1483 double * Dblock = Dtensor->gStorage(NR,TwoSRdown,IR,NR,TwoSR,IR);
1485 int TwoS1 = (N1==1)?1:0;
1486 int TwoJstart = ((TwoSRdown!=TwoSL) || (TwoS1==0)) ? 1 + TwoS1 : 0;
1487 for (
int TwoJdown=TwoJstart; TwoJdown<=1+TwoS1; TwoJdown+=2){
1488 if (abs(TwoSL-TwoSRdown)<=TwoJdown){
1490 int memSkappa = denS->gKappa(NL, TwoSL, IL, N1, N2, TwoJdown, NR, TwoSRdown, IR);
1494 int fase =
phase(TwoSRdown + TwoSL + TwoJ + TwoS1 + TwoJdown + 1);
1495 double alpha = fase * sqrt(3.0*(TwoJ+1)*(TwoJdown+1)*(TwoSRdown+1)) *
Wigner::wigner6j(TwoJdown,TwoJ,2,1,1,TwoS1) *
Wigner::wigner6j(TwoJdown,TwoJ,2,TwoSR,TwoSRdown,TwoSL);
1499 dgemm_(¬r,¬r,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Dblock,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
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.
static int phase(const int TwoTimesPower)
Phase function.