ABACUS/src/EXECS/LiebLin_Catalogue_Fixed_c_k...

117 lines
3.8 KiB
C++

/**********************************************************
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 != 7) { // 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 Nc \t\t number of steps in interaction value" << endl;
//cout << "int Nstep \t\t\t Steps to be taken in number of particles: use positive integer values only. Filling will be set to 1 (L == N)" << endl;
//cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers to scan over (in units of N == Nstep): recommended values: 0 and 2*N" << endl;
cout << "int kfact \t\t momentum factor: momemntum 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 Max_Secs \t\t Allowed computational time" << 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 = atoi(argv[ia++]);
//clock_t StartTime = clock();
double StartTime = omp_get_wtime();
//clock_t ActualTime = StartTime;
double ActualTime = omp_get_wtime();
int Secs_left = Max_Secs;
int iN = 0;
int nN = 12;
Vect<int> Nv(nN);
Nv[0] = 160; Nv[1] = 192; Nv[2] = 224; Nv[3] = 256;
Nv[4] = 320; Nv[5] = 384; Nv[6] = 448; Nv[7] = 512;
Nv[8] = 640; Nv[9] = 768; Nv[10] = 896; Nv[11] = 1024;
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));
if (srsat < target_sumrule && Secs_left > Max_Secs/2)
// Improve the icmin calculation by one chunk:
Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT, Secs_left, target_sumrule, refine);
ActualTime = omp_get_wtime();
//Secs_left = int(60*Max_minutes - double(ActualTime - StartTime)/CLOCKS_PER_SEC);
Secs_left = int(Max_Secs - (ActualTime - StartTime));
cout << "Done with N = " << N << ". Time left = " << Secs_left << " seconds." << endl;
if (Secs_left < 60) {
cout << "Breaking out after N = " << N << " since time left = " << Secs_left << endl;
break;
}
} // while there is time
} // else if arguments given OK
return(0);
}