9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-07 22:13:38 +01:00

Merge pull request #208 from v1j4y/csf_openshell

CSF-CI Open-Shell debugging
This commit is contained in:
Anthony Scemama 2022-06-10 13:46:11 +02:00 committed by GitHub
commit bc8a41fc6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 29 deletions

View File

@ -68,10 +68,16 @@ void getBFIndexList(int NSOMO, int *BF1, int *IdxListBF1){
break; break;
} }
} }
BFcopy[Iidx] = -1; if(countN1 <= 0){
BFcopy[Jidx] = -1; BFcopy[Iidx] = -1;
IdxListBF1[Jidx] = Iidx; IdxListBF1[Iidx] = Iidx;
IdxListBF1[Iidx] = Jidx; }
else{
BFcopy[Iidx] = -1;
BFcopy[Jidx] = -1;
IdxListBF1[Jidx] = Iidx;
IdxListBF1[Iidx] = Jidx;
}
} }
} }
@ -328,10 +334,21 @@ void convertCSFtoDetBasis(int64_t Isomo, int MS, int rowsmax, int colsmax, doubl
Get Overlap Get Overlap
************************************/ ************************************/
// Fill matrix // Fill matrix
int rowsbftodetI, colsbftodetI;
/***********************************
Get BFtoDeterminant Matrix
************************************/
printf("In convertcsftodet\n");
convertBFtoDetBasis(Isomo, MS, &bftodetmatrixI, &rowsbftodetI, &colsbftodetI);
int rowsI = 0; int rowsI = 0;
int colsI = 0; int colsI = 0;
getOverlapMatrix(Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO); //getOverlapMatrix(Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO);
getOverlapMatrix_withDet(bftodetmatrixI, rowsbftodetI, colsbftodetI, Isomo, MS, &overlapMatrixI, &rowsI, &colsI, &NSOMO);
/*********************************** /***********************************
@ -342,14 +359,6 @@ void convertCSFtoDetBasis(int64_t Isomo, int MS, int rowsmax, int colsmax, doubl
gramSchmidt(overlapMatrixI, rowsI, colsI, orthoMatrixI); gramSchmidt(overlapMatrixI, rowsI, colsI, orthoMatrixI);
/***********************************
Get BFtoDeterminant Matrix
************************************/
int rowsbftodetI, colsbftodetI;
convertBFtoDetBasis(Isomo, MS, &bftodetmatrixI, &rowsbftodetI, &colsbftodetI);
/*********************************** /***********************************
Get Final CSF to Det Matrix Get Final CSF to Det Matrix
************************************/ ************************************/
@ -1297,12 +1306,16 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv
double fac = 1.0; double fac = 1.0;
for(int i = 0; i < NSOMO; i++) for(int i = 0; i < NSOMO; i++)
donepq[i] = 0.0; donepq[i] = 0.0;
for(int i=0;i<npairs;++i){
for(int j=0;j<NSOMO;++j)
detslist[i*NSOMO + j]=0;
}
for(int i = 0; i < NSOMO; i++){ for(int i = 0; i < NSOMO; i++){
idxp = BF1[i]; idxp = BF1[i];
idxq = BF1[idxp]; idxq = BF1[idxp];
// Do one pair only once // 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; fac *= 2.0;
donepq[idxp] = 1.0; donepq[idxp] = 1.0;
donepq[idxq] = 1.0; donepq[idxq] = 1.0;
@ -1325,9 +1338,13 @@ void getbftodetfunction(Tree *dettree, int NSOMO, int MS, int *BF1, double *rowv
int phase_cfg_to_qp=1; int phase_cfg_to_qp=1;
int addr = -1; int addr = -1;
for(int i = 0; i < npairs; i++){ 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]; inpdet[j] = detslist[i*NSOMO + j];
printf(" %d ",inpdet[j]);
}
printf("\n");
findAddofDetDriver(dettree, NSOMO, inpdet, &addr); findAddofDetDriver(dettree, NSOMO, inpdet, &addr);
printf("(%d) - addr = %d\n",i,addr);
// Calculate the phase for cfg to QP2 conversion // Calculate the phase for cfg to QP2 conversion
//get_phase_cfg_to_qp_inpList(inpdet, NSOMO, &phase_cfg_to_qp); //get_phase_cfg_to_qp_inpList(inpdet, NSOMO, &phase_cfg_to_qp);
//rowvec[addr] = 1.0 * phaselist[i]*phase_cfg_to_qp/sqrt(fac); //rowvec[addr] = 1.0 * phaselist[i]*phase_cfg_to_qp/sqrt(fac);
@ -1416,7 +1433,6 @@ void convertBFtoDetBasis(int64_t Isomo, int MS, double **bftodetmatrixptr, int *
getIthBFDriver(&bftree, NSOMO, addI, BF1); getIthBFDriver(&bftree, NSOMO, addI, BF1);
getBFIndexList(NSOMO, BF1, IdxListBF1); getBFIndexList(NSOMO, BF1, IdxListBF1);
// Get ith row // Get ith row
getbftodetfunction(&dettree, NSOMO, MS, IdxListBF1, rowvec); getbftodetfunction(&dettree, NSOMO, MS, IdxListBF1, rowvec);
@ -1425,6 +1441,11 @@ void convertBFtoDetBasis(int64_t Isomo, int MS, double **bftodetmatrixptr, int *
for(int k=0;k<ndets;k++) for(int k=0;k<ndets;k++)
rowvec[k]=0.0; rowvec[k]=0.0;
for(int j=0;j<NSOMO;++j){
BF1[j]=0;
IdxListBF1[j]=0;
}
} }
// Garbage collection // Garbage collection
@ -1680,7 +1701,6 @@ void getApqIJMatrixDriverArrayInp(int64_t Isomo, int64_t Jsomo, int32_t orbp, in
gramSchmidt(overlapMatrixJ, rowsJ, colsJ, orthoMatrixJ); gramSchmidt(overlapMatrixJ, rowsJ, colsJ, orthoMatrixJ);
int rowsA = 0; int rowsA = 0;
int colsA = 0; int colsA = 0;

View File

@ -17,27 +17,31 @@ void buildTree(Tree *bftree,
if(isomo > NSOMOMax || icpl < 0 || izeros > zeromax ) return; if(isomo > NSOMOMax || icpl < 0 || izeros > zeromax ) return;
// If we find a valid BF assign its address // If we find a valid BF assign its address
if(isomo == NSOMOMax){ if(isomo == NSOMOMax && icpl == MSmax){
(*inode)->addr = bftree->rootNode->addr; (*inode)->addr = bftree->rootNode->addr;
bftree->rootNode->addr += 1; bftree->rootNode->addr += 1;
return; return;
} }
// Call 0 branch // Call 0 branch
if(((*inode)->C0) == NULL && izeros+1 <= zeromax){ if(izeros+1 <= zeromax){
((*inode)->C0) = malloc(sizeof(Node)); if(((*inode)->C0) == NULL){
(*(*inode)->C0) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 0, .iSOMO = isomo }; ((*inode)->C0) = malloc(sizeof(Node));
buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax); (*(*inode)->C0) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 0, .iSOMO = isomo };
buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax);
}
else buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax);
} }
else buildTree(bftree, &(*inode)->C0, isomo+1, izeros+1, icpl+1, NSOMOMax, MSmax);
// Call 1 branch // Call 1 branch
if(((*inode)->C1) == NULL && icpl-1 >= 0){ if(icpl-1 >=0){
((*inode)->C1) = malloc(sizeof(Node)); if(((*inode)->C1) == NULL){
(*(*inode)->C1) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 1, .iSOMO = isomo }; ((*inode)->C1) = malloc(sizeof(Node));
buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax); (*(*inode)->C1) = (Node){ .C0 = NULL, .C1 = NULL, .PREV = *inode, .addr = -1, .cpl = 1, .iSOMO = isomo };
buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax);
}
else buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax);
} }
else buildTree(bftree, &(*inode)->C1, isomo+1, izeros+0, icpl-1, NSOMOMax, MSmax);
return; return;
} }