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_t_from_RAW.cc 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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_t.cc
  6. Purpose: Fourier transform to spacetime 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 != 11) { // 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. cout << "int Npts_t \t Number of points in time for the Fourier transform" << endl;
  26. cout << "DP t_max \t Max time to be used" << endl;
  27. }
  28. else { // (argc == 9), correct nr of arguments
  29. char whichDSF = *argv[1];
  30. DP c_int = atof(argv[2]);
  31. DP L = atof(argv[3]);
  32. int N = atoi(argv[4]);
  33. int iKmin = atoi(argv[5]);
  34. int iKmax = atoi(argv[6]);
  35. char* rawfilename = argv[7];
  36. int Npts_x = atoi(argv[8]);
  37. int Npts_t = atoi(argv[9]);
  38. DP t_max = atof(argv[10]);
  39. ifstream RAW_infile;
  40. RAW_infile.open(rawfilename);
  41. if (RAW_infile.fail()) {
  42. cout << rawfilename << endl;
  43. ABACUSerror("Could not open RAW_infile... ");
  44. }
  45. // Define the output file name: use the RAW file name but with different suffix
  46. stringstream SFT_stringstream; string SFT_string;
  47. SFT_stringstream << rawfilename << "_xtf_Nx_" << Npts_x << "_Nt_" << Npts_t << "_tmax_" << t_max;
  48. SFT_string = SFT_stringstream.str(); const char* SFT_Cstr = SFT_string.c_str();
  49. ofstream SFT_outfile;
  50. SFT_outfile.open(SFT_Cstr);
  51. if (SFT_outfile.fail()) ABACUSerror("Could not open SFT_outfile... ");
  52. DP omega;
  53. int iK;
  54. DP FF;
  55. DP dev;
  56. string label;
  57. // Define space coordinates: between 0 and L
  58. Vect_DP xlattice(Npts_x);
  59. for (int i = 0; i < Npts_x; ++i) xlattice[i] = i * L/Npts_x;
  60. // Now define time coordinates: between 0 and t_max
  61. Vect_DP tlattice(Npts_t);
  62. for (int i = 0; i < Npts_t; ++i) tlattice[i] = i * t_max/Npts_t;
  63. RecMat<complex<DP> > FT(0.0, Npts_x, Npts_t);
  64. DP twopioverL = twoPI/L;
  65. DP FFsq;
  66. complex<DP> exp_ik, exp_miomega;
  67. while (RAW_infile.peek() != EOF) {
  68. RAW_infile >> omega >> iK >> FF >> dev >> label;
  69. FFsq = FF * FF;
  70. exp_ik = exp(II * (iK * twopioverL));
  71. exp_miomega = exp(-II * omega);
  72. for (int ix = 0; ix < Npts_x; ++ix)
  73. for (int it = 0; it < Npts_t; ++it)
  74. //FT[ix][it] += FF * FF * exp(II * (iK * twopioverL * xlattice[ix] - omega * tlattice[it]));
  75. FT[ix][it] = FFsq * pow(exp_ik, xlattice[ix]) * pow(exp_miomega, tlattice[it]);
  76. }
  77. RAW_infile.close();
  78. // Reset proper normalization:
  79. // for (int ix = 0; ix < Npts_x; ++ix)
  80. // for (int it = 0; it < Npts_t; ++it)
  81. // FT[ix][it] *= twopioverL;
  82. // Output to file:
  83. for (int ix = 0; ix < Npts_x; ++ix) {
  84. if (ix > 0) SFT_outfile << endl;
  85. for (int it = 0; it < Npts_t; ++it)
  86. SFT_outfile << FT[ix][it] << "\t";
  87. }
  88. SFT_outfile.close();
  89. }
  90. return(0);
  91. }