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_Fourier_to_t_equal_x.cc 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**********************************************************
  2. This software is part of J.-S. Caux's ABACUS library.
  3. Copyright (c) J.-S. Caux.
  4. -----------------------------------------------------------
  5. File: LiebLin_Fourier_to_t_equal_x.cc
  6. Purpose: Fourier transform to static space correlator for LiebLin.
  7. ***********************************************************/
  8. #include "ABACUS.h"
  9. using namespace std;
  10. using namespace ABACUS;
  11. int main(int argc, char* argv[])
  12. {
  13. if (argc != 10) { // provide some info
  14. cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
  15. cout << endl << "Usage of LiebLin_Fourier_to_x_equal_t executable: " << endl;
  16. cout << endl << "Provide the following arguments:" << endl << endl;
  17. 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;
  18. cout << "DP c_int \t\t Value of the interaction parameter" << endl;
  19. cout << "DP L \t\t\t Length of the system" << endl;
  20. cout << "int N \t\t\t Number of particles" << endl;
  21. cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers scanned over" << endl;
  22. cout << "DP kBT \t\t Temperature" << endl;
  23. cout << "int Npts_t \t Number of points in time for the Fourier transform" << endl;
  24. cout << "DP t_max \t Max time to be used" << endl;
  25. }
  26. else { // (argc == 10), 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 Npts_t = atoi(argv[8]);
  35. DP t_max = atof(argv[9]);
  36. // Momentum business: use symmetry
  37. if (iKmin != 0) ABACUSerror("LiebLin_Fourier_to_t_equal_x only implemented for raw files with iKmin == 0.");
  38. stringstream filenameprefix;
  39. Data_File_Name (filenameprefix, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
  40. string prefix = filenameprefix.str();
  41. stringstream RAW_stringstream; string RAW_string;
  42. RAW_stringstream << prefix << ".raw";
  43. RAW_string = RAW_stringstream.str(); const char* RAW_Cstr = RAW_string.c_str();
  44. ifstream RAW_infile;
  45. RAW_infile.open(RAW_Cstr);
  46. if (RAW_infile.fail()) {
  47. cout << RAW_Cstr << endl;
  48. ABACUSerror("Could not open RAW_infile... ");
  49. }
  50. // We also read the f-sumrule file, to correct for missing intensity.
  51. stringstream FSR_stringstream; string FSR_string;
  52. FSR_stringstream << prefix << ".fsr";
  53. FSR_string = FSR_stringstream.str(); const char* FSR_Cstr = FSR_string.c_str();
  54. ifstream FSR_infile;
  55. FSR_infile.open(FSR_Cstr);
  56. if (FSR_infile.fail()) {
  57. cout << FSR_Cstr << endl;
  58. ABACUSerror("Could not open FSR_infile... ");
  59. }
  60. stringstream SFT_stringstream; string SFT_string;
  61. SFT_stringstream << prefix << ".tft";
  62. SFT_string = SFT_stringstream.str(); const char* SFT_Cstr = SFT_string.c_str();
  63. ofstream SFT_outfile;
  64. SFT_outfile.open(SFT_Cstr);
  65. if (SFT_outfile.fail()) ABACUSerror("Could not open TFT_outfile... ");
  66. // First compute the static structure factor from the RAW data:
  67. Vect_DP TSF(0.0, Npts_t);
  68. DP omega;
  69. int iK;
  70. DP FF;
  71. //int conv;
  72. DP dev;
  73. string label;
  74. // Now define time coordinates: between 0 and t_max
  75. Vect_DP tlattice(Npts_t);
  76. for (int i = 0; i < Npts_t; ++i) tlattice[i] = (i + 0.5) * t_max/Npts_t;
  77. // Now the correlation at t:
  78. Vect<complex<DP> > FT(0.0, Npts_t);
  79. Vect_DP FTre(0.0, Npts_t);
  80. Vect_DP FTim(0.0, Npts_t);
  81. while (RAW_infile.peek() != EOF) {
  82. RAW_infile >> omega >> iK >> FF >> dev >> label;
  83. if (iK == 0)
  84. for (int it = 0; it < Npts_t; ++it)
  85. FT[it] += FF * FF * exp(II * omega * tlattice[it]);
  86. else
  87. for (int it = 0; it < Npts_t; ++it)
  88. FT[it] += 2.0 * FF * FF * exp(II * omega * tlattice[it]);
  89. }
  90. RAW_infile.close();
  91. // Reset proper normalization:
  92. for (int it = 0; it < Npts_t; ++it) {
  93. FTre[it] = real(FT[it]);
  94. FTim[it] = imag(FT[it]);
  95. }
  96. // Output to file:
  97. for (int it = 0; it < Npts_t; ++it) {
  98. if (it > 0) SFT_outfile << endl;
  99. SFT_outfile << tlattice[it] << "\t" << FTre[it] << "\t" << FTim[it];
  100. }
  101. SFT_outfile.close();
  102. }
  103. return(0);
  104. }