You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LiebLin_Catalogue_Fixed_c_k_Nscaling.cc 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: LiebLin_Catalogue_Fixed_c_k_Nscaling.cc
  6. Purpose: Produces sets of data files for correlations, increasing system size at fixed c and momentum.
  7. ***********************************************************/
  8. #include <omp.h>
  9. #include "ABACUS.h"
  10. using namespace std;
  11. using namespace ABACUS;
  12. int main(int argc, char* argv[])
  13. {
  14. if (argc != 8) { // provide some info
  15. cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
  16. cout << endl << "Usage of LiebLin_Catalogue_Fixed_c_k_Nscaling executable: " << endl;
  17. cout << endl << "Provide the following arguments:" << endl << endl;
  18. cout << "char whichDSF \t\t Which structure factor should be calculated ? Options are: "
  19. "d for rho rho, g for psi psi{dagger}, o for psi{dagger} psi" << endl;
  20. cout << "DP c_int \t\t Value of the interaction parameter: use positive real values only" << endl;
  21. cout << "int kfact \t\t momentum factor: momentum will be set to kfact * kF/4" << endl;
  22. cout << "DP kBT \t\t Temperature (positive only of course)" << endl;
  23. cout << "DP target_sumrule \t sumrule saturation you're satisfied with" << endl;
  24. cout << "int Hrs \t\t Allowed computational time (hours)" << endl;
  25. cout << "int Mns \t\t Allowed computational time (minutes)" << endl;
  26. }
  27. else { // correct nr of arguments
  28. int ia = 1;
  29. char whichDSF = *argv[ia++];
  30. DP c_int = atof(argv[ia++]);
  31. int kfact = atoi(argv[ia++]);
  32. DP kBT = atof(argv[ia++]);
  33. DP target_sumrule = atof(argv[ia++]);
  34. int Max_Secs = 3600*atoi(argv[ia++]) + 60*atoi(argv[ia++]);
  35. double StartTime = omp_get_wtime();
  36. double ActualTime = omp_get_wtime();
  37. int Secs_left = Max_Secs;
  38. int iN = 0;
  39. int nN = 16;
  40. Vect<int> Nv(nN);
  41. // Multiples of 32 up to 256
  42. for (int i = 1; i <= 8; ++i) Nv[i-1] = 32*i;
  43. // Then steps of 64 up to 512
  44. for (int i = 1; i <= 4; ++i) Nv[7+i] = 256 + 64*i;
  45. // Then steps of 128 up to 1024
  46. for (int i = 1; i <= 4; ++i) Nv[11+i] = 512 + 128*i;
  47. for (int iN = 0; iN < nN; ++iN) {
  48. int N = Nv[iN];
  49. DP L = N;
  50. int iKmin = (kfact * N)/8;
  51. int iKmax = iKmin;
  52. DP srsat = 0.0;
  53. bool refine = false;
  54. stringstream SRC_stringstream; string SRC_string;
  55. Data_File_Name (SRC_stringstream, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
  56. SRC_stringstream << ".src";
  57. SRC_string = SRC_stringstream.str(); const char* SRC_Cstr = SRC_string.c_str();
  58. fstream srcfile;
  59. srcfile.open(SRC_Cstr, fstream::in);
  60. if (srcfile.fail()) {
  61. srsat = 0.0;
  62. refine = false;
  63. }
  64. else {
  65. srcfile >> srsat;
  66. refine = true;
  67. }
  68. srcfile.close();
  69. ActualTime = omp_get_wtime();
  70. Secs_left = int(Max_Secs - (ActualTime - StartTime));
  71. Scan_Info resulting_info;
  72. if (srsat < target_sumrule && Secs_left > Max_Secs/2) {
  73. // Improve the icmin calculation by one chunk:
  74. cout << "---\nTime left = " << Secs_left << " seconds." << endl;
  75. if (srsat > 0) {
  76. cout << "Continue with N = " << N << ". Sumrule previously achieved: " << srsat << endl;
  77. } else {
  78. cout << "Start with N = " << N << "." << endl;
  79. }
  80. resulting_info = Scan_LiebLin (whichDSF, c_int, L, N, iKmin, iKmax, kBT,
  81. Secs_left, target_sumrule, refine);
  82. cout << "Done with N = " << N
  83. << ". Sumrule obtained: " << resulting_info.sumrule_obtained
  84. << endl;
  85. }
  86. if (resulting_info.sumrule_obtained > target_sumrule) {
  87. // Move files to storage, keeping a copy of the .src file in the current directory
  88. string command1 = "mkdir -p ../store/data/N_" + to_string(N);
  89. system(command1.c_str());
  90. string command2 = "mv *_N_" + to_string(N) + "* ../store/data/N_" + to_string(N) + "/";
  91. system(command2.c_str());
  92. string command3 = "cp ../store/data/N_" + to_string(N) + "/*src .";
  93. system(command3.c_str());
  94. }
  95. ActualTime = omp_get_wtime();
  96. Secs_left = int(Max_Secs - (ActualTime - StartTime));
  97. if (Secs_left < 30) {
  98. if (resulting_info.sumrule_obtained > target_sumrule) {
  99. cout << "---\nBreaking out after completing N = " << N
  100. << " since time left = " << Secs_left << " seconds." << endl;
  101. }
  102. else {
  103. cout << "---\nBreaking out while working on N = " << N
  104. << " since allocated time is exhausted." << endl;
  105. }
  106. break;
  107. }
  108. } // while there is time
  109. } // else if arguments given OK
  110. return(0);
  111. }