25 #include "MPIchemps2.h" 28 void CheMPS2::Heff::addDiagram4A1and4A2spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Atens)
const{
30 int NL = denS->gNL(ikappa);
31 int TwoSL = denS->gTwoSL(ikappa);
32 int IL = denS->gIL(ikappa);
34 int NR = denS->gNR(ikappa);
35 int TwoSR = denS->gTwoSR(ikappa);
36 int IR = denS->gIR(ikappa);
38 int N1 = denS->gN1(ikappa);
39 int N2 = denS->gN2(ikappa);
40 int TwoJ = denS->gTwoJ(ikappa);
42 int theindex = denS->gIndex();
43 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
44 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
53 if ((N1==0) && (N2==0)){
55 int memSkappa = denS->gKappa(NL-2,TwoSL,ILdown,1,1,0,NR,TwoSR,IR);
59 double * Ablock = Atens->gStorage(NL-2,TwoSL,ILdown,NL,TwoSL,IL);
60 int dimLdown = denBK->
gCurrentDim(theindex,NL-2,TwoSL,ILdown);
62 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Ablock,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
68 if ((N1==1) && (N2==0)){
70 int memSkappa = denS->gKappa(NL-2,TwoSL,ILdown,2,1,1,NR,TwoSR,IR);
73 double factor = - sqrt(0.5);
74 double * Ablock = Atens->gStorage(NL-2,TwoSL,ILdown,NL,TwoSL,IL);
75 int dimLdown = denBK->
gCurrentDim(theindex,NL-2,TwoSL,ILdown);
77 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Ablock,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
83 if ((N1==0) && (N2==1)){
85 int memSkappa = denS->gKappa(NL-2,TwoSL,ILdown,1,2,1,NR,TwoSR,IR);
88 double factor = - sqrt(0.5);
89 double * Ablock = Atens->gStorage(NL-2,TwoSL,ILdown,NL,TwoSL,IL);
90 int dimLdown = denBK->
gCurrentDim(theindex,NL-2,TwoSL,ILdown);
92 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Ablock,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
98 if ((N1==1) && (N2==1) && (TwoJ==0)){
100 int memSkappa = denS->gKappa(NL-2,TwoSL,ILdown,2,2,0,NR,TwoSR,IR);
103 double factor = -1.0;
104 double * Ablock = Atens->gStorage(NL-2,TwoSL,ILdown,NL,TwoSL,IL);
105 int dimLdown = denBK->
gCurrentDim(theindex,NL-2,TwoSL,ILdown);
107 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Ablock,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
110 memSkappa = denS->gKappa(NL+2,TwoSL,ILdown,0,0,0,NR,TwoSR,IR);
114 double * Ablock = Atens->gStorage(NL,TwoSL,IL,NL+2,TwoSL,ILdown);
115 int dimLdown = denBK->
gCurrentDim(theindex,NL+2,TwoSL,ILdown);
117 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Ablock,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
123 if ((N1==2) && (N2==1)){
125 int memSkappa = denS->gKappa(NL+2,TwoSL,ILdown,1,0,1,NR,TwoSR,IR);
128 double factor = - sqrt(0.5);
129 double * Ablock = Atens->gStorage(NL,TwoSL,IL,NL+2,TwoSL,ILdown);
130 int dimLdown = denBK->
gCurrentDim(theindex,NL+2,TwoSL,ILdown);
132 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Ablock,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
138 if ((N1==1) && (N2==2)){
140 int memSkappa = denS->gKappa(NL+2,TwoSL,ILdown,0,1,1,NR,TwoSR,IR);
143 double factor = - sqrt(0.5);
144 double * Ablock = Atens->gStorage(NL,TwoSL,IL,NL+2,TwoSL,ILdown);
145 int dimLdown = denBK->
gCurrentDim(theindex,NL+2,TwoSL,ILdown);
147 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Ablock,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
153 if ((N1==2) && (N2==2)){
155 int memSkappa = denS->gKappa(NL+2,TwoSL,ILdown,1,1,0,NR,TwoSR,IR);
158 double factor = -1.0;
159 double * Ablock = Atens->gStorage(NL,TwoSL,IL,NL+2,TwoSL,ILdown);
160 int dimLdown = denBK->
gCurrentDim(theindex,NL+2,TwoSL,ILdown);
162 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Ablock,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
169 void CheMPS2::Heff::addDiagram4A1and4A2spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Btens)
const{
171 int NL = denS->gNL(ikappa);
172 int TwoSL = denS->gTwoSL(ikappa);
173 int IL = denS->gIL(ikappa);
175 int NR = denS->gNR(ikappa);
176 int TwoSR = denS->gTwoSR(ikappa);
177 int IR = denS->gIR(ikappa);
179 int N1 = denS->gN1(ikappa);
180 int N2 = denS->gN2(ikappa);
181 int TwoJ = denS->gTwoJ(ikappa);
183 int theindex = denS->gIndex();
184 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
185 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
194 if ((N1==0) && (N2==0)){
196 for (
int TwoSLdown = TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
199 int memSkappa = denS->gKappa(NL-2,TwoSLdown,ILdown,1,1,2,NR,TwoSR,IR);
203 double * Bblock = Btens->gStorage(NL-2,TwoSLdown,ILdown,NL,TwoSL,IL);
204 int dimLdown = denBK->
gCurrentDim(theindex,NL-2,TwoSLdown,ILdown);
206 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Bblock,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
214 if ((N1==1) && (N2==0)){
216 for (
int TwoSLdown = TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
217 if ((abs(TwoSLdown-TwoSR)<=1) && (TwoSLdown>=0)){
219 int memSkappa = denS->gKappa(NL-2,TwoSLdown,ILdown,2,1,1,NR,TwoSR,IR);
222 int fase =
phase(TwoSLdown + TwoSR + 1);
223 double factor = fase * sqrt(3.0*(TwoSL+1)) *
Wigner::wigner6j(1,1,2,TwoSL,TwoSLdown,TwoSR);
224 double * Bblock = Btens->gStorage(NL-2,TwoSLdown,ILdown,NL,TwoSL,IL);
225 int dimLdown = denBK->
gCurrentDim(theindex,NL-2,TwoSLdown,ILdown);
227 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Bblock,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
234 if ((N1==0) && (N2==1)){
236 for (
int TwoSLdown = TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
237 if ((abs(TwoSLdown-TwoSR)<=1) && (TwoSLdown>=0)){
239 int memSkappa = denS->gKappa(NL-2,TwoSLdown,ILdown,1,2,1,NR,TwoSR,IR);
242 int fase =
phase(TwoSLdown + TwoSR + 3);
243 double factor = fase * sqrt(3.0*(TwoSL+1)) *
Wigner::wigner6j(1,1,2,TwoSL,TwoSLdown,TwoSR);
244 double * Bblock = Btens->gStorage(NL-2,TwoSLdown,ILdown,NL,TwoSL,IL);
245 int dimLdown = denBK->
gCurrentDim(theindex,NL-2,TwoSLdown,ILdown);
247 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Bblock,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
254 if ((N1==1) && (N2==1) && (TwoJ==2)){
256 int TwoSLdown = TwoSR;
258 int memSkappa = denS->gKappa(NL-2,TwoSLdown,ILdown,2,2,0,NR,TwoSR,IR);
261 int fase =
phase(TwoSLdown - TwoSL);
262 double factor = fase * sqrt((TwoSL+1.0)/(TwoSLdown+1.0));
263 double * Bblock = Btens->gStorage(NL-2,TwoSLdown,ILdown,NL,TwoSL,IL);
264 int dimLdown = denBK->
gCurrentDim(theindex,NL-2,TwoSLdown,ILdown);
266 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Bblock,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
269 memSkappa = denS->gKappa(NL+2,TwoSLdown,ILdown,0,0,0,NR,TwoSR,IR);
273 double * Bblock = Btens->gStorage(NL,TwoSL,IL,NL+2,TwoSLdown,ILdown);
274 int dimLdown = denBK->
gCurrentDim(theindex,NL+2,TwoSLdown,ILdown);
276 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Bblock,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
282 if ((N1==2) && (N2==1)){
284 for (
int TwoSLdown = TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
285 if ((abs(TwoSLdown-TwoSR)<=1) && (TwoSLdown>=0)){
287 int memSkappa = denS->gKappa(NL+2,TwoSLdown,ILdown,1,0,1,NR,TwoSR,IR);
290 int fase =
phase(TwoSL + TwoSR + 1);
291 double factor = fase * sqrt(3.0*(TwoSLdown+1)) *
Wigner::wigner6j(1,1,2,TwoSL,TwoSLdown,TwoSR);
292 double * Bblock = Btens->gStorage(NL,TwoSL,IL,NL+2,TwoSLdown,ILdown);
293 int dimLdown = denBK->
gCurrentDim(theindex,NL+2,TwoSLdown,ILdown);
295 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Bblock,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
302 if ((N1==1) && (N2==2)){
304 for (
int TwoSLdown = TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
305 if ((abs(TwoSLdown-TwoSR)<=1) && (TwoSLdown>=0)){
307 int memSkappa = denS->gKappa(NL+2,TwoSLdown,ILdown,0,1,1,NR,TwoSR,IR);
310 int fase =
phase(TwoSL + TwoSR + 3);
311 double factor = fase * sqrt(3.0*(TwoSLdown+1)) *
Wigner::wigner6j(1,1,2,TwoSL,TwoSLdown,TwoSR);
312 double * Bblock = Btens->gStorage(NL,TwoSL,IL,NL+2,TwoSLdown,ILdown);
313 int dimLdown = denBK->
gCurrentDim(theindex,NL+2,TwoSLdown,ILdown);
315 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Bblock,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
322 if ((N1==2) && (N2==2)){
324 for (
int TwoSLdown = TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
328 int memSkappa = denS->gKappa(NL+2,TwoSLdown,ILdown,1,1,2,NR,TwoSR,IR);
331 int fase =
phase(TwoSLdown - TwoSL);
332 double factor = fase * sqrt((TwoSLdown+1.0)/(TwoSL+1.0));
333 double * Bblock = Btens->gStorage(NL,TwoSL,IL,NL+2,TwoSLdown,ILdown);
334 int dimLdown = denBK->
gCurrentDim(theindex,NL+2,TwoSLdown,ILdown);
336 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,Bblock,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
344 void CheMPS2::Heff::addDiagram4A3and4A4spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Ctens)
const{
346 int NL = denS->gNL(ikappa);
347 int TwoSL = denS->gTwoSL(ikappa);
348 int IL = denS->gIL(ikappa);
350 int NR = denS->gNR(ikappa);
351 int TwoSR = denS->gTwoSR(ikappa);
352 int IR = denS->gIR(ikappa);
354 int N1 = denS->gN1(ikappa);
355 int N2 = denS->gN2(ikappa);
356 int TwoJ = denS->gTwoJ(ikappa);
358 int theindex = denS->gIndex();
359 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
360 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
369 if ((N1==1) && (N2==0)){
371 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,0,1,1,NR,TwoSR,IR);
374 double factor = sqrt(0.5);
375 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSL,ILdown);
376 double * ptr = Ctens->gStorage(NL,TwoSL,ILdown,NL,TwoSL,IL);
378 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
384 if ((N1==1) && (N2==1) && (TwoJ==0)){
386 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,0,2,0,NR,TwoSR,IR);
390 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSL,ILdown);
391 double * ptr = Ctens->gStorage(NL,TwoSL,ILdown,NL,TwoSL,IL);
393 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
399 if ((N1==2) && (N2==0)){
401 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,1,1,0,NR,TwoSR,IR);
405 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSL,ILdown);
406 double * ptr = Ctens->gStorage(NL,TwoSL,ILdown,NL,TwoSL,IL);
408 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
414 if ((N1==2) && (N2==1)){
416 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,1,2,1,NR,TwoSR,IR);
419 double factor = - sqrt(0.5);
420 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSL,ILdown);
421 double * ptr = Ctens->gStorage(NL,TwoSL,ILdown,NL,TwoSL,IL);
423 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
429 if ((N1==0) && (N2==1)){
431 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,1,0,1,NR,TwoSR,IR);
434 double factor = sqrt(0.5);
435 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSL,ILdown);
436 double * ptr = Ctens->gStorage(NL,TwoSL,IL,NL,TwoSL,ILdown);
438 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
444 if ((N1==0) && (N2==2)){
446 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,1,1,0,NR,TwoSR,IR);
450 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSL,ILdown);
451 double * ptr = Ctens->gStorage(NL,TwoSL,IL,NL,TwoSL,ILdown);
453 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
459 if ((N1==1) && (N2==1) && (TwoJ==0)){
461 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,2,0,0,NR,TwoSR,IR);
465 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSL,ILdown);
466 double * ptr = Ctens->gStorage(NL,TwoSL,IL,NL,TwoSL,ILdown);
468 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
474 if ((N1==1) && (N2==2)){
476 int memSkappa = denS->gKappa(NL,TwoSL,ILdown,2,1,1,NR,TwoSR,IR);
479 double factor = - sqrt(0.5);
480 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSL,ILdown);
481 double * ptr = Ctens->gStorage(NL,TwoSL,IL,NL,TwoSL,ILdown);
483 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
490 void CheMPS2::Heff::addDiagram4A3and4A4spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Dtens)
const{
492 int NL = denS->gNL(ikappa);
493 int TwoSL = denS->gTwoSL(ikappa);
494 int IL = denS->gIL(ikappa);
496 int NR = denS->gNR(ikappa);
497 int TwoSR = denS->gTwoSR(ikappa);
498 int IR = denS->gIR(ikappa);
500 int N1 = denS->gN1(ikappa);
501 int N2 = denS->gN2(ikappa);
502 int TwoJ = denS->gTwoJ(ikappa);
504 int theindex = denS->gIndex();
505 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
506 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
515 if ((N1==1) && (N2==0)){
517 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
518 if ((abs(TwoSLdown-TwoSR)<=1) && (TwoSLdown>=0)){
520 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,0,1,1,NR,TwoSR,IR);
523 int fase =
phase(TwoSLdown + TwoSR + 1);
524 double factor = fase * sqrt(3.0*(TwoSL+1)) *
Wigner::wigner6j(1, 1, 2, TwoSL, TwoSLdown, TwoSR);
525 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSLdown,ILdown);
526 double * ptr = Dtens->gStorage(NL,TwoSLdown,ILdown,NL,TwoSL,IL);
528 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
535 if ((N1==1) && (N2==1) && (TwoJ==2)){
537 int TwoSLdown = TwoSR;
539 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,0,2,0,NR,TwoSR,IR);
542 int fase =
phase(TwoSLdown - TwoSL);
543 double factor = fase * sqrt((TwoSL+1.0)/(TwoSLdown+1.0));
544 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSLdown,ILdown);
545 double * ptr = Dtens->gStorage(NL,TwoSLdown,ILdown,NL,TwoSL,IL);
547 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
553 if ((N1==2) && (N2==0)){
555 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
558 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,1,1,2,NR,TwoSR,IR);
561 double factor = -1.0;
562 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSLdown,ILdown);
563 double * ptr = Dtens->gStorage(NL,TwoSLdown,ILdown,NL,TwoSL,IL);
565 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
572 if ((N1==2) && (N2==1)){
574 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
575 if ((abs(TwoSLdown-TwoSR)<=1) && (TwoSLdown>=0)){
577 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,1,2,1,NR,TwoSR,IR);
580 int fase =
phase(TwoSLdown + TwoSR + 1);
581 double factor = fase * sqrt(3.0*(TwoSL+1)) *
Wigner::wigner6j(1, 1, 2, TwoSL, TwoSLdown, TwoSR);
582 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSLdown,ILdown);
583 double * ptr = Dtens->gStorage(NL,TwoSLdown,ILdown,NL,TwoSL,IL);
585 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
592 if ((N1==0) && (N2==1)){
594 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
595 if ((abs(TwoSLdown-TwoSR)<=1) && (TwoSLdown>=0)){
597 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,1,0,1,NR,TwoSR,IR);
600 int fase =
phase(TwoSL + TwoSR + 1);
601 double factor = fase * sqrt(3.0*(TwoSLdown+1)) *
Wigner::wigner6j(1, 1, 2, TwoSL, TwoSLdown, TwoSR);
602 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSLdown,ILdown);
603 double * ptr = Dtens->gStorage(NL,TwoSL,IL,NL,TwoSLdown,ILdown);
605 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
612 if ((N1==0) && (N2==2)){
614 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
617 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,1,1,2,NR,TwoSR,IR);
620 int fase =
phase(TwoSL - TwoSLdown);
621 double factor = fase * sqrt((TwoSLdown+1.0)/(TwoSL+1.0));
622 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSLdown,ILdown);
623 double * ptr = Dtens->gStorage(NL,TwoSL,IL,NL,TwoSLdown,ILdown);
625 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
632 if ((N1==1) && (N2==1) && (TwoJ==2)){
634 int TwoSLdown = TwoSR;
636 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,2,0,0,NR,TwoSR,IR);
639 double factor = -1.0;
640 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSLdown,ILdown);
641 double * ptr = Dtens->gStorage(NL,TwoSL,IL,NL,TwoSLdown,ILdown);
643 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
649 if ((N1==1) && (N2==2)){
651 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
652 if ((abs(TwoSLdown-TwoSR)<=1) && (TwoSLdown>=0)){
654 int memSkappa = denS->gKappa(NL,TwoSLdown,ILdown,2,1,1,NR,TwoSR,IR);
657 int fase =
phase(TwoSL + TwoSR + 1);
658 double factor = fase * sqrt(3.0*(TwoSLdown+1)) *
Wigner::wigner6j(1, 1, 2, TwoSL, TwoSLdown, TwoSR);
659 int dimLdown = denBK->
gCurrentDim(theindex,NL,TwoSLdown,ILdown);
660 double * ptr = Dtens->gStorage(NL,TwoSL,IL,NL,TwoSLdown,ILdown);
662 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,ptr,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
670 void CheMPS2::Heff::addDiagram4B1and4B2spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator *** Aleft, TensorL ** Lright,
double * temp)
const{
672 #ifdef CHEMPS2_MPI_COMPILATION 676 int NL = denS->gNL(ikappa);
677 int TwoSL = denS->gTwoSL(ikappa);
678 int IL = denS->gIL(ikappa);
680 int NR = denS->gNR(ikappa);
681 int TwoSR = denS->gTwoSR(ikappa);
682 int IR = denS->gIR(ikappa);
684 int N1 = denS->gN1(ikappa);
685 int N2 = denS->gN2(ikappa);
686 int TwoJ = denS->gTwoJ(ikappa);
687 int TwoS2 = (N2==1)?1:0;
689 int theindex = denS->gIndex();
690 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
691 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
699 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
701 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
702 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
703 if ((abs(TwoSL-TwoSRdown)<=TwoJdown) && (TwoSRdown>=0)){
705 int fase =
phase(TwoSR + TwoSL + 1 + TwoJdown + 2*TwoS2);
706 const double factor = fase * sqrt(0.5*(TwoSR+1)*(TwoJdown+1)) *
Wigner::wigner6j(TwoJdown, TwoS2, 1, TwoSR, TwoSRdown, TwoSL);
708 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
710 #ifdef CHEMPS2_MPI_COMPILATION 711 if ( MPIchemps2::owner_absigma( theindex, l_index ) == MPIRANK )
716 int memSkappa = denS->gKappa(NL-2, TwoSL, ILdown, 1, N2, TwoJdown, NR-1, TwoSRdown, IRdown);
720 int dimLdown = denBK->
gCurrentDim(theindex , NL-2, TwoSL, ILdown);
721 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
723 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
726 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown, &beta,temp,&dimLdown);
728 double * Ablock = Aleft[l_index-theindex][0]->gStorage(NL-2,TwoSL,ILdown,NL,TwoSL,IL);
731 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Ablock,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
744 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
745 if ((abs(TwoSL-TwoSRdown)<=TwoS2) && (TwoSRdown>=0)){
747 int fase =
phase(TwoSR + TwoSL + 2 + TwoJ + 2*TwoS2);
748 const double factor = fase * sqrt(0.5*(TwoSR+1)*(TwoJ+1)) *
Wigner::wigner6j(TwoJ, TwoS2, 1, TwoSRdown, TwoSR, TwoSL);
750 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
752 #ifdef CHEMPS2_MPI_COMPILATION 753 if ( MPIchemps2::owner_absigma( theindex, l_index ) == MPIRANK )
758 int memSkappa = denS->gKappa(NL-2, TwoSL, ILdown, 2, N2, TwoS2, NR-1, TwoSRdown, IRdown);
762 int dimLdown = denBK->
gCurrentDim(theindex , NL-2, TwoSL, ILdown);
763 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
765 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
768 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp,&dimLdown);
770 double * Ablock = Aleft[l_index-theindex][0]->gStorage(NL-2,TwoSL,ILdown,NL,TwoSL,IL);
773 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Ablock,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
785 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
786 if ((abs(TwoSL-TwoSRdown)<=TwoS2) && (TwoSRdown>=0)){
788 int fase =
phase(TwoSRdown + TwoSL + 1 + TwoJ + 2*TwoS2);
789 const double factor = fase * sqrt(0.5*(TwoSRdown+1)*(TwoJ+1)) *
Wigner::wigner6j(TwoJ, TwoS2, 1, TwoSRdown, TwoSR, TwoSL);
791 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
793 #ifdef CHEMPS2_MPI_COMPILATION 794 if ( MPIchemps2::owner_absigma( theindex, l_index ) == MPIRANK )
799 int memSkappa = denS->gKappa(NL+2, TwoSL, ILdown, 0, N2, TwoS2, NR+1, TwoSRdown, IRdown);
803 int dimLdown = denBK->
gCurrentDim(theindex , NL+2, TwoSL, ILdown);
804 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
806 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
809 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
811 double * Ablock = Aleft[l_index-theindex][0]->gStorage(NL,TwoSL,IL,NL+2,TwoSL,ILdown);
814 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Ablock,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
826 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
828 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
829 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
830 if ((abs(TwoSL-TwoSRdown)<=TwoJdown) && (TwoSRdown>=0)){
832 int fase =
phase(TwoSRdown + TwoSL + 2 + TwoJdown + 2*TwoS2);
833 const double factor = fase * sqrt(0.5*(TwoSRdown+1)*(TwoJdown+1)) *
Wigner::wigner6j(TwoJdown, TwoS2, 1, TwoSR, TwoSRdown, TwoSL);
835 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
837 #ifdef CHEMPS2_MPI_COMPILATION 838 if ( MPIchemps2::owner_absigma( theindex, l_index ) == MPIRANK )
843 int memSkappa = denS->gKappa(NL+2, TwoSL, ILdown, 1, N2, TwoJdown, NR+1, TwoSRdown, IRdown);
847 int dimLdown = denBK->
gCurrentDim(theindex , NL+2, TwoSL, ILdown);
848 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
850 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
853 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
855 double * Ablock = Aleft[l_index-theindex][0]->gStorage(NL,TwoSL,IL,NL+2,TwoSL,ILdown);
858 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Ablock,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
870 void CheMPS2::Heff::addDiagram4B1and4B2spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator *** Bleft, TensorL ** Lright,
double * temp)
const{
872 #ifdef CHEMPS2_MPI_COMPILATION 876 int NL = denS->gNL(ikappa);
877 int TwoSL = denS->gTwoSL(ikappa);
878 int IL = denS->gIL(ikappa);
880 int NR = denS->gNR(ikappa);
881 int TwoSR = denS->gTwoSR(ikappa);
882 int IR = denS->gIR(ikappa);
884 int N1 = denS->gN1(ikappa);
885 int N2 = denS->gN2(ikappa);
886 int TwoJ = denS->gTwoJ(ikappa);
887 int TwoS2 = (N2==1)?1:0;
889 int theindex = denS->gIndex();
890 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
891 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
899 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
900 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
902 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
903 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
904 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
906 int fase = (TwoS2==0)?1:-1;
907 const double factor = fase * sqrt(3.0*(TwoSR+1)*(TwoSL+1)*(TwoJdown+1))
908 *
Wigner::wigner9j(2, TwoSLdown, TwoSL, 1, TwoSRdown, TwoSR, 1, TwoJdown, TwoS2);
910 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
912 #ifdef CHEMPS2_MPI_COMPILATION 913 if ( MPIchemps2::owner_absigma( theindex, l_index ) == MPIRANK )
918 int memSkappa = denS->gKappa(NL-2, TwoSLdown, ILdown, 1, N2, TwoJdown, NR-1, TwoSRdown, IRdown);
922 int dimLdown = denBK->
gCurrentDim(theindex , NL-2, TwoSLdown, ILdown);
923 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
925 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
928 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown, Lblock,&dimRdown, &beta,temp, &dimLdown);
930 double * Bblock = Bleft[l_index-theindex][0]->gStorage(NL-2,TwoSLdown,ILdown,NL,TwoSL,IL);
933 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Bblock,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
947 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
948 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
949 if ((abs(TwoSLdown-TwoSRdown)<=TwoS2) && (TwoSLdown>=0) && (TwoSRdown>=0)){
951 int fase =
phase(TwoSR - TwoSRdown + TwoSL + 3 - TwoSLdown + 2*TwoS2);
952 const double factor = fase * sqrt(3.0*(TwoSR+1)*(TwoSL+1)*(TwoJ+1))
953 *
Wigner::wigner9j(2, TwoSL, TwoSLdown, 1, TwoSR, TwoSRdown, 1, TwoJ, TwoS2);
955 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
957 #ifdef CHEMPS2_MPI_COMPILATION 958 if ( MPIchemps2::owner_absigma( theindex, l_index ) == MPIRANK )
963 int memSkappa = denS->gKappa(NL-2, TwoSLdown, ILdown, 2, N2, TwoS2, NR-1, TwoSRdown, IRdown);
967 int dimLdown = denBK->
gCurrentDim(theindex , NL-2, TwoSLdown, ILdown);
968 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
970 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
973 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp, &dimLdown);
975 double * Bblock = Bleft[l_index-theindex][0]->gStorage(NL-2,TwoSLdown,ILdown,NL,TwoSL,IL);
978 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Bblock,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
991 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
992 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
993 if ((abs(TwoSLdown-TwoSRdown)<=TwoS2) && (TwoSLdown>=0) && (TwoSRdown>=0)){
995 int fase = (TwoS2==0)?1:-1;
996 const double factor = fase * sqrt(3.0*(TwoSRdown+1)*(TwoSLdown+1)*(TwoJ+1))
997 *
Wigner::wigner9j(2, TwoSL, TwoSLdown, 1, TwoSR, TwoSRdown, 1, TwoJ, TwoS2);
999 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1001 #ifdef CHEMPS2_MPI_COMPILATION 1002 if ( MPIchemps2::owner_absigma( theindex, l_index ) == MPIRANK )
1007 int memSkappa = denS->gKappa(NL+2, TwoSLdown, ILdown, 0, N2, TwoS2, NR+1, TwoSRdown, IRdown);
1011 int dimLdown = denBK->
gCurrentDim(theindex , NL+2, TwoSLdown, ILdown);
1012 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1014 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1017 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
1019 double * Bblock = Bleft[l_index-theindex][0]->gStorage(NL,TwoSL,IL,NL+2,TwoSLdown,ILdown);
1022 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Bblock,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1035 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1036 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1038 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
1039 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
1040 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1042 int fase =
phase(TwoSLdown + 3 - TwoSL + TwoSRdown - TwoSR + 2*TwoS2);
1043 const double factor = fase * sqrt(3.0*(TwoSRdown+1)*(TwoJdown+1)*(TwoSLdown+1))
1044 *
Wigner::wigner9j(2, TwoSLdown, TwoSL, 1, TwoSRdown, TwoSR, 1, TwoJdown, TwoS2);
1046 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1048 #ifdef CHEMPS2_MPI_COMPILATION 1049 if ( MPIchemps2::owner_absigma( theindex, l_index ) == MPIRANK )
1054 int memSkappa = denS->gKappa(NL+2, TwoSLdown, ILdown, 1, N2, TwoJdown, NR+1, TwoSRdown, IRdown);
1058 int dimLdown = denBK->
gCurrentDim(theindex , NL+2, TwoSLdown, ILdown);
1059 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1061 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1064 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp, &dimLdown);
1066 double * Bblock = Bleft[l_index-theindex][0]->gStorage(NL,TwoSL,IL,NL+2,TwoSLdown,ILdown);
1069 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Bblock,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1082 void CheMPS2::Heff::addDiagram4B3and4B4spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator *** Cleft, TensorL ** Lright,
double * temp)
const{
1084 #ifdef CHEMPS2_MPI_COMPILATION 1088 int NL = denS->gNL(ikappa);
1089 int TwoSL = denS->gTwoSL(ikappa);
1090 int IL = denS->gIL(ikappa);
1092 int NR = denS->gNR(ikappa);
1093 int TwoSR = denS->gTwoSR(ikappa);
1094 int IR = denS->gIR(ikappa);
1096 int N1 = denS->gN1(ikappa);
1097 int N2 = denS->gN2(ikappa);
1098 int TwoJ = denS->gTwoJ(ikappa);
1099 int TwoS2 = (N2==1)?1:0;
1101 int theindex = denS->gIndex();
1102 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
1103 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1111 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1112 if ((abs(TwoSL-TwoSRdown)<=TwoS2) && (TwoSRdown>=0)){
1114 int fase =
phase(TwoSR + TwoSL + TwoJ + 2*TwoS2);
1115 const double factor = fase * sqrt(0.5*(TwoSR+1)*(TwoJ+1)) *
Wigner::wigner6j(TwoJ, TwoS2, 1, TwoSRdown, TwoSR, TwoSL);
1117 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1119 #ifdef CHEMPS2_MPI_COMPILATION 1120 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex, l_index ) == MPIRANK )
1125 int memSkappa = denS->gKappa(NL, TwoSL, ILdown, 0, N2, TwoS2, NR-1, TwoSRdown, IRdown);
1129 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSL, ILdown);
1130 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1132 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1135 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp,&dimLdown);
1137 double * ptr = Cleft[l_index-theindex][0]->gStorage(NL,TwoSL,ILdown,NL,TwoSL,IL);
1141 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1153 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1155 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
1156 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
1157 if ((abs(TwoSL-TwoSRdown)<=TwoJdown) && (TwoSRdown>=0)){
1159 int fase =
phase(TwoSR + TwoSL + 1 + TwoJdown + 2*TwoS2);
1160 const double factor = fase * sqrt(0.5*(TwoSR+1)*(TwoJdown+1)) *
Wigner::wigner6j(TwoJdown, TwoS2, 1, TwoSR, TwoSRdown, TwoSL);
1162 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1164 #ifdef CHEMPS2_MPI_COMPILATION 1165 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex, l_index ) == MPIRANK )
1170 int memSkappa = denS->gKappa(NL, TwoSL, ILdown, 1, N2, TwoJdown, NR-1, TwoSRdown, IRdown);
1174 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSL, ILdown);
1175 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1177 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1180 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp, &dimLdown);
1182 double * ptr = Cleft[l_index-theindex][0]->gStorage(NL,TwoSL,ILdown,NL,TwoSL,IL);
1186 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1199 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1201 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
1202 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
1203 if ((abs(TwoSL-TwoSRdown)<=TwoJdown) && (TwoSRdown>=0)){
1205 int fase =
phase(TwoSRdown + TwoSL + TwoJdown + 2*TwoS2);
1206 const double factor = fase * sqrt(0.5*(TwoSRdown+1)*(TwoJdown+1)) *
Wigner::wigner6j(TwoJdown, TwoS2, 1, TwoSR, TwoSRdown, TwoSL);
1208 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1210 #ifdef CHEMPS2_MPI_COMPILATION 1211 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex, l_index ) == MPIRANK )
1216 int memSkappa = denS->gKappa(NL, TwoSL, ILdown, 1, N2, TwoJdown, NR+1, TwoSRdown, IRdown);
1220 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSL, ILdown);
1221 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1223 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1226 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
1228 double * ptr = Cleft[l_index-theindex][0]->gStorage(NL,TwoSL,IL,NL,TwoSL,ILdown);
1232 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1245 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1246 if ((abs(TwoSL-TwoSRdown)<=TwoS2) && (TwoSRdown>=0)){
1248 int fase =
phase(TwoSRdown + TwoSL + 1 + TwoJ + 2*TwoS2);
1249 const double factor = fase * sqrt(0.5*(TwoSRdown+1)*(TwoJ+1)) *
Wigner::wigner6j(TwoJ, TwoS2, 1, TwoSRdown, TwoSR, TwoSL);
1251 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1253 #ifdef CHEMPS2_MPI_COMPILATION 1254 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex, l_index ) == MPIRANK )
1259 int memSkappa = denS->gKappa(NL, TwoSL, ILdown, 2, N2, TwoS2, NR+1, TwoSRdown, IRdown);
1263 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSL, ILdown);
1264 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1266 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1269 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
1271 double * ptr = Cleft[l_index-theindex][0]->gStorage(NL,TwoSL,IL,NL,TwoSL,ILdown);
1275 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1286 void CheMPS2::Heff::addDiagram4B3and4B4spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator *** Dleft, TensorL ** Lright,
double * temp)
const{
1288 #ifdef CHEMPS2_MPI_COMPILATION 1292 int NL = denS->gNL(ikappa);
1293 int TwoSL = denS->gTwoSL(ikappa);
1294 int IL = denS->gIL(ikappa);
1296 int NR = denS->gNR(ikappa);
1297 int TwoSR = denS->gTwoSR(ikappa);
1298 int IR = denS->gIR(ikappa);
1300 int N1 = denS->gN1(ikappa);
1301 int N2 = denS->gN2(ikappa);
1302 int TwoJ = denS->gTwoJ(ikappa);
1303 int TwoS2 = (N2==1)?1:0;
1305 int theindex = denS->gIndex();
1306 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
1307 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1315 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1316 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1317 if ((abs(TwoSLdown-TwoSRdown)<=TwoS2) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1319 int fase =
phase(TwoSL-TwoSLdown + TwoSR - TwoSRdown + 3 + 2*TwoS2);
1320 const double factor = fase * sqrt(3.0*(TwoSR+1)*(TwoJ+1)*(TwoSL+1))
1321 *
Wigner::wigner9j(2, TwoSL, TwoSLdown, 1, TwoSR, TwoSRdown, 1, TwoJ, TwoS2);
1323 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1325 #ifdef CHEMPS2_MPI_COMPILATION 1326 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex, l_index ) == MPIRANK )
1331 int memSkappa = denS->gKappa(NL, TwoSLdown, ILdown, 0, N2, TwoS2, NR-1, TwoSRdown, IRdown);
1335 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSLdown, ILdown);
1336 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1338 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1341 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp, &dimLdown);
1343 double * ptr = Dleft[l_index-theindex][0]->gStorage(NL,TwoSLdown,ILdown,NL,TwoSL,IL);
1347 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1360 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1361 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1363 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
1364 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
1365 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1367 int fase = (TwoS2==0)?-1:1;
1368 const double factor = fase * sqrt(3.0*(TwoSR+1)*(TwoJdown+1)*(TwoSL+1))
1369 *
Wigner::wigner9j(2, TwoSLdown, TwoSL, 1, TwoSRdown, TwoSR, 1, TwoJdown, TwoS2);
1371 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1373 #ifdef CHEMPS2_MPI_COMPILATION 1374 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex, l_index ) == MPIRANK )
1379 int memSkappa = denS->gKappa(NL, TwoSLdown, ILdown, 1, N2, TwoJdown, NR-1, TwoSRdown, IRdown);
1383 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSLdown, ILdown);
1384 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1386 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1389 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp, &dimLdown);
1391 double * ptr = Dleft[l_index-theindex][0]->gStorage(NL,TwoSLdown,ILdown,NL,TwoSL,IL);
1395 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1409 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1410 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1412 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
1413 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
1414 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1416 int fase =
phase(TwoSRdown - TwoSR + TwoSLdown - TwoSL + 3 + 2*TwoS2);
1417 const double factor = fase * sqrt(3.0*(TwoSRdown+1)*(TwoJdown+1)*(TwoSLdown+1))
1418 *
Wigner::wigner9j(2, TwoSLdown, TwoSL, 1, TwoSRdown, TwoSR, 1, TwoJdown, TwoS2);
1420 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1422 #ifdef CHEMPS2_MPI_COMPILATION 1423 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex, l_index ) == MPIRANK )
1428 int memSkappa = denS->gKappa(NL, TwoSLdown, ILdown, 1, N2, TwoJdown, NR+1, TwoSRdown, IRdown);
1432 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSLdown, ILdown);
1433 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1435 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1438 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp, &dimLdown);
1440 double * ptr = Dleft[l_index-theindex][0]->gStorage(NL,TwoSL,IL,NL,TwoSLdown,ILdown);
1444 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1458 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1459 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1460 if ((abs(TwoSLdown-TwoSRdown)<=TwoS2) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1462 int fase = (TwoS2==0)?-1:1;
1463 const double factor = fase * sqrt(3.0*(TwoSRdown+1)*(TwoJ+1)*(TwoSLdown+1))
1464 *
Wigner::wigner9j(2, TwoSL, TwoSLdown, 1, TwoSR, TwoSRdown, 1, TwoJ, TwoS2);
1466 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1468 #ifdef CHEMPS2_MPI_COMPILATION 1469 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex, l_index ) == MPIRANK )
1474 int memSkappa = denS->gKappa(NL, TwoSLdown, ILdown, 2, N2, TwoS2, NR+1, TwoSRdown, IRdown);
1478 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSLdown, ILdown);
1479 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1481 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1484 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
1486 double * ptr = Dleft[l_index-theindex][0]->gStorage(NL,TwoSL,IL,NL,TwoSLdown,ILdown);
1490 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1502 void CheMPS2::Heff::addDiagram4C1and4C2spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator *** Aleft, TensorL ** Lright,
double * temp)
const{
1504 #ifdef CHEMPS2_MPI_COMPILATION 1508 int NL = denS->gNL(ikappa);
1509 int TwoSL = denS->gTwoSL(ikappa);
1510 int IL = denS->gIL(ikappa);
1512 int NR = denS->gNR(ikappa);
1513 int TwoSR = denS->gTwoSR(ikappa);
1514 int IR = denS->gIR(ikappa);
1516 int N1 = denS->gN1(ikappa);
1517 int N2 = denS->gN2(ikappa);
1518 int TwoJ = denS->gTwoJ(ikappa);
1519 int TwoS1 = (N1==1)?1:0;
1521 int theindex = denS->gIndex();
1522 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
1523 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1531 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1533 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
1534 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
1535 if ((abs(TwoSL-TwoSRdown)<=TwoJdown) && (TwoSRdown>=0)){
1537 const double factor =
phase(TwoSR + TwoSL + 2 + TwoS1) * sqrt(0.5*(TwoSR+1)*(TwoJdown+1))
1540 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1542 #ifdef CHEMPS2_MPI_COMPILATION 1543 if ( MPIchemps2::owner_absigma( theindex+1, l_index ) == MPIRANK )
1548 int memSkappa = denS->gKappa(NL-2, TwoSL, ILdown, N1, 1, TwoJdown, NR-1, TwoSRdown, IRdown);
1552 int dimLdown = denBK->
gCurrentDim(theindex , NL-2, TwoSL, ILdown);
1553 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1555 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1558 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp,&dimLdown);
1560 double * Ablock = Aleft[l_index-theindex-1][1]->gStorage(NL-2,TwoSL,ILdown,NL,TwoSL,IL);
1563 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Ablock,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1576 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1577 if ((abs(TwoSL-TwoSRdown)<=TwoS1) && (TwoSRdown>=0)){
1579 const double factor =
phase(TwoSR + TwoSL + 3 + TwoS1) * sqrt(0.5*(TwoSR+1)*(TwoJ+1))
1582 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1584 #ifdef CHEMPS2_MPI_COMPILATION 1585 if ( MPIchemps2::owner_absigma( theindex+1, l_index ) == MPIRANK )
1590 int memSkappa = denS->gKappa(NL-2, TwoSL, ILdown, N1, 2, TwoS1, NR-1, TwoSRdown, IRdown);
1594 int dimLdown = denBK->
gCurrentDim(theindex , NL-2, TwoSL, ILdown);
1595 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1597 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1600 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp,&dimLdown);
1602 double * Ablock = Aleft[l_index-theindex-1][1]->gStorage(NL-2,TwoSL,ILdown,NL,TwoSL,IL);
1605 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Ablock,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1617 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1618 if ((abs(TwoSL-TwoSRdown)<=TwoS1) && (TwoSRdown>=0)){
1620 const double factor =
phase(TwoSRdown + TwoSL + 2 + TwoS1) * sqrt(0.5*(TwoSRdown+1)*(TwoJ+1))
1623 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1625 #ifdef CHEMPS2_MPI_COMPILATION 1626 if ( MPIchemps2::owner_absigma( theindex+1, l_index ) == MPIRANK )
1631 int memSkappa = denS->gKappa(NL+2, TwoSL, ILdown, N1, 0, TwoS1, NR+1, TwoSRdown, IRdown);
1635 int dimLdown = denBK->
gCurrentDim(theindex , NL+2, TwoSL, ILdown);
1636 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1638 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1641 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
1643 double * Ablock = Aleft[l_index-theindex-1][1]->gStorage(NL,TwoSL,IL,NL+2,TwoSL,ILdown);
1646 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Ablock,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1658 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1660 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
1661 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
1662 if ((abs(TwoSL-TwoSRdown)<=TwoJdown) && (TwoSRdown>=0)){
1664 const double factor =
phase(TwoSRdown + TwoSL + 3 + TwoS1) * sqrt(0.5*(TwoSRdown+1)*(TwoJdown+1))
1667 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1669 #ifdef CHEMPS2_MPI_COMPILATION 1670 if ( MPIchemps2::owner_absigma( theindex+1, l_index ) == MPIRANK )
1675 int memSkappa = denS->gKappa(NL+2, TwoSL, ILdown, N1, 1, TwoJdown, NR+1, TwoSRdown, IRdown);
1679 int dimLdown = denBK->
gCurrentDim(theindex , NL+2, TwoSL, ILdown);
1680 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1682 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1685 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
1687 double * Ablock = Aleft[l_index-theindex-1][1]->gStorage(NL,TwoSL,IL,NL+2,TwoSL,ILdown);
1690 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Ablock,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1702 void CheMPS2::Heff::addDiagram4C1and4C2spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator *** Bleft, TensorL ** Lright,
double * temp)
const{
1704 #ifdef CHEMPS2_MPI_COMPILATION 1708 int NL = denS->gNL(ikappa);
1709 int TwoSL = denS->gTwoSL(ikappa);
1710 int IL = denS->gIL(ikappa);
1712 int NR = denS->gNR(ikappa);
1713 int TwoSR = denS->gTwoSR(ikappa);
1714 int IR = denS->gIR(ikappa);
1716 int N1 = denS->gN1(ikappa);
1717 int N2 = denS->gN2(ikappa);
1718 int TwoJ = denS->gTwoJ(ikappa);
1719 int TwoS1 = (N1==1)?1:0;
1721 int theindex = denS->gIndex();
1722 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
1723 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1731 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1732 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1734 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
1735 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
1736 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1738 const double factor =
phase(1 + TwoS1 - TwoJdown)
1739 * sqrt(3.0*(TwoSR+1)*(TwoSL+1)*(TwoJdown+1))
1740 *
Wigner::wigner9j(2, TwoSLdown, TwoSL, 1, TwoSRdown, TwoSR, 1, TwoJdown, TwoS1);
1742 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1744 #ifdef CHEMPS2_MPI_COMPILATION 1745 if ( MPIchemps2::owner_absigma( theindex+1, l_index ) == MPIRANK )
1750 int memSkappa = denS->gKappa(NL-2, TwoSLdown, ILdown, N1, 1, TwoJdown, NR-1, TwoSRdown, IRdown);
1754 int dimLdown = denBK->
gCurrentDim(theindex , NL-2, TwoSLdown, ILdown);
1755 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1757 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1760 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp,&dimLdown);
1762 double * Bblock = Bleft[l_index-theindex-1][1]->gStorage(NL-2,TwoSLdown,ILdown,NL,TwoSL,IL);
1765 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Bblock,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1779 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1780 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1781 if ((abs(TwoSLdown-TwoSRdown)<=TwoS1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1783 const double factor =
phase(TwoSR - TwoSRdown + TwoSL - TwoSLdown + TwoS1 - TwoJ)
1784 * sqrt(3.0*(TwoSR+1)*(TwoSL+1)*(TwoJ+1))
1785 *
Wigner::wigner9j(2, TwoSL, TwoSLdown, 1, TwoSR, TwoSRdown, 1, TwoJ, TwoS1);
1787 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1789 #ifdef CHEMPS2_MPI_COMPILATION 1790 if ( MPIchemps2::owner_absigma( theindex+1, l_index ) == MPIRANK )
1795 int memSkappa = denS->gKappa(NL-2, TwoSLdown, ILdown, N1, 2, TwoS1, NR-1, TwoSRdown, IRdown);
1799 int dimLdown = denBK->
gCurrentDim(theindex , NL-2, TwoSLdown, ILdown);
1800 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1802 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1805 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp,&dimLdown);
1807 double * Bblock = Bleft[l_index-theindex-1][1]->gStorage(NL-2,TwoSLdown,ILdown,NL,TwoSL,IL);
1810 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Bblock,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1823 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1824 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1825 if ((abs(TwoSLdown-TwoSRdown)<=TwoS1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1827 const double factor =
phase(1 + TwoS1 - TwoJ)
1828 * sqrt(3.0*(TwoSRdown+1)*(TwoSLdown+1)*(TwoJ+1))
1829 *
Wigner::wigner9j(2, TwoSL, TwoSLdown, 1, TwoSR, TwoSRdown, 1, TwoJ, TwoS1);
1831 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1833 #ifdef CHEMPS2_MPI_COMPILATION 1834 if ( MPIchemps2::owner_absigma( theindex+1, l_index ) == MPIRANK )
1839 int memSkappa = denS->gKappa(NL+2, TwoSLdown, ILdown, N1, 0, TwoS1, NR+1, TwoSRdown, IRdown);
1843 int dimLdown = denBK->
gCurrentDim(theindex , NL+2, TwoSLdown, ILdown);
1844 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1846 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1849 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
1851 double * Bblock = Bleft[l_index-theindex-1][1]->gStorage(NL,TwoSL,IL,NL+2,TwoSLdown,ILdown);
1854 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Bblock,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1867 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1868 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
1870 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
1871 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
1872 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
1874 const double factor =
phase(TwoSLdown - TwoSL + TwoSRdown - TwoSR + TwoS1 - TwoJdown)
1875 * sqrt(3.0*(TwoSRdown+1)*(TwoJdown+1)*(TwoSLdown+1))
1876 *
Wigner::wigner9j(2, TwoSLdown, TwoSL, 1, TwoSRdown, TwoSR, 1, TwoJdown, TwoS1);
1878 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1880 #ifdef CHEMPS2_MPI_COMPILATION 1881 if ( MPIchemps2::owner_absigma( theindex+1, l_index ) == MPIRANK )
1886 int memSkappa = denS->gKappa(NL+2, TwoSLdown, ILdown, N1, 1, TwoJdown, NR+1, TwoSRdown, IRdown);
1890 int dimLdown = denBK->
gCurrentDim(theindex , NL+2, TwoSLdown, ILdown);
1891 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
1893 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
1896 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
1898 double * Bblock = Bleft[l_index-theindex-1][1]->gStorage(NL,TwoSL,IL,NL+2,TwoSLdown,ILdown);
1901 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,Bblock,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1914 void CheMPS2::Heff::addDiagram4C3and4C4spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator *** Cleft, TensorL ** Lright,
double * temp)
const{
1916 #ifdef CHEMPS2_MPI_COMPILATION 1920 int NL = denS->gNL(ikappa);
1921 int TwoSL = denS->gTwoSL(ikappa);
1922 int IL = denS->gIL(ikappa);
1924 int NR = denS->gNR(ikappa);
1925 int TwoSR = denS->gTwoSR(ikappa);
1926 int IR = denS->gIR(ikappa);
1928 int N1 = denS->gN1(ikappa);
1929 int N2 = denS->gN2(ikappa);
1930 int TwoJ = denS->gTwoJ(ikappa);
1931 int TwoS1 = (N1==1)?1:0;
1933 int theindex = denS->gIndex();
1934 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
1935 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
1943 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1944 if ((abs(TwoSL-TwoSRdown)<=TwoS1) && (TwoSRdown>=0)){
1946 const double factor =
phase(TwoSR + TwoSL + 1 + TwoS1) * sqrt(0.5*(TwoSR+1)*(TwoJ+1))
1949 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1951 #ifdef CHEMPS2_MPI_COMPILATION 1952 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex+1, l_index ) == MPIRANK )
1957 int memSkappa = denS->gKappa(NL, TwoSL, ILdown, N1, 0, TwoS1, NR-1, TwoSRdown, IRdown);
1961 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSL, ILdown);
1962 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
1964 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
1967 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp,&dimLdown);
1969 double * ptr = Cleft[l_index-theindex-1][1]->gStorage(NL,TwoSL,ILdown,NL,TwoSL,IL);
1973 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
1985 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
1987 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
1988 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
1989 if ((abs(TwoSL-TwoSRdown)<=TwoJdown) && (TwoSRdown>=0)){
1991 const double factor =
phase(TwoSR + TwoSL + 2 + TwoS1) * sqrt(0.5*(TwoSR+1)*(TwoJdown+1))
1994 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
1996 #ifdef CHEMPS2_MPI_COMPILATION 1997 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex+1, l_index ) == MPIRANK )
2002 int memSkappa = denS->gKappa(NL, TwoSL, ILdown, N1, 1, TwoJdown, NR-1, TwoSRdown, IRdown);
2006 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSL, ILdown);
2007 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
2009 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
2012 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp,&dimLdown);
2014 double * ptr = Cleft[l_index-theindex-1][1]->gStorage(NL,TwoSL,ILdown,NL,TwoSL,IL);
2018 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2031 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2033 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
2034 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
2035 if ((abs(TwoSL-TwoSRdown)<=TwoJdown) && (TwoSRdown>=0)){
2037 const double factor =
phase(TwoSRdown + TwoSL + 1 + TwoS1) * sqrt(0.5*(TwoSRdown+1)*(TwoJdown+1))
2040 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
2042 #ifdef CHEMPS2_MPI_COMPILATION 2043 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex+1, l_index ) == MPIRANK )
2048 int memSkappa = denS->gKappa(NL, TwoSL, ILdown, N1, 1, TwoJdown, NR+1, TwoSRdown, IRdown);
2052 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSL, ILdown);
2053 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
2055 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
2058 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
2060 double * ptr = Cleft[l_index-theindex-1][1]->gStorage(NL,TwoSL,IL,NL,TwoSL,ILdown);
2064 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2077 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2078 if ((abs(TwoSL-TwoSRdown)<=TwoS1) && (TwoSRdown>=0)){
2080 const double factor =
phase(TwoSRdown+TwoSL+2+TwoS1) * sqrt(0.5*(TwoSRdown+1)*(TwoJ+1))
2083 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
2085 #ifdef CHEMPS2_MPI_COMPILATION 2086 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex+1, l_index ) == MPIRANK )
2091 int memSkappa = denS->gKappa(NL, TwoSL, ILdown, N1, 2, TwoS1, NR+1, TwoSRdown, IRdown);
2095 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSL, ILdown);
2096 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
2098 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
2101 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
2103 double * ptr = Cleft[l_index-theindex-1][1]->gStorage(NL,TwoSL,IL,NL,TwoSL,ILdown);
2107 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2118 void CheMPS2::Heff::addDiagram4C3and4C4spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator *** Dleft, TensorL ** Lright,
double * temp)
const{
2120 #ifdef CHEMPS2_MPI_COMPILATION 2124 int NL = denS->gNL(ikappa);
2125 int TwoSL = denS->gTwoSL(ikappa);
2126 int IL = denS->gIL(ikappa);
2128 int NR = denS->gNR(ikappa);
2129 int TwoSR = denS->gTwoSR(ikappa);
2130 int IR = denS->gIR(ikappa);
2132 int N1 = denS->gN1(ikappa);
2133 int N2 = denS->gN2(ikappa);
2134 int TwoJ = denS->gTwoJ(ikappa);
2135 int TwoS1 = (N1==1)?1:0;
2137 int theindex = denS->gIndex();
2138 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
2139 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
2147 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2148 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
2149 if ((abs(TwoSLdown-TwoSRdown)<=TwoS1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
2151 int fase =
phase(TwoSL-TwoSLdown + TwoSR - TwoSRdown + TwoS1 - TwoJ);
2152 const double factor = fase * sqrt(3.0*(TwoSR+1)*(TwoJ+1)*(TwoSL+1))
2153 *
Wigner::wigner9j(2, TwoSL, TwoSLdown, 1, TwoSR, TwoSRdown, 1, TwoJ, TwoS1);
2155 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
2157 #ifdef CHEMPS2_MPI_COMPILATION 2158 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex+1, l_index ) == MPIRANK )
2163 int memSkappa = denS->gKappa(NL, TwoSLdown, ILdown, N1, 0, TwoS1, NR-1, TwoSRdown, IRdown);
2167 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSLdown, ILdown);
2168 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
2170 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
2173 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp,&dimLdown);
2175 double * ptr = Dleft[l_index-theindex-1][1]->gStorage(NL,TwoSLdown,ILdown,NL,TwoSL,IL);
2179 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2192 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2193 for (
int TwoSLdown=TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
2195 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
2196 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
2197 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
2199 int fase =
phase(3 + TwoS1 - TwoJdown);
2200 const double factor = fase * sqrt(3.0*(TwoSR+1)*(TwoJdown+1)*(TwoSL+1))
2201 *
Wigner::wigner9j(2, TwoSLdown, TwoSL, 1, TwoSRdown, TwoSR, 1, TwoJdown, TwoS1);
2203 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
2205 #ifdef CHEMPS2_MPI_COMPILATION 2206 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex+1, l_index ) == MPIRANK )
2211 int memSkappa = denS->gKappa(NL, TwoSLdown, ILdown, N1, 1, TwoJdown, NR-1, TwoSRdown, IRdown);
2215 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSLdown, ILdown);
2216 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-1, TwoSRdown, IRdown);
2218 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
2221 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRdown,&beta,temp,&dimLdown);
2223 double * ptr = Dleft[l_index-theindex-1][1]->gStorage(NL,TwoSLdown,ILdown,NL,TwoSL,IL);
2227 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2241 for (
int TwoSRdown = TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2242 for (
int TwoSLdown = TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
2244 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
2245 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
2246 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
2248 int fase =
phase(TwoSRdown - TwoSR + TwoSLdown - TwoSL + TwoS1 - TwoJdown);
2249 const double factor = fase * sqrt(3.0*(TwoSRdown+1)*(TwoJdown+1)*(TwoSLdown+1))
2250 *
Wigner::wigner9j(2, TwoSLdown, TwoSL, 1, TwoSRdown, TwoSR, 1, TwoJdown, TwoS1);
2252 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
2254 #ifdef CHEMPS2_MPI_COMPILATION 2255 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex+1, l_index ) == MPIRANK )
2260 int memSkappa = denS->gKappa(NL, TwoSLdown, ILdown, N1, 1, TwoJdown, NR+1, TwoSRdown, IRdown);
2264 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSLdown, ILdown);
2265 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
2267 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
2270 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
2272 double * ptr = Dleft[l_index-theindex-1][1]->gStorage(NL,TwoSL,IL,NL,TwoSLdown,ILdown);
2276 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2290 for (
int TwoSRdown = TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2291 for (
int TwoSLdown = TwoSL-2; TwoSLdown<=TwoSL+2; TwoSLdown+=2){
2292 if ((abs(TwoSLdown-TwoSRdown)<=TwoS1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
2294 int fase =
phase(3 + TwoS1 - TwoJ);
2295 const double factor = fase * sqrt(3.0*(TwoSRdown+1)*(TwoJ+1)*(TwoSLdown+1))
2296 *
Wigner::wigner9j(2, TwoSL, TwoSLdown, 1, TwoSR, TwoSRdown, 1, TwoJ, TwoS1);
2298 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
2300 #ifdef CHEMPS2_MPI_COMPILATION 2301 if ( MPIchemps2::owner_cdf( Prob->
gL(), theindex+1, l_index ) == MPIRANK )
2306 int memSkappa = denS->gKappa(NL, TwoSLdown, ILdown, N1, 2, TwoS1, NR+1, TwoSRdown, IRdown);
2310 int dimLdown = denBK->
gCurrentDim(theindex , NL, TwoSLdown, ILdown);
2311 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+1, TwoSRdown, IRdown);
2313 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
2316 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,Lblock,&dimRup,&beta,temp,&dimLdown);
2318 double * ptr = Dleft[l_index-theindex-1][1]->gStorage(NL,TwoSL,IL,NL,TwoSLdown,ILdown);
2322 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,ptr,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2334 void CheMPS2::Heff::addDiagram4D(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft,
double * temp)
const{
2336 #ifdef CHEMPS2_MPI_COMPILATION 2340 int NL = denS->gNL(ikappa);
2341 int TwoSL = denS->gTwoSL(ikappa);
2342 int IL = denS->gIL(ikappa);
2344 int NR = denS->gNR(ikappa);
2345 int TwoSR = denS->gTwoSR(ikappa);
2346 int IR = denS->gIR(ikappa);
2348 int N1 = denS->gN1(ikappa);
2349 int N2 = denS->gN2(ikappa);
2350 int TwoJ = denS->gTwoJ(ikappa);
2352 int theindex = denS->gIndex();
2353 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
2354 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
2363 #ifdef CHEMPS2_MPI_COMPILATION 2364 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4D1AB ) == MPIRANK ) && (N1==0) && (N2>0)){
2366 if ((N1==0) && (N2>0)){
2369 int TwoS2down = (N2==1)?0:1;
2370 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
2371 if (abs(TwoSLdown-TwoSR)<=TwoS2down){
2373 int dimLdown = denBK->
gCurrentDim(theindex,NL-1,TwoSLdown,ILdown);
2376 int size = dimLup * dimLdown;
2377 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
2380 for (
int l_index=0; l_index<theindex; l_index++){
2381 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex+1)){
2382 double alpha = Prob->
gMxElement(l_index,theindex+1,theindex,theindex);
2383 double * Lblock = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
2384 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
2391 double factor = -1.0;
2393 int fase =
phase(TwoSR+1-TwoSL);
2394 factor = fase * sqrt((TwoSL+1.0)/(TwoSR+1.0));
2396 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,2,N2-1,TwoS2down,NR,TwoSR,IR);
2397 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,temp,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2405 #ifdef CHEMPS2_MPI_COMPILATION 2406 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4D2AB ) == MPIRANK ) && (N1==2) && (N2<2)){
2408 if ((N1==2) && (N2<2)){
2411 int TwoS2down = (N2==0)?1:0;
2412 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
2413 if (abs(TwoSLdown-TwoSR)<=TwoS2down){
2415 int dimLdown = denBK->
gCurrentDim(theindex,NL+1,TwoSLdown,ILdown);
2418 int size = dimLup * dimLdown;
2419 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
2422 for (
int l_index=0; l_index<theindex; l_index++){
2423 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex+1)){
2424 double alpha = Prob->
gMxElement(l_index,theindex+1,theindex,theindex);
2425 double * Lblock = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
2426 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
2433 double factor = -1.0;
2435 int fase =
phase(TwoSR+1-TwoSLdown);
2436 factor = fase * sqrt((TwoSLdown+1.0)/(TwoSR+1.0));
2438 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,0,N2+1,TwoS2down,NR,TwoSR,IR);
2439 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,temp,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2447 #ifdef CHEMPS2_MPI_COMPILATION 2448 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4D3ABCD ) == MPIRANK ) && (N1>0) && (N2<2)){
2450 if ((N1>0) && (N2<2)){
2453 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
2455 int dimLdown = denBK->
gCurrentDim(theindex,NL-1,TwoSLdown,ILdown);
2458 int TwoSdownSum = ((N1==1)?1:0) + ((N2==0)?1:0);
2459 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoSdownSum<2)) ? TwoSdownSum : 0;
2460 for (
int TwoJdown = TwoJstart ; TwoJdown <= TwoSdownSum ; TwoJdown+=2){
2461 if (abs(TwoSLdown-TwoSR)<=TwoJdown){
2463 int size = dimLup * dimLdown;
2464 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
2466 double alpha_fact = 0.0;
2467 if ((N1==1) && (N2==0)){
2468 int fase =
phase(TwoSLdown + TwoSR + 2);
2469 alpha_fact = fase * sqrt((TwoSL+1.0)*(TwoJdown+1)) *
Wigner::wigner6j(TwoJdown,1,1,TwoSL,TwoSLdown,TwoSR);
2471 if ((N1==1) && (N2==1)){
2472 int fase =
phase(TwoSLdown + TwoSR + 3 + TwoJ);
2473 alpha_fact = fase * sqrt((TwoSL+1.0)*(TwoJ+1)) *
Wigner::wigner6j(TwoSL,TwoSR,TwoJ,1,1,TwoSLdown);
2475 if ((N1==2) && (N2==0)){
2478 if ((N1==2) && (N2==1)){
2479 int fase =
phase(TwoSL+1-TwoSR);
2480 alpha_fact = fase * sqrt((TwoSL+1.0)/(TwoSR+1.0));
2484 for (
int l_index=0; l_index<theindex; l_index++){
2485 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex+1)){
2488 if ((N1==1) && (N2==0)){
2489 alpha = alpha_fact * ( Prob->
gMxElement(l_index, theindex, theindex, theindex+1) + ((TwoJdown==0)?1:-1) * Prob->
gMxElement(l_index, theindex, theindex+1, theindex) );
2491 if ((N1==1) && (N2==1)){
2492 alpha = alpha_fact * Prob->
gMxElement(l_index,theindex,theindex+1,theindex);
2494 alpha += sqrt(2.0) * Prob->
gMxElement(l_index,theindex,theindex,theindex+1);
2498 alpha = alpha_fact * ( Prob->
gMxElement(l_index, theindex, theindex, theindex+1) - 2 * Prob->
gMxElement(l_index, theindex, theindex+1, theindex) );
2501 double * Lblock = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
2502 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
2509 double factor = 1.0;
2510 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,N2+1,TwoJdown,NR,TwoSR,IR);
2511 dgemm_(&trans,¬rans,&dimLup,&dimR,&dimLdown,&factor,temp,&dimLdown,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2520 #ifdef CHEMPS2_MPI_COMPILATION 2521 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4D4ABCD ) == MPIRANK ) && (N1>0) && (N2>0)){
2523 if ((N1>0) && (N2>0)){
2526 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
2528 int dimLdown = denBK->
gCurrentDim(theindex,NL+1,TwoSLdown,ILdown);
2533 int TwoSdownSum = ((N1==1)?1:0) + ((N2==2)?1:0);
2534 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoSdownSum<2)) ? TwoSdownSum : 0;
2535 for (
int TwoJdown = TwoJstart ; TwoJdown <= TwoSdownSum ; TwoJdown+=2){
2536 if (abs(TwoSLdown-TwoSR)<=TwoJdown){
2538 int size = dimLup * dimLdown;
2539 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
2541 double alpha_fact = 0.0;
2542 if ((N1==1) && (N2==1)){
2543 int fase =
phase(TwoSL + TwoSR + 2);
2544 alpha_fact = fase * sqrt((TwoSLdown+1.0)*(TwoJ+1)) *
Wigner::wigner6j(TwoJ,1,1,TwoSLdown,TwoSL,TwoSR);
2546 if ((N1==1) && (N2==2)){
2547 int fase =
phase(TwoSL + TwoSR + 3 + TwoJdown);
2548 alpha_fact = fase * sqrt((TwoSLdown+1.0)*(TwoJdown+1)) *
Wigner::wigner6j(TwoSLdown,TwoSR,TwoJdown,1,1,TwoSL);
2550 if ((N1==2) && (N2==1)){
2553 if ((N1==2) && (N2==2)){
2554 int fase =
phase(TwoSLdown+1-TwoSR);
2555 alpha_fact = fase * sqrt((TwoSLdown+1.0)/(TwoSR+1.0));
2559 for (
int l_index=0; l_index<theindex; l_index++){
2560 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex+1)){
2563 if ((N1==1) && (N2==1)){
2564 alpha = alpha_fact * ( Prob->
gMxElement(l_index, theindex, theindex, theindex+1) + ((TwoJ==0)?1:-1) * Prob->
gMxElement(l_index, theindex, theindex+1, theindex) );
2566 if ((N1==1) && (N2==2)){
2567 alpha = alpha_fact * Prob->
gMxElement(l_index,theindex,theindex+1,theindex);
2569 alpha += sqrt(2.0) * Prob->
gMxElement(l_index,theindex,theindex,theindex+1);
2573 alpha = alpha_fact * ( Prob->
gMxElement(l_index, theindex, theindex, theindex+1) - 2 * Prob->
gMxElement(l_index, theindex, theindex+1, theindex) );
2576 double * Lblock = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
2577 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
2584 double factor = 1.0;
2585 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,N2-1,TwoJdown,NR,TwoSR,IR);
2586 dgemm_(¬rans,¬rans,&dimLup,&dimR,&dimLdown,&factor,temp,&dimLup,memS+denS->gKappa2index(memSkappa),&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2596 void CheMPS2::Heff::addDiagram4E(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorL ** Lright,
double * temp,
double * temp2)
const{
2598 #ifdef CHEMPS2_MPI_COMPILATION 2602 int NL = denS->gNL(ikappa);
2603 int TwoSL = denS->gTwoSL(ikappa);
2604 int IL = denS->gIL(ikappa);
2606 int NR = denS->gNR(ikappa);
2607 int TwoSR = denS->gTwoSR(ikappa);
2608 int IR = denS->gIR(ikappa);
2610 int N1 = denS->gN1(ikappa);
2611 int N2 = denS->gN2(ikappa);
2612 int TwoJ = denS->gTwoJ(ikappa);
2613 int TwoS2 = (N2==1)?1:0;
2615 int theindex = denS->gIndex();
2616 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
2617 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
2624 #ifdef CHEMPS2_MPI_COMPILATION 2625 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4E1 ) == MPIRANK ) && (N1==0)){
2630 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
2631 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2632 if ((abs(TwoSLdown-TwoSRdown)<=TwoJ) && (TwoSLdown>=0) && (TwoSRdown>=0)){
2634 int fase =
phase(TwoSL+TwoSR-TwoS2);
2635 const double factor = fase * sqrt((TwoSL+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j(TwoSL,TwoSR,TwoS2,TwoSRdown,TwoSLdown,1);
2641 int dimLdown = denBK->
gCurrentDim(theindex, NL-1,TwoSLdown,ILdown);
2642 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+1,TwoSRdown,IRdown);
2644 if ((dimLdown>0) && (dimRdown>0)){
2645 bool isPossibleLeft =
false;
2646 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
2647 if (Irrep == denBK->
gIrrep(l_alpha)){ isPossibleLeft =
true; }
2649 bool isPossibleRight =
false;
2650 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
2651 if (Irrep == denBK->
gIrrep(l_beta)){ isPossibleRight =
true; }
2653 if ( (isPossibleLeft) && (isPossibleRight) ){
2655 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
2656 if (Irrep == denBK->
gIrrep(l_alpha)){
2658 int size = dimRup * dimRdown;
2659 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
2660 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
2661 if (Irrep == denBK->
gIrrep(l_beta)){
2662 double * LblockRight = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
2663 double prefact = Prob->
gMxElement(l_alpha,l_beta,theindex,theindex);
2664 daxpy_(&size,&prefact,LblockRight,&inc,temp,&inc);
2668 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,2,N2,TwoS2,NR+1,TwoSRdown,IRdown);
2669 double alpha = factor;
2671 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
2675 double * LblockLeft = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
2676 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockLeft,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2688 #ifdef CHEMPS2_MPI_COMPILATION 2689 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4E2 ) == MPIRANK ) && (N1==2)){
2694 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
2695 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2696 if ((abs(TwoSLdown-TwoSRdown)<=TwoJ) && (TwoSLdown>=0) && (TwoSRdown>=0)){
2698 int fase =
phase(TwoSLdown+TwoSRdown-TwoS2);
2699 const double factor = fase * sqrt((TwoSLdown+1)*(TwoSR+1.0)) *
Wigner::wigner6j(TwoSLdown,TwoSRdown,TwoS2,TwoSR,TwoSL,1);
2705 int dimLdown = denBK->
gCurrentDim(theindex, NL+1,TwoSLdown,ILdown);
2706 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-1,TwoSRdown,IRdown);
2708 if ((dimLdown>0) && (dimRdown>0)){
2709 bool isPossibleLeft =
false;
2710 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
2711 if (Irrep == denBK->
gIrrep(l_gamma)){ isPossibleLeft =
true; }
2713 bool isPossibleRight =
false;
2714 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
2715 if (Irrep == denBK->
gIrrep(l_delta)){ isPossibleRight =
true; }
2717 if ( (isPossibleLeft) && (isPossibleRight) ){
2719 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
2720 if (Irrep == denBK->
gIrrep(l_gamma)){
2722 int size = dimRup * dimRdown;
2723 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
2724 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
2725 if (Irrep == denBK->
gIrrep(l_delta)){
2726 double * LblockRight = Lright[l_delta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
2727 double prefact = Prob->
gMxElement(l_gamma,l_delta,theindex,theindex);
2728 daxpy_(&size,&prefact,LblockRight,&inc,temp,&inc);
2732 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,0,N2,TwoS2,NR-1,TwoSRdown,IRdown);
2733 double alpha = factor;
2735 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
2739 double * LblockLeft = Lleft[theindex-1-l_gamma]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
2740 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockLeft,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2752 #ifdef CHEMPS2_MPI_COMPILATION 2753 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4E3A ) == MPIRANK ) && (N1==1)){
2758 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
2759 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2761 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
2762 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
2763 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
2765 int fase =
phase(TwoSL + TwoSR + TwoJ + TwoSLdown + TwoSRdown + 1 - TwoS2);
2766 const double factor1 = fase * sqrt((TwoJ+1)*(TwoJdown+1)*(TwoSL+1)*(TwoSR+1.0)) *
Wigner::wigner6j(TwoSL, TwoSRdown, TwoS2, TwoJdown, 1, TwoSLdown) *
Wigner::wigner6j(TwoJ, 1, TwoS2, TwoSRdown, TwoSL, TwoSR);
2768 double factor2 = 0.0;
2769 if (TwoJ == TwoJdown){
2770 fase =
phase(TwoSL+TwoSRdown+TwoJ+3+2*TwoS2);
2771 factor2 = fase * sqrt((TwoSL+1)*(TwoSR+1.0)) *
Wigner::wigner6j(TwoSLdown, TwoSRdown, TwoJ, TwoSR, TwoSL, 1);
2778 int dimLdown = denBK->
gCurrentDim(theindex, NL-1,TwoSLdown,ILdown);
2779 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-1,TwoSRdown,IRdown);
2781 if ((dimLdown>0) && (dimRdown>0)){
2782 bool isPossibleLeft =
false;
2783 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
2784 if (Irrep == denBK->
gIrrep(l_alpha)){ isPossibleLeft =
true; }
2786 bool isPossibleRight =
false;
2787 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
2788 if (Irrep == denBK->
gIrrep(l_delta)){ isPossibleRight =
true; }
2790 if ( (isPossibleLeft) && (isPossibleRight) ){
2792 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
2793 if (Irrep == denBK->
gIrrep(l_alpha)){
2795 int size = dimRup * dimRdown;
2796 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
2797 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
2798 if (Irrep == denBK->
gIrrep(l_delta)){
2799 double * LblockRight = Lright[l_delta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
2800 double prefact = factor1 * Prob->
gMxElement(l_alpha,theindex,theindex,l_delta);
2801 if (TwoJ == TwoJdown){ prefact += factor2 * Prob->
gMxElement(l_alpha,theindex,l_delta,theindex); }
2802 daxpy_(&size,&prefact,LblockRight,&inc,temp,&inc);
2806 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,1,N2,TwoJdown,NR-1,TwoSRdown,IRdown);
2809 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
2812 double * LblockLeft = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
2813 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockLeft,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2826 #ifdef CHEMPS2_MPI_COMPILATION 2827 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4E3B ) == MPIRANK ) && (N1==2)){
2832 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
2833 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2834 if ((abs(TwoSLdown-TwoSRdown)<=TwoJ) && (TwoSLdown>=0) && (TwoSRdown>=0)){
2836 int fase =
phase(TwoSL + TwoSRdown - TwoS2 + 3);
2837 const double factor = fase * sqrt((TwoSL+1)*(TwoSR+1.0)) *
Wigner::wigner6j(TwoSLdown, TwoSRdown, TwoS2, TwoSR, TwoSL, 1);
2843 int dimLdown = denBK->
gCurrentDim(theindex, NL-1,TwoSLdown,ILdown);
2844 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-1,TwoSRdown,IRdown);
2846 if ((dimLdown>0) && (dimRdown>0)){
2847 bool isPossibleLeft =
false;
2848 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
2849 if (Irrep == denBK->
gIrrep(l_alpha)){ isPossibleLeft =
true; }
2851 bool isPossibleRight =
false;
2852 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
2853 if (Irrep == denBK->
gIrrep(l_delta)){ isPossibleRight =
true; }
2855 if ( (isPossibleLeft) && (isPossibleRight) ){
2857 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
2858 if (Irrep == denBK->
gIrrep(l_alpha)){
2860 int size = dimRup * dimRdown;
2861 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
2862 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
2863 if (Irrep == denBK->
gIrrep(l_delta)){
2864 double * LblockRight = Lright[l_delta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
2865 double prefact = Prob->
gMxElement(l_alpha,theindex,theindex,l_delta) - 2 * Prob->
gMxElement(l_alpha,theindex,l_delta,theindex);
2866 daxpy_(&size,&prefact,LblockRight,&inc,temp,&inc);
2870 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,2,N2,TwoS2,NR-1,TwoSRdown,IRdown);
2871 double alpha = factor;
2873 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta,temp2,&dimLdown);
2877 double * LblockLeft = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
2878 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockLeft,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2890 #ifdef CHEMPS2_MPI_COMPILATION 2891 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4E4A ) == MPIRANK ) && (N1==1)){
2896 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
2897 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2899 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
2900 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
2901 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
2903 int fase =
phase(TwoSL + TwoSR + TwoJdown + TwoSLdown + TwoSRdown + 1 - TwoS2);
2904 const double factor1 = fase * sqrt((TwoJ+1)*(TwoJdown+1)*(TwoSLdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j(TwoSLdown, TwoSR, TwoS2, TwoJ, 1, TwoSL) *
Wigner::wigner6j(TwoJdown, 1, TwoS2, TwoSR, TwoSLdown, TwoSRdown);
2906 double factor2 = 0.0;
2907 if (TwoJ == TwoJdown){
2908 fase =
phase(TwoSLdown+TwoSR+TwoJ+3+2*TwoS2);
2909 factor2 = fase * sqrt((TwoSLdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j(TwoSL, TwoSR, TwoJ, TwoSRdown, TwoSLdown, 1);
2916 int dimLdown = denBK->
gCurrentDim(theindex, NL+1,TwoSLdown,ILdown);
2917 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+1,TwoSRdown,IRdown);
2919 if ((dimLdown>0) && (dimRdown>0)){
2920 bool isPossibleLeft =
false;
2921 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
2922 if (Irrep == denBK->
gIrrep(l_gamma)){ isPossibleLeft =
true; }
2924 bool isPossibleRight =
false;
2925 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
2926 if (Irrep == denBK->
gIrrep(l_beta)){ isPossibleRight =
true; }
2928 if ( (isPossibleLeft) && (isPossibleRight) ){
2930 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
2931 if (Irrep == denBK->
gIrrep(l_gamma)){
2933 int size = dimRup * dimRdown;
2934 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
2935 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
2936 if (Irrep == denBK->
gIrrep(l_beta)){
2937 double * LblockRight = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
2938 double prefact = factor1 * Prob->
gMxElement(l_gamma,theindex,theindex,l_beta);
2939 if (TwoJ == TwoJdown){ prefact += factor2 * Prob->
gMxElement(l_gamma,theindex,l_beta,theindex); }
2940 daxpy_(&size,&prefact,LblockRight,&inc,temp,&inc);
2944 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,1,N2,TwoJdown,NR+1,TwoSRdown,IRdown);
2947 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
2950 double * LblockLeft = Lleft[theindex-1-l_gamma]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
2951 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockLeft,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
2964 #ifdef CHEMPS2_MPI_COMPILATION 2965 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4E4B ) == MPIRANK ) && (N1==2)){
2970 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
2971 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
2972 if ((abs(TwoSLdown-TwoSRdown)<=TwoJ) && (TwoSLdown>=0) && (TwoSRdown>=0)){
2974 int fase =
phase(TwoSLdown + TwoSR - TwoS2 + 3);
2975 const double factor = fase * sqrt((TwoSLdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j(TwoSL, TwoSR, TwoS2, TwoSRdown, TwoSLdown, 1);
2981 int dimLdown = denBK->
gCurrentDim(theindex, NL+1,TwoSLdown,ILdown);
2982 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+1,TwoSRdown,IRdown);
2984 if ((dimLdown>0) && (dimRdown>0)){
2985 bool isPossibleLeft =
false;
2986 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
2987 if (Irrep == denBK->
gIrrep(l_gamma)){ isPossibleLeft =
true; }
2989 bool isPossibleRight =
false;
2990 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
2991 if (Irrep == denBK->
gIrrep(l_beta)){ isPossibleRight =
true; }
2993 if ( (isPossibleLeft) && (isPossibleRight) ){
2995 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
2996 if (Irrep == denBK->
gIrrep(l_gamma)){
2998 int size = dimRup * dimRdown;
2999 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3000 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
3001 if (Irrep == denBK->
gIrrep(l_beta)){
3002 double * LblockRight = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
3003 double prefact = Prob->
gMxElement(l_gamma,theindex,theindex,l_beta) - 2 * Prob->
gMxElement(l_gamma,theindex,l_beta,theindex);
3004 daxpy_(&size,&prefact,LblockRight,&inc,temp,&inc);
3008 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,2,N2,TwoS2,NR+1,TwoSRdown,IRdown);
3009 double alpha = factor;
3011 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta,temp2,&dimLdown);
3015 double * LblockLeft = Lleft[theindex-1-l_gamma]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
3016 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockLeft,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
3029 void CheMPS2::Heff::addDiagram4F(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lright,
double * temp)
const{
3031 #ifdef CHEMPS2_MPI_COMPILATION 3035 int NL = denS->gNL(ikappa);
3036 int TwoSL = denS->gTwoSL(ikappa);
3037 int IL = denS->gIL(ikappa);
3039 int NR = denS->gNR(ikappa);
3040 int TwoSR = denS->gTwoSR(ikappa);
3041 int IR = denS->gIR(ikappa);
3043 int N1 = denS->gN1(ikappa);
3044 int N2 = denS->gN2(ikappa);
3045 int TwoJ = denS->gTwoJ(ikappa);
3047 int theindex = denS->gIndex();
3048 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
3049 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
3058 #ifdef CHEMPS2_MPI_COMPILATION 3059 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4F1AB ) == MPIRANK ) && (N1==2) && (N2<2)){
3061 if ((N1==2) && (N2<2)){
3064 int TwoS2down = (N2==1)?0:1;
3065 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3066 if (abs(TwoSL-TwoSRdown)<=TwoS2down){
3068 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-1,TwoSRdown,IRdown);
3071 int size = dimRup * dimRdown;
3072 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3075 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
3076 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex+1)){
3077 double alpha = Prob->
gMxElement(theindex,theindex,theindex+1,l_index);
3078 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
3079 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
3086 double factor = 0.0;
3088 factor = - sqrt((TwoSR+1.0)/(TwoSRdown+1.0));
3090 factor =
phase(TwoSR+1-TwoSRdown);
3092 int memSkappa = denS->gKappa(NL,TwoSL,IL,0,N2+1,TwoS2down,NR-1,TwoSRdown,IRdown);
3093 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&factor,memS+denS->gKappa2index(memSkappa),&dimL,temp,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
3101 #ifdef CHEMPS2_MPI_COMPILATION 3102 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4F2AB ) == MPIRANK ) && (N1==0) && (N2>0)){
3104 if ((N1==0) && (N2>0)){
3107 int TwoS2down = (N2==1)?0:1;
3108 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3109 if (abs(TwoSL-TwoSRdown)<=TwoS2down){
3111 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+1,TwoSRdown,IRdown);
3114 int size = dimRup * dimRdown;
3115 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3118 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
3119 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex+1)){
3120 double alpha = Prob->
gMxElement(theindex,theindex,theindex+1,l_index);
3121 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
3122 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
3129 double factor = 0.0;
3131 factor = - sqrt((TwoSRdown+1.0)/(TwoSR+1.0));
3133 factor =
phase(TwoSRdown+1-TwoSR);
3135 int memSkappa = denS->gKappa(NL,TwoSL,IL,2,N2-1,TwoS2down,NR+1,TwoSRdown,IRdown);
3136 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&factor,memS+denS->gKappa2index(memSkappa),&dimL,temp,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
3144 #ifdef CHEMPS2_MPI_COMPILATION 3145 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4F3ABCD ) == MPIRANK ) && (N1>0) && (N2>0)){
3147 if ((N1>0) && (N2>0)){
3150 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3152 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-1,TwoSRdown,IRdown);
3157 int TwoSdownSum = ((N1==1)?1:0) + ((N2==2)?1:0);
3158 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoSdownSum<2)) ? TwoSdownSum : 0;
3159 for (
int TwoJdown=TwoJstart ; TwoJdown<=TwoSdownSum ; TwoJdown+=2){
3160 if (abs(TwoSL-TwoSRdown)<=TwoJdown){
3162 int size = dimRup * dimRdown;
3163 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3165 double factor = 0.0;
3166 double factor2 = 0.0;
3167 if ((N1==1) && (N2==1)){
3168 int fase =
phase(TwoSL+TwoSR+2);
3169 factor = fase * sqrt((TwoSR+1.0)*(TwoJ+1)) *
Wigner::wigner6j(TwoJ, 1, 1, TwoSRdown, TwoSR, TwoSL);
3171 if ((N1==1) && (N2==2)){
3172 int fase =
phase(TwoSL+TwoSR+3);
3173 factor = fase * sqrt((TwoSR+1.0)*(TwoJdown+1)) *
Wigner::wigner6j(TwoJdown, 1, 1, TwoSR, TwoSRdown, TwoSL);
3174 factor2 = (TwoJdown==0) ? sqrt(2.0*(TwoSR+1.0)/(TwoSRdown+1.0)) : 0.0;
3176 if ((N1==2) && (N2==1)){
3177 factor = sqrt((TwoSR+1.0)/(TwoSRdown+1.0));
3179 if ((N1==2) && (N2==2)){
3180 factor =
phase(TwoSR + 1 - TwoSRdown);
3184 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
3185 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex+1)){
3186 double prefact = 0.0;
3187 if ((N1==1) && (N2==1)){
3188 prefact = factor * ( Prob->
gMxElement(theindex,theindex+1,theindex,l_index)
3189 + ((TwoJ==0)?1:-1) * Prob->
gMxElement(theindex,theindex+1,l_index,theindex) );
3191 if ((N1==1) && (N2==2)){
3192 prefact = factor * Prob->
gMxElement(theindex,theindex+1,theindex,l_index);
3193 if (TwoJdown==0){ prefact += factor2 * Prob->
gMxElement(theindex,theindex+1,l_index,theindex); }
3196 prefact = factor * ( 2 * Prob->
gMxElement(theindex,theindex+1,theindex,l_index)
3197 - Prob->
gMxElement(theindex,theindex+1,l_index,theindex) );
3200 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
3201 daxpy_(&size,&prefact,Lblock,&inc,temp,&inc);
3209 int memSkappa = denS->gKappa(NL,TwoSL,IL,N1,N2-1,TwoJdown,NR-1,TwoSRdown,IRdown);
3210 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,temp,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
3220 #ifdef CHEMPS2_MPI_COMPILATION 3221 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4F4ABCD ) == MPIRANK ) && (N1>0) && (N2<2)){
3223 if ((N1>0) && (N2<2)){
3226 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3228 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+1,TwoSRdown,IRdown);
3233 int TwoSdownSum = ((N1==1)?1:0) + ((N2==0)?1:0);
3234 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoSdownSum<2)) ? TwoSdownSum : 0;
3235 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoSdownSum ; TwoJdown+=2){
3236 if (abs(TwoSL-TwoSRdown)<=TwoJdown){
3238 int size = dimRup * dimRdown;
3239 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3241 double factor = 0.0;
3242 double factor2 = 0.0;
3243 if ((N1==1) && (N2==0)){
3244 int fase =
phase(TwoSL+TwoSRdown+2);
3245 factor = fase * sqrt((TwoSRdown+1.0)*(TwoJdown+1)) *
Wigner::wigner6j(TwoJdown, 1, 1, TwoSR, TwoSRdown, TwoSL);
3247 if ((N1==1) && (N2==1)){
3248 int fase =
phase(TwoSL+TwoSRdown+3);
3249 factor = fase * sqrt((TwoSRdown+1.0)*(TwoJ+1)) *
Wigner::wigner6j(TwoJ, 1, 1, TwoSRdown, TwoSR, TwoSL);
3250 factor2 = (TwoJ==0) ? sqrt(2.0*(TwoSRdown+1.0)/(TwoSR+1.0)) : 0.0;
3252 if ((N1==2) && (N2==0)){
3253 factor = sqrt((TwoSRdown+1.0)/(TwoSR+1.0));
3255 if ((N1==2) && (N2==1)){
3256 factor =
phase(TwoSRdown + 1 - TwoSR);
3260 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
3261 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex+1)){
3262 double prefact = 0.0;
3263 if ((N1==1) && (N2==0)){
3264 prefact = factor * ( Prob->
gMxElement(theindex,theindex+1,theindex,l_index)
3265 + ((TwoJdown==0)?1:-1) * Prob->
gMxElement(theindex,theindex+1,l_index,theindex) );
3267 if ((N1==1) && (N2==1)){
3268 prefact = factor * Prob->
gMxElement(theindex,theindex+1,theindex,l_index);
3269 if (TwoJ==0){ prefact += factor2 * Prob->
gMxElement(theindex,theindex+1,l_index,theindex); }
3272 prefact = factor * ( 2 * Prob->
gMxElement(theindex,theindex+1,theindex,l_index)
3273 - Prob->
gMxElement(theindex,theindex+1,l_index,theindex) );
3276 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
3277 daxpy_(&size,&prefact,Lblock,&inc,temp,&inc);
3285 int memSkappa = denS->gKappa(NL,TwoSL,IL,N1,N2+1,TwoJdown,NR+1,TwoSRdown,IRdown);
3286 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,temp,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
3297 void CheMPS2::Heff::addDiagram4G(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lright,
double * temp)
const{
3299 #ifdef CHEMPS2_MPI_COMPILATION 3303 int NL = denS->gNL(ikappa);
3304 int TwoSL = denS->gTwoSL(ikappa);
3305 int IL = denS->gIL(ikappa);
3307 int NR = denS->gNR(ikappa);
3308 int TwoSR = denS->gTwoSR(ikappa);
3309 int IR = denS->gIR(ikappa);
3311 int N1 = denS->gN1(ikappa);
3312 int N2 = denS->gN2(ikappa);
3313 int TwoJ = denS->gTwoJ(ikappa);
3315 int theindex = denS->gIndex();
3316 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
3317 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
3326 #ifdef CHEMPS2_MPI_COMPILATION 3327 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4G1AB ) == MPIRANK ) && (N1<2) && (N2==2)){
3329 if ((N1<2) && (N2==2)){
3332 int TwoS1down = (N1==1)?0:1;
3333 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3334 if (abs(TwoSL-TwoSRdown)<=TwoS1down){
3336 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-1,TwoSRdown,IRdown);
3339 int size = dimRup * dimRdown;
3340 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3343 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
3344 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex)){
3345 double alpha = Prob->
gMxElement(theindex,l_index,theindex+1,theindex+1);
3346 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
3347 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
3354 double factor = 0.0;
3356 factor = - sqrt((TwoSR+1.0)/(TwoSRdown+1.0));
3358 factor =
phase(TwoSR+1-TwoSRdown);
3360 int memSkappa = denS->gKappa(NL,TwoSL,IL,N1+1,0,TwoS1down,NR-1,TwoSRdown,IRdown);
3361 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&factor,memS+denS->gKappa2index(memSkappa),&dimL,temp,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
3369 #ifdef CHEMPS2_MPI_COMPILATION 3370 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4G2AB ) == MPIRANK ) && (N1>0) && (N2==0)){
3372 if ((N1>0) && (N2==0)){
3375 int TwoS1down = (N1==1)?0:1;
3376 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3377 if (abs(TwoSL-TwoSRdown)<=TwoS1down){
3379 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+1,TwoSRdown,IRdown);
3382 int size = dimRup * dimRdown;
3383 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3386 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
3387 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex)){
3388 double alpha = Prob->
gMxElement(theindex,l_index,theindex+1,theindex+1);
3389 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
3390 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
3397 double factor = 0.0;
3399 factor = - sqrt((TwoSRdown+1.0)/(TwoSR+1.0));
3401 factor =
phase(TwoSRdown+1-TwoSR);
3403 int memSkappa = denS->gKappa(NL,TwoSL,IL,N1-1,2,TwoS1down,NR+1,TwoSRdown,IRdown);
3404 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&factor,memS+denS->gKappa2index(memSkappa),&dimL,temp,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
3413 #ifdef CHEMPS2_MPI_COMPILATION 3414 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4G3ABCD ) == MPIRANK ) && (N1<2) && (N2>0)){
3416 if ((N1<2) && (N2>0)){
3419 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3421 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+1,TwoSRdown,IRdown);
3426 int TwoSdownSum = ((N1==1)?0:1) + ((N2==1)?1:0);
3427 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoSdownSum<2))? TwoSdownSum : 0;
3428 for (
int TwoJdown = TwoJstart; TwoJdown <= TwoSdownSum ; TwoJdown+=2){
3429 if (abs(TwoSL-TwoSRdown)<=TwoJdown){
3431 int size = dimRup * dimRdown;
3432 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3434 double alpha_prefact = 0.0;
3435 double alpha_prefact2 = 0.0;
3436 if ((N1==0) && (N2==1)){
3437 int fase =
phase(TwoSL + TwoSRdown + 2);
3438 alpha_prefact = fase * sqrt((TwoJdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j(TwoJdown, 1, 1, TwoSR, TwoSRdown, TwoSL);
3440 if ((N1==1) && (N2==1)){
3441 int fase =
phase(TwoSL + TwoSRdown + TwoJ + 3);
3442 alpha_prefact = fase * sqrt((TwoJ+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j(TwoJ, 1, 1, TwoSRdown, TwoSR, TwoSL);
3443 alpha_prefact2 = (TwoJ==0)? sqrt(2.0*(TwoSRdown+1.0)/(TwoSR+1.0)) : 0.0;
3445 if ((N1==0) && (N2==2)){
3446 alpha_prefact = - sqrt((TwoSRdown+1.0)/(TwoSR+1.0));
3448 if ((N1==1) && (N2==2)){
3449 alpha_prefact =
phase(TwoSR + 1 - TwoSRdown);
3453 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
3454 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex)){
3457 if ((N1==0) && (N2==1)){
3458 alpha = alpha_prefact * ( Prob->
gMxElement(theindex,theindex+1,theindex+1,l_index) + ((TwoJdown==0)?1:-1) * Prob->
gMxElement(theindex,theindex+1,l_index,theindex+1) );
3460 if ((N1==1) && (N2==1)){
3461 alpha = alpha_prefact * Prob->
gMxElement(theindex,theindex+1,l_index,theindex+1);
3462 if (TwoJ==0){ alpha += alpha_prefact2 * Prob->
gMxElement(theindex,theindex+1,theindex+1,l_index); }
3465 alpha = alpha_prefact * (Prob->
gMxElement(theindex,theindex+1,theindex+1,l_index) - 2 * Prob->
gMxElement(theindex,theindex+1,l_index,theindex+1) );
3468 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
3469 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
3476 double factor = 1.0;
3477 int memSkappa = denS->gKappa(NL,TwoSL,IL,N1+1,N2,TwoJdown,NR+1,TwoSRdown,IRdown);
3478 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&factor,memS+denS->gKappa2index(memSkappa),&dimL,temp,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
3487 #ifdef CHEMPS2_MPI_COMPILATION 3488 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4G4ABCD ) == MPIRANK ) && (N1>0) && (N2>0)){
3490 if ((N1>0) && (N2>0)){
3493 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3495 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-1,TwoSRdown,IRdown);
3500 int TwoSdownSum = ((N1==1)?0:1) + ((N2==1)?1:0);
3501 int TwoJstart = ((TwoSL!=TwoSRdown) || (TwoSdownSum < 2)) ? TwoSdownSum : 0;
3502 for (
int TwoJdown = TwoJstart ; TwoJdown <= TwoSdownSum ; TwoJdown+=2){
3503 if (abs(TwoSL-TwoSRdown)<=TwoJdown){
3505 int size = dimRup * dimRdown;
3506 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3508 double alpha_prefact = 0.0;
3509 double alpha_prefact2 = 0.0;
3510 if ((N1==1) && (N2==1)){
3511 int fase =
phase(TwoSL + TwoSR + 2);
3512 alpha_prefact = fase * sqrt((TwoJ+1)*(TwoSR+1.0)) *
Wigner::wigner6j(TwoJ, 1, 1, TwoSRdown, TwoSR, TwoSL);
3514 if ((N1==2) && (N2==1)){
3515 int fase =
phase(TwoSL + TwoSR + TwoJdown + 3);
3516 alpha_prefact = fase * sqrt((TwoJdown+1)*(TwoSR+1.0)) *
Wigner::wigner6j(TwoJdown, 1, 1, TwoSR, TwoSRdown, TwoSL);
3517 alpha_prefact2 = (TwoJdown==0) ? sqrt(2.0*(TwoSR+1.0)/(TwoSRdown+1.0)) : 0.0;
3519 if ((N1==1) && (N2==2)){
3520 alpha_prefact = - sqrt((TwoSR+1.0)/(TwoSRdown+1.0));
3522 if ((N1==2) && (N2==2)){
3523 alpha_prefact =
phase(TwoSRdown + 1 - TwoSR);
3527 for (
int l_index=theindex+2; l_index<Prob->
gL(); l_index++){
3528 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex)){
3531 if ((N1==1) && (N2==1)){
3532 alpha = alpha_prefact * ( Prob->
gMxElement(theindex,theindex+1,theindex+1,l_index) + ((TwoJ==0)?1:-1) * Prob->
gMxElement(theindex,theindex+1,l_index,theindex+1) );
3534 if ((N1==2) && (N2==1)){
3535 alpha = alpha_prefact * Prob->
gMxElement(theindex,theindex+1,l_index,theindex+1);
3536 if (TwoJdown==0){ alpha += alpha_prefact2 * Prob->
gMxElement(theindex,theindex+1,theindex+1,l_index); }
3539 alpha = alpha_prefact * (Prob->
gMxElement(theindex,theindex+1,theindex+1,l_index) - 2 * Prob->
gMxElement(theindex,theindex+1,l_index,theindex+1) );
3542 double * Lblock = Lright[l_index-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
3543 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
3550 double factor = 1.0;
3551 int memSkappa = denS->gKappa(NL,TwoSL,IL,N1-1,N2,TwoJdown,NR-1,TwoSRdown,IRdown);
3552 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&factor,memS+denS->gKappa2index(memSkappa),&dimL,temp,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimL);
3563 void CheMPS2::Heff::addDiagram4H(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorL ** Lright,
double * temp,
double * temp2)
const{
3565 #ifdef CHEMPS2_MPI_COMPILATION 3569 int NL = denS->gNL(ikappa);
3570 int TwoSL = denS->gTwoSL(ikappa);
3571 int IL = denS->gIL(ikappa);
3573 int NR = denS->gNR(ikappa);
3574 int TwoSR = denS->gTwoSR(ikappa);
3575 int IR = denS->gIR(ikappa);
3577 int N1 = denS->gN1(ikappa);
3578 int N2 = denS->gN2(ikappa);
3579 int TwoJ = denS->gTwoJ(ikappa);
3580 int TwoS1 = (N1==1)?1:0;
3582 int theindex = denS->gIndex();
3583 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
3584 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
3590 #ifdef CHEMPS2_MPI_COMPILATION 3591 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4H1 ) == MPIRANK ) && (N2==2)){
3596 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3597 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
3598 if ((abs(TwoSLdown-TwoSRdown)<=TwoJ) && (TwoSLdown>=0) && (TwoSRdown>=0)){
3600 int fase =
phase(TwoSLdown + TwoSRdown - TwoS1);
3601 const double factor = fase * sqrt((TwoSLdown+1)*(TwoSR+1.0)) *
Wigner::wigner6j(TwoSL, TwoSR, TwoS1, TwoSRdown, TwoSLdown, 1);
3607 int dimLdown = denBK->
gCurrentDim(theindex, NL+1,TwoSLdown,ILdown);
3608 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-1,TwoSRdown,IRdown);
3610 if ((dimLdown>0) && (dimRdown>0)){
3611 bool isPossibleLeft =
false;
3612 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
3613 if (Irrep == denBK->
gIrrep(l_gamma)){ isPossibleLeft =
true; }
3615 bool isPossibleRight =
false;
3616 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
3617 if (Irrep == denBK->
gIrrep(l_delta)){ isPossibleRight =
true; }
3619 if ( (isPossibleLeft) && (isPossibleRight) ){
3621 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
3622 if (Irrep == denBK->
gIrrep(l_gamma)){
3624 int size = dimRup * dimRdown;
3625 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3627 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
3628 if (Irrep == denBK->
gIrrep(l_delta)){
3629 double fact = factor * Prob->
gMxElement(l_gamma,l_delta,theindex+1,theindex+1);
3630 double * LblockR = Lright[l_delta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
3632 daxpy_(&size,&fact,LblockR,&inc,temp,&inc);
3638 double * LblockL = Lleft[theindex-1-l_gamma]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
3640 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,0,TwoS1,NR-1,TwoSRdown,IRdown);
3641 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta, temp2,&dimLdown);
3644 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
3657 #ifdef CHEMPS2_MPI_COMPILATION 3658 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4H2 ) == MPIRANK ) && (N2==0)){
3663 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3664 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
3665 if ((abs(TwoSLdown-TwoSRdown)<=TwoJ) && (TwoSLdown>=0) && (TwoSRdown>=0)){
3667 int fase =
phase(TwoSL + TwoSR - TwoS1);
3668 const double factor = fase * sqrt((TwoSL+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j(TwoSLdown, TwoSRdown, TwoS1, TwoSR, TwoSL, 1);
3674 int dimLdown = denBK->
gCurrentDim(theindex, NL-1,TwoSLdown,ILdown);
3675 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+1,TwoSRdown,IRdown);
3677 if ((dimLdown>0) && (dimRdown>0)){
3678 bool isPossibleLeft =
false;
3679 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
3680 if (Irrep == denBK->
gIrrep(l_alpha)){ isPossibleLeft =
true; }
3682 bool isPossibleRight =
false;
3683 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
3684 if (Irrep == denBK->
gIrrep(l_beta)){ isPossibleRight =
true; }
3686 if ( (isPossibleLeft) && (isPossibleRight) ){
3688 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
3689 if (Irrep == denBK->
gIrrep(l_alpha)){
3691 int size = dimRup * dimRdown;
3692 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3694 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
3695 if (Irrep == denBK->
gIrrep(l_beta)){
3696 double fact = factor * Prob->
gMxElement(l_alpha,l_beta,theindex+1,theindex+1);
3697 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
3699 daxpy_(&size,&fact,LblockR,&inc,temp,&inc);
3705 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
3707 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,2,TwoS1,NR+1,TwoSRdown,IRdown);
3708 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta, temp2,&dimLdown);
3711 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
3724 #ifdef CHEMPS2_MPI_COMPILATION 3725 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4H3A ) == MPIRANK ) && (N2==1)){
3730 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3731 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
3733 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
3734 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
3735 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
3737 int fase =
phase(TwoSL+TwoSR+TwoSLdown+TwoSRdown+TwoJdown+1-TwoS1);
3738 const double factor1 = fase * sqrt((TwoJ+1)*(TwoJdown+1)*(TwoSL+1)*(TwoSR+1.0)) *
Wigner::wigner6j(TwoSL, TwoSRdown, TwoS1, TwoJdown, 1, TwoSLdown) *
Wigner::wigner6j(TwoJ, 1, TwoS1, TwoSRdown, TwoSL, TwoSR);
3740 double factor2 = 0.0;
3741 if (TwoJ == TwoJdown){
3742 fase =
phase(TwoSL+TwoSRdown+TwoJ+3+2*TwoS1);
3743 factor2 = fase * sqrt((TwoSL+1)*(TwoSR+1.0)) *
Wigner::wigner6j(TwoSLdown, TwoSRdown, TwoJ, TwoSR, TwoSL, 1);
3750 int dimLdown = denBK->
gCurrentDim(theindex, NL-1,TwoSLdown,ILdown);
3751 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-1,TwoSRdown,IRdown);
3753 if ((dimLdown>0) && (dimRdown>0)){
3754 bool isPossibleLeft =
false;
3755 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
3756 if (Irrep == denBK->
gIrrep(l_alpha)){ isPossibleLeft =
true; }
3758 bool isPossibleRight =
false;
3759 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
3760 if (Irrep == denBK->
gIrrep(l_delta)){ isPossibleRight =
true; }
3762 if ( (isPossibleLeft) && (isPossibleRight) ){
3764 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
3765 if (Irrep == denBK->
gIrrep(l_alpha)){
3767 int size = dimRup * dimRdown;
3768 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3770 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
3771 if (Irrep == denBK->
gIrrep(l_delta)){
3772 double fact = factor1 * Prob->
gMxElement(l_alpha,theindex+1,theindex+1,l_delta);
3773 if (TwoJ==TwoJdown){ fact += factor2 * Prob->
gMxElement(l_alpha,theindex+1,l_delta,theindex+1); }
3774 double * LblockR = Lright[l_delta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
3776 daxpy_(&size,&fact,LblockR,&inc,temp,&inc);
3782 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
3784 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,1,TwoJdown,NR-1,TwoSRdown,IRdown);
3785 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta, temp2,&dimLdown);
3788 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
3802 #ifdef CHEMPS2_MPI_COMPILATION 3803 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4H3B ) == MPIRANK ) && (N2==2)){
3808 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3809 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
3810 if ((abs(TwoSLdown-TwoSRdown)<=TwoJ) && (TwoSLdown>=0) && (TwoSRdown>=0)){
3812 int fase =
phase(TwoSL+TwoSRdown+3-TwoS1);
3813 const double factor = fase * sqrt((TwoSL+1)*(TwoSR+1.0)) *
Wigner::wigner6j(TwoSLdown, TwoSRdown, TwoS1, TwoSR, TwoSL, 1);
3819 int dimLdown = denBK->
gCurrentDim(theindex, NL-1,TwoSLdown,ILdown);
3820 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-1,TwoSRdown,IRdown);
3822 if ((dimLdown>0) && (dimRdown>0)){
3823 bool isPossibleLeft =
false;
3824 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
3825 if (Irrep == denBK->
gIrrep(l_alpha)){ isPossibleLeft =
true; }
3827 bool isPossibleRight =
false;
3828 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
3829 if (Irrep == denBK->
gIrrep(l_delta)){ isPossibleRight =
true; }
3831 if ( (isPossibleLeft) && (isPossibleRight) ){
3833 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
3834 if (Irrep == denBK->
gIrrep(l_alpha)){
3836 int size = dimRup * dimRdown;
3837 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3839 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
3840 if (Irrep == denBK->
gIrrep(l_delta)){
3841 double fact = factor * ( Prob->
gMxElement(l_alpha,theindex+1,theindex+1,l_delta) - 2 * Prob->
gMxElement(l_alpha,theindex+1,l_delta,theindex+1) );
3842 double * LblockR = Lright[l_delta-theindex-2]->gStorage(NR-1,TwoSRdown,IRdown,NR,TwoSR,IR);
3844 daxpy_(&size,&fact,LblockR,&inc,temp,&inc);
3850 double * LblockL = Lleft[theindex-1-l_alpha]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
3852 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,2,TwoS1,NR-1,TwoSRdown,IRdown);
3853 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRdown,&beta, temp2,&dimLdown);
3856 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLdown,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
3869 #ifdef CHEMPS2_MPI_COMPILATION 3870 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4H4A ) == MPIRANK ) && (N2==1)){
3875 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3876 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
3878 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
3879 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
3880 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
3882 int fase =
phase(TwoSL+TwoSR+TwoSLdown+TwoSRdown+TwoJ+1-TwoS1);
3883 const double factor1 = fase * sqrt((TwoJ+1)*(TwoJdown+1)*(TwoSLdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j(TwoSLdown, TwoSR, TwoS1, TwoJ, 1, TwoSL) *
Wigner::wigner6j(TwoJdown, 1, TwoS1, TwoSR, TwoSLdown, TwoSRdown);
3885 double factor2 = 0.0;
3886 if (TwoJ == TwoJdown){
3887 fase =
phase(TwoSLdown+TwoSR+TwoJ+3+2*TwoS1);
3888 factor2 = fase * sqrt((TwoSLdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j(TwoSL, TwoSR, TwoJ, TwoSRdown, TwoSLdown, 1);
3895 int dimLdown = denBK->
gCurrentDim(theindex, NL+1,TwoSLdown,ILdown);
3896 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+1,TwoSRdown,IRdown);
3898 if ((dimLdown>0) && (dimRdown>0)){
3899 bool isPossibleLeft =
false;
3900 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
3901 if (Irrep == denBK->
gIrrep(l_gamma)){ isPossibleLeft =
true; }
3903 bool isPossibleRight =
false;
3904 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
3905 if (Irrep == denBK->
gIrrep(l_beta)){ isPossibleRight =
true; }
3907 if ( (isPossibleLeft) && (isPossibleRight) ){
3909 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
3910 if (Irrep == denBK->
gIrrep(l_gamma)){
3912 int size = dimRup * dimRdown;
3913 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3915 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
3916 if (Irrep == denBK->
gIrrep(l_beta)){
3917 double fact = factor1 * Prob->
gMxElement(l_gamma,theindex+1,theindex+1,l_beta);
3918 if (TwoJ==TwoJdown){ fact += factor2 * Prob->
gMxElement(l_gamma,theindex+1,l_beta,theindex+1); }
3919 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
3921 daxpy_(&size,&fact,LblockR,&inc,temp,&inc);
3927 double * LblockL = Lleft[theindex-1-l_gamma]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
3929 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,1,TwoJdown,NR+1,TwoSRdown,IRdown);
3930 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta, temp2,&dimLdown);
3933 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
3947 #ifdef CHEMPS2_MPI_COMPILATION 3948 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4H4B ) == MPIRANK ) && (N2==2)){
3953 for (
int TwoSRdown=TwoSR-1; TwoSRdown<=TwoSR+1; TwoSRdown+=2){
3954 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
3955 if ((abs(TwoSLdown-TwoSRdown)<=TwoJ) && (TwoSLdown>=0) && (TwoSRdown>=0)){
3957 int fase =
phase(TwoSLdown+TwoSR+3-TwoS1);
3958 const double factor = fase * sqrt((TwoSLdown+1)*(TwoSRdown+1.0)) *
Wigner::wigner6j(TwoSL, TwoSR, TwoS1, TwoSRdown, TwoSLdown, 1);
3964 int dimLdown = denBK->
gCurrentDim(theindex, NL+1,TwoSLdown,ILdown);
3965 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+1,TwoSRdown,IRdown);
3967 if ((dimLdown>0) && (dimRdown>0)){
3968 bool isPossibleLeft =
false;
3969 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
3970 if (Irrep == denBK->
gIrrep(l_gamma)){ isPossibleLeft =
true; }
3972 bool isPossibleRight =
false;
3973 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
3974 if (Irrep == denBK->
gIrrep(l_beta)){ isPossibleRight =
true; }
3976 if ( (isPossibleLeft) && (isPossibleRight) ){
3978 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
3979 if (Irrep == denBK->
gIrrep(l_gamma)){
3981 int size = dimRup * dimRdown;
3982 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
3984 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
3985 if (Irrep == denBK->
gIrrep(l_beta)){
3986 double fact = factor * ( Prob->
gMxElement(l_gamma,theindex+1,theindex+1,l_beta) - 2 * Prob->
gMxElement(l_gamma,theindex+1,l_beta,theindex+1) );
3987 double * LblockR = Lright[l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR+1,TwoSRdown,IRdown);
3989 daxpy_(&size,&fact,LblockR,&inc,temp,&inc);
3995 double * LblockL = Lleft[theindex-1-l_gamma]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
3997 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,2,TwoS1,NR+1,TwoSRdown,IRdown);
3998 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,temp,&dimRup,&beta, temp2,&dimLdown);
4001 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,LblockL,&dimLup,temp2,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
4015 void CheMPS2::Heff::addDiagram4I(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft,
double * temp)
const{
4017 #ifdef CHEMPS2_MPI_COMPILATION 4021 int NL = denS->gNL(ikappa);
4022 int TwoSL = denS->gTwoSL(ikappa);
4023 int IL = denS->gIL(ikappa);
4025 int NR = denS->gNR(ikappa);
4026 int TwoSR = denS->gTwoSR(ikappa);
4027 int IR = denS->gIR(ikappa);
4029 int N1 = denS->gN1(ikappa);
4030 int N2 = denS->gN2(ikappa);
4031 int TwoJ = denS->gTwoJ(ikappa);
4033 int theindex = denS->gIndex();
4034 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
4035 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
4044 #ifdef CHEMPS2_MPI_COMPILATION 4045 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4I1AB ) == MPIRANK ) && (N1>0) && (N2==0)){
4047 if ((N1>0) && (N2==0)){
4050 int TwoJdown = ((N1==2)?1:0);
4051 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
4052 if (abs(TwoSLdown-TwoSR)<=TwoJdown){
4054 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
4057 int size = dimLdown * dimLup;
4058 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
4061 for (
int l_index=0; l_index<theindex; l_index++){
4062 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex)){
4064 double alpha = Prob->
gMxElement(l_index,theindex,theindex+1,theindex+1);
4065 double * Lblock = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
4066 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
4072 double factor = -1.0;
4074 int fase =
phase(TwoSR + 1 - TwoSL);
4075 factor = fase * sqrt((TwoSL+1.0)/(TwoSR+1.0));
4077 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, N1-1, 2, TwoJdown, NR, TwoSR, IR);
4078 dgemm_(&trans, ¬rans, &dimLup, &dimR, &dimLdown, &factor, temp, &dimLdown, memS+denS->gKappa2index(memSkappa), &dimLdown, &beta, memHeff+denS->gKappa2index(ikappa), &dimLup);
4086 #ifdef CHEMPS2_MPI_COMPILATION 4087 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4I2AB ) == MPIRANK ) && (N1<2) && (N2==2)){
4089 if ((N1<2) && (N2==2)){
4092 int TwoJdown = ((N1==0)?1:0);
4093 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
4094 if (abs(TwoSLdown-TwoSR)<=TwoJdown){
4096 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
4099 int size = dimLdown * dimLup;
4100 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
4103 for (
int l_index=0; l_index<theindex; l_index++){
4104 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex)){
4106 double alpha = Prob->
gMxElement(l_index,theindex,theindex+1,theindex+1);
4107 double * Lblock = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
4108 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
4114 double factor = -1.0;
4116 int fase =
phase(TwoSR + 1 - TwoSLdown);
4117 factor = fase * sqrt((TwoSLdown+1.0)/(TwoSR+1.0));
4119 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, N1+1, 0, TwoJdown, NR, TwoSR, IR);
4120 dgemm_(¬rans, ¬rans, &dimLup, &dimR, &dimLdown, &factor, temp, &dimLup, memS+denS->gKappa2index(memSkappa), &dimLdown, &beta, memHeff+denS->gKappa2index(ikappa), &dimLup);
4128 #ifdef CHEMPS2_MPI_COMPILATION 4129 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4I3ABCD ) == MPIRANK ) && (N1<2) && (N2>0)){
4131 if ((N1<2) && (N2>0)){
4134 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
4136 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
4141 int TwoSdownSum = ((N1==0)?1:0) + ((N2==1)?1:0);
4142 int TwoJstart = ((TwoSR!=TwoSLdown) || (TwoSdownSum<2)) ? TwoSdownSum : 0;
4143 for (
int TwoJdown = TwoJstart ; TwoJdown <= TwoSdownSum ; TwoJdown+=2){
4144 if (abs(TwoSLdown-TwoSR)<=TwoJdown){
4146 int size = dimLdown * dimLup;
4147 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
4149 double prefact = 0.0;
4150 if ((N1==0)&&(N2==1)){
4151 int fase =
phase(TwoSLdown+TwoSR+2);
4152 prefact = fase * sqrt((TwoSL+1.0)*(TwoJdown+1)) *
Wigner::wigner6j(TwoJdown,1,1,TwoSL,TwoSLdown,TwoSR);
4154 if ((N1==1)&&(N2==1)){
4155 int fase =
phase(TwoSLdown+TwoSR+3);
4156 prefact = fase * sqrt((TwoJ+1)*(TwoSL+1.0)) *
Wigner::wigner6j(TwoJ, 1, 1, TwoSLdown, TwoSL, TwoSR);
4158 if ((N1==0)&&(N2==2)){
4161 if ((N1==1)&&(N2==2)){
4162 int fase =
phase(TwoSR+1-TwoSL);
4163 prefact = fase * sqrt((TwoSL+1.0)/(TwoSR+1.0));
4167 for (
int l_index=0; l_index<theindex; l_index++){
4168 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex)){
4171 if ((N1==0)&&(N2==1)){
4172 alpha = prefact * ( Prob->
gMxElement(l_index,theindex+1,theindex,theindex+1)
4173 + ((TwoJdown==0)?1:-1) * Prob->
gMxElement(l_index,theindex+1,theindex+1,theindex) );
4175 if ((N1==1)&&(N2==1)){
4176 alpha = prefact * Prob->
gMxElement(l_index,theindex+1,theindex,theindex+1);
4177 if (TwoJ==0){ alpha += sqrt(2.0) * Prob->
gMxElement(l_index,theindex+1,theindex+1,theindex); }
4180 alpha = prefact * ( 2 * Prob->
gMxElement(l_index,theindex+1,theindex,theindex+1)
4181 - Prob->
gMxElement(l_index,theindex+1,theindex+1,theindex) );
4184 double * Lblock = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
4185 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
4191 double factor = 1.0;
4192 int memSkappa = denS->gKappa(NL-1, TwoSLdown, ILdown, N1+1, N2, TwoJdown, NR, TwoSR, IR);
4193 dgemm_(&trans, ¬rans, &dimLup, &dimR, &dimLdown, &factor, temp, &dimLdown, memS+denS->gKappa2index(memSkappa), &dimLdown, &beta, memHeff+denS->gKappa2index(ikappa), &dimLup);
4202 #ifdef CHEMPS2_MPI_COMPILATION 4203 if (( MPIchemps2::owner_specific_diagram( Prob->
gL(), MPI_CHEMPS2_4I4ABCD ) == MPIRANK ) && (N1>0) && (N2>0)){
4205 if ((N1>0) && (N2>0)){
4208 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
4210 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
4215 int TwoSdownSum = ((N1==2)?1:0) + ((N2==1)?1:0);
4216 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoSdownSum<2)) ? TwoSdownSum : 0;
4217 for (
int TwoJdown = TwoJstart ; TwoJdown <= TwoSdownSum ; TwoJdown+=2){
4218 if (abs(TwoSLdown-TwoSR)<=TwoJdown){
4220 int size = dimLdown * dimLup;
4221 for (
int cnt=0; cnt<size; cnt++){ temp[cnt] = 0.0; }
4223 double prefact = 0.0;
4224 if ((N1==1)&&(N2==1)){
4225 int fase =
phase(TwoSL+TwoSR+2);
4226 prefact = fase * sqrt((TwoSLdown+1.0)*(TwoJ+1)) *
Wigner::wigner6j(TwoJ,1,1,TwoSLdown,TwoSL,TwoSR);
4228 if ((N1==2)&&(N2==1)){
4229 int fase =
phase(TwoSL+TwoSR+3);
4230 prefact = fase * sqrt((TwoJdown+1)*(TwoSLdown+1.0)) *
Wigner::wigner6j(TwoJdown, 1, 1, TwoSL, TwoSLdown, TwoSR);
4232 if ((N1==1)&&(N2==2)){
4235 if ((N1==2)&&(N2==2)){
4236 int fase =
phase(TwoSR+1-TwoSLdown);
4237 prefact = fase * sqrt((TwoSLdown+1.0)/(TwoSR+1.0));
4241 for (
int l_index=0; l_index<theindex; l_index++){
4242 if (denBK->
gIrrep(l_index) == denBK->
gIrrep(theindex)){
4245 if ((N1==1)&&(N2==1)){
4246 alpha = prefact * ( Prob->
gMxElement(l_index,theindex+1,theindex,theindex+1)
4247 + ((TwoJ==0)?1:-1) * Prob->
gMxElement(l_index,theindex+1,theindex+1,theindex) );
4249 if ((N1==2)&&(N2==1)){
4250 alpha = prefact * Prob->
gMxElement(l_index,theindex+1,theindex,theindex+1);
4251 if (TwoJdown==0){ alpha += sqrt(2.0) * Prob->
gMxElement(l_index,theindex+1,theindex+1,theindex); }
4254 alpha = prefact * ( 2 * Prob->
gMxElement(l_index,theindex+1,theindex,theindex+1)
4255 - Prob->
gMxElement(l_index,theindex+1,theindex+1,theindex) );
4258 double * Lblock = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
4259 daxpy_(&size,&alpha,Lblock,&inc,temp,&inc);
4265 double factor = 1.0;
4266 int memSkappa = denS->gKappa(NL+1, TwoSLdown, ILdown, N1-1, N2, TwoJdown, NR, TwoSR, IR);
4267 dgemm_(¬rans, ¬rans, &dimLup, &dimR, &dimLdown, &factor, temp, &dimLup, memS+denS->gKappa2index(memSkappa), &dimLdown, &beta, memHeff+denS->gKappa2index(ikappa), &dimLup);
4277 void CheMPS2::Heff::addDiagram4J1and4J2spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Aright)
const{
4279 int NL = denS->gNL(ikappa);
4280 int TwoSL = denS->gTwoSL(ikappa);
4281 int IL = denS->gIL(ikappa);
4283 int NR = denS->gNR(ikappa);
4284 int TwoSR = denS->gTwoSR(ikappa);
4285 int IR = denS->gIR(ikappa);
4287 int N1 = denS->gN1(ikappa);
4288 int N2 = denS->gN2(ikappa);
4289 int TwoJ = denS->gTwoJ(ikappa);
4291 int theindex = denS->gIndex();
4292 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
4293 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
4300 if ((N1==0) && (N2==0)){
4302 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSR,IRdown);
4305 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,1,0,NR+2,TwoSR,IRdown);
4308 double * Ablock = Aright->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IRdown);
4309 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Ablock,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4315 if ((N1==1) && (N2==0)){
4317 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSR,IRdown);
4320 int memSkappa = denS->gKappa(NL,TwoSL,IL,2,1,1,NR+2,TwoSR,IRdown);
4321 double alpha = - sqrt(0.5);
4323 double * Ablock = Aright->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IRdown);
4324 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Ablock,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4330 if ((N1==0) && (N2==1)){
4332 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSR,IRdown);
4335 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,2,1,NR+2,TwoSR,IRdown);
4336 double alpha = - sqrt(0.5);
4338 double * Ablock = Aright->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IRdown);
4339 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Ablock,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4345 if ((N1==1) && (N2==1) && (TwoJ==0)){
4347 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSR,IRdown);
4350 int memSkappa = denS->gKappa(NL,TwoSL,IL,2,2,0,NR+2,TwoSR,IRdown);
4351 double alpha = -1.0;
4353 double * Ablock = Aright->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IRdown);
4354 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Ablock,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4358 dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSR,IRdown);
4361 int memSkappa = denS->gKappa(NL,TwoSL,IL,0,0,0,NR-2,TwoSR,IRdown);
4364 double * Ablock = Aright->gStorage(NR-2,TwoSR,IRdown,NR,TwoSR,IR);
4365 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Ablock,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4371 if ((N1==2) && (N2==1)){
4373 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSR,IRdown);
4376 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,0,1,NR-2,TwoSR,IRdown);
4377 double alpha = - sqrt(0.5);
4379 double * Ablock = Aright->gStorage(NR-2,TwoSR,IRdown,NR,TwoSR,IR);
4380 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Ablock,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4386 if ((N1==1) && (N2==2)){
4388 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSR,IRdown);
4391 int memSkappa = denS->gKappa(NL,TwoSL,IL,0,1,1,NR-2,TwoSR,IRdown);
4392 double alpha = - sqrt(0.5);
4394 double * Ablock = Aright->gStorage(NR-2,TwoSR,IRdown,NR,TwoSR,IR);
4395 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Ablock,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4401 if ((N1==2) && (N2==2)){
4403 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSR,IRdown);
4406 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,1,0,NR-2,TwoSR,IRdown);
4407 double alpha = -1.0;
4409 double * Ablock = Aright->gStorage(NR-2,TwoSR,IRdown,NR,TwoSR,IR);
4410 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Ablock,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4417 void CheMPS2::Heff::addDiagram4J1and4J2spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Bright)
const{
4419 int NL = denS->gNL(ikappa);
4420 int TwoSL = denS->gTwoSL(ikappa);
4421 int IL = denS->gIL(ikappa);
4423 int NR = denS->gNR(ikappa);
4424 int TwoSR = denS->gTwoSR(ikappa);
4425 int IR = denS->gIR(ikappa);
4427 int N1 = denS->gN1(ikappa);
4428 int N2 = denS->gN2(ikappa);
4429 int TwoJ = denS->gTwoJ(ikappa);
4431 int theindex = denS->gIndex();
4432 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
4433 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
4440 if ((N1==0) && (N2==0)){
4442 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
4444 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSRdown,IRdown);
4447 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,1,2,NR+2,TwoSRdown,IRdown);
4448 double alpha = sqrt((TwoSRdown+1.0)/(TwoSR+1.0));
4450 double * Bblock = Bright->gStorage(NR,TwoSR,IR,NR+2,TwoSRdown,IRdown);
4451 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Bblock,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4458 if ((N1==1) && (N2==0)){
4460 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
4461 if (abs(TwoSL-TwoSRdown)<=1){
4463 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSRdown,IRdown);
4466 int memSkappa = denS->gKappa(NL,TwoSL,IL,2,1,1,NR+2,TwoSRdown,IRdown);
4467 int fase =
phase(TwoSL+TwoSRdown+3);
4468 double alpha = fase * sqrt(3.0 * (TwoSRdown+1)) *
Wigner::wigner6j(1,1,2,TwoSR,TwoSRdown,TwoSL);
4470 double * Bblock = Bright->gStorage(NR,TwoSR,IR,NR+2,TwoSRdown,IRdown);
4471 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Bblock,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4478 if ((N1==0) && (N2==1)){
4480 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
4481 if (abs(TwoSL-TwoSRdown)<=1){
4483 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSRdown,IRdown);
4486 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,2,1,NR+2,TwoSRdown,IRdown);
4487 int fase =
phase(TwoSL+TwoSRdown+1);
4488 double alpha = fase * sqrt(3.0 * (TwoSRdown+1)) *
Wigner::wigner6j(1,1,2,TwoSR,TwoSRdown,TwoSL);
4490 double * Bblock = Bright->gStorage(NR,TwoSR,IR,NR+2,TwoSRdown,IRdown);
4491 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Bblock,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4498 if ((N1==1) && (N2==1) && (TwoJ==2)){
4500 int TwoSRdown = TwoSL;
4502 int dimRdown = denBK->
gCurrentDim(theindex+2,NR+2,TwoSRdown,IRdown);
4505 int memSkappa = denS->gKappa(NL,TwoSL,IL,2,2,0,NR+2,TwoSRdown,IRdown);
4506 double alpha =
phase(TwoSR-TwoSRdown);
4508 double * Bblock = Bright->gStorage(NR,TwoSR,IR,NR+2,TwoSRdown,IRdown);
4509 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Bblock,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4514 dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSRdown,IRdown);
4517 int memSkappa = denS->gKappa(NL,TwoSL,IL,0,0,0,NR-2,TwoSRdown,IRdown);
4518 double alpha = sqrt((TwoSR+1.0)/(TwoSRdown+1.0));
4520 double * Bblock = Bright->gStorage(NR-2,TwoSRdown,IRdown,NR,TwoSR,IR);
4521 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Bblock,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4528 if ((N1==2) && (N2==1)){
4530 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
4531 if (abs(TwoSL-TwoSRdown)<=1){
4533 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSRdown,IRdown);
4536 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,0,1,NR-2,TwoSRdown,IRdown);
4537 int fase =
phase(TwoSL+TwoSR+3);
4538 double alpha = fase * sqrt(3.0 * (TwoSR+1)) *
Wigner::wigner6j(1,1,2,TwoSRdown,TwoSR,TwoSL);
4540 double * Bblock = Bright->gStorage(NR-2,TwoSRdown,IRdown,NR,TwoSR,IR);
4541 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Bblock,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4548 if ((N1==1) && (N2==2)){
4550 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
4551 if (abs(TwoSL-TwoSRdown)<=1){
4553 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSRdown,IRdown);
4556 int memSkappa = denS->gKappa(NL,TwoSL,IL,0,1,1,NR-2,TwoSRdown,IRdown);
4557 int fase =
phase(TwoSL+TwoSR+1);
4558 double alpha = fase * sqrt(3.0 * (TwoSR+1)) *
Wigner::wigner6j(1,1,2,TwoSRdown,TwoSR,TwoSL);
4560 double * Bblock = Bright->gStorage(NR-2,TwoSRdown,IRdown,NR,TwoSR,IR);
4561 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Bblock,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4569 if ((N1==2) && (N2==2)){
4571 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
4573 int dimRdown = denBK->
gCurrentDim(theindex+2,NR-2,TwoSRdown,IRdown);
4576 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,1,2,NR-2,TwoSRdown,IRdown);
4577 double alpha =
phase(TwoSR-TwoSRdown);
4579 double * Bblock = Bright->gStorage(NR-2,TwoSRdown,IRdown,NR,TwoSR,IR);
4580 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,Bblock,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4588 void CheMPS2::Heff::addDiagram4J3and4J4spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Cright)
const{
4590 int NR = denS->gNR(ikappa);
4591 int TwoSR = denS->gTwoSR(ikappa);
4592 int IR = denS->gIR(ikappa);
4595 int theindex = denS->gIndex();
4597 int dimRdown = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IRdown);
4600 int NL = denS->gNL(ikappa);
4601 int TwoSL = denS->gTwoSL(ikappa);
4602 int IL = denS->gIL(ikappa);
4604 int N1 = denS->gN1(ikappa);
4605 int N2 = denS->gN2(ikappa);
4606 int TwoJ = denS->gTwoJ(ikappa);
4608 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
4609 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
4615 if ((N1==1) && (N2==0)){
4617 int memSkappa = denS->gKappa(NL,TwoSL,IL,0,1,1,NR,TwoSR,IRdown);
4618 double alpha = sqrt(0.5);
4620 double * ptr = Cright->gStorage(NR,TwoSR,IRdown,NR,TwoSR,IR);
4622 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4627 if ((N1==2) && (N2==0)){
4629 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,1,0,NR,TwoSR,IRdown);
4632 double * ptr = Cright->gStorage(NR,TwoSR,IRdown,NR,TwoSR,IR);
4634 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4639 if ((N1==1) && (N2==1) && (TwoJ==0)){
4641 int memSkappa = denS->gKappa(NL,TwoSL,IL,0,2,0,NR,TwoSR,IRdown);
4644 double * ptr = Cright->gStorage(NR,TwoSR,IRdown,NR,TwoSR,IR);
4646 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4651 if ((N1==2) && (N2==1)){
4653 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,2,1,NR,TwoSR,IRdown);
4654 double alpha = -sqrt(0.5);
4656 double * ptr = Cright->gStorage(NR,TwoSR,IRdown,NR,TwoSR,IR);
4658 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4663 if ((N1==0) && (N2==1)){
4665 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,0,1,NR,TwoSR,IRdown);
4666 double alpha = sqrt(0.5);
4668 double * ptr = Cright->gStorage(NR,TwoSR,IR,NR,TwoSR,IRdown);
4670 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4675 if ((N1==1) && (N2==1) && (TwoJ==0)){
4677 int memSkappa = denS->gKappa(NL,TwoSL,IL,2,0,0,NR,TwoSR,IRdown);
4680 double * ptr = Cright->gStorage(NR,TwoSR,IR,NR,TwoSR,IRdown);
4682 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4687 if ((N1==0) && (N2==2)){
4689 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,1,0,NR,TwoSR,IRdown);
4692 double * ptr = Cright->gStorage(NR,TwoSR,IR,NR,TwoSR,IRdown);
4694 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4699 if ((N1==1) && (N2==2)){
4701 int memSkappa = denS->gKappa(NL,TwoSL,IL,2,1,1,NR,TwoSR,IRdown);
4702 double alpha = -sqrt(0.5);
4704 double * ptr = Cright->gStorage(NR,TwoSR,IR,NR,TwoSR,IRdown);
4706 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4714 void CheMPS2::Heff::addDiagram4J3and4J4spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorOperator * Dright)
const{
4716 int NL = denS->gNL(ikappa);
4717 int TwoSL = denS->gTwoSL(ikappa);
4718 int IL = denS->gIL(ikappa);
4720 int NR = denS->gNR(ikappa);
4721 int TwoSR = denS->gTwoSR(ikappa);
4722 int IR = denS->gIR(ikappa);
4724 int N1 = denS->gN1(ikappa);
4725 int N2 = denS->gN2(ikappa);
4726 int TwoJ = denS->gTwoJ(ikappa);
4728 int theindex = denS->gIndex();
4729 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
4730 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
4737 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
4739 int dimRdown = denBK->
gCurrentDim(theindex+2,NR,TwoSRdown,IRdown);
4743 if ((N1==1) && (N2==0) && (abs(TwoSL-TwoSRdown)<=1)){
4745 int memSkappa = denS->gKappa(NL,TwoSL,IL,0,1,1,NR,TwoSRdown,IRdown);
4746 int fase =
phase(TwoSL+TwoSRdown+3);
4747 double alpha = fase * sqrt(3.0*(TwoSRdown+1)) *
Wigner::wigner6j(1,1,2,TwoSR,TwoSRdown,TwoSL);
4749 double * ptr = Dright->gStorage(NR,TwoSRdown,IRdown,NR,TwoSR,IR);
4751 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4756 if ((N1==2) && (N2==0)){
4758 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,1,2,NR,TwoSRdown,IRdown);
4759 double alpha = - sqrt((TwoSRdown+1.0)/(TwoSR+1.0));
4761 double * ptr = Dright->gStorage(NR,TwoSRdown,IRdown,NR,TwoSR,IR);
4763 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4768 if ((N1==1) && (N2==1) && (TwoJ==2) && (TwoSL==TwoSRdown)){
4770 int memSkappa = denS->gKappa(NL,TwoSL,IL,0,2,0,NR,TwoSRdown,IRdown);
4771 double alpha =
phase(TwoSR-TwoSRdown);
4773 double * ptr = Dright->gStorage(NR,TwoSRdown,IRdown,NR,TwoSR,IR);
4775 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4780 if ((N1==2) && (N2==1) && (abs(TwoSL-TwoSRdown)<=1)){
4782 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,2,1,NR,TwoSRdown,IRdown);
4783 int fase =
phase(TwoSL+TwoSRdown+3);
4784 double alpha = fase * sqrt(3.0*(TwoSRdown+1)) *
Wigner::wigner6j(1,1,2,TwoSR,TwoSRdown,TwoSL);
4786 double * ptr = Dright->gStorage(NR,TwoSRdown,IRdown,NR,TwoSR,IR);
4788 dgemm_(¬rans,¬rans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRdown,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4793 if ((N1==0) && (N2==1) && (abs(TwoSL-TwoSRdown)<=1)){
4795 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,0,1,NR,TwoSRdown,IRdown);
4796 int fase =
phase(TwoSL+TwoSR+3);
4797 double alpha = fase * sqrt(3.0*(TwoSR+1)) *
Wigner::wigner6j(1,1,2,TwoSR,TwoSRdown,TwoSL);
4799 double * ptr = Dright->gStorage(NR,TwoSR,IR,NR,TwoSRdown,IRdown);
4801 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4806 if ((N1==1) && (N2==1) && (TwoJ==2) && (TwoSL==TwoSRdown)){
4808 int memSkappa = denS->gKappa(NL,TwoSL,IL,2,0,0,NR,TwoSRdown,IRdown);
4809 double alpha = - sqrt((TwoSR+1.0)/(TwoSRdown+1.0));
4811 double * ptr = Dright->gStorage(NR,TwoSR,IR,NR,TwoSRdown,IRdown);
4813 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4818 if ((N1==0) && (N2==2)){
4820 int memSkappa = denS->gKappa(NL,TwoSL,IL,1,1,2,NR,TwoSRdown,IRdown);
4821 double alpha =
phase(TwoSR-TwoSRdown);
4823 double * ptr = Dright->gStorage(NR,TwoSR,IR,NR,TwoSRdown,IRdown);
4825 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4830 if ((N1==1) && (N2==2) && (abs(TwoSL-TwoSRdown)<=1)){
4832 int memSkappa = denS->gKappa(NL,TwoSL,IL,2,1,1,NR,TwoSRdown,IRdown);
4833 int fase =
phase(TwoSL+TwoSR+3);
4834 double alpha = fase * sqrt(3.0*(TwoSR+1)) *
Wigner::wigner6j(1,1,2,TwoSR,TwoSRdown,TwoSL);
4836 double * ptr = Dright->gStorage(NR,TwoSR,IR,NR,TwoSRdown,IRdown);
4838 dgemm_(¬rans,&trans,&dimL,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimL,ptr,&dimRup,&beta,memHeff+denS->gKappa2index(ikappa), &dimL);
4847 void CheMPS2::Heff::addDiagram4K1and4K2spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorOperator *** Aright,
double * temp)
const{
4849 #ifdef CHEMPS2_MPI_COMPILATION 4853 int NL = denS->gNL(ikappa);
4854 int TwoSL = denS->gTwoSL(ikappa);
4855 int IL = denS->gIL(ikappa);
4857 int NR = denS->gNR(ikappa);
4858 int TwoSR = denS->gTwoSR(ikappa);
4859 int IR = denS->gIR(ikappa);
4861 int N1 = denS->gN1(ikappa);
4862 int N2 = denS->gN2(ikappa);
4863 int TwoJ = denS->gTwoJ(ikappa);
4864 int TwoS1 = (N1==1)?1:0;
4866 int theindex = denS->gIndex();
4867 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
4868 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
4875 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
4876 if ((abs(TwoSLdown-TwoSR)<=TwoS1) && (TwoSLdown>=0)){
4878 int fase =
phase(TwoSLdown + TwoSR + TwoJ + 1 + 2*TwoS1);
4879 const double factor = fase * sqrt(0.5 * (TwoSL+1) * (TwoJ+1)) *
Wigner::wigner6j(TwoS1,TwoJ,1,TwoSL,TwoSLdown,TwoSR);
4881 for (
int l_index=0; l_index<theindex; l_index++){
4883 #ifdef CHEMPS2_MPI_COMPILATION 4884 if ( MPIchemps2::owner_absigma( l_index, theindex+1 ) == MPIRANK )
4890 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
4891 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-2, TwoSR, IRdown);
4893 if ((dimLdown>0) && (dimRdown>0)){
4895 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,0,TwoS1,NR-2,TwoSR,IRdown);
4896 double * blockA = Aright[theindex+1-l_index][0]->gStorage(NR-2,TwoSR,IRdown,NR,TwoSR,IR);
4898 double alpha = factor;
4900 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockA,&dimRdown,&beta,temp,&dimLdown);
4904 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
4906 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
4917 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
4919 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoS1==0)) ? TwoS1+1 : 0;
4920 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
4921 if ((abs(TwoSLdown-TwoSR)<=TwoJdown) && (TwoSLdown>=0)){
4923 int fase =
phase(TwoSLdown + TwoSR + TwoJdown + 2 + 2*TwoS1);
4924 const double factor = fase * sqrt(0.5 * (TwoSL+1) * (TwoJdown+1)) *
Wigner::wigner6j(TwoJdown,TwoS1,1,TwoSL,TwoSLdown,TwoSR);
4926 for (
int l_index=0; l_index<theindex; l_index++){
4928 #ifdef CHEMPS2_MPI_COMPILATION 4929 if ( MPIchemps2::owner_absigma( l_index, theindex+1 ) == MPIRANK )
4935 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
4936 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-2, TwoSR, IRdown);
4938 if ((dimLdown>0) && (dimRdown>0)){
4940 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,1,TwoJdown,NR-2,TwoSR,IRdown);
4941 double * blockA = Aright[theindex+1-l_index][0]->gStorage(NR-2,TwoSR,IRdown,NR,TwoSR,IR);
4943 double alpha = factor;
4945 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockA,&dimRdown,&beta,temp,&dimLdown);
4949 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
4951 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
4963 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
4965 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoS1==0)) ? TwoS1+1 : 0;
4966 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
4967 if ((abs(TwoSLdown-TwoSR)<=TwoJdown) && (TwoSLdown>=0)){
4969 int fase =
phase(TwoSL + TwoSR + TwoJdown + 1 + 2*TwoS1);
4970 const double factor = fase * sqrt(0.5 * (TwoSLdown+1) * (TwoJdown+1)) *
Wigner::wigner6j(TwoJdown,TwoS1,1,TwoSL,TwoSLdown,TwoSR);
4972 for (
int l_index=0; l_index<theindex; l_index++){
4974 #ifdef CHEMPS2_MPI_COMPILATION 4975 if ( MPIchemps2::owner_absigma( l_index, theindex+1 ) == MPIRANK )
4981 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
4982 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+2, TwoSR, IRdown);
4984 if ((dimLdown>0) && (dimRdown>0)){
4986 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,1,TwoJdown,NR+2,TwoSR,IRdown);
4987 double * blockA = Aright[theindex+1-l_index][0]->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IRdown);
4989 double alpha = factor;
4991 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockA,&dimRup,&beta,temp,&dimLdown);
4995 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
4997 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5009 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5010 if ((abs(TwoSLdown-TwoSR)<=TwoS1) && (TwoSLdown>=0)){
5012 int fase =
phase(TwoSL + TwoSR + TwoJ + 2 + 2*TwoS1);
5013 const double factor = fase * sqrt(0.5 * (TwoSLdown+1) * (TwoJ+1)) *
Wigner::wigner6j(TwoJ,TwoS1,1,TwoSLdown,TwoSL,TwoSR);
5015 for (
int l_index=0; l_index<theindex; l_index++){
5017 #ifdef CHEMPS2_MPI_COMPILATION 5018 if ( MPIchemps2::owner_absigma( l_index, theindex+1 ) == MPIRANK )
5024 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5025 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+2, TwoSR, IRdown);
5027 if ((dimLdown>0) && (dimRdown>0)){
5029 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,2,TwoS1,NR+2,TwoSR,IRdown);
5030 double * blockA = Aright[theindex+1-l_index][0]->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IRdown);
5032 double alpha = factor;
5034 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockA,&dimRup,&beta,temp,&dimLdown);
5038 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5040 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5051 void CheMPS2::Heff::addDiagram4L1and4L2spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorOperator *** Aright,
double * temp)
const{
5053 #ifdef CHEMPS2_MPI_COMPILATION 5057 int NL = denS->gNL(ikappa);
5058 int TwoSL = denS->gTwoSL(ikappa);
5059 int IL = denS->gIL(ikappa);
5061 int NR = denS->gNR(ikappa);
5062 int TwoSR = denS->gTwoSR(ikappa);
5063 int IR = denS->gIR(ikappa);
5065 int N1 = denS->gN1(ikappa);
5066 int N2 = denS->gN2(ikappa);
5067 int TwoJ = denS->gTwoJ(ikappa);
5068 int TwoS2 = (N2==1)?1:0;
5070 int theindex = denS->gIndex();
5071 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
5072 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
5079 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5080 if ((abs(TwoSLdown-TwoSR)<=TwoS2) && (TwoSLdown>=0)){
5082 int fase =
phase(TwoSLdown + TwoSR + 2 + TwoS2);
5083 const double factor = fase * sqrt(0.5 * (TwoSL+1) * (TwoJ+1))
5086 for (
int l_index=0; l_index<theindex; l_index++){
5088 #ifdef CHEMPS2_MPI_COMPILATION 5089 if ( MPIchemps2::owner_absigma( l_index, theindex ) == MPIRANK )
5095 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
5096 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-2, TwoSR, IRdown);
5098 if ((dimLdown>0) && (dimRdown>0)){
5100 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,0,N2,TwoS2,NR-2,TwoSR,IRdown);
5101 double * blockA = Aright[theindex-l_index][1]->gStorage(NR-2,TwoSR,IRdown,NR,TwoSR,IR);
5103 double alpha = factor;
5105 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockA,&dimRdown,&beta,temp,&dimLdown);
5109 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
5111 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5122 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5124 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoS2==0)) ? TwoS2+1 : 0;
5125 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
5126 if ((abs(TwoSLdown-TwoSR)<=TwoJdown) && (TwoSLdown>=0)){
5128 int fase =
phase(TwoSLdown + TwoSR + 3 + TwoS2);
5129 const double factor = fase * sqrt(0.5 * (TwoSL+1) * (TwoJdown+1))
5132 for (
int l_index=0; l_index<theindex; l_index++){
5134 #ifdef CHEMPS2_MPI_COMPILATION 5135 if ( MPIchemps2::owner_absigma( l_index, theindex ) == MPIRANK )
5141 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
5142 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-2, TwoSR, IRdown);
5144 if ((dimLdown>0) && (dimRdown>0)){
5146 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,1,N2,TwoJdown,NR-2,TwoSR,IRdown);
5147 double * blockA = Aright[theindex-l_index][1]->gStorage(NR-2,TwoSR,IRdown,NR,TwoSR,IR);
5149 double alpha = factor;
5151 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockA,&dimRdown,&beta,temp,&dimLdown);
5155 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
5157 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5169 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5171 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoS2==0)) ? TwoS2+1 : 0;
5172 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
5173 if ((abs(TwoSLdown-TwoSR)<=TwoJdown) && (TwoSLdown>=0)){
5175 int fase =
phase(TwoSL + TwoSR + 2 + TwoS2);
5176 const double factor = fase * sqrt(0.5 * (TwoSLdown+1) * (TwoJdown+1))
5179 for (
int l_index=0; l_index<theindex; l_index++){
5181 #ifdef CHEMPS2_MPI_COMPILATION 5182 if ( MPIchemps2::owner_absigma( l_index, theindex ) == MPIRANK )
5188 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5189 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+2, TwoSR, IRdown);
5191 if ((dimLdown>0) && (dimRdown>0)){
5193 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,1,N2,TwoJdown,NR+2,TwoSR,IRdown);
5194 double * blockA = Aright[theindex-l_index][1]->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IRdown);
5196 double alpha = factor;
5198 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockA,&dimRup,&beta,temp,&dimLdown);
5202 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5204 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5216 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5217 if ((abs(TwoSLdown-TwoSR)<=TwoS2) && (TwoSLdown>=0)){
5219 int fase =
phase(TwoSL + TwoSR + 3 + TwoS2);
5220 const double factor = fase * sqrt(0.5 * (TwoSLdown+1) * (TwoJ+1))
5223 for (
int l_index=0; l_index<theindex; l_index++){
5225 #ifdef CHEMPS2_MPI_COMPILATION 5226 if ( MPIchemps2::owner_absigma( l_index, theindex ) == MPIRANK )
5232 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5233 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+2, TwoSR, IRdown);
5235 if ((dimLdown>0) && (dimRdown>0)){
5237 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,2,N2,TwoS2,NR+2,TwoSR,IRdown);
5238 double * blockA = Aright[theindex-l_index][1]->gStorage(NR,TwoSR,IR,NR+2,TwoSR,IRdown);
5240 double alpha = factor;
5242 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockA,&dimRup,&beta,temp,&dimLdown);
5246 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5248 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5259 void CheMPS2::Heff::addDiagram4K1and4K2spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorOperator *** Bright,
double * temp)
const{
5261 #ifdef CHEMPS2_MPI_COMPILATION 5265 int NL = denS->gNL(ikappa);
5266 int TwoSL = denS->gTwoSL(ikappa);
5267 int IL = denS->gIL(ikappa);
5269 int NR = denS->gNR(ikappa);
5270 int TwoSR = denS->gTwoSR(ikappa);
5271 int IR = denS->gIR(ikappa);
5273 int N1 = denS->gN1(ikappa);
5274 int N2 = denS->gN2(ikappa);
5275 int TwoJ = denS->gTwoJ(ikappa);
5276 int TwoS1 = (N1==1)?1:0;
5278 int theindex = denS->gIndex();
5279 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
5280 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
5287 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5288 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
5289 if ((abs(TwoSLdown-TwoSRdown)<=TwoS1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
5291 int fase = (TwoS1==1)?-1:1;
5292 const double factor = fase * sqrt(3.0 * (TwoSR+1) * (TwoSL+1) * (TwoJ+1))
5293 *
Wigner::wigner9j(2, TwoSR, TwoSRdown, 1, TwoSL, TwoSLdown, 1, TwoJ, TwoS1);
5295 for (
int l_index=0; l_index<theindex; l_index++){
5297 #ifdef CHEMPS2_MPI_COMPILATION 5298 if ( MPIchemps2::owner_absigma( l_index, theindex+1 ) == MPIRANK )
5304 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
5305 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-2, TwoSRdown, IRdown);
5307 if ((dimLdown>0) && (dimRdown>0)){
5309 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,0,TwoS1,NR-2,TwoSRdown,IRdown);
5310 double * blockB = Bright[theindex+1-l_index][0]->gStorage(NR-2,TwoSRdown,IRdown,NR,TwoSR,IR);
5312 double alpha = factor;
5314 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockB,&dimRdown,&beta,temp,&dimLdown);
5318 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
5320 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5332 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5333 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
5335 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
5336 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
5337 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
5339 int fase =
phase(TwoSR-TwoSRdown+TwoSLdown-TwoSL+3+2*TwoS1);
5340 const double factor = fase * sqrt(3.0 * (TwoSR+1) * (TwoSL+1) * (TwoJdown+1))
5341 *
Wigner::wigner9j(2, TwoSRdown, TwoSR, 1, TwoSLdown, TwoSL, 1, TwoJdown, TwoS1);
5343 for (
int l_index=0; l_index<theindex; l_index++){
5345 #ifdef CHEMPS2_MPI_COMPILATION 5346 if ( MPIchemps2::owner_absigma( l_index, theindex+1 ) == MPIRANK )
5352 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
5353 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-2, TwoSRdown, IRdown);
5355 if ((dimLdown>0) && (dimRdown>0)){
5357 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,1,TwoJdown,NR-2,TwoSRdown,IRdown);
5358 double * blockB = Bright[theindex+1-l_index][0]->gStorage(NR-2,TwoSRdown,IRdown,NR,TwoSR,IR);
5360 double alpha = factor;
5362 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockB,&dimRdown,&beta, temp,&dimLdown);
5366 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
5368 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5381 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5382 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
5384 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
5385 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
5386 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
5388 int fase = (TwoS1==1)?-1:1;
5389 const double factor = fase * sqrt(3.0 * (TwoSRdown+1) * (TwoSLdown+1) * (TwoJdown+1))
5390 *
Wigner::wigner9j(2, TwoSRdown, TwoSR, 1, TwoSLdown, TwoSL, 1, TwoJdown, TwoS1);
5392 for (
int l_index=0; l_index<theindex; l_index++){
5394 #ifdef CHEMPS2_MPI_COMPILATION 5395 if ( MPIchemps2::owner_absigma( l_index, theindex+1 ) == MPIRANK )
5401 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5402 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+2, TwoSRdown, IRdown);
5404 if ((dimLdown>0) && (dimRdown>0)){
5406 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,1,TwoJdown,NR+2,TwoSRdown,IRdown);
5407 double * blockB = Bright[theindex+1-l_index][0]->gStorage(NR,TwoSR,IR,NR+2,TwoSRdown,IRdown);
5409 double alpha = factor;
5411 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockB,&dimRup,&beta,temp,&dimLdown);
5415 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5417 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5430 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5431 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
5432 if ((abs(TwoSLdown-TwoSRdown)<=TwoS1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
5434 int fase =
phase(TwoSRdown-TwoSR+TwoSL-TwoSLdown+3+2*TwoS1);
5435 const double factor = fase * sqrt(3.0 * (TwoSRdown+1) * (TwoSLdown+1) * (TwoJ+1))
5436 *
Wigner::wigner9j(2, TwoSR, TwoSRdown, 1, TwoSL, TwoSLdown, 1, TwoJ, TwoS1);
5438 for (
int l_index=0; l_index<theindex; l_index++){
5440 #ifdef CHEMPS2_MPI_COMPILATION 5441 if ( MPIchemps2::owner_absigma( l_index, theindex+1 ) == MPIRANK )
5447 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5448 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+2, TwoSRdown, IRdown);
5450 if ((dimLdown>0) && (dimRdown>0)){
5452 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,2,TwoS1,NR+2,TwoSRdown,IRdown);
5453 double * blockB = Bright[theindex+1-l_index][0]->gStorage(NR,TwoSR,IR,NR+2,TwoSRdown,IRdown);
5455 double alpha = factor;
5457 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockB,&dimRup,&beta,temp,&dimLdown);
5461 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5463 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5474 void CheMPS2::Heff::addDiagram4L1and4L2spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorOperator *** Bright,
double * temp)
const{
5476 #ifdef CHEMPS2_MPI_COMPILATION 5480 int NL = denS->gNL(ikappa);
5481 int TwoSL = denS->gTwoSL(ikappa);
5482 int IL = denS->gIL(ikappa);
5484 int NR = denS->gNR(ikappa);
5485 int TwoSR = denS->gTwoSR(ikappa);
5486 int IR = denS->gIR(ikappa);
5488 int N1 = denS->gN1(ikappa);
5489 int N2 = denS->gN2(ikappa);
5490 int TwoJ = denS->gTwoJ(ikappa);
5491 int TwoS2 = (N2==1)?1:0;
5493 int theindex = denS->gIndex();
5494 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
5495 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
5502 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5503 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
5504 if ((abs(TwoSLdown-TwoSRdown)<=TwoS2) && (TwoSLdown>=0) && (TwoSRdown>=0)){
5506 int fase =
phase(1+TwoS2-TwoJ);
5507 const double factor = fase * sqrt(3.0 * (TwoSR+1) * (TwoSL+1) * (TwoJ+1))
5508 *
Wigner::wigner9j(2, TwoSR, TwoSRdown, 1, TwoSL, TwoSLdown, 1, TwoJ, TwoS2);
5510 for (
int l_index=0; l_index<theindex; l_index++){
5512 #ifdef CHEMPS2_MPI_COMPILATION 5513 if ( MPIchemps2::owner_absigma( l_index, theindex ) == MPIRANK )
5519 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
5520 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-2, TwoSRdown, IRdown);
5522 if ((dimLdown>0) && (dimRdown>0)){
5524 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,0,N2,TwoS2,NR-2,TwoSRdown,IRdown);
5525 double * blockB = Bright[theindex-l_index][1]->gStorage(NR-2,TwoSRdown,IRdown,NR,TwoSR,IR);
5527 double alpha = factor;
5529 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockB,&dimRdown,&beta,temp,&dimLdown);
5533 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
5535 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5546 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5547 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
5549 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
5550 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
5551 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
5553 int fase =
phase(TwoSR-TwoSRdown+TwoSLdown-TwoSL+TwoS2-TwoJdown);
5554 const double factor = fase * sqrt(3.0 * (TwoSR+1) * (TwoSL+1) * (TwoJdown+1))
5555 *
Wigner::wigner9j(2, TwoSRdown, TwoSR, 1, TwoSLdown, TwoSL, 1, TwoJdown, TwoS2);
5557 for (
int l_index=0; l_index<theindex; l_index++){
5559 #ifdef CHEMPS2_MPI_COMPILATION 5560 if ( MPIchemps2::owner_absigma( l_index, theindex ) == MPIRANK )
5566 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
5567 int dimRdown = denBK->
gCurrentDim(theindex+2, NR-2, TwoSRdown, IRdown);
5569 if ((dimLdown>0) && (dimRdown>0)){
5571 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,1,N2,TwoJdown,NR-2,TwoSRdown,IRdown);
5572 double * blockB = Bright[theindex-l_index][1]->gStorage(NR-2,TwoSRdown,IRdown,NR,TwoSR,IR);
5574 double alpha = factor;
5576 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockB,&dimRdown,&beta, temp,&dimLdown);
5580 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
5582 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5594 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5595 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
5597 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
5598 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
5599 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
5601 int fase =
phase(1+TwoS2-TwoJdown);
5602 const double factor = fase * sqrt(3.0 * (TwoSRdown+1) * (TwoSLdown+1) * (TwoJdown+1))
5603 *
Wigner::wigner9j(2, TwoSRdown, TwoSR, 1, TwoSLdown, TwoSL, 1, TwoJdown, TwoS2);
5605 for (
int l_index=0; l_index<theindex; l_index++){
5607 #ifdef CHEMPS2_MPI_COMPILATION 5608 if ( MPIchemps2::owner_absigma( l_index, theindex ) == MPIRANK )
5614 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5615 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+2, TwoSRdown, IRdown);
5617 if ((dimLdown>0) && (dimRdown>0)){
5619 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,1,N2,TwoJdown,NR+2,TwoSRdown,IRdown);
5620 double * blockB = Bright[theindex-l_index][1]->gStorage(NR,TwoSR,IR,NR+2,TwoSRdown,IRdown);
5622 double alpha = factor;
5624 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockB,&dimRup,&beta,temp,&dimLdown);
5628 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5630 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5642 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5643 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
5644 if ((abs(TwoSLdown-TwoSRdown)<=TwoS2) && (TwoSLdown>=0) && (TwoSRdown>=0)){
5646 int fase =
phase(TwoSRdown-TwoSR+TwoSL-TwoSLdown+TwoS2-TwoJ);
5647 const double factor = fase * sqrt(3.0 * (TwoSRdown+1) * (TwoSLdown+1) * (TwoJ+1))
5648 *
Wigner::wigner9j(2, TwoSR, TwoSRdown, 1, TwoSL, TwoSLdown, 1, TwoJ, TwoS2);
5650 for (
int l_index=0; l_index<theindex; l_index++){
5652 #ifdef CHEMPS2_MPI_COMPILATION 5653 if ( MPIchemps2::owner_absigma( l_index, theindex ) == MPIRANK )
5659 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5660 int dimRdown = denBK->
gCurrentDim(theindex+2, NR+2, TwoSRdown, IRdown);
5662 if ((dimLdown>0) && (dimRdown>0)){
5664 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,2,N2,TwoS2,NR+2,TwoSRdown,IRdown);
5665 double * blockB = Bright[theindex-l_index][1]->gStorage(NR,TwoSR,IR,NR+2,TwoSRdown,IRdown);
5667 double alpha = factor;
5669 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,blockB,&dimRup,&beta,temp,&dimLdown);
5673 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5675 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5686 void CheMPS2::Heff::addDiagram4K3and4K4spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorOperator *** Cright,
double * temp)
const{
5688 #ifdef CHEMPS2_MPI_COMPILATION 5692 int NL = denS->gNL(ikappa);
5693 int TwoSL = denS->gTwoSL(ikappa);
5694 int IL = denS->gIL(ikappa);
5696 int NR = denS->gNR(ikappa);
5697 int TwoSR = denS->gTwoSR(ikappa);
5698 int IR = denS->gIR(ikappa);
5700 int N1 = denS->gN1(ikappa);
5701 int N2 = denS->gN2(ikappa);
5702 int TwoJ = denS->gTwoJ(ikappa);
5703 int TwoS1 = (N1==1)?1:0;
5705 int theindex = denS->gIndex();
5706 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
5707 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
5714 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5715 if ((abs(TwoSLdown-TwoSR)<=TwoS1) && (TwoSLdown>=0)){
5717 int fase =
phase(TwoSL + TwoSR + TwoJ + 2*TwoS1);
5718 const double factor = fase * sqrt(0.5 * (TwoSLdown+1) * (TwoJ+1)) *
Wigner::wigner6j(TwoJ,TwoS1,1,TwoSLdown,TwoSL,TwoSR);
5720 for (
int l_index=0; l_index<theindex; l_index++){
5722 #ifdef CHEMPS2_MPI_COMPILATION 5723 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex+1 ) == MPIRANK )
5729 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5730 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSR, IRdown);
5732 if ((dimLdown>0) && (dimRdown>0)){
5734 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,0,TwoS1,NR,TwoSR,IRdown);
5735 double * ptr = Cright[theindex+1-l_index][0]->gStorage(NR,TwoSR,IR,NR,TwoSR,IRdown);
5738 double alpha = factor;
5740 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRup,&beta,temp,&dimLdown);
5744 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5746 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5756 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5758 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoS1==0)) ? TwoS1+1 : 0;
5759 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
5760 if ((abs(TwoSLdown-TwoSR)<=TwoJdown) && (TwoSLdown>=0)){
5762 int fase =
phase(TwoSL + TwoSR + TwoJdown + 1 + 2*TwoS1);
5763 const double factor = fase * sqrt(0.5 * (TwoSLdown+1) * (TwoJdown+1)) *
Wigner::wigner6j(TwoJdown,TwoS1,1,TwoSL,TwoSLdown,TwoSR);
5765 for (
int l_index=0; l_index<theindex; l_index++){
5767 #ifdef CHEMPS2_MPI_COMPILATION 5768 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex+1 ) == MPIRANK )
5774 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5775 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSR, IRdown);
5777 if ((dimLdown>0) && (dimRdown>0)){
5779 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,1,TwoJdown,NR,TwoSR,IRdown);
5780 double * ptr = Cright[theindex+1-l_index][0]->gStorage(NR,TwoSR,IR,NR,TwoSR,IRdown);
5783 double alpha = factor;
5785 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRup,&beta,temp,&dimLdown);
5789 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5791 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5802 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5804 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoS1==0)) ? TwoS1+1 : 0;
5805 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
5806 if ((abs(TwoSLdown-TwoSR)<=TwoJdown) && (TwoSLdown>=0)){
5808 int fase =
phase(TwoSLdown + TwoSR + TwoJdown + 2*TwoS1);
5809 const double factor = fase * sqrt(0.5 * (TwoSL+1) * (TwoJdown+1)) *
Wigner::wigner6j(TwoJdown,TwoS1,1,TwoSL,TwoSLdown,TwoSR);
5811 for (
int l_index=0; l_index<theindex; l_index++){
5813 #ifdef CHEMPS2_MPI_COMPILATION 5814 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex+1 ) == MPIRANK )
5820 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
5821 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSR, IRdown);
5823 if ((dimLdown>0) && (dimRdown>0)){
5825 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,1,TwoJdown,NR,TwoSR,IRdown);
5826 double * ptr = Cright[theindex+1-l_index][0]->gStorage(NR,TwoSR,IRdown,NR,TwoSR,IR);
5829 double alpha = factor;
5831 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRdown,&beta,temp,&dimLdown);
5835 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
5837 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5848 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5849 if ((abs(TwoSLdown-TwoSR)<=TwoS1) && (TwoSLdown>=0)){
5851 int fase =
phase(TwoSLdown + TwoSR + 1 + TwoJ + 2*TwoS1);
5852 const double factor = fase * sqrt(0.5 * (TwoSL+1) * (TwoJ+1)) *
Wigner::wigner6j(TwoJ,TwoS1,1,TwoSLdown,TwoSL,TwoSR);
5854 for (
int l_index=0; l_index<theindex; l_index++){
5856 #ifdef CHEMPS2_MPI_COMPILATION 5857 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex+1 ) == MPIRANK )
5863 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
5864 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSR, IRdown);
5866 if ((dimLdown>0) && (dimRdown>0)){
5868 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,2,TwoS1,NR,TwoSR,IRdown);
5869 double * ptr = Cright[theindex+1-l_index][0]->gStorage(NR,TwoSR,IRdown,NR,TwoSR,IR);
5872 double alpha = factor;
5874 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRdown,&beta,temp,&dimLdown);
5878 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
5880 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5890 void CheMPS2::Heff::addDiagram4L3and4L4spin0(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorOperator *** Cright,
double * temp)
const{
5892 #ifdef CHEMPS2_MPI_COMPILATION 5896 int NL = denS->gNL(ikappa);
5897 int TwoSL = denS->gTwoSL(ikappa);
5898 int IL = denS->gIL(ikappa);
5900 int NR = denS->gNR(ikappa);
5901 int TwoSR = denS->gTwoSR(ikappa);
5902 int IR = denS->gIR(ikappa);
5904 int N1 = denS->gN1(ikappa);
5905 int N2 = denS->gN2(ikappa);
5906 int TwoJ = denS->gTwoJ(ikappa);
5907 int TwoS2 = (N2==1)?1:0;
5909 int theindex = denS->gIndex();
5910 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
5911 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
5918 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5919 if ((abs(TwoSLdown-TwoSR)<=TwoS2) && (TwoSLdown>=0)){
5921 int fase =
phase(TwoSL + TwoSR + 1 + TwoS2);
5922 const double factor = fase * sqrt(0.5 * (TwoSLdown+1) * (TwoJ+1)) *
Wigner::wigner6j(TwoJ,TwoS2,1,TwoSLdown,TwoSL,TwoSR);
5924 for (
int l_index=0; l_index<theindex; l_index++){
5926 #ifdef CHEMPS2_MPI_COMPILATION 5927 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex ) == MPIRANK )
5933 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5934 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSR, IRdown);
5936 if ((dimLdown>0) && (dimRdown>0)){
5938 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,0,N2,TwoS2,NR,TwoSR,IRdown);
5939 double * ptr = Cright[theindex-l_index][1]->gStorage(NR,TwoSR,IR,NR,TwoSR,IRdown);
5942 double alpha = factor;
5944 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRup,&beta,temp,&dimLdown);
5948 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5950 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
5960 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
5962 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoS2==0)) ? TwoS2+1 : 0;
5963 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
5964 if ((abs(TwoSLdown-TwoSR)<=TwoJdown) && (TwoSLdown>=0)){
5966 int fase =
phase(TwoSL + TwoSR + 2 + TwoS2);
5967 const double factor = fase * sqrt(0.5 * (TwoSLdown+1) * (TwoJdown+1)) *
Wigner::wigner6j(TwoJdown,TwoS2,1,TwoSL,TwoSLdown,TwoSR);
5969 for (
int l_index=0; l_index<theindex; l_index++){
5971 #ifdef CHEMPS2_MPI_COMPILATION 5972 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex ) == MPIRANK )
5978 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
5979 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSR, IRdown);
5981 if ((dimLdown>0) && (dimRdown>0)){
5983 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,1,N2,TwoJdown,NR,TwoSR,IRdown);
5984 double * ptr = Cright[theindex-l_index][1]->gStorage(NR,TwoSR,IR,NR,TwoSR,IRdown);
5987 double alpha = factor;
5989 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRup,&beta,temp,&dimLdown);
5993 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
5995 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
6006 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
6008 int TwoJstart = ((TwoSLdown!=TwoSR) || (TwoS2==0)) ? TwoS2+1 : 0;
6009 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
6010 if ((abs(TwoSLdown-TwoSR)<=TwoJdown) && (TwoSLdown>=0)){
6012 int fase =
phase(TwoSLdown + TwoSR + 1 + TwoS2);
6013 const double factor = fase * sqrt(0.5 * (TwoSL+1) * (TwoJdown+1)) *
Wigner::wigner6j(TwoJdown,TwoS2,1,TwoSL,TwoSLdown,TwoSR);
6015 for (
int l_index=0; l_index<theindex; l_index++){
6017 #ifdef CHEMPS2_MPI_COMPILATION 6018 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex ) == MPIRANK )
6024 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
6025 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSR, IRdown);
6027 if ((dimLdown>0) && (dimRdown>0)){
6029 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,1,N2,TwoJdown,NR,TwoSR,IRdown);
6030 double * ptr = Cright[theindex-l_index][1]->gStorage(NR,TwoSR,IRdown,NR,TwoSR,IR);
6033 double alpha = factor;
6035 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRdown,&beta,temp,&dimLdown);
6039 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
6041 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
6052 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
6053 if ((abs(TwoSLdown-TwoSR)<=TwoS2) && (TwoSLdown>=0)){
6055 int fase =
phase(TwoSLdown + TwoSR + 2 + TwoS2);
6056 const double factor = fase * sqrt(0.5 * (TwoSL+1) * (TwoJ+1)) *
Wigner::wigner6j(TwoJ,TwoS2,1,TwoSLdown,TwoSL,TwoSR);
6058 for (
int l_index=0; l_index<theindex; l_index++){
6060 #ifdef CHEMPS2_MPI_COMPILATION 6061 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex ) == MPIRANK )
6067 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
6068 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSR, IRdown);
6070 if ((dimLdown>0) && (dimRdown>0)){
6072 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,2,N2,TwoS2,NR,TwoSR,IRdown);
6073 double * ptr = Cright[theindex-l_index][1]->gStorage(NR,TwoSR,IRdown,NR,TwoSR,IR);
6076 double alpha = factor;
6078 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRdown,&beta,temp,&dimLdown);
6082 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
6084 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
6094 void CheMPS2::Heff::addDiagram4K3and4K4spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorOperator *** Dright,
double * temp)
const{
6096 #ifdef CHEMPS2_MPI_COMPILATION 6100 int NL = denS->gNL(ikappa);
6101 int TwoSL = denS->gTwoSL(ikappa);
6102 int IL = denS->gIL(ikappa);
6104 int NR = denS->gNR(ikappa);
6105 int TwoSR = denS->gTwoSR(ikappa);
6106 int IR = denS->gIR(ikappa);
6108 int N1 = denS->gN1(ikappa);
6109 int N2 = denS->gN2(ikappa);
6110 int TwoJ = denS->gTwoJ(ikappa);
6111 int TwoS1 = (N1==1)?1:0;
6113 int theindex = denS->gIndex();
6114 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
6115 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
6122 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
6123 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
6124 if ((abs(TwoSLdown-TwoSRdown)<=TwoS1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
6126 int fase =
phase(TwoSL - TwoSLdown + 1 + 2*TwoS1);
6127 const double factor = fase * sqrt(3.0 * (TwoSR+1) * (TwoSLdown+1) * (TwoJ+1))
6128 *
Wigner::wigner9j(2, TwoSR, TwoSRdown, 1, TwoSL, TwoSLdown, 1, TwoJ, TwoS1);
6130 for (
int l_index=0; l_index<theindex; l_index++){
6132 #ifdef CHEMPS2_MPI_COMPILATION 6133 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex+1 ) == MPIRANK )
6139 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
6140 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSRdown, IRdown);
6142 if ((dimLdown>0) && (dimRdown>0)){
6144 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,0,TwoS1,NR,TwoSRdown,IRdown);
6145 double * ptr = Dright[theindex+1-l_index][0]->gStorage(NR,TwoSR,IR,NR,TwoSRdown,IRdown);
6147 double alpha = factor;
6149 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRup,&beta,temp,&dimLdown);
6153 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
6155 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
6166 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
6167 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
6169 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
6170 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
6171 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
6173 int fase =
phase(TwoSR - TwoSRdown + 2*TwoS1);
6174 const double factor = fase * sqrt(3.0 * (TwoSR+1) * (TwoSLdown+1) * (TwoJdown+1))
6175 *
Wigner::wigner9j(2, TwoSRdown, TwoSR, 1, TwoSLdown, TwoSL, 1, TwoJdown, TwoS1);
6177 for (
int l_index=0; l_index<theindex; l_index++){
6179 #ifdef CHEMPS2_MPI_COMPILATION 6180 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex+1 ) == MPIRANK )
6186 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
6187 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSRdown, IRdown);
6189 if ((dimLdown>0) && (dimRdown>0)){
6191 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,N1,1,TwoJdown,NR,TwoSRdown,IRdown);
6192 double * ptr = Dright[theindex+1-l_index][0]->gStorage(NR,TwoSR,IR,NR,TwoSRdown,IRdown);
6194 double alpha = factor;
6196 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRup,&beta,temp,&dimLdown);
6200 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
6202 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
6214 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
6215 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
6217 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS1==0)) ? TwoS1+1 : 0;
6218 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS1+1; TwoJdown+=2){
6219 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
6221 int fase =
phase(TwoSLdown + 1 - TwoSL + 2*TwoS1);
6222 const double factor = fase * sqrt(3.0 * (TwoSRdown+1) * (TwoSL+1) * (TwoJdown+1))
6223 *
Wigner::wigner9j(2, TwoSRdown, TwoSR, 1, TwoSLdown, TwoSL, 1, TwoJdown, TwoS1);
6225 for (
int l_index=0; l_index<theindex; l_index++){
6227 #ifdef CHEMPS2_MPI_COMPILATION 6228 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex+1 ) == MPIRANK )
6234 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
6235 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSRdown, IRdown);
6237 if ((dimLdown>0) && (dimRdown>0)){
6239 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,1,TwoJdown,NR,TwoSRdown,IRdown);
6240 double * ptr = Dright[theindex+1-l_index][0]->gStorage(NR,TwoSRdown,IRdown,NR,TwoSR,IR);
6242 double alpha = factor;
6244 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRdown,&beta,temp,&dimLdown);
6248 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
6250 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
6262 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
6263 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
6264 if ((abs(TwoSLdown-TwoSRdown)<=TwoS1) && (TwoSLdown>=0) && (TwoSRdown>=0)){
6266 int fase =
phase(TwoSR - TwoSRdown + 2*TwoS1);
6267 const double factor = fase * sqrt(3.0 * (TwoSRdown+1) * (TwoSL+1) * (TwoJ+1))
6268 *
Wigner::wigner9j( 2, TwoSR, TwoSRdown, 1, TwoSL, TwoSLdown, 1, TwoJ, TwoS1 );
6270 for (
int l_index=0; l_index<theindex; l_index++){
6272 #ifdef CHEMPS2_MPI_COMPILATION 6273 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex+1 ) == MPIRANK )
6279 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
6280 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSRdown, IRdown);
6282 if ((dimLdown>0) && (dimRdown>0)){
6284 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,N1,2,TwoS1,NR,TwoSRdown,IRdown);
6285 double * ptr = Dright[theindex+1-l_index][0]->gStorage(NR,TwoSRdown,IRdown,NR,TwoSR,IR);
6287 double alpha = factor;
6289 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRdown,&beta,temp,&dimLdown);
6293 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
6295 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
6306 void CheMPS2::Heff::addDiagram4L3and4L4spin1(
const int ikappa,
double * memS,
double * memHeff,
const Sobject * denS, TensorL ** Lleft, TensorOperator *** Dright,
double * temp)
const{
6308 #ifdef CHEMPS2_MPI_COMPILATION 6312 int NL = denS->gNL(ikappa);
6313 int TwoSL = denS->gTwoSL(ikappa);
6314 int IL = denS->gIL(ikappa);
6316 int NR = denS->gNR(ikappa);
6317 int TwoSR = denS->gTwoSR(ikappa);
6318 int IR = denS->gIR(ikappa);
6320 int N1 = denS->gN1(ikappa);
6321 int N2 = denS->gN2(ikappa);
6322 int TwoJ = denS->gTwoJ(ikappa);
6323 int TwoS2 = (N2==1)?1:0;
6325 int theindex = denS->gIndex();
6326 int dimLup = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
6327 int dimRup = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
6334 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
6335 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
6336 if ((abs(TwoSLdown-TwoSRdown)<=TwoS2) && (TwoSLdown>=0) && (TwoSRdown>=0)){
6338 int fase =
phase(TwoSL - TwoSLdown + 2 + TwoS2 - TwoJ);
6339 const double factor = fase * sqrt(3.0 * (TwoSR+1) * (TwoSLdown+1) * (TwoJ+1))
6340 *
Wigner::wigner9j( 2, TwoSR, TwoSRdown, 1, TwoSL, TwoSLdown, 1, TwoJ, TwoS2 );
6342 for (
int l_index=0; l_index<theindex; l_index++){
6344 #ifdef CHEMPS2_MPI_COMPILATION 6345 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex ) == MPIRANK )
6351 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
6352 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSRdown, IRdown);
6354 if ((dimLdown>0) && (dimRdown>0)){
6356 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,0, N2,TwoS2,NR,TwoSRdown,IRdown);
6357 double * ptr = Dright[theindex-l_index][1]->gStorage(NR,TwoSR,IR,NR,TwoSRdown,IRdown);
6359 double alpha = factor;
6361 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRup,&beta,temp,&dimLdown);
6365 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
6367 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
6378 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
6379 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
6381 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
6382 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
6383 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
6385 int fase =
phase(TwoSR - TwoSRdown + 1 + TwoS2 - TwoJdown);
6386 const double factor = fase * sqrt(3.0 * (TwoSR+1) * (TwoSLdown+1) * (TwoJdown+1))
6387 *
Wigner::wigner9j( 2, TwoSRdown, TwoSR, 1, TwoSLdown, TwoSL, 1, TwoJdown, TwoS2 );
6389 for (
int l_index=0; l_index<theindex; l_index++){
6391 #ifdef CHEMPS2_MPI_COMPILATION 6392 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex ) == MPIRANK )
6398 int dimLdown = denBK->
gCurrentDim(theindex, NL+1, TwoSLdown, ILdown);
6399 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSRdown, IRdown);
6401 if ((dimLdown>0) && (dimRdown>0)){
6403 int memSkappa = denS->gKappa(NL+1,TwoSLdown,ILdown,1,N2,TwoJdown,NR,TwoSRdown,IRdown);
6404 double * ptr = Dright[theindex-l_index][1]->gStorage(NR,TwoSR,IR,NR,TwoSRdown,IRdown);
6406 double alpha = factor;
6408 dgemm_(¬rans,&trans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRup,&beta,temp,&dimLdown);
6412 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL,TwoSL,IL,NL+1,TwoSLdown,ILdown);
6414 dgemm_(¬rans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLup,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
6426 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
6427 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
6429 int TwoJstart = ((TwoSLdown!=TwoSRdown) || (TwoS2==0)) ? TwoS2+1 : 0;
6430 for (
int TwoJdown=TwoJstart; TwoJdown<=TwoS2+1; TwoJdown+=2){
6431 if ((abs(TwoSLdown-TwoSRdown)<=TwoJdown) && (TwoSLdown>=0) && (TwoSRdown>=0)){
6433 int fase =
phase(TwoSLdown + 2 - TwoSL + TwoS2 - TwoJdown);
6434 const double factor = fase * sqrt(3.0 * (TwoSRdown+1) * (TwoSL+1) * (TwoJdown+1))
6435 *
Wigner::wigner9j( 2, TwoSRdown, TwoSR, 1, TwoSLdown, TwoSL, 1, TwoJdown, TwoS2 );
6437 for (
int l_index=0; l_index<theindex; l_index++){
6439 #ifdef CHEMPS2_MPI_COMPILATION 6440 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex ) == MPIRANK )
6446 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
6447 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSRdown, IRdown);
6449 if ((dimLdown>0) && (dimRdown>0)){
6451 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,1,N2,TwoJdown,NR,TwoSRdown,IRdown);
6452 double * ptr = Dright[theindex-l_index][1]->gStorage(NR,TwoSRdown,IRdown,NR,TwoSR,IR);
6454 double alpha = factor;
6456 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRdown,&beta,temp,&dimLdown);
6460 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
6462 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&dimLdown,&beta,memHeff+denS->gKappa2index(ikappa),&dimLup);
6474 for (
int TwoSLdown=TwoSL-1; TwoSLdown<=TwoSL+1; TwoSLdown+=2){
6475 for (
int TwoSRdown=TwoSR-2; TwoSRdown<=TwoSR+2; TwoSRdown+=2){
6476 if ((abs(TwoSLdown-TwoSRdown)<=TwoS2) && (TwoSLdown>=0) && (TwoSRdown>=0)){
6478 int fase =
phase(TwoSR - TwoSRdown + 1 + TwoS2 - TwoJ);
6479 const double factor = fase * sqrt(3.0 * (TwoSRdown+1) * (TwoSL+1) * (TwoJ+1))
6480 *
Wigner::wigner9j( 2, TwoSR, TwoSRdown, 1, TwoSL, TwoSLdown, 1, TwoJ, TwoS2 );
6482 for (
int l_index=0; l_index<theindex; l_index++){
6484 #ifdef CHEMPS2_MPI_COMPILATION 6485 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_index, theindex ) == MPIRANK )
6491 int dimLdown = denBK->
gCurrentDim(theindex, NL-1, TwoSLdown, ILdown);
6492 int dimRdown = denBK->
gCurrentDim(theindex+2, NR, TwoSRdown, IRdown);
6494 if ((dimLdown>0) && (dimRdown>0)){
6496 int memSkappa = denS->gKappa(NL-1,TwoSLdown,ILdown,2,N2,TwoS2,NR,TwoSRdown,IRdown);
6497 double * ptr = Dright[theindex-l_index][1]->gStorage(NR,TwoSRdown,IRdown,NR,TwoSR,IR);
6499 double alpha = factor;
6501 dgemm_(¬rans,¬rans,&dimLdown,&dimRup,&dimRdown,&alpha,memS+denS->gKappa2index(memSkappa),&dimLdown,ptr,&dimRdown,&beta,temp,&dimLdown);
6505 double * blockL = Lleft[theindex-1-l_index]->gStorage(NL-1,TwoSLdown,ILdown,NL,TwoSL,IL);
6507 dgemm_(&trans,¬rans,&dimLup,&dimRup,&dimLdown,&alpha,blockL,&dimLdown,temp,&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.
static double wigner9j(const int two_ja, const int two_jb, const int two_jc, const int two_jd, const int two_je, const int two_jf, const int two_jg, const int two_jh, const int two_ji)
Wigner-9j symbol (gsl api)