|
@@ -0,0 +1,156 @@
|
|
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: Histogram_RAW_File.cc
|
|
10
|
+
|
|
11
|
+Purpose: Produce a histogram of matrix elements from a RAW file.
|
|
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 != 7) {
|
|
24
|
+ cout << "Argument needed: rawfile, iKmin, iKmax, omega, domega, logscale_int" << endl;
|
|
25
|
+ ABACUSerror("");
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ int n = 1;
|
|
29
|
+ const char* rawfilename = argv[n++];
|
|
30
|
+ int iKmin = atoi(argv[n++]);
|
|
31
|
+ int iKmax = atoi(argv[n++]);
|
|
32
|
+ DP om = atof(argv[n++]);
|
|
33
|
+ DP dom = atof(argv[n++]);
|
|
34
|
+ int logscale_int = atoi(argv[n++]); // see below for meaning
|
|
35
|
+
|
|
36
|
+ ifstream RAW_infile;
|
|
37
|
+ RAW_infile.open(rawfilename);
|
|
38
|
+ if (RAW_infile.fail()) {
|
|
39
|
+ cout << rawfilename << endl;
|
|
40
|
+ ABACUSerror("Could not open RAW_infile... ");
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ stringstream outfilename;
|
|
44
|
+ string outfilename_string;
|
|
45
|
+ outfilename << rawfilename << "_hist";
|
|
46
|
+ if (iKmin != iKmax) outfilename << "_iKmin_" << iKmin << "_iKmax_" << iKmax;
|
|
47
|
+ outfilename << "_om_" << om << "_dom_" << dom << "_li_" << logscale_int;
|
|
48
|
+ outfilename_string = outfilename.str();
|
|
49
|
+ const char* outfilename_c_str = outfilename_string.c_str();
|
|
50
|
+
|
|
51
|
+ ofstream outfile;
|
|
52
|
+ outfile.open(outfilename_c_str);
|
|
53
|
+ outfile.precision(16);
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+ // Use the binning in current ABACUS version's threads,
|
|
58
|
+ // with logscale unit = 2^{1/64} \simeq 1.01
|
|
59
|
+ int npts = 6400/logscale_int;
|
|
60
|
+ DP logscale_used = logscale_int * (1.0/64) * log(2.0);
|
|
61
|
+
|
|
62
|
+ DP omega_min = om - 0.5* dom;
|
|
63
|
+ DP omega_max = om + 0.5* dom;
|
|
64
|
+
|
|
65
|
+ DP omega;
|
|
66
|
+ int iK;
|
|
67
|
+ DP FF;
|
|
68
|
+ DP dev;
|
|
69
|
+ string label;
|
|
70
|
+
|
|
71
|
+ Vect<int> nFF (0, npts);
|
|
72
|
+
|
|
73
|
+ int nread = 0;
|
|
74
|
+ int nfound = 0;
|
|
75
|
+ int il = 0;
|
|
76
|
+
|
|
77
|
+ while (RAW_infile.peek() != EOF) {
|
|
78
|
+ RAW_infile >> omega >> iK >> FF >> dev >> label;
|
|
79
|
+
|
|
80
|
+ nread++;
|
|
81
|
+
|
|
82
|
+ if (iK >= iKmin && iK <= iKmax && omega > omega_min && omega < omega_max) {
|
|
83
|
+ nfound++;
|
|
84
|
+ il = int(-log(FF*FF)/logscale_used);
|
|
85
|
+ if (il < 0) il=0;
|
|
86
|
+ if (il > npts) continue;
|
|
87
|
+ nFF[il] += 1;
|
|
88
|
+ }
|
|
89
|
+ }
|
|
90
|
+ RAW_infile.close();
|
|
91
|
+
|
|
92
|
+ if (nfound == 0) {
|
|
93
|
+ cout << "Didn't find any contributing state." << endl;
|
|
94
|
+ return(1)
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ for (int i = 0; i < npts; ++i) {
|
|
98
|
+ if (i > 0) outfile << endl;
|
|
99
|
+ outfile << i << "\t" << exp(-i * logscale_used) << "\t" << nFF[i] << "\t" << DP(nFF[i])/nfound;
|
|
100
|
+ }
|
|
101
|
+ outfile.close();
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+ // Now that we know the total number of entries, produce animated data:
|
|
105
|
+ // the total number of entries is sliced into 100 pieces
|
|
106
|
+ // and binned in the same way as before
|
|
107
|
+
|
|
108
|
+ int stepsize = nfound/100;
|
|
109
|
+
|
|
110
|
+ outfilename << "_sliced";
|
|
111
|
+ outfilename_string = outfilename.str();
|
|
112
|
+ const char* sliced_c_str = outfilename_string.c_str();
|
|
113
|
+
|
|
114
|
+ ofstream sliced_file;
|
|
115
|
+ sliced_file.open(sliced_c_str);
|
|
116
|
+ sliced_file.precision(16);
|
|
117
|
+
|
|
118
|
+ RAW_infile.open(rawfilename);
|
|
119
|
+ if (RAW_infile.fail()) {
|
|
120
|
+ cout << rawfilename << endl;
|
|
121
|
+ ABACUSerror("Could not open RAW_infile... ");
|
|
122
|
+ }
|
|
123
|
+
|
|
124
|
+ nread = 0;
|
|
125
|
+ nfound = 0;
|
|
126
|
+ int nsteps = 0;
|
|
127
|
+ for (int i = 0; i < npts; ++i) nFF[i] = 0;
|
|
128
|
+
|
|
129
|
+ while (RAW_infile.peek() != EOF) {
|
|
130
|
+ RAW_infile >> omega >> iK >> FF >> dev >> label;
|
|
131
|
+
|
|
132
|
+ nread++;
|
|
133
|
+
|
|
134
|
+ if (iK >= iKmin && iK <= iKmax && omega > omega_min && omega < omega_max) {
|
|
135
|
+ nfound++;
|
|
136
|
+ il = int(-log(FF*FF)/logscale_used);
|
|
137
|
+ if (il < 0) il=0;
|
|
138
|
+ if (il > npts) continue;
|
|
139
|
+ nFF[il] += 1;
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ if (nfound == stepsize) {// || RAW_infile.peek() == EOF) {
|
|
143
|
+ if (nsteps++ > 0) sliced_file << endl;
|
|
144
|
+ sliced_file << DP(nFF[0])/stepsize;
|
|
145
|
+ for (int i = 1; i < npts; ++i) sliced_file << "\t" << DP(nFF[i])/stepsize;
|
|
146
|
+ for (int i = 0; i < npts; ++i) nFF[i] = 0;
|
|
147
|
+ nfound = 0;
|
|
148
|
+ }
|
|
149
|
+ }
|
|
150
|
+
|
|
151
|
+ RAW_infile.close();
|
|
152
|
+
|
|
153
|
+ sliced_file.close();
|
|
154
|
+
|
|
155
|
+ return(0);
|
|
156
|
+}
|