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]);
    85   int ierr, nWan, nWSC, iWSC, jWSC, iWan, jWan, iWan0, jWan0, ii;
    87   char ctmp[256], *ctmp2;
    88   double complex ***Mat_tot;
    91   fprintf(stdout, 
"   Wannier90 file = %s\n", filename);
    95   fp = fopen(filename, 
"r");
    96   ctmp2 = fgets(ctmp, 256, fp);
    97   ierr = fscanf(fp, 
"%d", &nWan);
    98   if(ierr == EOF) printf(
"%d %s\n", ierr, ctmp2);
    99   ierr = fscanf(fp, 
"%d", &nWSC);
   100   for (iWSC = 0; iWSC < nWSC; iWSC++) {
   101     ierr = fscanf(fp, 
"%d", &ii);
   103   fprintf(stdout, 
"             Number of Wannier = %d\n", nWan);
   104   fprintf(stdout, 
"   Number of Wigner-Seitz Cell = %d\n", nWSC);
   108   Mat_tot = (
double complex ***)malloc(
sizeof(
double complex **) * nWSC);
   109   indx_tot = (
int **)malloc(
sizeof(
int*) * nWSC);
   110   for (iWSC = 0; iWSC < nWSC; iWSC++) {
   111     Mat_tot[iWSC] = (
double complex **)malloc(
sizeof(
double complex *) * nWan);
   112     indx_tot[iWSC] = (
int *)malloc(
sizeof(
int) * 3);
   113     for (iWan = 0; iWan < nWan; iWan++) {
   114       Mat_tot[iWSC][iWan] = (
double complex *)malloc(
sizeof(
double complex) * nWan);
   120   for (iWSC = 0; iWSC < nWSC; iWSC++) {
   121     for (iWan = 0; iWan < nWan; iWan++) {
   122       for (jWan = 0; jWan < nWan; jWan++) {
   123         ierr = fscanf(fp, 
"%d%d%d%d%d%lf%lf",
   124           &indx_tot[iWSC][0], &indx_tot[iWSC][1], &indx_tot[iWSC][2], &iWan0, &jWan0,
   126         if(iWan0 <= StdI->NsiteUC && jWan0 <= StdI->NsiteUC)
   127           Mat_tot[iWSC][iWan0 - 1][jWan0 - 1] = dtmp[0] + I * dtmp[1];
   133     for (jWSC = 0; jWSC < iWSC; jWSC++) {
   135         indx_tot[iWSC][0] == -indx_tot[jWSC][0] &&
   136         indx_tot[iWSC][1] == -indx_tot[jWSC][1] &&
   137         indx_tot[iWSC][2] == -indx_tot[jWSC][2]
   139         for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
   140           for (jWan = 0; jWan < StdI->
NsiteUC; jWan++) {
   141             Mat_tot[iWSC][iWan][jWan] = 0.0;
   145     if (indx_tot[iWSC][0] == 0 &&
   146         indx_tot[iWSC][1] == 0 &&
   147         indx_tot[iWSC][2] == 0) 
   148       for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
   149         for (jWan = 0; jWan < iWan; jWan++) {
   150           Mat_tot[iWSC][iWan][jWan] = 0.0;
   158   fprintf(stdout, 
"\n      EFFECTIVE terms:\n");
   159   fprintf(stdout, 
"           R0   R1   R2 band_i band_f Hamiltonian\n");
   161   for (iWSC = 0; iWSC < nWSC; iWSC++) {
   162     for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
   163       for (jWan = 0; jWan < StdI->
NsiteUC; jWan++) {
   164         if (cutoff < cabs(Mat_tot[iWSC][iWan][jWan])) {
   165           fprintf(stdout, 
"        %5d%5d%5d%5d%5d%12.6f%12.6f\n",
   166             indx_tot[iWSC][0], indx_tot[iWSC][1], indx_tot[iWSC][2], iWan, jWan,
   167             creal(Mat_tot[iWSC][iWan][jWan]), cimag(Mat_tot[iWSC][iWan][jWan]));
   173   fprintf(stdout, 
"      Total number of EFFECTIVE term = %d\n", nMat);
   175   for (iWSC = 0; iWSC < nWSC; iWSC++) {
   176     for (iWan = 0; iWan < nWan; iWan++) {
   177       free(Mat_tot[iWSC][iWan]);
   180     free(indx_tot[iWSC]);
   201   int ierr, nWan, nWSC, iWSC, jWSC, iWan, jWan, iWan0, jWan0, ii;
   203   char ctmp[256], *ctmp2;
   204   double complex ***Mat_tot;
   209   fp = fopen(filename, 
"r");
   210   ctmp2 = fgets(ctmp, 256, fp);
   211   ierr = fscanf(fp, 
"%d", &nWan);
   212   if (ierr == EOF) printf(
"%d %s\n", ierr, ctmp2);
   213   ierr = fscanf(fp, 
"%d", &nWSC);
   214   for (iWSC = 0; iWSC < nWSC; iWSC++) {
   215     ierr = fscanf(fp, 
"%d", &ii);
   220   Mat_tot = (
double complex ***)malloc(
sizeof(
double complex **) * nWSC);
   221   indx_tot = (
int **)malloc(
sizeof(
int*) * nWSC);
   222   for (iWSC = 0; iWSC < nWSC; iWSC++) {
   223     Mat_tot[iWSC] = (
double complex **)malloc(
sizeof(
double complex *) * nWan);
   224     indx_tot[iWSC] = (
int *)malloc(
sizeof(
int) * 3);
   225     for (iWan = 0; iWan < nWan; iWan++) {
   226       Mat_tot[iWSC][iWan] = (
double complex *)malloc(
sizeof(
double complex) * nWan);
   232   for (iWSC = 0; iWSC < nWSC; iWSC++) {
   233     for (iWan = 0; iWan < nWan; iWan++) {
   234       for (jWan = 0; jWan < nWan; jWan++) {
   235         ierr = fscanf(fp, 
"%d%d%d%d%d%lf%lf",
   236           &indx_tot[iWSC][0], &indx_tot[iWSC][1], &indx_tot[iWSC][2],
   239         if (iWan0 <= StdI->NsiteUC && jWan0 <= StdI->NsiteUC)
   240           Mat_tot[iWSC][iWan0 - 1][jWan0 - 1] = dtmp[0] + I * dtmp[1];
   246     for (jWSC = 0; jWSC < iWSC; jWSC++) {
   248         indx_tot[iWSC][0] == -indx_tot[jWSC][0] &&
   249         indx_tot[iWSC][1] == -indx_tot[jWSC][1] &&
   250         indx_tot[iWSC][2] == -indx_tot[jWSC][2]
   252         for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
   253           for (jWan = 0; jWan < StdI->
NsiteUC; jWan++) {
   254             Mat_tot[iWSC][iWan][jWan] = 0.0;
   258     if (indx_tot[iWSC][0] == 0 &&
   259       indx_tot[iWSC][1] == 0 &&
   260       indx_tot[iWSC][2] == 0)
   261       for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
   262         for (jWan = 0; jWan < iWan; jWan++) {
   263           Mat_tot[iWSC][iWan][jWan] = 0.0;
   273   for (iWSC = 0; iWSC < nWSC; iWSC++) {
   274     for (iWan = 0; iWan < StdI->
NsiteUC; iWan++) {
   275       for (jWan = 0; jWan < StdI->
NsiteUC; jWan++) {
   276         if (cutoff < cabs(Mat_tot[iWSC][iWan][jWan])) {
   277           for (ii = 0; ii < 3; ii++) Matindx[nMat][ii] = indx_tot[iWSC][ii];
   278           Matindx[nMat][3] = iWan;
   279           Matindx[nMat][4] = jWan;
   280           Mat[nMat] = Mat_tot[iWSC][iWan][jWan];
   287   for (iWSC = 0; iWSC < nWSC; iWSC++) {
   288     for (iWan = 0; iWan < nWan; iWan++) {
   289       free(Mat_tot[iWSC][iWan]);
   292     free(indx_tot[iWSC]);
   304   int isite, jsite, ispin, ntransMax, nintrMax;
   305   int iL, iW, iH, kCell, it, ii;
   306   double Jtmp[3][3] = { {0.0} };
   308   double complex Cphase;
   309   double dR[3], *Uspin;
   311   double complex *W90_t, *W90_j, *W90_u;
   312   int **t_indx, **u_indx, **j_indx;
   315   fprintf(stdout, 
"\n  @ Wannier90 Geometry \n\n");
   321   fp = fopen(
"lattice.xsf", 
"w");
   330   fprintf(stdout, 
"\n  @ Wannier90 hopping \n\n");
   334   W90_t = (
double complex *)malloc(
sizeof(
double complex) * n_t);
   335   t_indx = (
int **)malloc(
sizeof(
int*) * n_t);
   336   for (ii = 0; ii < n_t; ii++) t_indx[ii] = (
int *)malloc(
sizeof(
int) * 5);
   341   fprintf(stdout, 
"\n  @ Wannier90 Coulomb \n\n");
   345   W90_u = (
double complex *)malloc(
sizeof(
double complex) * n_u);
   346   u_indx = (
int **)malloc(
sizeof(
int*) * n_u);
   347   for (ii = 0; ii < n_u; ii++) u_indx[ii] = (
int *)malloc(
sizeof(
int) * 5);
   352   fprintf(stdout, 
"\n  @ Wannier90 Hund \n\n");
   356   W90_j = (
double complex *)malloc(
sizeof(
double complex) * n_j);
   357   j_indx = (
int **)malloc(
sizeof(
int*) * n_j);
   358   for (ii = 0; ii < n_j; ii++) j_indx[ii] = (
int *)malloc(
sizeof(
int) * 5);
   363   fprintf(stdout, 
"\n  @ Hamiltonian \n\n");
   369   if (strcmp(StdI->
model, 
"spin") == 0 ) {
   372   else if (strcmp(StdI->
model, 
"hubbard") == 0) {
   376     printf(
"wannier + Kondo is not available !\n");
   379   fprintf(stdout, 
"\n  @ Numerical conditions\n\n");
   387   if(strcmp(StdI->
model, 
"spin") == 0 )
   389   else if(strcmp(StdI->
model, 
"hubbard") == 0 )
   394   if (strcmp(StdI->
model, 
"spin") == 0 ) {
   395     ntransMax = StdI->
nsite * (StdI->
S2 + 1 + 2 * StdI->
S2);
   396     nintrMax = StdI->
NCell * (StdI->
NsiteUC + n_t + n_u + n_j)
   397       * (3 * StdI->
S2 + 1) * (3 * StdI->
S2 + 1);
   399   else if (strcmp(StdI->
model, 
"hubbard") == 0) {
   400     ntransMax = StdI->
NCell * 2 * (2 * StdI->
NsiteUC + n_t * 2);
   401     nintrMax = StdI->
NCell * (n_u + n_j + 1);
   408   if (strcmp(StdI->
model, 
"spin") == 0) {
   409     Uspin = (
double *)malloc(
sizeof(
double) * StdI->
NsiteUC);
   410     for (it = 0; it < n_u; it++)
   411       if (u_indx[it][0] == 0 && u_indx[it][1] == 0 && u_indx[it][2] == 0
   412         && u_indx[it][3] == u_indx[it][4])     
   413         Uspin[u_indx[it][3]] = creal(W90_u[it]);
   418   for (kCell = 0; kCell < StdI->
NCell; kCell++){
   420     iW = StdI->
Cell[kCell][0];
   421     iL = StdI->
Cell[kCell][1];
   422     iH = StdI->
Cell[kCell][2];
   426     if (strcmp(StdI->
model, 
"spin") == 0) {
   427       for (isite = StdI->
NsiteUC*kCell; isite < StdI->NsiteUC*(kCell + 1); isite++) {
   432       for (isite = StdI->
NsiteUC*kCell; isite < StdI->NsiteUC*(kCell + 1); isite++) {
   439     for (it = 0; it < n_t; it++) {
   443       if (t_indx[it][0] == 0 && t_indx[it][1] == 0 && t_indx[it][2] == 0
   444         && t_indx[it][3] == t_indx[it][4])
   446         if (strcmp(StdI->
model, 
"hubbard") == 0) {
   447           isite = StdI->
NsiteUC*kCell + t_indx[it][3];
   448           for (ispin = 0; ispin < 2; ispin++) {
   463           t_indx[it][0], t_indx[it][1], t_indx[it][2],
   464           t_indx[it][3], t_indx[it][4], &isite, &jsite, &Cphase, dR);
   465         if (strcmp(StdI->
model, 
"spin") == 0) {
   466           for (ii = 0; ii < 3; ii++) 
   467             Jtmp[ii][ii] = 2.0 * W90_t[it] * conj(W90_t[it])
   468             * (1.0 / Uspin[t_indx[it][3]] + 1.0 / Uspin[t_indx[it][4]]);
   479     for (it = 0; it < n_u; it++) {
   483       if (u_indx[it][0] == 0 && u_indx[it][1] == 0 && u_indx[it][2] == 0
   484         && u_indx[it][3] == u_indx[it][4])
   495           u_indx[it][0], u_indx[it][1], u_indx[it][2],
   496           u_indx[it][3], u_indx[it][4], &isite, &jsite, &Cphase, dR);
   503     for (it = 0; it < n_j; it++) {
   507       if (j_indx[it][0] != 0 || j_indx[it][1] != 0 || j_indx[it][2] != 0
   508         || j_indx[it][3] != j_indx[it][4])
   511           j_indx[it][0], j_indx[it][1], j_indx[it][2],
   512           j_indx[it][3], j_indx[it][4], &isite, &jsite, &Cphase, dR);
   514         StdI->
Hund[StdI->
NHund] = creal(W90_j[it]);
   519         if (strcmp(StdI->
model, 
"hubbard") == 0) {
   520           StdI->
Ex[StdI->
NEx] = creal(W90_j[it]);
   532           StdI->
Ex[StdI->
NEx] = creal(W90_j[it]);
   534           StdI->
Ex[StdI->
NEx] = -creal(W90_j[it]);
   548   for (it = 0; it < n_t; it++) free(t_indx[it]);
   551   for (it = 0; it < n_u; it++) free(u_indx[it]);
   554   for (it = 0; it < n_j; it++) free(j_indx[it]);
   557   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. 
static int read_W90_query(struct StdIntList *StdI, char *filename, double cutoff)
Read Wannier90 hamiltonian file (*_hr) and compute the number of effective term. 
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 ...
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 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. 
static void read_W90(struct StdIntList *StdI, char *filename, double cutoff, double complex *Mat, int **Matindx)
Read Wannier90 hamiltonian file (*_hr) 
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). 
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...
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.