ABACUS/src/EXECS/LiebLin_Fourier_to_t_equal_...

119 lines
3.6 KiB
C++

/**********************************************************
This software is part of J.-S. Caux's ABACUS library.
Copyright (c) J.-S. Caux.
-----------------------------------------------------------
File: LiebLin_Fourier_to_t_equal_x.cc
Purpose: Fourier transform to static space correlator for LiebLin.
***********************************************************/
#include "ABACUS.h"
using namespace std;
using namespace ABACUS;
int main(int argc, char* argv[])
{
if (argc != 10) { // provide some info
cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
cout << endl << "Usage of LiebLin_Fourier_to_x_equal_t executable: " << endl;
cout << endl << "Provide the following arguments:" << endl << endl;
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;
cout << "DP c_int \t\t Value of the interaction parameter" << endl;
cout << "DP L \t\t\t Length of the system" << endl;
cout << "int N \t\t\t Number of particles" << endl;
cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers scanned over" << endl;
//cout << "DP kBT \t\t Temperature" << endl;
cout << "RAW file name" << endl;
cout << "int Npts_t \t Number of points in time for the Fourier transform" << endl;
cout << "DP t_max \t Max time to be used" << endl;
}
else { // (argc == 10), correct nr of arguments
char whichDSF = *argv[1];
DP c_int = atof(argv[2]);
DP L = atof(argv[3]);
int N = atoi(argv[4]);
int iKmin = atoi(argv[5]);
int iKmax = atoi(argv[6]);
//DP kBT = atof(argv[7]);
char* rawfilename = argv[7];
int Npts_t = atoi(argv[8]);
DP t_max = atof(argv[9]);
// Momentum business: use symmetry
if (iKmin != 0) ABACUSerror("LiebLin_Fourier_to_t_equal_x only implemented for raw files with iKmin == 0.");
ifstream RAW_infile;
//RAW_infile.open(RAW_Cstr);
RAW_infile.open(rawfilename);
if (RAW_infile.fail()) {
//cout << RAW_Cstr << endl;
cout << rawfilename << endl;
ABACUSerror("Could not open RAW_infile... ");
}
stringstream SFT_stringstream; string SFT_string;
SFT_stringstream << rawfilename << "_tft";
SFT_string = SFT_stringstream.str(); const char* SFT_Cstr = SFT_string.c_str();
ofstream SFT_outfile;
SFT_outfile.open(SFT_Cstr);
if (SFT_outfile.fail()) ABACUSerror("Could not open TFT_outfile... ");
// First compute the static structure factor from the RAW data:
Vect_DP TSF(0.0, Npts_t);
DP omega;
int iK;
DP FF;
//int conv;
DP dev;
string label;
// Now define time coordinates: between 0 and t_max
Vect_DP tlattice(Npts_t);
for (int i = 0; i < Npts_t; ++i) tlattice[i] = (i + 0.5) * t_max/Npts_t;
// Now the correlation at t:
Vect<complex<DP> > FT(0.0, Npts_t);
Vect_DP FTre(0.0, Npts_t);
Vect_DP FTim(0.0, Npts_t);
while (RAW_infile.peek() != EOF) {
RAW_infile >> omega >> iK >> FF >> dev >> label;
if (iK == 0)
for (int it = 0; it < Npts_t; ++it)
FT[it] += FF * FF * exp(II * omega * tlattice[it]);
else
for (int it = 0; it < Npts_t; ++it)
FT[it] += 2.0 * FF * FF * exp(II * omega * tlattice[it]);
}
RAW_infile.close();
// Reset proper normalization:
for (int it = 0; it < Npts_t; ++it) {
FTre[it] = real(FT[it]);
FTim[it] = imag(FT[it]);
}
// Output to file:
for (int it = 0; it < Npts_t; ++it) {
if (it > 0) SFT_outfile << endl;
SFT_outfile << tlattice[it] << "\t" << FTre[it] << "\t" << FTim[it];
}
SFT_outfile.close();
}
return(0);
}