int main() { // initialize grid. params are read from input file GRID grid; // initialize a result object on grid Result result(&grid); // fill in Delta by initializing it to semi-circle InitDelta(DOStypes::SemiCircle, grid.get_N(), 0.2, 0.0, 0.01, 0.5, result.omega, result.Delta); result.mu = 0.1; result.n = 0.5; result.mu0 = 0.3; //make a copy Result r2(result); //r2.CopyFrom(&result); r2.mu = 0.2; r2.Delta[1000] = 7; result.PrintResult("Result.dat"); r2.PrintResult("Result.dat.c"); Result r3(&grid); // this way mu, n and mu0 are not read r3.ReadFromFile("Result.dat.c"); r3.n = 0.3; r3.PrintResult("Result.dat.cc"); return 0; }
int main() { GRID grid("params"); Result result(&grid); grid.assign_omega(result.omega); Input input("params"); double t = 0.5; // always set a default value in case parameter is not found in the input file!!! input.ReadParam(t,"CHM::t"); InitDOS( DOStypes::SemiCircle, // type of DOS t, // hopping amplitude grid.get_N(), result.omega, result.NIDOS); // total number of omega grid points, omega-grid array, the array in which NIDOS will be stored double n = 0.5; // always set a default value in case parameter is not found in the input file!!! result.n = n; CHM chm("params"); for (double U=2.6; U<3.5; U+=0.025) { char rhoFN[300]; sprintf(rhoFN,"UHTMI_rho_vs_T.U%.3f",U); FILE* rhoFile = fopen(rhoFN,"w"); InitDelta( DOStypes::SemiCircle, // type of DOS grid.get_N(), // total number of omega grid points 0.5, 0.0, 0.01, t, // hybridization-V, chemical potential-mu (defines the omega shift), broadening eta, and hopping amplitude result.omega, result.Delta); // omega-grid array and the array in which Delta will be stored for (double T=1.0; T>0.05; T-=0.05) { result.n = n; chm.SetParams(U,T,t); chm.Run(&result); char FN[300]; sprintf( FN, "CHM.U%.3f.T%.3f", chm.get_U(), chm.get_T() ); result.PrintResult(FN); fprintf(rhoFile, "%.15le %.15le %.15le\n", T, result.Conductivity( T , U*0.5 , 400, 400, NULL, false ), result.Conductivity( T , U*0.5 , 400, 400, NULL, true ) ); } fclose(rhoFile); } return 0; }
int main(int argc, char* argv[]) { #ifdef _MPI int myrank; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &myrank ); #endif GRID grid("params"); TMT tmt("params"); #ifdef _MPI if (myrank != 0) { // MPI SLAVE tmt.SetGrid(&grid); tmt.Slave(myrank); } else { // MPI MASTER #endif Result result(&grid); grid.assign_omega(result.omega); InitDOS(DOStypes::SemiCircle, 0.5, grid.get_N(), result.omega, result.NIDOS); //for(double T=0.02; T>0.009; T -= 0.02) double T=0.02; double U=4.0; //for(double U=3.0; U<4.1; U+=0.5) { InitDelta(DOStypes::SemiCircle, grid.get_N(), 0.5, 0.0, 0.01, 0.5, result.omega, result.Delta); //for(double W=0.6; W<4.1; W+=0.2) double W=0; for(double dmu=0.0; dmu<2.0; dmu+=1000.05) { //InitDelta(DOStypes::SemiCircle, grid.get_N(), 0.5, 0.0, 0.01, 0.5, result.omega, result.Delta); result.mu = U/2.0+dmu; result.mu0 = 0; tmt.SetWDN(W, Distributions::Uniform, (W>0.0) ? (int) (W/0.05) : 1); tmt.SetParams(U, T, 0.5); bool failed = tmt.Run(&result); if (failed) printf ("==== ERROR ==== Solution is INVALID\n"); char FN[50]; sprintf(FN, "TMT.T%.3f.U%.3f.dmu%.3f%s", tmt.get_T(), tmt.get_U(), dmu, (failed) ? ".FAILED" : "" ); result.PrintResult(FN); } } #ifdef _MPI tmt.SendExitSignal(); } //end MPI MASTER MPI_Finalize(); #endif return 0; }
int main(int argc, char* argv[]) { #ifdef _MPI int myrank; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &myrank ); #endif GRID grid("params"); TMT tmt("params"); #ifdef _MPI if (myrank != 0) { // MPI SLAVE tmt.SetGrid(&grid); tmt.Slave(myrank); } else { // MPI MASTER #endif Result result(&grid); grid.assign_omega(result.omega); InitDOS(DOStypes::SemiCircle, 0.5, grid.get_N(), result.omega, result.NIDOS); for(double T=0.05; T<0.06; T += 10000.0) for(double U=3.00; U<=7.1; U+=0.5) { InitDelta(DOStypes::SemiCircle, grid.get_N(), 0.5, 0.0, 0.01, 0.5, result.omega, result.Delta); for(double W=0.5; W<=7.1; W+=0.5) { //InitDelta(DOStypes::SemiCircle, grid.get_N(), 0.5, 0.0, 0.01, 0.5, result.omega, result.Delta); result.mu = U/2.0; result.mu0 = 0; tmt.SetWDN(W, Distributions::Uniform, (W>0.0) ? 20 + (int) ( ((U>2.8) ? 2.0 : 1.0) * W / 0.1 ) : 1); tmt.SetParams(U, T, 0.5); char OFN[300]; sprintf(OFN,".T%.3f.U%.3f.W%.3f",T,U,W); tmt.LC->SetOutputFileName(OFN); tmt.LC->SetNMT(grid.get_N(), 1000, T); //printf("grid.get_N(): %d, half: %d\n",grid.get_N(),grid.get_N()/2) ; //tmt.LC->SetOffset(grid.get_N()/2); bool failed = tmt.Run(&result); FILE* f = fopen("lambdaUW.T0.050","a"); fprintf(f, "%.15le %.15le %.15le %.15le\n", U,W, tmt.LC->lambdas[0], tmt.LC->continued_lambdas[0]); fclose(f); if (failed) printf ("==== ERROR ==== Solution is INVALID\n"); char FN[50]; sprintf(FN, "TMT.T%.3f.U%.3f.W%.3f%s", tmt.get_T(), tmt.get_U(), tmt.get_W(), (failed) ? ".FAILED" : "" ); result.PrintResult(FN); } } #ifdef _MPI tmt.SendExitSignal(); } //end MPI MASTER MPI_Finalize(); #endif return 0; }
int main(int argc, char* argv[]) { #ifdef _MPI // MPI initialization. Every MPI process has an ordinal number (myrank). // 0 is the master process, and all the others slave processes int myrank; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &myrank ); #endif // initialize grid and tmt from input file. This is done in both master and slave processes. GRID grid("params"); TMT tmt("params"); // NOTE: since TMT is initialized with same parameters in all process there is no actual need // for master process to send the values for U and T along with Delta to slave processes. // However if U and T are changed in an automatized manner (using for-loops for example) to // obtain results for different sets of parameters in a single run, then this is needed since // TMT in slave processes does not experience the change in parameters. Still, things can // be implemented a bit differently to avoid sending U and T. For example, put the entire // "if else" below in the for loop instead of just the "else" part. This way the exit signal // would have to be sent after each calculation and Result would have to be initialized in both // master and slave processes. Maybe I'll change this in future and exclude the sending of // U and T, but this way seems "cleaner" to me for now (check TMT::SolveSIAM and TMT::Slave) #ifdef _MPI if (myrank != 0) { // MPI SLAVE // in the case of slave processes, grid has to be set maunally to the tmt // object because no result object will be passed to its Run method (neither it will be called) tmt.SetGrid(&grid); // slave method sets tmt in a perpetual loop of waiting for input from master process, performing // SIAM calculation on recieved data, and returning results to the master process until Exit Signal // is received. If an error occurs during solving SIAM, an error signal is sent to master process. tmt.Slave(myrank); } else { // MPI MASTER #endif Result result(&grid); grid.assign_omega(result.omega); // create an initial guess for Delta InitDelta(DOStypes::SemiCircle, grid.get_N(), 0.5, 0.0, 0.01, 0.5, result.omega, result.Delta); // NIDOS is not needed for input since tmt only works with bethe-specific self-consistency // opposite to what is the case with CHM, tmt takes mu as an input parameter, rather than n // To use tmt away from half-filling, set mu to values other than U/2 result.mu = tmt.get_U()/2.0; // this is just the initial guess for SIAM inside TMT result.mu0 = 0; // run the calculation and receive the error code. bool failed = tmt.Run(&result); if (failed) printf ("==== ERROR ==== Solution is INVALID\n"); // prepare the file name and print out results char FN[50]; sprintf(FN, "TMT.U%.3f.T%.3f.W%.3f%s", tmt.get_U(), tmt.get_T(), tmt.get_W(), (failed) ? ".FAILED" : "" ); result.PrintResult(FN); #ifdef _MPI // when finished, send exit signal to slave processes to end them. tmt.SendExitSignal(); } //end MPI MASTER // all processes must reach MPI finalize. MPI_Finalize(); #endif return 0; }
int main() { double Ts [] = { 7.000000000000001e-02, 8.000000000000000e-02, 9.000000000000000e-02, 9.999999999999999e-02, 1.100000000000000e-01, 1.200000000000000e-01, 1.300000000000000e-01, 1.400000000000000e-01, 1.500000000000000e-01, 1.600000000000000e-01, 1.700000000000000e-01, 1.800000000000000e-01, 1.900000000000000e-01 }; double Us [] = { 2.359999999999992, 2.329999999999993, 2.299999999999994, 2.279999999999994, 2.259999999999994, 2.239999999999995, 2.219999999999995, 2.199999999999996, 2.179999999999996, 2.169999999999996, 2.149999999999997, 2.129999999999997, 2.119999999999997 }; int NT = sizeof(Ts)/sizeof(double); GRID grid("params"); Result result(&grid); grid.assign_omega(result.omega); Input input("params"); double t = 0.5; // always set a default value in case parameter is not found in the input file!!! input.ReadParam(t,"CHM::t"); InitDelta( DOStypes::SemiCircle, // type of DOS grid.get_N(), // total number of omega grid points 0.5, 0.0, 0.01, t, // hybridization-V, chemical potential-mu (defines the omega shift), broadening eta, and hopping amplitude result.omega, result.Delta); // omega-grid array and the array in which Delta will be stored InitDOS( DOStypes::SemiCircle, // type of DOS t, // hopping amplitude grid.get_N(), result.omega, result.NIDOS); // total number of omega grid points, omega-grid array, the array in which NIDOS will be stored double n = 0.5; // always set a default value in case parameter is not found in the input file!!! input.ReadParam(n,"main::n"); result.n = n; CHM chm("params"); for (int i=0; i<NT; i++) { chm.SetParams(Us[i],Ts[i],t); chm.Run(&result); char FN[50]; sprintf( FN, "CHM.U%.3f.T%.3f", chm.get_U(), chm.get_T() ); result.PrintResult(FN); FILE* rhocFile = fopen("rhoc","a"); double rhoc = result.Conductivity( chm.get_T() , 0.5*chm.get_U() , 400.0, 400.0, 10000.0 ) ; fprintf(rhocFile, "%.15le %.15le %.15le\n", chm.get_T(), rhoc, 1/rhoc); fclose(rhocFile); for (double dU=-0.3; dU<0.31; dU+=0.04) { chm.SetParams(Us[i]+dU,Ts[i],t); chm.Run(&result); char FN[50]; sprintf( FN, "CHM.U%.3f.T%.3f", chm.get_U(), chm.get_T() ); result.PrintResult(FN); char rhoFN[50]; sprintf( rhoFN, "rho.dU%.3f", dU ); FILE* rhoFile = fopen(rhoFN,"a"); double rho = result.Conductivity( chm.get_T() , 0.5*chm.get_U() , 400.0, 400.0, 10000.0 ) ; fprintf(rhoFile, "%.15le %.15le %.15le %.15le %.15le\n", chm.get_T(), rho, 1.0/rho, rho/rhoc, rhoc/rho); fclose(rhoFile); } } return 0; }