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_RAW_File_Stats.cc 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: LiebLin_RAW_File_stats.cc
  6. Purpose: Analyzes the distribution of matrix element values in a RAW file,
  7. to help with optimization of the scanning procedure.
  8. ***********************************************************/
  9. #include "ABACUS.h"
  10. using namespace std;
  11. using namespace ABACUS;
  12. int main(int argc, char* argv[])
  13. {
  14. if (argc != 9) { // provide some info
  15. cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
  16. cout << endl << "Usage of LiebLin_RAW_File_Stats executable: " << endl;
  17. cout << endl << "Provide the following arguments:" << endl << endl;
  18. cout << "char whichDSF \t\t Which structure factor? Options are: d for rho rho, g for psi psi{dagger}, o for psi{dagger} psi" << endl;
  19. cout << "DP c_int \t\t Value of the interaction parameter: use positive real values only" << endl;
  20. cout << "DP L \t\t\t Length of the system: use positive real values only" << endl;
  21. cout << "int N \t\t\t Number of particles: use positive integer values only" << endl;
  22. cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers to scan over: recommended values: -2*N and 2*N" << endl;
  23. cout << "DP kBT \t\t Temperature (positive only of course)" << endl;
  24. cout << "int Aggregate size" << endl;
  25. }
  26. else { // (argc == 9), correct nr of arguments
  27. char whichDSF = *argv[1];
  28. DP c_int = atof(argv[2]);
  29. DP L = atof(argv[3]);
  30. int N = atoi(argv[4]);
  31. int iKmin = atoi(argv[5]);
  32. int iKmax = atoi(argv[6]);
  33. DP kBT = atof(argv[7]);
  34. int AgSize = atoi(argv[8]);
  35. if (AgSize < 2) ABACUSerror("Give an aggregate size > 1 in LiebLin_RAW_File_Stats.");
  36. stringstream RAW_stringstream; string RAW_string;
  37. Data_File_Name (RAW_stringstream, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
  38. RAW_stringstream << ".raw";
  39. RAW_string = RAW_stringstream.str(); const char* RAW_Cstr = RAW_string.c_str();
  40. ifstream RAW_infile;
  41. RAW_infile.open(RAW_Cstr);
  42. if (RAW_infile.fail()) {
  43. cout << RAW_Cstr << endl;
  44. ABACUSerror("Could not open RAW_infile... ");
  45. }
  46. stringstream STAT_stringstream; string STAT_string;
  47. Data_File_Name (STAT_stringstream, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
  48. STAT_stringstream << ".stat";
  49. STAT_string = STAT_stringstream.str(); const char* STAT_Cstr = STAT_string.c_str();
  50. ofstream STATfile;
  51. STATfile.open(STAT_Cstr);
  52. if (STATfile.fail()) {
  53. cout << STAT_Cstr << endl; ABACUSerror("Could not open STATfile.");
  54. }
  55. LiebLin_Bethe_State AveragingState = Canonical_Saddle_Point_State (c_int, L, N, whichDSF == 'Z' ? 0.0 : kBT);
  56. DP Chem_Pot = Chemical_Potential (AveragingState);
  57. //DP sumrule_factor = Sumrule_Factor (whichDSF, AveragingState, Chem_Pot, fixed_iK, iKneeded);
  58. Vect<DP> sumrule_factor(iKmax - iKmin + 1);
  59. for (int ik = 0; ik < iKmax - iKmin + 1; ++ik)
  60. sumrule_factor[ik] = Sumrule_Factor (whichDSF, AveragingState, Chem_Pot, ik, ik);
  61. // Normalize by total number of considered momenta
  62. DP correction_factor = 1.0/(iKmax - iKmin + 1);
  63. if (iKmin <= 0 && iKmax >= 0 && whichDSF == 'd') { // correct for fact that RhoRho is 0 at k = 0
  64. sumrule_factor[0] = 0.0;
  65. correction_factor = 1.0/(iKmax - iKmin);
  66. }
  67. for (int ik = 0; ik < iKmax - iKmin + 1; ++ik) sumrule_factor[ik] *= correction_factor;
  68. DP omega;
  69. int iK;
  70. DP ME;
  71. DP dev;
  72. string label;
  73. int nread = 0;
  74. DP srcont = 0.0;
  75. DP abssrcont = 0.0;
  76. DP maxsrcont = 0.0;
  77. DP totsrcont = 0.0;
  78. DP accumulatedsrcont = 0.0;
  79. int naccounted = 0;
  80. while (RAW_infile.peek() != EOF) {
  81. RAW_infile >> omega >> iK >> ME >> dev >> label;
  82. nread++;
  83. if (iK >= iKmin && iK <= iKmax) {
  84. srcont = omega * ME * ME * sumrule_factor[iK - iKmin];
  85. abssrcont = fabs(srcont);
  86. maxsrcont = ABACUS::max(maxsrcont, abssrcont);
  87. totsrcont += srcont;
  88. accumulatedsrcont += srcont;
  89. naccounted++;
  90. }
  91. if (naccounted >= AgSize) {
  92. STATfile << nread << "\t" << maxsrcont << "\t" << totsrcont/AgSize << "\t" << totsrcont/(AgSize * (maxsrcont > 0.0 ? maxsrcont : 1.0)) << "\t" << accumulatedsrcont << endl;
  93. naccounted = 0;
  94. maxsrcont = 0.0;
  95. totsrcont = 0.0;
  96. }
  97. }
  98. RAW_infile.close();
  99. STATfile.close();
  100. }
  101. return(0);
  102. }