22 #include "StdFace_ModelUtil.h" 41 fprintf(stdout,
" Wannier90 Geometry file = %s\n", filename);
43 fp = fopen(filename,
"r");
47 for (ii = 0; ii < 3; ii++)
48 ierr = fscanf(fp,
"%lf%lf%lf", &StdI->
direct[ii][0], &StdI->
direct[ii][1], &StdI->
direct[ii][2]);
49 if(ierr == EOF) printf(
"%d\n", ierr);
53 for (isite = 0; isite < StdI->
NsiteUC; isite++) free(StdI->
tau[isite]);
55 ierr = fscanf(fp,
"%d", &StdI->
NsiteUC);
56 fprintf(stdout,
" Number of Correlated Sites = %d\n", StdI->
NsiteUC);
58 StdI->
tau = (
double **)malloc(
sizeof(
double*) * StdI->
NsiteUC);
59 for (ii = 0; ii < StdI->
NsiteUC; ii++) StdI->
tau[ii] = (
double *)malloc(
sizeof(
double) * 3);
61 for (isite = 0; isite < StdI->
NsiteUC; isite++)
62 ierr = fscanf(fp,
"%lf%lf%lf", &StdI->
tau[isite][0], &StdI->
tau[isite][1], &StdI->
tau[isite][2]);
65 printf(
" Direct lattice vectors:\n");
66 for (ii = 0; ii < 3; ii++) printf(
" %10.5f %10.5f %10.5f\n",
68 printf(
" Wannier centres:\n");
69 for (isite = 0; isite < StdI->
NsiteUC; isite++) printf(
" %10.5f %10.5f %10.5f\n",
70 StdI->
tau[isite][0], StdI->
tau[isite][1], StdI->
tau[isite][2]);
87 int ierr, nWan, nWSC, iWSC, jWSC, iWan, jWan, iWan0, jWan0, ii, jj;
88 double dtmp[2], dR[3], length;
89 char ctmp[256], *ctmp2;
90 double complex ***Mat_tot;
93 fprintf(stdout,
" Wannier90 file = %s\n", filename);
97 fp = fopen(filename,
"r");
98 ctmp2 = fgets(ctmp, 256, fp);
99 ierr = fscanf(fp,
"%d", &nWan);
100 if(ierr == EOF) printf(
"%d %s\n", ierr, ctmp2);
101 ierr = fscanf(fp,
"%d", &nWSC);
102 for (iWSC = 0; iWSC < nWSC; iWSC++) {
103 ierr = fscanf(fp,
"%d", &ii);
105 fprintf(stdout,
" Number of Wannier = %d\n", nWan);
106 fprintf(stdout,
" Number of Wigner-Seitz Cell = %d\n", nWSC);
110 Mat_tot = (
double complex ***)malloc(
sizeof(
double complex **) * nWSC);
111 indx_tot = (
int **)malloc(
sizeof(
int*) * nWSC);
112 for (iWSC = 0; iWSC < nWSC; iWSC++) {
113 Mat_tot[iWSC] = (
double complex **)malloc(
sizeof(
double complex *) * nWan);
114 indx_tot[iWSC] = (
int *)malloc(
sizeof(
int) * 3);
115 for (iWan = 0; iWan < nWan; iWan++) {
116 Mat_tot[iWSC][iWan] = (
double complex *)malloc(
sizeof(
double complex) * nWan);
122 for (iWSC = 0; iWSC < nWSC; iWSC++) {
123 for (iWan = 0; iWan < nWan; iWan++) {
124 for (jWan = 0; jWan < nWan; jWan++) {
125 ierr = fscanf(fp,
"%d%d%d%d%d%lf%lf",
126 &indx_tot[iWSC][0], &indx_tot[iWSC][1], &indx_tot[iWSC][2], &iWan0, &jWan0,
131 for (ii = 0; ii < 3; ii++) {
134 dR[ii] += StdI->
direct[jj][ii] * (StdI->
tau[jWan][jj] - StdI->
tau[iWan][jj] + indx_tot[iWSC][jj]);
136 length = sqrt(dR[0] * dR[0] + dR[1] * dR[1] + dR[2] * dR[2]);
137 if (length > cutoff_length && cutoff_length > 0.0) {
141 if (abs(indx_tot[iWSC][0]) > cutoff_R[0] ||
142 abs(indx_tot[iWSC][1]) > cutoff_R[1] ||
143 abs(indx_tot[iWSC][2]) > cutoff_R[2]) {
147 if(iWan0 <= StdI->NsiteUC && jWan0 <= StdI->NsiteUC)
148 Mat_tot[iWSC][iWan0 - 1][jWan0 - 1] = dtmp[0] + I * dtmp[1];
154 for (jWSC = 0; jWSC < iWSC; jWSC++) {
156 indx_tot[iWSC][0] == -indx_tot[jWSC][0] &&
157 indx_tot[iWSC][1] == -indx_tot[jWSC][1] &&
158 indx_tot[iWSC][2] == -indx_tot[jWSC][2]
160 for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
161 for (jWan = 0; jWan < StdI->
NsiteUC; jWan++) {
162 Mat_tot[iWSC][iWan][jWan] = 0.0;
166 if (indx_tot[iWSC][0] == 0 &&
167 indx_tot[iWSC][1] == 0 &&
168 indx_tot[iWSC][2] == 0)
169 for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
170 for (jWan = 0; jWan < iWan; jWan++) {
171 Mat_tot[iWSC][iWan][jWan] = 0.0;
179 fprintf(stdout,
"\n EFFECTIVE terms:\n");
180 fprintf(stdout,
" R0 R1 R2 band_i band_f Hamiltonian\n");
182 for (iWSC = 0; iWSC < nWSC; iWSC++) {
183 for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
184 for (jWan = 0; jWan < StdI->
NsiteUC; jWan++) {
185 if (cutoff < cabs(Mat_tot[iWSC][iWan][jWan])) {
186 fprintf(stdout,
" %5d%5d%5d%5d%5d%12.6f%12.6f\n",
187 indx_tot[iWSC][0], indx_tot[iWSC][1], indx_tot[iWSC][2], iWan, jWan,
188 creal(Mat_tot[iWSC][iWan][jWan]), cimag(Mat_tot[iWSC][iWan][jWan]));
194 fprintf(stdout,
" Total number of EFFECTIVE term = %d\n", nMat);
196 for (iWSC = 0; iWSC < nWSC; iWSC++) {
197 for (iWan = 0; iWan < nWan; iWan++) {
198 free(Mat_tot[iWSC][iWan]);
201 free(indx_tot[iWSC]);
217 double cutoff_length,
224 int ierr, nWan, nWSC, iWSC, jWSC, iWan, jWan, iWan0, jWan0, ii, jj;
225 double dtmp[2], dR[3], length;
226 char ctmp[256], *ctmp2;
227 double complex ***Mat_tot;
232 fp = fopen(filename,
"r");
233 ctmp2 = fgets(ctmp, 256, fp);
234 ierr = fscanf(fp,
"%d", &nWan);
235 if (ierr == EOF) printf(
"%d %s\n", ierr, ctmp2);
236 ierr = fscanf(fp,
"%d", &nWSC);
237 for (iWSC = 0; iWSC < nWSC; iWSC++) {
238 ierr = fscanf(fp,
"%d", &ii);
243 Mat_tot = (
double complex ***)malloc(
sizeof(
double complex **) * nWSC);
244 indx_tot = (
int **)malloc(
sizeof(
int*) * nWSC);
245 for (iWSC = 0; iWSC < nWSC; iWSC++) {
246 Mat_tot[iWSC] = (
double complex **)malloc(
sizeof(
double complex *) * nWan);
247 indx_tot[iWSC] = (
int *)malloc(
sizeof(
int) * 3);
248 for (iWan = 0; iWan < nWan; iWan++) {
249 Mat_tot[iWSC][iWan] = (
double complex *)malloc(
sizeof(
double complex) * nWan);
255 for (iWSC = 0; iWSC < nWSC; iWSC++) {
256 for (iWan = 0; iWan < nWan; iWan++) {
257 for (jWan = 0; jWan < nWan; jWan++) {
258 ierr = fscanf(fp,
"%d%d%d%d%d%lf%lf",
259 &indx_tot[iWSC][0], &indx_tot[iWSC][1], &indx_tot[iWSC][2],
265 for (ii = 0; ii < 3; ii++) {
267 for (jj = 0; jj < 3; jj++)
268 dR[ii] += StdI->
direct[jj][ii] * (StdI->
tau[jWan][jj] - StdI->
tau[iWan][jj] + indx_tot[iWSC][jj]);
270 length = sqrt(dR[0] * dR[0] + dR[1] * dR[1] + dR[2] * dR[2]);
271 if (length > cutoff_length && cutoff_length > 0.0) {
275 if (abs(indx_tot[iWSC][0]) > cutoff_R[0] ||
276 abs(indx_tot[iWSC][1]) > cutoff_R[1] ||
277 abs(indx_tot[iWSC][2]) > cutoff_R[2]) {
281 if (iWan0 <= StdI->NsiteUC && jWan0 <= StdI->NsiteUC)
282 Mat_tot[iWSC][iWan0 - 1][jWan0 - 1] = dtmp[0] + I * dtmp[1];
288 for (jWSC = 0; jWSC < iWSC; jWSC++) {
290 indx_tot[iWSC][0] == -indx_tot[jWSC][0] &&
291 indx_tot[iWSC][1] == -indx_tot[jWSC][1] &&
292 indx_tot[iWSC][2] == -indx_tot[jWSC][2]
294 for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
295 for (jWan = 0; jWan < StdI->
NsiteUC; jWan++) {
296 Mat_tot[iWSC][iWan][jWan] = 0.0;
300 if (indx_tot[iWSC][0] == 0 &&
301 indx_tot[iWSC][1] == 0 &&
302 indx_tot[iWSC][2] == 0)
303 for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
304 for (jWan = 0; jWan < iWan; jWan++) {
305 Mat_tot[iWSC][iWan][jWan] = 0.0;
315 for (iWSC = 0; iWSC < nWSC; iWSC++) {
316 for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
317 for (jWan = 0; jWan < StdI->
NsiteUC; jWan++) {
318 if (cutoff < cabs(Mat_tot[iWSC][iWan][jWan])) {
319 for (ii = 0; ii < 3; ii++) Matindx[nMat][ii] = indx_tot[iWSC][ii];
320 Matindx[nMat][3] = iWan;
321 Matindx[nMat][4] = jWan;
322 Mat[nMat] = Mat_tot[iWSC][iWan][jWan];
329 for (iWSC = 0; iWSC < nWSC; iWSC++) {
330 for (iWan = 0; iWan < nWan; iWan++) {
331 free(Mat_tot[iWSC][iWan]);
334 free(indx_tot[iWSC]);
346 int isite, jsite, ispin, ntransMax, nintrMax;
347 int iL, iW, iH, kCell, it, ii;
348 double Jtmp[3][3] = { {0.0} };
350 double complex Cphase;
351 double dR[3], *Uspin;
353 double complex *W90_t, *W90_j, *W90_u;
354 int **t_indx, **u_indx, **j_indx;
359 fp = fopen(
"lattice.xsf",
"w");
366 fprintf(stdout,
"\n @ Wannier90 Geometry \n\n");
371 fprintf(stdout,
"\n @ Wannier90 hopping \n\n");
377 W90_t = (
double complex *)malloc(
sizeof(
double complex) * n_t);
378 t_indx = (
int **)malloc(
sizeof(
int*) * n_t);
379 for (ii = 0; ii < n_t; ii++) t_indx[ii] = (
int *)malloc(
sizeof(
int) * 5);
385 fprintf(stdout,
"\n @ Wannier90 Coulomb \n\n");
391 W90_u = (
double complex *)malloc(
sizeof(
double complex) * n_u);
392 u_indx = (
int **)malloc(
sizeof(
int*) * n_u);
393 for (ii = 0; ii < n_u; ii++) u_indx[ii] = (
int *)malloc(
sizeof(
int) * 5);
399 fprintf(stdout,
"\n @ Wannier90 Hund \n\n");
405 W90_j = (
double complex *)malloc(
sizeof(
double complex) * n_j);
406 j_indx = (
int **)malloc(
sizeof(
int*) * n_j);
407 for (ii = 0; ii < n_j; ii++) j_indx[ii] = (
int *)malloc(
sizeof(
int) * 5);
413 fprintf(stdout,
"\n @ Hamiltonian \n\n");
419 if (strcmp(StdI->
model,
"spin") == 0 ) {
422 else if (strcmp(StdI->
model,
"hubbard") == 0) {
426 printf(
"wannier + Kondo is not available !\n");
429 fprintf(stdout,
"\n @ Numerical conditions\n\n");
437 if(strcmp(StdI->
model,
"spin") == 0 )
439 else if(strcmp(StdI->
model,
"hubbard") == 0 )
444 if (strcmp(StdI->
model,
"spin") == 0 ) {
445 ntransMax = StdI->
nsite * (StdI->
S2 + 1 + 2 * StdI->
S2);
446 nintrMax = StdI->
NCell * (StdI->
NsiteUC + n_t + n_u + n_j)
447 * (3 * StdI->
S2 + 1) * (3 * StdI->
S2 + StdI->
NsiteUC);
449 else if (strcmp(StdI->
model,
"hubbard") == 0) {
450 ntransMax = StdI->
NCell * 2 * (2 * StdI->
NsiteUC + n_t * 2);
458 if (strcmp(StdI->
model,
"spin") == 0) {
459 Uspin = (
double *)malloc(
sizeof(
double) * StdI->
NsiteUC);
460 for (it = 0; it < n_u; it++)
461 if (u_indx[it][0] == 0 && u_indx[it][1] == 0 && u_indx[it][2] == 0
462 && u_indx[it][3] == u_indx[it][4])
463 Uspin[u_indx[it][3]] = creal(W90_u[it]);
468 for (kCell = 0; kCell < StdI->
NCell; kCell++){
470 iW = StdI->
Cell[kCell][0];
471 iL = StdI->
Cell[kCell][1];
472 iH = StdI->
Cell[kCell][2];
476 if (strcmp(StdI->
model,
"spin") == 0) {
477 for (isite = StdI->
NsiteUC*kCell; isite < StdI->NsiteUC*(kCell + 1); isite++) {
482 for (isite = StdI->
NsiteUC*kCell; isite < StdI->NsiteUC*(kCell + 1); isite++) {
489 for (it = 0; it < n_t; it++) {
493 if (t_indx[it][0] == 0 && t_indx[it][1] == 0 && t_indx[it][2] == 0
494 && t_indx[it][3] == t_indx[it][4])
496 if (strcmp(StdI->
model,
"hubbard") == 0) {
497 isite = StdI->
NsiteUC*kCell + t_indx[it][3];
498 for (ispin = 0; ispin < 2; ispin++) {
513 t_indx[it][0], t_indx[it][1], t_indx[it][2],
514 t_indx[it][3], t_indx[it][4], &isite, &jsite, &Cphase, dR);
515 if (strcmp(StdI->
model,
"spin") == 0) {
516 for (ii = 0; ii < 3; ii++)
517 Jtmp[ii][ii] = 2.0 * W90_t[it] * conj(W90_t[it])
518 * (1.0 / Uspin[t_indx[it][3]] + 1.0 / Uspin[t_indx[it][4]]);
529 for (it = 0; it < n_u; it++) {
533 if (u_indx[it][0] == 0 && u_indx[it][1] == 0 && u_indx[it][2] == 0
534 && u_indx[it][3] == u_indx[it][4])
545 u_indx[it][0], u_indx[it][1], u_indx[it][2],
546 u_indx[it][3], u_indx[it][4], &isite, &jsite, &Cphase, dR);
553 for (it = 0; it < n_j; it++) {
557 if (j_indx[it][0] != 0 || j_indx[it][1] != 0 || j_indx[it][2] != 0
558 || j_indx[it][3] != j_indx[it][4])
561 j_indx[it][0], j_indx[it][1], j_indx[it][2],
562 j_indx[it][3], j_indx[it][4], &isite, &jsite, &Cphase, dR);
564 StdI->
Hund[StdI->
NHund] = creal(W90_j[it]);
569 if (strcmp(StdI->
model,
"hubbard") == 0) {
570 StdI->
Ex[StdI->
NEx] = creal(W90_j[it]);
582 StdI->
Ex[StdI->
NEx] = creal(W90_j[it]);
584 StdI->
Ex[StdI->
NEx] = -creal(W90_j[it]);
598 for (it = 0; it < n_t; it++) free(t_indx[it]);
601 for (it = 0; it < n_u; it++) free(u_indx[it]);
604 for (it = 0; it < n_j; it++) free(j_indx[it]);
607 if (strcmp(StdI->
model,
"spin") == 0) free(Uspin);
void StdFace_PrintVal_i(char *valname, int *val, int val0)
Print a valiable (integer) read from the input file if it is not specified in the input file (=214748...
int NPairHopp
Number of pair-hopping term, counted in each lattice file.
int NHund
Number of Hund term, counted in each lattice file.
double cutoff_t
Cutoof for the hopping in wannier90, input from file.
void StdFace_GeneralJ(struct StdIntList *StdI, double J[3][3], int Si2, int Sj2, int isite, int jsite)
Treat J as a 3*3 matrix [(6S + 1)*(6S' + 1) interactions].
void StdFace_HubbardLocal(struct StdIntList *StdI, double mu0, double h0, double Gamma0, double U0, int isite)
Add intra-Coulomb, magnetic field, chemical potential for the itenerant electron. ...
void StdFace_PrintGeometry(struct StdIntList *StdI)
Print geometry of sites for the pos-process of correlation function.
double * Ex
[StdIntList::NEx] Coefficient of exchange term, malloc in StdFace_MallocInteractions() and set in Std...
double complex * trans
[StdIntList::ntrans] Coefficient of one-body term, malloc in StdFace_MallocInteractions() and set in ...
static void read_W90(struct StdIntList *StdI, char *filename, double cutoff, int *cutoff_R, double cutoff_length, double complex *Mat, int **Matindx)
Read Wannier90 hamiltonian file (*_hr)
void StdFace_Hopping(struct StdIntList *StdI, double complex trans0, int isite, int jsite, double *dR)
Add Hopping for the both spin.
void StdFace_MallocInteractions(struct StdIntList *StdI, int ntransMax, int nintrMax)
Malloc Arrays for interactions.
int S2
Total spin |S| of a local spin, input from file.
int ** ExIndx
[StdIntList::NEx][2] Site indices of exchange term, malloc in StdFace_MallocInteractions() and set in...
double cutoff_j
Cutoof for the Hund in wannier90, input from file.
int NsiteUC
Number of sites in the unit cell. Defined in the beginning of each lattice function.
void StdFace_InitSite(struct StdIntList *StdI, FILE *fp, int dim)
Initialize the super-cell where simulation is performed.
int ntrans
Number of transfer, counted in each lattice file.
char model[256]
Name of model, input parameter.
int ** CintraIndx
[StdIntList::NCintra][1] Site indices of intra-site Coulomb term, malloc in StdFace_MallocInteraction...
double Gamma
Transvars magnetic field, input parameter.
int NCintra
Number of intra-site Coulomb interaction, counted in each lattice file.
double cutoff_length_J
Cutoof for R in wannier90, input from file.
double U
On-site Coulomb potential, input parameter.
double * Hund
[StdIntList::NHund] Coefficient of Hund term, malloc in StdFace_MallocInteractions() and set in StdFa...
int ** Cell
[StdIntList][3] The cell position in the fractional coordinate. Malloc and Set in StdFace_InitSite()...
double phase[3]
Boundary phase, input parameter phase0, etc.
int * locspinflag
[StdIntList::nsite] LocSpin in Expert mode, malloc and set in each lattice file.
int ** HundIndx
[StdIntList::NHund][2] Site indices of Hund term, malloc in StdFace_MallocInteractions() and set in S...
static void geometry_W90(struct StdIntList *StdI)
Read Geometry file for wannier90.
double direct[3][3]
The unit direct lattice vector. Set in StdFace_InitSite().
void StdFace_MagField(struct StdIntList *StdI, int S2, double h, double Gamma, int isite)
Add longitudinal and transvars magnetic field to the list.
void StdFace_NotUsed_d(char *valname, double val)
Stop HPhi if a variable (real) not used is specified in the input file (!=NaN).
double cutoff_length_t
Cutoof for R in wannier90, input from file.
void StdFace_Coulomb(struct StdIntList *StdI, double V, int isite, int jsite)
Add onsite/offsite Coulomb term to the list StdIntList::Cinter and StdIntList::CinterIndx, and increase the number of them (StdIntList::NCinter).
int NEx
Number of exchange term, counted in each lattice file.
double mu
Chemical potential, input parameter.
void StdFace_PrintVal_d(char *valname, double *val, double val0)
Print a valiable (real) read from the input file if it is not specified in the input file (=NaN)...
int NCell
The number of the unit cell in the super-cell (determinant of StdIntList::box). Set in StdFace_InitSi...
static int read_W90_query(struct StdIntList *StdI, char *filename, double cutoff, int *cutoff_R, double cutoff_length)
Read Wannier90 hamiltonian file (*_hr) and compute the number of effective term.
double cutoff_length_U
Cutoof for R in wannier90, input from file.
double * PairHopp
[StdIntList::NPairLift] Coefficient of pair-hopping term, malloc in StdFace_MallocInteractions() and ...
int nsite
Number of sites, set in the each lattice file.
int ** transindx
[StdIntList::ntrans][4] Site/spin indices of one-body term, malloc in StdFace_MallocInteractions() an...
Variables used in the Standard mode. These variables are passed as a pointer of the structure(StdIntL...
double * Cintra
[StdIntList::NCintra] Coefficient of intra-site Coulomb term, malloc in StdFace_MallocInteractions() ...
void StdFace_PrintXSF(struct StdIntList *StdI)
Print lattice.xsf (XCrysDen format)
double h
Longitudinal magnetic field, input parameter.
void StdFace_FindSite(struct StdIntList *StdI, int iW, int iL, int iH, int diW, int diL, int diH, int isiteUC, int jsiteUC, int *isite, int *jsite, double complex *Cphase, double *dR)
Find the index of transfer and interaction.
int ** PHIndx
[StdIntList::NPairLift][2] Site indices of pair-hopping term, malloc in StdFace_MallocInteractions() ...
void StdFace_Wannier90(struct StdIntList *StdI)
Setup a Hamiltonian for the Wannier90 *_hr.dat.
double ** tau
Cell-internal site position in the fractional coordinate. Defined in the beginning of each lattice fu...
void StdFace_exit(int errorcode)
MPI Abortation wrapper.
char CDataFileHead[256]
Header of the output files. Input from file.
double cutoff_u
Cutoof for the Coulomb in wannier90, input from file.
double K
4-spin term. Not used.