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_from_RAW.cc 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 << "RAW file name" << 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. char* rawfilename = argv[7];
  34. int Npts_x = atoi(argv[8]);
  35. ifstream RAW_infile;
  36. RAW_infile.open(rawfilename);
  37. if (RAW_infile.fail()) {
  38. cout << rawfilename << endl;
  39. ABACUSerror("Could not open RAW_infile... ");
  40. }
  41. // Define the output file name: use the RAW file name but with different suffix
  42. stringstream SFT_stringstream; string SFT_string;
  43. SFT_stringstream << rawfilename << "_sft";
  44. SFT_string = SFT_stringstream.str(); const char* SFT_Cstr = SFT_string.c_str();
  45. ofstream SFT_outfile;
  46. SFT_outfile.open(SFT_Cstr);
  47. if (SFT_outfile.fail()) ABACUSerror("Could not open SFT_outfile... ");
  48. // First compute the static structure factor from the RAW data:
  49. Vect_DP SSF(0.0, iKmax - iKmin + 1);
  50. DP omega;
  51. int iK;
  52. DP FF;
  53. DP dev;
  54. string label;
  55. while (RAW_infile.peek() != EOF) {
  56. RAW_infile >> omega >> iK >> FF >> dev >> label;
  57. if (iK >= iKmin && iK <= iKmax) {
  58. SSF[iK - iKmin] += FF * FF;
  59. }
  60. }
  61. RAW_infile.close();
  62. // Reset proper normalization:
  63. DP normalization = twoPI * L;
  64. for (int iK = 0; iK < iKmax - iKmin + 1; ++iK) SSF[iK] *= normalization/twoPI; // twoPI from integral over omega
  65. // Now define real-space coordinates: between 0 and L
  66. Vect_DP xlattice(Npts_x);
  67. for (int i = 0; i < Npts_x; ++i) xlattice[i] = (i + 0.5) * L/Npts_x;
  68. // Now the correlation at x:
  69. Vect_DP FTre(0.0, Npts_x);
  70. Vect_DP FTim(0.0, Npts_x);
  71. DP twopioverL = twoPI/L;
  72. // Fourier transform:
  73. for (int ix = 0; ix < Npts_x; ++ix) {
  74. for (int iK = iKmin; iK <= iKmax; ++iK) {
  75. FTre[ix] += SSF[iK - iKmin] * cos(twopioverL * iK * xlattice[ix]);
  76. FTim[ix] += SSF[iK - iKmin] * sin(twopioverL * iK * xlattice[ix]);
  77. }
  78. // Reset proper normalization: 1/L from space FT,
  79. FTre[ix] /= L;
  80. FTim[ix] /= L;
  81. // Outside of window iKmin, iKmax, we take the DSF to be a constant with delta function
  82. // at free energy k^2, so DSF = 2\pi N/L \delta(\omega - k^2) (to fit f-sumrule)
  83. // so SSF becomes N/L.
  84. // We thus need to correct above by adding
  85. // \frac{1}{L} \sum_{-\infty}^{iKmin - 1} SSF e^{ikx} + \frac{1}{L} \sum_{iKmax + 1}^\infty SSF e^{ikx}
  86. // Resumming carefully:
  87. //if (whichDSF == 'd') {
  88. //FTre[ix] += (sin(twopioverL * (iKmin - 0.5) * xlattice[ix]) - sin(twopioverL * (iKmax + 0.5) * xlattice[ix]))
  89. // * N/(2.0 * L*L * sin(PI * xlattice[ix]/L));
  90. //FTim[ix] += (-cos(twopioverL * (iKmin - 0.5) * xlattice[ix]) + cos(twopioverL * (iKmax + 0.5) * xlattice[ix]))
  91. // * N/(2.0 * L*L * sin(PI * xlattice[ix]/L));
  92. //}
  93. }
  94. // Output to file:
  95. for (int ix = 0; ix < Npts_x; ++ix) {
  96. if (ix > 0) SFT_outfile << endl;
  97. SFT_outfile << xlattice[ix] << "\t" << FTre[ix] << "\t" << FTim[ix];
  98. }
  99. SFT_outfile.close();
  100. }
  101. return(0);
  102. }