Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial state with OrbitalSgn generated by UHF #55

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/ComplexUHF/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ int MakeOrbitalFile(struct BindStruct *X){
}

void OutputAntiParallel_2(struct BindStruct *X,double complex **UHF_Fij,double complex *ParamOrbital,int *CountOrbital){
int i,j,Orbitalidx,isite,jsite;
int i,j,Orbitalidx,Orbitalsgn, isite,jsite;
char fileName[256];
FILE *fp;

Expand All @@ -258,10 +258,11 @@ void OutputAntiParallel_2(struct BindStruct *X,double complex **UHF_Fij,double c
isite = i + 0 * X->Def.Nsite;
jsite = j + 1 * X->Def.Nsite;
Orbitalidx = X->Def.OrbitalIdx[isite][jsite];
Orbitalsgn = X->Def.OrbitalSgn[isite][jsite];
fprintf(fp," %d %d %lf %lf\n",i,j,creal(UHF_Fij[i][j]),cimag(UHF_Fij[i][j]));
//printf(" %d %d %d \n", isite,jsite,Orbitalidx);
if(Orbitalidx != -1) {
ParamOrbital[Orbitalidx] += UHF_Fij[i][j];
ParamOrbital[Orbitalidx] += UHF_Fij[i][j]*Orbitalsgn;
CountOrbital[Orbitalidx] += 1;
//printf(" %d %d %d %lf %lf \n", isite,jsite,Orbitalidx,creal(ParamOrbital[Orbitalidx]),cimag(ParamOrbital[Orbitalidx]));
}
Expand All @@ -280,7 +281,7 @@ void OutputAntiParallel_2(struct BindStruct *X,double complex **UHF_Fij,double c


void OutputAntiParallel(struct BindStruct *X,double complex **UHF_Fij,double complex *ParamOrbital,int *CountOrbital){
int i,j,Orbitalidx,isite,jsite;
int i,j,Orbitalidx,Orbitalsgn,isite,jsite;
char fileName[256];
FILE *fp;

Expand All @@ -295,9 +296,10 @@ void OutputAntiParallel(struct BindStruct *X,double complex **UHF_Fij,double com
isite = i + 0 * X->Def.Nsite;
jsite = j + 1 * X->Def.Nsite;
Orbitalidx = X->Def.OrbitalIdx[isite][jsite];
Orbitalsgn = X->Def.OrbitalSgn[isite][jsite];
fprintf(fp," %d %d %lf %lf\n",i,j,creal(UHF_Fij[isite][jsite]),cimag(UHF_Fij[isite][jsite]));
if(Orbitalidx != -1) {
ParamOrbital[Orbitalidx] += UHF_Fij[isite][jsite];
ParamOrbital[Orbitalidx] += UHF_Fij[isite][jsite]*Orbitalsgn;
CountOrbital[Orbitalidx] += 1;
}
}
Expand All @@ -313,7 +315,7 @@ void OutputAntiParallel(struct BindStruct *X,double complex **UHF_Fij,double com
}

void OutputParallel(struct BindStruct *X,double complex **UHF_Fij,double complex *ParamOrbital,int *CountOrbital){
int i,j,Orbitalidx,isite,jsite,ini,fin,tmp_i;
int i,j,Orbitalidx,Orbitalsgn,isite,jsite,ini,fin,tmp_i;
char fileName[256];
FILE *fp;

Expand All @@ -331,17 +333,19 @@ void OutputParallel(struct BindStruct *X,double complex **UHF_Fij,double complex
isite = i + 0 * X->Def.Nsite;
jsite = j + 0 * X->Def.Nsite;
Orbitalidx = X->Def.OrbitalIdx[isite][jsite];
Orbitalsgn = X->Def.OrbitalSgn[isite][jsite];
fprintf(fp," %d %d %lf %lf\n",isite,jsite,creal(UHF_Fij[isite][jsite]),cimag(UHF_Fij[isite][jsite]));
if(Orbitalidx != -1) {
ParamOrbital[Orbitalidx] += UHF_Fij[isite][jsite];
ParamOrbital[Orbitalidx] += UHF_Fij[isite][jsite]*Orbitalsgn;
CountOrbital[Orbitalidx] += 1;
}
isite = i + 1 * X->Def.Nsite;
jsite = j + 1 * X->Def.Nsite;
Orbitalidx = X->Def.OrbitalIdx[isite][jsite];
Orbitalsgn = X->Def.OrbitalSgn[isite][jsite];
fprintf(fp," %d %d %lf %lf\n",isite,jsite,creal(UHF_Fij[isite][jsite]),cimag(UHF_Fij[isite][jsite]));
if(Orbitalidx != -1) {
ParamOrbital[Orbitalidx] += UHF_Fij[isite][jsite];
ParamOrbital[Orbitalidx] += UHF_Fij[isite][jsite]*Orbitalsgn;
CountOrbital[Orbitalidx] += 1;
}
}//for(j = i+1; j < X->Def.Nsite; j++)
Expand All @@ -361,7 +365,7 @@ void OutputParallel(struct BindStruct *X,double complex **UHF_Fij,double complex
}

void OutputGeneral(struct BindStruct *X,double complex **UHF_Fij,double complex *ParamOrbital,int *CountOrbital){
int i,j,Orbitalidx,isite,jsite,ispin,jspin;
int i,j,Orbitalidx,Orbitalsgn,isite,jsite,ispin,jspin;
char fileName[256];
FILE *fp;
for (i = 0; i < X->Def.NOrbitalIdx; i++) {
Expand All @@ -377,10 +381,11 @@ void OutputGeneral(struct BindStruct *X,double complex **UHF_Fij,double complex
isite = i + ispin * X->Def.Nsite;
jsite = j + jspin * X->Def.Nsite;
Orbitalidx = X->Def.OrbitalIdx[isite][jsite];
Orbitalsgn = X->Def.OrbitalSgn[isite][jsite];
fprintf(fp," %d %d %lf %lf\n",isite,jsite,creal(UHF_Fij[isite][jsite]),cimag(UHF_Fij[isite][jsite]));
if (Orbitalidx != -1) {
// ParamOrbital[Orbitalidx]+=UHF_Fij[isite][jsite];
ParamOrbital[Orbitalidx] += UHF_Fij[isite][jsite];
ParamOrbital[Orbitalidx] += UHF_Fij[isite][jsite]*Orbitalsgn;
CountOrbital[Orbitalidx] += 1;
//printf("debug: Orbitaidx[%d][%d]=%d, UHF_Fij=%lf, %lf \n", isite, jsite, Orbitalidx, creal(UHF_Fij[isite][jsite]), cimag(UHF_Fij[isite][jsite]));
//printf("debug: Orbitaidx[%d][%d]=%d, ParamOrbital_Fij=%lf, %lf \n", isite, jsite, Orbitalidx, creal(ParamOrbital[Orbitalidx]), cimag(ParamOrbital[Orbitalidx]));
Expand Down
47 changes: 39 additions & 8 deletions src/ComplexUHF/readdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,9 @@ int ReadDefFileIdxPara(
int iKWidx = 0;
int i, j;
int spn_i, spn_j, all_i, all_j;
int fij;
int idx, Orbitalidx;//, Orbitalsgn;
int fij, fijsgn;
int ndata;
int idx, Orbitalidx, Orbitalsgn;
int x0, x1, x2, x3;
int info, i_spin, j_spin;
double dReValue;
Expand All @@ -415,13 +416,15 @@ int ReadDefFileIdxPara(
for (i = 0; i < X->Nsite; i++) {
for (j = 0; j < X->Nsite; j++) {
X->OrbitalIdx[i][j] = -1;
X->OrbitalSgn[i][j] = 0;
}
}
}
else{
for (i = 0; i < X->Nsite*2; i++) {
for (j = 0; j < X->Nsite*2; j++) {
X->OrbitalIdx[i][j] = -1;
X->OrbitalSgn[i][j] = 0;
}
}
}
Expand Down Expand Up @@ -597,11 +600,17 @@ int ReadDefFileIdxPara(
idx = 0;
if(X->iFlgOrbitalGeneral==0) {
while( fgets(ctmp2, sizeof(ctmp2)/sizeof(char), fp) != NULL){
sscanf(ctmp2, "%d %d %d\n",
ndata = sscanf(ctmp2, "%d %d %d %d\n",
&i,
&j,
&Orbitalidx);
&Orbitalidx,
&Orbitalsgn);
//printf("Debug: %d %d %d %d %d\n", ndata, i, j, Orbitalidx, Orbitalsgn);
X->OrbitalIdx[i+X->Nsite*0][j+X->Nsite*1]=Orbitalidx;
if (ndata == 3){ //sgn does not exist in input file
Orbitalsgn = 1;
}
X->OrbitalSgn[i+X->Nsite*0][j+X->Nsite*1]=Orbitalsgn;
if(CheckPairSite(i, j, X->Nsite) != 0){
fprintf(stderr, "Error: Site index is incorrect. \n");
info=1;
Expand All @@ -614,20 +623,28 @@ int ReadDefFileIdxPara(
info=ReadDefFileError(defname);
}
}else{//general orbital
while( fscanf(fp, "%d %d %d\n", &i, &j, &fij) != EOF){
//while( fscanf(fp, "%d %d %d %d\n", &i, &j, &fij, &fijsgn) != EOF){
while( fgets(ctmp2, sizeof(ctmp2)/sizeof(char), fp) != NULL){
ndata = sscanf(ctmp2, "%d %d %d %d\n", &i, &j, &fij, &fijsgn);
spn_i = 0;
spn_j = 1;
all_i = i+spn_i*X->Nsite; //fsz
all_j = j+spn_j*X->Nsite; //fsz
if (ndata == 3){ //sgn does not exist in input file
fijsgn = 1;
}
//printf("Debug: %d %d %d %d %d\n", ndata, i, j, fij, fijsgn);
if(CheckPairSite(i, j, X->Nsite) != 0){
fprintf(stderr, "Error: Site index is incorrect. \n");
info=1;
break;
}
idx++;
X->OrbitalIdx[all_i][all_j]=fij;
X->OrbitalSgn[all_i][all_j]=fijsgn;
// Note F_{IJ}=-F_{JI}
X->OrbitalIdx[all_j][all_i]=fij;
X->OrbitalSgn[all_j][all_i]=-fijsgn;
if(idx==(X->Nsite*X->Nsite)) break;
}
}
Expand All @@ -637,8 +654,14 @@ int ReadDefFileIdxPara(
/*orbitalidxt.def------------------------------------*/
idx = 0;
int fij_org;
while (fscanf(fp, "%d %d %d\n", &i, &j, &fij_org) != EOF) {
//while (fscanf(fp, "%d %d %d %d\n", &i, &j, &fij_org, &fijsgn) != EOF) {
while( fgets(ctmp2, sizeof(ctmp2)/sizeof(char), fp) != NULL){
ndata = sscanf(ctmp2, "%d %d %d %d\n", &i, &j, &fij_org, &fijsgn);
//fprintf(stdout, "Debug: test-1 %d %d %d %d\n", i, j, fij, idx0);
if (ndata == 3){ //sgn does not exist in input file
fijsgn = 1;
}
//printf("Debug: %d %d %d %d %d\n", ndata, i, j, fij_org, fijsgn);
for (spn_i = 0; spn_i < 2; spn_i++) {
all_i = i + spn_i * X->Nsite; //fsz
all_j = j + spn_i * X->Nsite; //fsz
Expand All @@ -650,7 +673,9 @@ int ReadDefFileIdxPara(
idx++;
fij = X->NOrbitalAP + 2 * fij_org + spn_i;
X->OrbitalIdx[all_i][all_j] = fij;
X->OrbitalSgn[all_i][all_j] = fijsgn;
X->OrbitalIdx[all_j][all_i] = fij;
X->OrbitalSgn[all_j][all_i] = -fijsgn;
}
if (idx == (X->Nsite * (X->Nsite - 1))) {
break;
Expand All @@ -665,13 +690,19 @@ int ReadDefFileIdxPara(
idx = 0;
while (fgets(ctmp2, sizeof(ctmp2) / sizeof(char), fp) != NULL) {
//TODO: Replace for spin dependent
sscanf(ctmp2, "%d %d %d %d %d\n",
ndata = sscanf(ctmp2, "%d %d %d %d %d %d\n",
&i,
&i_spin,
&j,
&j_spin,
&Orbitalidx);
&Orbitalidx,
&Orbitalsgn);
if (ndata == 5){ //sgn does not exist in input file
Orbitalsgn = 1;
}
//printf("Debug: %d %d %d %d %d %d %d\n", ndata, i, i_spin, j, j_spin, Orbitalidx, Orbitalsgn);
(X->OrbitalIdx[i + X->Nsite * i_spin][j + X->Nsite * j_spin]) = Orbitalidx;
(X->OrbitalSgn[i + X->Nsite * i_spin][j + X->Nsite * j_spin]) = Orbitalsgn;
idx++;
if (idx == X->Nsite * (2 * X->Nsite - 1)) break;
}
Expand Down