10
0
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-06-26 15:12:19 +02:00

Open-Shell CSF: Fix bug in getbftodetfunction.

This commit is contained in:
v1j4y 2022-06-06 13:41:29 +02:00
parent 727815751c
commit 4ccaa8f695

View File

@ -68,10 +68,16 @@ void getBFIndexList(int NSOMO, int *BF1, int *IdxListBF1){
break;
}
}
BFcopy[Iidx] = -1;
BFcopy[Jidx] = -1;
IdxListBF1[Jidx] = Iidx;
IdxListBF1[Iidx] = Jidx;
if(countN1 <= 0){
BFcopy[Iidx] = -1;
IdxListBF1[Iidx] = Iidx;
}
else{
BFcopy[Iidx] = -1;
BFcopy[Jidx] = -1;
IdxListBF1[Jidx] = Iidx;
IdxListBF1[Iidx] = Jidx;
}
}
}
@ -1297,16 +1303,21 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv
double fac = 1.0;
for(int i = 0; i < NSOMO; i++)
donepq[i] = 0.0;
for(int i=0;i<npairs;++i){
for(int j=0;j<NSOMO;++j)
detslist[i*npairs + j]=0;
}
for(int i = 0; i < NSOMO; i++){
idxp = BF1[i];
idxq = BF1[idxp];
// Do one pair only once
if(donepq[idxp] > 0.0 || donepq[idxq] > 0.0) continue;
if(donepq[idxp] > 0.0 || donepq[idxq] > 0.0 || idxp == idxq) continue;
fac *= 2.0;
donepq[idxp] = 1.0;
donepq[idxq] = 1.0;
for(int j = 0; j < npairs; j = j + shft){
printf("i=%d j=%d (%d,%d)\n",i,j,idxp,idxq);
for(int k = 0; k < shft/2; k++){
detslist[(k+j)*NSOMO + idxp] = 1;
detslist[(k+j)*NSOMO + idxq] = 0;
@ -1319,15 +1330,26 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv
}
shft /= 2;
}
for(int i=0;i<npairs;++i){
for(int j=0;j<NSOMO;++j)
printf(" %d ",detslist[i*NSOMO + j]);
printf("\n");
}
printf(" done detslist npairs=%d NSOMO=%d\n",npairs,NSOMO);
// Now get the addresses
int inpdet[NSOMO];
int phase_cfg_to_qp=1;
int addr = -1;
for(int i = 0; i < npairs; i++){
for(int j = 0; j < NSOMO; j++)
for(int j = 0; j < NSOMO; j++) {
inpdet[j] = detslist[i*NSOMO + j];
printf(" %d ",inpdet[j]);
printf("\n-- i=%d j=%d \n",i,j);
}
findAddofDetDriver(dettree, NSOMO, inpdet, &addr);
printf("(%d) add=%d\n",i,addr);
// Calculate the phase for cfg to QP2 conversion
//get_phase_cfg_to_qp_inpList(inpdet, NSOMO, &phase_cfg_to_qp);
//rowvec[addr] = 1.0 * phaselist[i]*phase_cfg_to_qp/sqrt(fac);
@ -1415,6 +1437,10 @@ void convertBFtoDetBasis(int64_t Isomo, int MS, double **bftodetmatrixptr, int *
addI = i;
getIthBFDriver(&bftree, NSOMO, addI, BF1);
getBFIndexList(NSOMO, BF1, IdxListBF1);
printf("ms=%d \n",MS);
for(int j=0;j<NSOMO;++j)
printf(" %d(%d) ",BF1[j],IdxListBF1[j]);
printf("\n");
// Get ith row
@ -1661,6 +1687,12 @@ void getApqIJMatrixDriverArrayInp(int64_t Isomo, int64_t Jsomo, int32_t orbp, in
orthoMatrixI = malloc(rowsI*colsI*sizeof(double));
gramSchmidt(overlapMatrixI, rowsI, colsI, orthoMatrixI);
for(int i=0;i<rowsI;++i) {
for(int j=0;j<colsI; ++j) {
printf(" %5.3f ",orthoMatrixI[j*rowsI + i]);
}
printf("\n");
}
/***********************************
Doing J
@ -1680,6 +1712,12 @@ void getApqIJMatrixDriverArrayInp(int64_t Isomo, int64_t Jsomo, int32_t orbp, in
gramSchmidt(overlapMatrixJ, rowsJ, colsJ, orthoMatrixJ);
for(int i=0;i<rowsJ;++i) {
for(int j=0;j<colsJ; ++j) {
printf(" %5.3f ",orthoMatrixJ[j*rowsJ + i]);
}
printf("\n");
}
int rowsA = 0;
int colsA = 0;