Browse Source

Add general Fourier transform from RAW

master
J.-S. Caux 2 years ago
parent
commit
e1b2b0f1ec

+ 0
- 3
src/EXECS/LiebLin_Fourier_to_t_equal_x_from_RAW.cc View File

@@ -64,9 +64,6 @@ int main(int argc, char* argv[])
64 64
     SFT_outfile.open(SFT_Cstr);
65 65
     if (SFT_outfile.fail()) ABACUSerror("Could not open TFT_outfile... ");
66 66
 
67
-    // First compute the static structure factor from the RAW data:
68
-
69
-    Vect_DP TSF(0.0, Npts_t);
70 67
 
71 68
     DP omega;
72 69
     int iK;

+ 110
- 0
src/EXECS/LiebLin_Fourier_to_x_t_from_RAW.cc View File

@@ -0,0 +1,110 @@
1
+/**********************************************************
2
+
3
+This software is part of J.-S. Caux's ABACUS library.
4
+
5
+Copyright (c) J.-S. Caux.
6
+
7
+-----------------------------------------------------------
8
+
9
+File:  LiebLin_Fourier_to_x_t.cc
10
+
11
+Purpose:  Fourier transform to spacetime correlator for LiebLin.
12
+
13
+***********************************************************/
14
+
15
+#include "ABACUS.h"
16
+
17
+using namespace std;
18
+using namespace ABACUS;
19
+
20
+
21
+int main(int argc, char* argv[])
22
+{
23
+  if (argc != 11) { // provide some info
24
+
25
+    cout << endl << "Welcome to ABACUS\t(copyright J.-S. Caux)." << endl;
26
+    cout << endl << "Usage of LiebLin_Fourier_to_x_equal_t executable: " << endl;
27
+    cout << endl << "Provide the following arguments:" << endl << endl;
28
+    cout << "char whichDSF \t\t Which structure factor ?  Options are:  "
29
+      "d for rho rho, g for psi psi{dagger}, o for psi{dagger} psi" << endl;
30
+    cout << "DP c_int \t\t Value of the interaction parameter" << endl;
31
+    cout << "DP L \t\t\t Length of the system" << endl;
32
+    cout << "int N \t\t\t Number of particles" << endl;
33
+    cout << "int iKmin" << endl << "int iKmax \t\t Min and max momentum integers scanned over" << endl;
34
+    cout << "RAW file name" << endl;
35
+    cout << "int Npts_x Number of points in space for the Fourier transform" << endl;
36
+    cout << "int Npts_t \t Number of points in time for the Fourier transform" << endl;
37
+    cout << "DP t_max \t Max time to be used" << endl;
38
+  }
39
+
40
+  else { // (argc == 9), correct nr of arguments
41
+    char whichDSF = *argv[1];
42
+    DP c_int = atof(argv[2]);
43
+    DP L = atof(argv[3]);
44
+    int N = atoi(argv[4]);
45
+    int iKmin = atoi(argv[5]);
46
+    int iKmax = atoi(argv[6]);
47
+    char* rawfilename = argv[7];
48
+    int Npts_x = atoi(argv[8]);
49
+    int Npts_t = atoi(argv[9]);
50
+    DP t_max = atof(argv[10]);
51
+
52
+    ifstream RAW_infile;
53
+    RAW_infile.open(rawfilename);
54
+    if (RAW_infile.fail()) {
55
+      cout << rawfilename << endl;
56
+      ABACUSerror("Could not open RAW_infile... ");
57
+    }
58
+
59
+    // Define the output file name: use the RAW file name but with different suffix
60
+
61
+    stringstream SFT_stringstream;    string SFT_string;
62
+    SFT_stringstream << rawfilename << "_xtf_Nx_" << Npts_x << "_Nt_" << Npts_t << "_tmax_" << t_max;
63
+    SFT_string = SFT_stringstream.str();    const char* SFT_Cstr = SFT_string.c_str();
64
+    ofstream SFT_outfile;
65
+    SFT_outfile.open(SFT_Cstr);
66
+    if (SFT_outfile.fail()) ABACUSerror("Could not open SFT_outfile... ");
67
+
68
+    DP omega;
69
+    int iK;
70
+    DP FF;
71
+    DP dev;
72
+    string label;
73
+
74
+    // Define space coordinates: between 0 and L
75
+    Vect_DP xlattice(Npts_x);
76
+    for (int i = 0; i < Npts_x; ++i) xlattice[i] = i * L/Npts_x;
77
+
78
+    // Now define time coordinates: between 0 and t_max
79
+    Vect_DP tlattice(Npts_t);
80
+    for (int i = 0; i < Npts_t; ++i) tlattice[i] = i * t_max/Npts_t;
81
+
82
+    RecMat<complex<DP> > FT(0.0, Npts_x, Npts_t);
83
+    DP twopioverL = twoPI/L;
84
+
85
+    while (RAW_infile.peek() != EOF) {
86
+      RAW_infile >> omega >> iK >> FF >> dev >> label;
87
+      for (int ix = 0; ix < Npts_x; ++ix)
88
+	for (int it = 0; it < Npts_t; ++it)
89
+	  FT[ix][it] += FF * FF * exp(II * (iK * twopioverL * xlattice[ix] - omega * tlattice[it]));
90
+    }
91
+    RAW_infile.close();
92
+
93
+    // Reset proper normalization:
94
+    // for (int ix = 0; ix < Npts_x; ++ix)
95
+    //   for (int it = 0; it < Npts_t; ++it)
96
+    // 	FT[ix][it] *= twopioverL;
97
+
98
+    // Output to file:
99
+    for (int ix = 0; ix < Npts_x; ++ix) {
100
+      if (ix > 0) SFT_outfile << endl;
101
+      for (int it = 0; it < Npts_t; ++it)
102
+	SFT_outfile << FT[ix][it] << "\t";
103
+    }
104
+
105
+    SFT_outfile.close();
106
+  }
107
+
108
+  return(0);
109
+
110
+}

Loading…
Cancel
Save