24 #include "MPIchemps2.h" 27 void CheMPS2::Heff::addDiagonal1A(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorX * Xleft)
const{
28 int dimL = denBK->
gCurrentDim(denS->gIndex(), denS->gNL(ikappa), denS->gTwoSL(ikappa), denS->gIL(ikappa));
29 int dimR = denBK->
gCurrentDim(denS->gIndex()+2, denS->gNR(ikappa), denS->gTwoSR(ikappa), denS->gIR(ikappa));
30 double * BlockX = Xleft->gStorage( denS->gNL(ikappa), denS->gTwoSL(ikappa), denS->gIL(ikappa), denS->gNL(ikappa), denS->gTwoSL(ikappa), denS->gIL(ikappa) );
31 int ptr = denS->gKappa2index(ikappa);
33 for (
int cnt=0; cnt<dimL; cnt++){
34 for (
int cnt2=0; cnt2<dimR; cnt2++){
35 memHeffDiag[ptr + cnt + dimL*cnt2] += BlockX[cnt*(dimL+1)];
41 void CheMPS2::Heff::addDiagonal1B(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorX * Xright)
const{
42 int dimL = denBK->
gCurrentDim(denS->gIndex(), denS->gNL(ikappa), denS->gTwoSL(ikappa), denS->gIL(ikappa));
43 int dimR = denBK->
gCurrentDim(denS->gIndex()+2, denS->gNR(ikappa), denS->gTwoSR(ikappa), denS->gIR(ikappa));
44 double * BlockX = Xright->gStorage( denS->gNR(ikappa), denS->gTwoSR(ikappa), denS->gIR(ikappa), denS->gNR(ikappa), denS->gTwoSR(ikappa), denS->gIR(ikappa) );
45 int ptr = denS->gKappa2index(ikappa);
47 for (
int cnt=0; cnt<dimL; cnt++){
48 for (
int cnt2=0; cnt2<dimR; cnt2++){
49 memHeffDiag[ptr + cnt + dimL*cnt2] += BlockX[cnt2*(dimR+1)];
55 void CheMPS2::Heff::addDiagonal1C(
const int ikappa,
double * memHeffDiag,
const Sobject * denS,
const double Helem_links)
const{
56 if (denS->gN1(ikappa)==2){
57 int ptr = denS->gKappa2index(ikappa);
58 int dim = denS->gKappa2index(ikappa+1) - ptr;
59 for (
int cnt=0; cnt<dim; cnt++){ memHeffDiag[ptr + cnt] += Helem_links; }
63 void CheMPS2::Heff::addDiagonal1D(
const int ikappa,
double * memHeffDiag,
const Sobject * denS,
const double Helem_rechts)
const{
64 if (denS->gN2(ikappa)==2){
65 int ptr = denS->gKappa2index(ikappa);
66 int dim = denS->gKappa2index(ikappa+1) - ptr;
67 for (
int cnt=0; cnt<dim; cnt++){ memHeffDiag[ptr + cnt] += Helem_rechts; }
71 void CheMPS2::Heff::addDiagonal2d3all(
const int ikappa,
double * memHeffDiag,
const Sobject * denS)
const{
73 if ((denS->gN1(ikappa)==2)&&(denS->gN2(ikappa)==2)){
75 const int theindex = denS->gIndex();
76 const int ptr = denS->gKappa2index(ikappa);
77 const int dim = denS->gKappa2index(ikappa+1) - ptr;
78 const double factor = 4 * Prob->
gMxElement(theindex,theindex+1,theindex,theindex+1)
79 - 2 * Prob->
gMxElement(theindex,theindex+1,theindex+1,theindex);
81 for (
int cnt=0; cnt<dim; cnt++){ memHeffDiag[ptr + cnt] += factor; }
85 if ((denS->gN1(ikappa)==1)&&(denS->gN2(ikappa)==1)){
87 const int theindex = denS->gIndex();
88 const int ptr = denS->gKappa2index(ikappa);
89 const int dim = denS->gKappa2index(ikappa+1) - ptr;
90 const int fase = (denS->gTwoJ(ikappa) == 2)? -1: 1;
91 const double factor = Prob->
gMxElement(theindex,theindex+1,theindex,theindex+1)
92 + fase * Prob->
gMxElement(theindex,theindex+1,theindex+1,theindex);
94 for (
int cnt=0; cnt<dim; cnt++){ memHeffDiag[ptr + cnt] += factor; }
98 if ((denS->gN1(ikappa)==2)&&(denS->gN2(ikappa)==1)){
100 const int theindex = denS->gIndex();
101 const int ptr = denS->gKappa2index(ikappa);
102 const int dim = denS->gKappa2index(ikappa+1) - ptr;
103 const double factor = 2 * Prob->
gMxElement(theindex,theindex+1,theindex,theindex+1)
104 - Prob->
gMxElement(theindex,theindex+1,theindex+1,theindex);
106 for (
int cnt=0; cnt<dim; cnt++){ memHeffDiag[ptr + cnt] += factor; }
110 if ((denS->gN1(ikappa)==1)&&(denS->gN2(ikappa)==2)){
112 const int theindex = denS->gIndex();
113 const int ptr = denS->gKappa2index(ikappa);
114 const int dim = denS->gKappa2index(ikappa+1) - ptr;
115 const double factor = 2 * Prob->
gMxElement(theindex,theindex+1,theindex,theindex+1)
116 - Prob->
gMxElement(theindex,theindex+1,theindex+1,theindex);
118 for (
int cnt=0; cnt<dim; cnt++){ memHeffDiag[ptr + cnt] += factor; }
124 void CheMPS2::Heff::addDiagonal2b3spin0(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorOperator * Ctensor)
const{
126 int N1 = denS->gN1(ikappa);
130 int theindex = denS->gIndex();
131 int ptr = denS->gKappa2index(ikappa);
133 double sqrt0p5 = sqrt(0.5);
135 int NL = denS->gNL(ikappa);
136 int TwoSL = denS->gTwoSL(ikappa);
137 int IL = denS->gIL(ikappa);
139 int dimL = denBK->
gCurrentDim(theindex, NL, TwoSL, IL);
140 int dimR = denBK->
gCurrentDim(theindex+2,denS->gNR(ikappa),denS->gTwoSR(ikappa),denS->gIR(ikappa));
142 double * Cblock = Ctensor->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
143 for (
int cntR=0; cntR<dimR; cntR++){
144 for (
int cntL=0; cntL<dimL; cntL++){
145 memHeffDiag[ptr + cntL + dimL*cntR] += N1*sqrt0p5*Cblock[(dimL+1)*cntL];
153 void CheMPS2::Heff::addDiagonal2c3spin0(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorOperator * Ctensor)
const{
155 int N2 = denS->gN2(ikappa);
159 int theindex = denS->gIndex();
160 int ptr = denS->gKappa2index(ikappa);
162 double sqrt0p5 = sqrt(0.5);
164 int NL = denS->gNL(ikappa);
165 int TwoSL = denS->gTwoSL(ikappa);
166 int IL = denS->gIL(ikappa);
168 int dimL = denBK->
gCurrentDim(theindex, NL, TwoSL, IL);
169 int dimR = denBK->
gCurrentDim(theindex+2,denS->gNR(ikappa),denS->gTwoSR(ikappa),denS->gIR(ikappa));
171 double * Cblock = Ctensor->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
172 for (
int cntR=0; cntR<dimR; cntR++){
173 for (
int cntL=0; cntL<dimL; cntL++){
174 memHeffDiag[ptr + cntL + dimL*cntR] += N2*sqrt0p5*Cblock[(dimL+1)*cntL];
182 void CheMPS2::Heff::addDiagonal2e3spin0(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorOperator * Ctensor)
const{
184 int N1 = denS->gN1(ikappa);
188 int theindex = denS->gIndex();
189 int ptr = denS->gKappa2index(ikappa);
191 double sqrt0p5 = sqrt(0.5);
193 int NR = denS->gNR(ikappa);
194 int TwoSR = denS->gTwoSR(ikappa);
195 int IR = denS->gIR(ikappa);
197 int dimR = denBK->
gCurrentDim(theindex+2,NR, TwoSR, IR);
198 int dimL = denBK->
gCurrentDim(theindex ,denS->gNL(ikappa),denS->gTwoSL(ikappa),denS->gIL(ikappa));
200 double * Cblock = Ctensor->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
201 for (
int cntR=0; cntR<dimR; cntR++){
202 for (
int cntL=0; cntL<dimL; cntL++){
203 memHeffDiag[ptr + cntL + dimL*cntR] += N1*sqrt0p5*Cblock[(dimR+1)*cntR];
211 void CheMPS2::Heff::addDiagonal2f3spin0(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorOperator * Ctensor)
const{
213 int N2 = denS->gN2(ikappa);
217 int theindex = denS->gIndex();
218 int ptr = denS->gKappa2index(ikappa);
220 double sqrt0p5 = sqrt(0.5);
222 int NR = denS->gNR(ikappa);
223 int TwoSR = denS->gTwoSR(ikappa);
224 int IR = denS->gIR(ikappa);
226 int dimR = denBK->
gCurrentDim(theindex+2,NR, TwoSR, IR);
227 int dimL = denBK->
gCurrentDim(theindex ,denS->gNL(ikappa),denS->gTwoSL(ikappa),denS->gIL(ikappa));
229 double * Cblock = Ctensor->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
230 for (
int cntR=0; cntR<dimR; cntR++){
231 for (
int cntL=0; cntL<dimL; cntL++){
232 memHeffDiag[ptr + cntL + dimL*cntR] += N2*sqrt0p5*Cblock[(dimR+1)*cntR];
240 void CheMPS2::Heff::addDiagonal2b3spin1(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorOperator * Dtensor)
const{
242 int N1 = denS->gN1(ikappa);
246 int theindex = denS->gIndex();
247 int ptr = denS->gKappa2index(ikappa);
249 int NL = denS->gNL(ikappa);
250 int TwoSL = denS->gTwoSL(ikappa);
251 int IL = denS->gIL(ikappa);
252 int NR = denS->gNR(ikappa);
253 int TwoSR = denS->gTwoSR(ikappa);
254 int IR = denS->gIR(ikappa);
255 int TwoJ = denS->gTwoJ(ikappa);
256 int N2 = denS->gN2(ikappa);
258 int dimL = denBK->
gCurrentDim(theindex, NL,TwoSL,IL);
259 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
261 int fase =
phase(TwoSL + TwoSR + 2*TwoJ + ((N2==1)?1:0) - 1);
262 const double alpha = fase * (TwoJ+1) * sqrt(3.0*(TwoSL+1)) *
Wigner::wigner6j(TwoJ,TwoJ,2,1,1,((N2==1)?1:0)) *
Wigner::wigner6j(TwoJ,TwoJ,2,TwoSL,TwoSL,TwoSR);
264 double * Dblock = Dtensor->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
265 for (
int cntR=0; cntR<dimR; cntR++){
266 for (
int cntL=0; cntL<dimL; cntL++){
267 memHeffDiag[ptr + cntL + dimL*cntR] += alpha * Dblock[(dimL+1)*cntL];
275 void CheMPS2::Heff::addDiagonal2c3spin1(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorOperator * Dtensor)
const{
277 int N2 = denS->gN2(ikappa);
281 int theindex = denS->gIndex();
282 int ptr = denS->gKappa2index(ikappa);
284 int NL = denS->gNL(ikappa);
285 int TwoSL = denS->gTwoSL(ikappa);
286 int IL = denS->gIL(ikappa);
287 int NR = denS->gNR(ikappa);
288 int TwoSR = denS->gTwoSR(ikappa);
289 int IR = denS->gIR(ikappa);
290 int TwoJ = denS->gTwoJ(ikappa);
291 int N1 = denS->gN1(ikappa);
293 int dimL = denBK->
gCurrentDim(theindex, NL,TwoSL,IL);
294 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
296 int fase =
phase(TwoSL + TwoSR + 2*TwoJ + ((N1==1)?1:0) - 1);
297 const double alpha = fase * (TwoJ+1) * sqrt(3.0*(TwoSL+1)) *
Wigner::wigner6j(TwoJ,TwoJ,2,1,1,((N1==1)?1:0)) *
Wigner::wigner6j(TwoJ,TwoJ,2,TwoSL,TwoSL,TwoSR);
299 double * Dblock = Dtensor->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
300 for (
int cntR=0; cntR<dimR; cntR++){
301 for (
int cntL=0; cntL<dimL; cntL++){
302 memHeffDiag[ptr + cntL + dimL*cntR] += alpha * Dblock[(dimL+1)*cntL];
310 void CheMPS2::Heff::addDiagonal2e3spin1(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorOperator * Dtensor)
const{
312 int N1 = denS->gN1(ikappa);
316 int theindex = denS->gIndex();
317 int ptr = denS->gKappa2index(ikappa);
319 int NL = denS->gNL(ikappa);
320 int TwoSL = denS->gTwoSL(ikappa);
321 int IL = denS->gIL(ikappa);
322 int NR = denS->gNR(ikappa);
323 int TwoSR = denS->gTwoSR(ikappa);
324 int IR = denS->gIR(ikappa);
325 int TwoJ = denS->gTwoJ(ikappa);
326 int N2 = denS->gN2(ikappa);
328 int dimL = denBK->
gCurrentDim(theindex, NL,TwoSL,IL);
329 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
331 int fase =
phase(TwoSR + TwoSL + 2*TwoJ + ((N2==1)?1:0) + 1);
332 const double alpha = fase * (TwoJ+1) * sqrt(3.0*(TwoSR+1)) *
Wigner::wigner6j(TwoJ,TwoJ,2,1,1,((N2==1)?1:0)) *
Wigner::wigner6j(TwoJ,TwoJ,2,TwoSR,TwoSR,TwoSL);
334 double * Dblock = Dtensor->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
335 for (
int cntR=0; cntR<dimR; cntR++){
336 for (
int cntL=0; cntL<dimL; cntL++){
337 memHeffDiag[ptr + cntL + dimL*cntR] += alpha * Dblock[(dimR+1)*cntR];
345 void CheMPS2::Heff::addDiagonal2f3spin1(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorOperator * Dtensor)
const{
347 int N2 = denS->gN2(ikappa);
351 int theindex = denS->gIndex();
352 int ptr = denS->gKappa2index(ikappa);
354 int NL = denS->gNL(ikappa);
355 int TwoSL = denS->gTwoSL(ikappa);
356 int IL = denS->gIL(ikappa);
357 int NR = denS->gNR(ikappa);
358 int TwoSR = denS->gTwoSR(ikappa);
359 int IR = denS->gIR(ikappa);
360 int TwoJ = denS->gTwoJ(ikappa);
361 int N1 = denS->gN1(ikappa);
363 int dimL = denBK->
gCurrentDim(theindex, NL,TwoSL,IL);
364 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
366 int fase =
phase(TwoSR + TwoSL + 2*TwoJ + ((N1==1)?1:0) + 1);
367 const double alpha = fase * (TwoJ+1) * sqrt(3.0*(TwoSR+1)) *
Wigner::wigner6j(TwoJ,TwoJ,2,1,1,((N1==1)?1:0)) *
Wigner::wigner6j(TwoJ,TwoJ,2,TwoSR,TwoSR,TwoSL);
369 double * Dblock = Dtensor->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
370 for (
int cntR=0; cntR<dimR; cntR++){
371 for (
int cntL=0; cntL<dimL; cntL++){
372 memHeffDiag[ptr + cntL + dimL*cntR] += alpha * Dblock[(dimR+1)*cntR];
380 void CheMPS2::Heff::addDiagonal2a3spin0(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorOperator **** Ctensors, TensorF0 **** F0tensors)
const{
382 #ifdef CHEMPS2_MPI_COMPILATION 386 int NL = denS->gNL(ikappa);
387 int TwoSL = denS->gTwoSL(ikappa);
388 int IL = denS->gIL(ikappa);
390 int NR = denS->gNR(ikappa);
391 int TwoSR = denS->gTwoSR(ikappa);
392 int IR = denS->gIR(ikappa);
394 int theindex = denS->gIndex();
395 int ptr = denS->gKappa2index(ikappa);
397 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
398 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
400 bool leftSum = ( theindex < Prob->
gL()*0.5 )?
true:
false;
404 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
405 for (
int l_alpha=l_gamma+1; l_alpha<theindex; l_alpha++){
407 #ifdef CHEMPS2_MPI_COMPILATION 408 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_gamma, l_alpha ) == MPIRANK )
413 double * Cblock = Ctensors[theindex+1][l_alpha-l_gamma][theindex+1-l_alpha]->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
414 double * BlockF0 = F0tensors[theindex-1][l_alpha-l_gamma][theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
416 for (
int cntL=0; cntL<dimL; cntL++){
417 for (
int cntR=0; cntR<dimR; cntR++){
418 memHeffDiag[ptr + cntL + dimL*cntR] += BlockF0[(dimL+1)*cntL] * Cblock[(dimR+1)*cntR];
426 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
427 for (
int l_gamma=l_alpha; l_gamma<theindex; l_gamma++){
429 #ifdef CHEMPS2_MPI_COMPILATION 430 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_alpha, l_gamma ) == MPIRANK )
435 double * Cblock = Ctensors[theindex+1][l_gamma-l_alpha][theindex+1-l_gamma]->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
436 double * BlockF0 = F0tensors[theindex-1][l_gamma-l_alpha][theindex-1-l_gamma]->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
438 for (
int cntL=0; cntL<dimL; cntL++){
439 for (
int cntR=0; cntR<dimR; cntR++){
440 memHeffDiag[ptr + cntL + dimL*cntR] += BlockF0[(dimL+1)*cntL] * Cblock[(dimR+1)*cntR];
450 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
451 for (
int l_beta=l_delta+1; l_beta<Prob->
gL(); l_beta++){
453 #ifdef CHEMPS2_MPI_COMPILATION 454 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_delta, l_beta ) == MPIRANK )
459 double * Cblock = Ctensors[theindex-1][l_beta-l_delta][l_delta-theindex]->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
460 double * BlockF0 = F0tensors[theindex+1][l_beta-l_delta][l_delta-theindex-2]->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
462 for (
int cntL=0; cntL<dimL; cntL++){
463 for (
int cntR=0; cntR<dimR; cntR++){
464 memHeffDiag[ptr + cntL + dimL*cntR] += Cblock[(dimL+1)*cntL] * BlockF0[(dimR+1)*cntR];
472 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
473 for (
int l_delta=l_beta; l_delta<Prob->
gL(); l_delta++){
475 #ifdef CHEMPS2_MPI_COMPILATION 476 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_beta, l_delta ) == MPIRANK )
481 double * Cblock = Ctensors[theindex-1][l_delta-l_beta][l_beta-theindex]->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
482 double * BlockF0 = F0tensors[theindex+1][l_delta-l_beta][l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
484 for (
int cntL=0; cntL<dimL; cntL++){
485 for (
int cntR=0; cntR<dimR; cntR++){
486 memHeffDiag[ptr + cntL + dimL*cntR] += Cblock[(dimL+1)*cntL] * BlockF0[(dimR+1)*cntR];
498 void CheMPS2::Heff::addDiagonal2a3spin1(
const int ikappa,
double * memHeffDiag,
const Sobject * denS, TensorOperator **** Dtensors, TensorF1 **** F1tensors)
const{
500 #ifdef CHEMPS2_MPI_COMPILATION 504 int NL = denS->gNL(ikappa);
505 int TwoSL = denS->gTwoSL(ikappa);
506 int IL = denS->gIL(ikappa);
508 int NR = denS->gNR(ikappa);
509 int TwoSR = denS->gTwoSR(ikappa);
510 int IR = denS->gIR(ikappa);
512 int TwoJ = denS->gTwoJ(ikappa);
513 const int fase =
phase(TwoSL+TwoSR+TwoJ+2);
514 const double alpha = fase * sqrt((TwoSR + 1)*(TwoSL + 1.0)) *
Wigner::wigner6j(TwoSL,TwoSR,TwoJ,TwoSR,TwoSL,2);
516 int theindex = denS->gIndex();
517 int ptr = denS->gKappa2index(ikappa);
519 int dimL = denBK->
gCurrentDim(theindex ,NL,TwoSL,IL);
520 int dimR = denBK->
gCurrentDim(theindex+2,NR,TwoSR,IR);
522 bool leftSum = ( theindex < Prob->
gL()*0.5 )?
true:
false;
526 for (
int l_gamma=0; l_gamma<theindex; l_gamma++){
527 for (
int l_alpha=l_gamma+1; l_alpha<theindex; l_alpha++){
529 #ifdef CHEMPS2_MPI_COMPILATION 530 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_gamma, l_alpha ) == MPIRANK )
535 double * Dblock = Dtensors[theindex+1][l_alpha-l_gamma][theindex+1-l_alpha]->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
536 double * BlockF1 = F1tensors[theindex-1][l_alpha-l_gamma][theindex-1-l_alpha]->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
538 for (
int cntL=0; cntL<dimL; cntL++){
539 for (
int cntR=0; cntR<dimR; cntR++){
540 memHeffDiag[ptr + cntL + dimL*cntR] += alpha * BlockF1[(dimL+1)*cntL] * Dblock[(dimR+1)*cntR];
548 for (
int l_alpha=0; l_alpha<theindex; l_alpha++){
549 for (
int l_gamma=l_alpha; l_gamma<theindex; l_gamma++){
551 #ifdef CHEMPS2_MPI_COMPILATION 552 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_alpha, l_gamma ) == MPIRANK )
558 double * Dblock = Dtensors[theindex+1][l_gamma-l_alpha][theindex+1-l_gamma]->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
559 double * BlockF1 = F1tensors[theindex-1][l_gamma-l_alpha][theindex-1-l_gamma]->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
561 for (
int cntL=0; cntL<dimL; cntL++){
562 for (
int cntR=0; cntR<dimR; cntR++){
563 memHeffDiag[ptr + cntL + dimL*cntR] += alpha * BlockF1[(dimL+1)*cntL] * Dblock[(dimR+1)*cntR];
573 for (
int l_delta=theindex+2; l_delta<Prob->
gL(); l_delta++){
574 for (
int l_beta=l_delta+1; l_beta<Prob->
gL(); l_beta++){
576 #ifdef CHEMPS2_MPI_COMPILATION 577 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_delta, l_beta ) == MPIRANK )
582 double * Dblock = Dtensors[theindex-1][l_beta-l_delta][l_delta-theindex]->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
583 double * BlockF1 = F1tensors[theindex+1][l_beta-l_delta][l_delta-theindex-2]->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
585 for (
int cntL=0; cntL<dimL; cntL++){
586 for (
int cntR=0; cntR<dimR; cntR++){
587 memHeffDiag[ptr + cntL + dimL*cntR] += alpha * Dblock[(dimL+1)*cntL] * BlockF1[(dimR+1)*cntR];
595 for (
int l_beta=theindex+2; l_beta<Prob->
gL(); l_beta++){
596 for (
int l_delta=l_beta; l_delta<Prob->
gL(); l_delta++){
598 #ifdef CHEMPS2_MPI_COMPILATION 599 if ( MPIchemps2::owner_cdf( Prob->
gL(), l_beta, l_delta ) == MPIRANK )
604 double * Dblock = Dtensors[theindex-1][l_delta-l_beta][l_beta-theindex]->gStorage(NL,TwoSL,IL,NL,TwoSL,IL);
605 double * BlockF1 = F1tensors[theindex+1][l_delta-l_beta][l_beta-theindex-2]->gStorage(NR,TwoSR,IR,NR,TwoSR,IR);
607 for (
int cntL=0; cntL<dimL; cntL++){
608 for (
int cntR=0; cntR<dimR; cntR++){
609 memHeffDiag[ptr + cntL + dimL*cntR] += alpha * Dblock[(dimL+1)*cntL] * BlockF1[(dimR+1)*cntR];
621 void CheMPS2::Heff::addDiagonalExcitations(
const int ikappa,
double * memHeffDiag,
const Sobject * denS,
int nLower,
double ** VeffTilde)
const{
623 const int loc = denS->gKappa2index(ikappa);
624 const int dim = denS->gKappa2index(ikappa+1) - loc;
625 #ifdef CHEMPS2_MPI_COMPILATION 629 for (
int state=0; state<nLower; state++){
630 #ifdef CHEMPS2_MPI_COMPILATION 631 if ( MPIchemps2::owner_specific_excitation( Prob->
gL(), state ) == MPIRANK )
634 for (
int cnt=0; cnt<dim; cnt++){
635 memHeffDiag[loc + cnt] += VeffTilde[state][loc+cnt] * VeffTilde[state][loc+cnt];
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.
int gL() const
Get the number of orbitals.
static int phase(const int TwoTimesPower)
Phase function.
int gIrrep(const int orbital) const
Get an orbital irrep.