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_x_equal_t.cc 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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_x_equal_t.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 != 9) { // 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: "
  18. "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" << endl;
  20. cout << "DP L \t\t\t Length of the system" << endl;
  21. cout << "int N \t\t\t Number of particles" << endl;
  22. cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers scanned over" << endl;
  23. cout << "DP kBT \t\t Temperature" << endl;
  24. cout << "int Npts_x Number of points in space for the Fourier transform" << 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 Npts_x = atoi(argv[8]);
  35. stringstream filenameprefix;
  36. Data_File_Name (filenameprefix, whichDSF, c_int, L, N, iKmin, iKmax, kBT, 0.0, "");
  37. string prefix = filenameprefix.str();
  38. stringstream RAW_stringstream; string RAW_string;
  39. RAW_stringstream << prefix << ".raw";
  40. RAW_string = RAW_stringstream.str(); const char* RAW_Cstr = RAW_string.c_str();
  41. ifstream RAW_infile;
  42. RAW_infile.open(RAW_Cstr);
  43. if (RAW_infile.fail()) {
  44. cout << RAW_Cstr << endl;
  45. ABACUSerror("Could not open RAW_infile... ");
  46. }
  47. // We also read the f-sumrule file, to correct for missing intensity.
  48. stringstream FSR_stringstream; string FSR_string;
  49. FSR_stringstream << prefix << ".fsr";
  50. FSR_string = FSR_stringstream.str(); const char* FSR_Cstr = FSR_string.c_str();
  51. ifstream FSR_infile;
  52. FSR_infile.open(FSR_Cstr);
  53. if (FSR_infile.fail()) {
  54. cout << FSR_Cstr << endl;
  55. ABACUSerror("Could not open FSR_infile... ");
  56. }
  57. stringstream SFT_stringstream; string SFT_string;
  58. SFT_stringstream << prefix << ".sft";
  59. SFT_string = SFT_stringstream.str(); const char* SFT_Cstr = SFT_string.c_str();
  60. ofstream SFT_outfile;
  61. SFT_outfile.open(SFT_Cstr);
  62. if (SFT_outfile.fail()) ABACUSerror("Could not open SFT_outfile... ");
  63. // First compute the static structure factor from the RAW data:
  64. Vect_DP SSF(0.0, iKmax - iKmin + 1);
  65. DP omega;
  66. int iK;
  67. DP FF;
  68. DP dev;
  69. string label;
  70. while (RAW_infile.peek() != EOF) {
  71. RAW_infile >> omega >> iK >> FF >> dev >> label;
  72. if (iK >= iKmin && iK <= iKmax) {
  73. SSF[iK - iKmin] += FF * FF;
  74. }
  75. }
  76. RAW_infile.close();
  77. // Reset proper normalization:
  78. DP normalization = twoPI * L;
  79. for (int iK = 0; iK < iKmax - iKmin + 1; ++iK) SSF[iK] *= normalization/twoPI; // twoPI from integral over omega
  80. // We now refine the SSF in the following way.
  81. // First, we read off the f-sumrule saturation from the FSR file.
  82. // Then, we put back the missing weight, assuming that it lives
  83. // on the free k^2 dispersion relation (so the DSF is then simply 2\pi N/L \delta(\omega - k^2)).
  84. Vect_DP FSRsaturated(0.0, iKmax - iKmin + 1);
  85. int dummyint;
  86. DP dummy;
  87. for (int i = iKmin; i <= iKmax; ++i)
  88. FSR_infile >> dummyint >> FSRsaturated[i - iKmin] >> dummy;
  89. FSR_infile.close();
  90. // Now correct the SSF by the missing piece:
  91. //for (int iK = iKmin; iK <= iKmax; ++iK)
  92. //SSF[iK - iKmin] += (1.0 - FSRsaturated[iK - iKmin]) * N/L;
  93. //cout << FSRsaturated << endl;
  94. //cout << SSF << endl;
  95. // Now define real-space coordinates: between 0 and L
  96. Vect_DP xlattice(Npts_x);
  97. for (int i = 0; i < Npts_x; ++i) xlattice[i] = (i + 0.5) * L/Npts_x;
  98. // Now the correlation at x:
  99. Vect_DP FTre(0.0, Npts_x);
  100. Vect_DP FTim(0.0, Npts_x);
  101. DP twopioverL = twoPI/L;
  102. // Fourier transform:
  103. for (int ix = 0; ix < Npts_x; ++ix) {
  104. for (int iK = iKmin; iK <= iKmax; ++iK) {
  105. FTre[ix] += SSF[iK - iKmin] * cos(twopioverL * iK * xlattice[ix]);
  106. FTim[ix] += SSF[iK - iKmin] * sin(twopioverL * iK * xlattice[ix]);
  107. }
  108. // Reset proper normalization: 1/L from space FT,
  109. FTre[ix] /= L;
  110. FTim[ix] /= L;
  111. // Outside of window iKmin, iKmax, we take the DSF to be a constant with delta function
  112. // at free energy k^2, so DSF = 2\pi N/L \delta(\omega - k^2) (to fit f-sumrule)
  113. // so SSF becomes N/L.
  114. // We thus need to correct above by adding
  115. // \frac{1}{L} \sum_{-\infty}^{iKmin - 1} SSF e^{ikx} + \frac{1}{L} \sum_{iKmax + 1}^\infty SSF e^{ikx}
  116. // Resumming carefully:
  117. if (whichDSF == 'd') {
  118. FTre[ix] += (sin(twopioverL * (iKmin - 0.5) * xlattice[ix]) - sin(twopioverL * (iKmax + 0.5) * xlattice[ix]))
  119. * N/(2.0 * L*L * sin(PI * xlattice[ix]/L));
  120. FTim[ix] += (-cos(twopioverL * (iKmin - 0.5) * xlattice[ix]) + cos(twopioverL * (iKmax + 0.5) * xlattice[ix]))
  121. * N/(2.0 * L*L * sin(PI * xlattice[ix]/L));
  122. }
  123. }
  124. // Since iKmax and iKmin are finite, we need to average over an interval of
  125. // deltax such that (2\pi/L) iKmax deltax = 2\pi, with deltax == deltaix * L/Npts_x
  126. // so deltaix = (Npts_x/L) * (L/iKmax)
  127. /*
  128. int deltaix = 0*int(Npts_x/(2.0*iKmax));
  129. cout << "deltaix = " << deltaix << endl;
  130. Vect_DP FTreavg(0.0, Npts_x);
  131. Vect_DP FTimavg(0.0, Npts_x);
  132. for (int ix = 0; ix < Npts_x; ++ix) {
  133. for (int ix2 = -deltaix; ix2 < deltaix; ++ix2) {
  134. FTreavg[ix] += FTre[ABACUS::min(ABACUS::max(0, ix + ix2), Npts_x - 1)];
  135. FTimavg[ix] += FTim[ABACUS::min(ABACUS::max(0, ix + ix2), Npts_x - 1)];
  136. }
  137. FTreavg[ix] /= (2*deltaix + 1);
  138. FTimavg[ix] /= (2*deltaix + 1);
  139. }
  140. */
  141. if (whichDSF == 'd') cout << "g2(0) = dE0_dc/L = " << LiebLin_dE0_dc (c_int, L, N)/L
  142. << "\t" << LiebLin_dE0_dc (c_int, 2.0*L, 2*N)/(2.0*L) << endl;
  143. // Output to file:
  144. for (int ix = 0; ix < Npts_x; ++ix) {
  145. if (ix > 0) SFT_outfile << endl;
  146. //SFT_outfile << xlattice[ix] << "\t" << FTre[ix] << "\t" << FTim[ix] << "\t" << FTreavg[ix] << "\t" << FTimavg[ix];
  147. SFT_outfile << xlattice[ix] << "\t" << FTre[ix] << "\t" << FTim[ix];
  148. }
  149. SFT_outfile.close();
  150. }
  151. return(0);
  152. }