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 4.1KB

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