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_Data_Daemon.cc 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: LiebLin_Data_Daemon.cc
  6. Purpose: Produces sets of data files for correlations.
  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 != 11) { // provide some info
  15. cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
  16. cout << endl << "Usage of LiebLin_Data_Daemon 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_max \t\t Largest value of the interaction parameter: use positive real values only" << endl;
  21. cout << "int Nc \t\t number of steps in interaction value" << endl;
  22. cout << "int cfact \t\t dividing factor (each new interaction value if 1/cfact times the previous)" << endl;
  23. cout << "DP L \t\t\t Length of the system: use positive real values only" << endl;
  24. cout << "int N \t\t\t Number of particles: use positive integer values only" << endl;
  25. cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers to scan over: "
  26. "recommended values: -2*N and 2*N" << endl;
  27. cout << "DP kBT \t\t Temperature (positive only of course)" << endl;
  28. cout << "int Max_Hrs \t\t Allowed computational time: (in hours)" << endl;
  29. }
  30. else { // (argc == 10), correct nr of arguments
  31. int ia = 1;
  32. char whichDSF = *argv[ia++];
  33. DP c_int_max = atof(argv[ia++]);
  34. int Nc = atoi(argv[ia++]);
  35. int cfact = atoi(argv[ia++]);
  36. DP L = atof(argv[ia++]);
  37. int N = atoi(argv[ia++]);
  38. int iKmin = atoi(argv[ia++]);
  39. int iKmax = atoi(argv[ia++]);
  40. DP kBT = atof(argv[ia++]);
  41. int Max_Hrs = atoi(argv[ia++]);
  42. // Individual computations are split into chuncks of Max_Hrs/(Nc * 4)
  43. int Max_Secs = (Max_Hrs * 2700)/Nc; // to minimize wrapping up & restarting time
  44. cout << "Data daemon will use chunks of " << Max_Secs << " seconds." << endl;
  45. double StartTime = omp_get_wtime();
  46. double ActualTime = omp_get_wtime();
  47. DP c_int;
  48. DP target_sumrule = 1.0;
  49. while (ActualTime - StartTime < double(3600 * Max_Hrs - Max_Secs)) {
  50. Vect<DP> srsat(0.0, Nc);
  51. Vect<bool> refine(false, Nc);
  52. DP srmin = 1.0;
  53. int icmin = 0;
  54. // Determine which correlation has the worst sum rule:
  55. for (int ic = 0; ic < Nc; ++ic) {
  56. c_int = c_int_max/pow(cfact, ic);
  57. stringstream SRC_stringstream; string SRC_string;
  58. Data_File_Name (SRC_stringstream, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
  59. SRC_stringstream << ".src";
  60. SRC_string = SRC_stringstream.str(); const char* SRC_Cstr = SRC_string.c_str();
  61. fstream srcfile;
  62. srcfile.open(SRC_Cstr, fstream::in);
  63. if (srcfile.fail()) {
  64. srsat[ic] = 0.0;
  65. refine[ic] = false;
  66. }
  67. else {
  68. srcfile >> srsat[ic];
  69. refine[ic] = true;
  70. }
  71. if (srsat[ic] < srmin) {
  72. srmin = srsat[ic];
  73. icmin = ic;
  74. }
  75. srcfile.close();
  76. } // for ic
  77. cout << "srsat min found: " << srmin << "\t for c = " << c_int_max/pow(cfact, icmin) << ". Now refining this."
  78. << " Time left: " << 3600* Max_Hrs - (ActualTime - StartTime) << " seconds." << endl;
  79. // Improve the icmin calculation by one chunk:
  80. Scan_LiebLin (whichDSF, c_int_max/pow(cfact, icmin), L, N, iKmin, iKmax, kBT, Max_Secs,
  81. target_sumrule, refine[icmin]);
  82. ActualTime = omp_get_wtime();
  83. } // while there is time
  84. cout << "Wrapping up, time's up." << endl;
  85. } // else if arguments given OK
  86. return(0);
  87. }