123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- /**********************************************************
-
- This software is part of J.-S. Caux's ABACUS library.
-
- Copyright (c) J.-S. Caux.
-
- -----------------------------------------------------------
-
- File: LiebLin_Catalogue_Fixed_c_k_Nscaling.cc
-
- Purpose: Produces sets of data files for correlations, increasing system size at fixed c and momentum.
-
- ***********************************************************/
-
- #include <omp.h>
- #include "ABACUS.h"
-
- using namespace std;
- using namespace ABACUS;
-
-
- int main(int argc, char* argv[])
- {
-
- if (argc != 8) { // provide some info
-
- cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
- cout << endl << "Usage of LiebLin_Catalogue_Fixed_c_k_Nscaling 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 \t\t Value of the interaction parameter: use positive real values only" << endl;
- cout << "int kfact \t\t momentum factor: momentum will be set to kfact * kF/4" << endl;
- cout << "DP kBT \t\t Temperature (positive only of course)" << endl;
- cout << "DP target_sumrule \t sumrule saturation you're satisfied with" << endl;
- cout << "int Hrs \t\t Allowed computational time (hours)" << endl;
- cout << "int Mns \t\t Allowed computational time (minutes)" << endl;
- }
-
- else { // correct nr of arguments
- int ia = 1;
- char whichDSF = *argv[ia++];
- DP c_int = atof(argv[ia++]);
- int kfact = atoi(argv[ia++]);
- DP kBT = atof(argv[ia++]);
- DP target_sumrule = atof(argv[ia++]);
- int Max_Secs = 3600*atoi(argv[ia++]) + 60*atoi(argv[ia++]);
-
- double StartTime = omp_get_wtime();
-
- double ActualTime = omp_get_wtime();
-
- int Secs_left = Max_Secs;
-
- int iN = 0;
-
- int nN = 16;
- Vect<int> Nv(nN);
- // Multiples of 32 up to 256
- for (int i = 1; i <= 8; ++i) Nv[i-1] = 32*i;
- // Then steps of 64 up to 512
- for (int i = 1; i <= 4; ++i) Nv[7+i] = 256 + 64*i;
- // Then steps of 128 up to 1024
- for (int i = 1; i <= 4; ++i) Nv[11+i] = 512 + 128*i;
-
- for (int iN = 0; iN < nN; ++iN) {
-
- int N = Nv[iN];
- DP L = N;
- int iKmin = (kfact * N)/8;
- int iKmax = iKmin;
- DP srsat = 0.0;
- bool refine = false;
-
- 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 = 0.0;
- refine = false;
- }
- else {
- srcfile >> srsat;
- refine = true;
- }
- srcfile.close();
-
- ActualTime = omp_get_wtime();
- Secs_left = int(Max_Secs - (ActualTime - StartTime));
-
- Scan_Info resulting_info;
- if (srsat < target_sumrule && Secs_left > Max_Secs/2) {
- // Improve the icmin calculation by one chunk:
- cout << "---\nTime left = " << Secs_left << " seconds." << endl;
- if (srsat > 0) {
- cout << "Continue with N = " << N << ". Sumrule previously achieved: " << srsat << endl;
- } else {
- cout << "Start with N = " << N << "." << endl;
- }
- resulting_info = Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT,
- Secs_left, target_sumrule, refine);
- cout << "Done with N = " << N
- << ". Sumrule obtained: " << resulting_info.sumrule_obtained
- << endl;
- }
-
- if (resulting_info.sumrule_obtained > target_sumrule) {
- // Move files to storage, keeping a copy of the .src file in the current directory
- string command1 = "mkdir -p ../store/data/N_" + to_string(N);
- system(command1.c_str());
- string command2 = "mv *_N_" + to_string(N) + "* ../store/data/N_" + to_string(N) + "/";
- system(command2.c_str());
- string command3 = "cp ../store/data/N_" + to_string(N) + "/*src .";
- system(command3.c_str());
- }
-
- ActualTime = omp_get_wtime();
-
- Secs_left = int(Max_Secs - (ActualTime - StartTime));
-
- if (Secs_left < 30) {
- if (resulting_info.sumrule_obtained > target_sumrule) {
- cout << "---\nBreaking out after completing N = " << N
- << " since time left = " << Secs_left << " seconds." << endl;
- }
- else {
- cout << "---\nBreaking out while working on N = " << N
- << " since allocated time is exhausted." << endl;
- }
- break;
- }
-
- } // while there is time
-
- } // else if arguments given OK
-
- return(0);
- }
|