123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- /**********************************************************
-
- This software is part of J.-S. Caux's ABACUS library.
-
- Copyright (c) J.-S. Caux.
-
- -----------------------------------------------------------
-
- File: LiebLin_Data_Daemon.cc
-
- Purpose: Produces sets of data files for correlations.
-
- ***********************************************************/
-
- #include <omp.h>
- #include "ABACUS.h"
-
- using namespace std;
- using namespace ABACUS;
-
-
- int main(int argc, char* argv[])
- {
-
- if (argc != 11) { // provide some info
-
- cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
- cout << endl << "Usage of LiebLin_Data_Daemon executable: " << endl;
- cout << endl << "Provide the following arguments:" << endl << endl;
- cout << "char whichDSF \t\t Which structure factor should be calculated ? Options are: d for rho rho, g for psi psi{dagger}, o for psi{dagger} psi" << endl;
- cout << "DP c_int_max \t\t Largest value of the interaction parameter: use positive real values only" << endl;
- cout << "int Nc \t\t number of steps in interaction value" << endl;
- cout << "int cfact \t\t dividing factor (each new interaction value if 1/cfact times the previous)" << endl;
- cout << "DP L \t\t\t Length of the system: use positive real values only" << endl;
- cout << "int N \t\t\t Number of particles: use positive integer values only" << endl;
- cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers to scan over: recommended values: -2*N and 2*N" << endl;
- cout << "DP kBT \t\t Temperature (positive only of course)" << endl;
- cout << "int Max_Hrs \t\t Allowed computational time: (in hours)" << endl;
- }
-
- else { // (argc == 10), correct nr of arguments
- int ia = 1;
- char whichDSF = *argv[ia++];
- DP c_int_max = atof(argv[ia++]);
- int Nc = atoi(argv[ia++]);
- int cfact = atoi(argv[ia++]);
- DP L = atof(argv[ia++]);
- int N = atoi(argv[ia++]);
- int iKmin = atoi(argv[ia++]);
- int iKmax = atoi(argv[ia++]);
- DP kBT = atof(argv[ia++]);
- int Max_Hrs = atoi(argv[ia++]);
-
- // Individual computations are split into chuncks of Max_Hrs/(Nc * 4)
- //int Max_Secs = (Max_Hrs * 900)/Nc;
- int Max_Secs = (Max_Hrs * 2700)/Nc; // to minimize wrapping up & restarting time
-
- cout << "Data daemon will use chunks of " << Max_Secs << " seconds." << endl;
-
- //clock_t StartTime = clock();
- double StartTime = omp_get_wtime();
-
- //clock_t ActualTime = StartTime;
- double ActualTime = omp_get_wtime();
-
- DP c_int;
- DP target_sumrule = 1.0;
-
- //while (double(ActualTime - StartTime)/CLOCKS_PER_SEC < double(3600 * Max_Hrs - Max_Secs)) {
- while (ActualTime - StartTime < double(3600 * Max_Hrs - Max_Secs)) {
-
- Vect<DP> srsat(0.0, Nc);
- Vect<bool> refine(false, Nc);
- DP srmin = 1.0;
- int icmin = 0;
-
- // Determine which correlation has the worst sum rule:
- for (int ic = 0; ic < Nc; ++ic) {
- c_int = c_int_max/pow(cfact, ic);
- stringstream SRC_stringstream; string SRC_string;
- Data_File_Name (SRC_stringstream, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
- SRC_stringstream << ".src";
- SRC_string = SRC_stringstream.str(); const char* SRC_Cstr = SRC_string.c_str();
-
- fstream srcfile;
- srcfile.open(SRC_Cstr, fstream::in);
- if (srcfile.fail()) {
- srsat[ic] = 0.0;
- refine[ic] = false;
- }
- else {
- srcfile >> srsat[ic];
- refine[ic] = true;
- }
- if (srsat[ic] < srmin) {
- srmin = srsat[ic];
- icmin = ic;
- }
- srcfile.close();
-
- } // for ic
-
- cout << "srsat min found: " << srmin << "\t for c = " << c_int_max/pow(cfact, icmin) << ". Now refining this."
- //<< " Time left: " << 3600* Max_Hrs - (ActualTime - StartTime)/CLOCKS_PER_SEC << " seconds." << endl;
- << " Time left: " << 3600* Max_Hrs - (ActualTime - StartTime) << " seconds." << endl;
-
- // Improve the icmin calculation by one chunk:
- Scan_LiebLin (whichDSF, c_int_max/pow(cfact, icmin), L, N, iKmin, iKmax, kBT, Max_Secs, target_sumrule, refine[icmin]);
-
- //ActualTime = clock();
- ActualTime = omp_get_wtime();
-
- } // while there is time
-
- cout << "Wrapping up, time's up." << endl;
-
- } // else if arguments given OK
-
- return(0);
- }
|