29 {
31 std::cerr << USAGE << std::endl;
32 std::exit(EX_USAGE);
33 }
46
48
50 double gE, EnergyRange, OpRange, OpMin;
51 double Fluc, MaxFluc, MaxPos;
52 double const cutoff = 0.45;
53 double const dE = 0.02;
56
57 std::stringstream
buff;
58
59 std::cout <<
"dloc_h=" <<
dloc_h <<
", dloc_op=" <<
dloc_op <<
"\n";
61 std::cerr <<
"Error: n_min(" <<
n_min <<
") > n_max(" <<
n_max <<
")." << std::endl;
62 std::exit(EX_USAGE);
63 }
64 if( !Initialize(argc, argv) ) {
65 std::cerr << "Error: Initialization failed." << std::endl;
66 std::exit(EX_USAGE);
67 }
68 #ifndef NDEBUG
69 std::cerr << "# Successfully initialized." << std::endl;
70 #endif
71
72
73 #ifndef NDEBUG
74 std::cerr << "# Checking for the directory structure." << std::endl;
75 #endif
76 std::string d_str1(argv[6]); d_str1 += "/Probability/"; d_str1 += QUOTE(ENSEMBLE);
77 std::string d_str2(d_str1);
79 buff.clear(std::stringstream::goodbit);
82 std::filesystem::create_directories(d_str1);
83
86 buff.clear(std::stringstream::goodbit);
87 buff <<
"/" << TYPE <<
"Structure_" <<
"Local" <<
num_h <<
"_Seed" << seed <<
"_Min" <<
n_min <<
"_Max" <<
n_max;
89 std::filesystem::create_directories(d_str2);
90 }
91
95 buff.clear(std::stringstream::goodbit);
96 buff <<
"/MeasureOfETH_N" << n <<
"_" <<
div <<
".txt";
97 std::string filename(d_str1); filename +=
buff.str();
100 std::cerr << "Can't open a file" << filename << "." << std::endl;
101 std::exit(EX_CANTCREAT);
102 }
104 }
105
106 std::ofstream OutSample;
107
108
111 std::cout << "(n=" << n << ") dim = " << dim_sub << "\n";
112
114 << "# 1.(Sample No.) 2.(Fluc_2) 3.(Fluc_infty) 4.(Pos_max_flux) 5.(ndata)\n"
115 << std::endl << std::scientific;
116 }
117
118
119
120
121 #ifndef NDEBUG
122 std::cerr << "# Allocating CPU memories." << std::endl;
123 #endif
125 std::vector<Integer_t> NdataInShell(dim_max);
126 std::vector<double> eigenEnergy(dim_max);
127 std::vector<double> EXPvalue(dim_max);
128 std::vector<double> MCAverage(dim_max);
131 matrix<MKL_Complex16> h_tot(dim_max, dim_max);
132 matrix<MKL_Complex16> loc_tot(dim_max, dim_max);
133
134 double start, t_int, end, temp_t;
135 double T_diag=0, T_post=0, T_pre=0;
136 init_genrand(seed);
139 generateLocal_h( h,
dloc_h, -1);
140 generateLocal_op(loc,
dloc_op, -1);
141 }
143 std::cout << "(init_genrand): time=" << std::fixed << (end-start) << std::endl;
144
145
146
147
149 end = start;
151
152 generateLocal_h( h,
dloc_h, -1);
153 generateLocal_op(loc,
dloc_op, -1);
154
155 if(repetition < 10000) {
156
158 buff.clear(std::stringstream::goodbit);
159 buff <<
"/Sample_No" << repetition <<
".txt";
160 std::string filename(d_str2); filename += "/RawData";
161 std::filesystem::create_directory(filename);
162 filename +=
buff.str();
163 OutSample.open(filename);
164 if( OutSample.fail() ) {
165 std::cerr << "Can't open a file" << filename;
166 std::exit(EX_CANTCREAT);
167 }
168 OutSample <<
"# dim_loc=" <<
dim_loc <<
", num_h=" <<
num_h <<
", num_op=" <<
num_op <<
"\n"
169
170 << "# 1.(System size) 2.(Energy density) 3.(Relative Pos) 4.(Exp. value)\n" << std::endl
171 << std::scientific;
172
173 }
176
177 #ifndef NDEBUG
178 std::cout << "# (rep,n)=(" << repetition << "," << n << ")" << std::endl;
179 #endif
181 #pragma omp parallel
182 {
183 std::cout << "parallel(rep,n)=(" << repetition << "," << n << ")" << std::endl;
184 #pragma omp sections
185 {
186 #pragma omp section
187 {
188 #pragma omp critical
189 std::cout << "section1(rep,n)=(" << repetition << "," << n << ")" << std::endl;
191 }
192 #pragma omp section
193 {
194 #pragma omp critical
195 std::cout << "section2(rep,n)=(" << repetition << "," << n << ")" << std::endl;
197 }
198 }
199 }
201
202 #ifndef NDEBUG
203 std::cerr << "# Calculating eigenstate expectation values." << std::endl;
204 #endif
206 info =
EigenExpValue(EXPvalue, eigenEnergy, dim_sub, h_tot, loc_tot);
207 if(info != 0) {
208 failed += 1;
210 buff.clear(std::stringstream::goodbit);
211 buff <<
"/Failed_N" << n <<
"_No" << repetition <<
".txt";
212 std::string filename(d_str1); filename +=
buff.str();
213 std::ofstream ErrFp;
214 ErrFp.open(filename);
215 if( !ErrFp.is_open() ) {
216 std::cerr << "# Warning: Can't open a file " << filename << ". Continue..." << std::endl;
217 } else {
218 ErrFp << "# info=" << info << "\n\n"
219 "# seed=" << seed <<
", div=" <<
div <<
", N=" << n <<
", repetition=" << repetition <<
"\n"
220 "# Local Hamiltonian\n";
222 ErrFp << "# Local operator\n";
224 ErrFp.close();
225 }
226 continue;
227 }
230
231 #ifndef NDEBUG
232 std::cerr << "# Calculating measures of the ETH." << std::endl;
233 #endif
235 for(
Integer_t i = 0;i < dim_sub; ++i) EXPvalue[i] /= OpRange;
236 EnergyRange = eigenEnergy[dim_sub-1] -eigenEnergy[0];
237 gE = eigenEnergy[0];
238 for(
Integer_t i = 0;i < dim_sub; ++i) eigenEnergy[i] = (eigenEnergy[i] -gE)/EnergyRange;
239
240 MCAverage.resize(dim); NdataInShell.resize(dim);
241 std::fill( MCAverage.begin(), MCAverage.end(), 0.0);
242 std::fill(NdataInShell.begin(), NdataInShell.end(), 0.0);
245 }
246
247 ndata =
MeasureOfETH(Fluc, MaxFluc, MaxPos,
Emin,
Emax, dim_sub, eigenEnergy, EXPvalue, MCAverage);
249
250 OutMeasure[n] << std::setw(6) << repetition <<
" " << std::showpos
251 << std::setw(13) << Fluc << " "
252 << std::setw(13) << MaxFluc << " "
253 << std::setw(13) << MaxPos << " " << std::noshowpos << ndata << "\n";
254
255 if(repetition < 10000) {
257 OutSample << std::setw(2) << n << " " << std::showpos
258 << std::setw(13) << eigenEnergy[i]*(double)EnergyRange +(double)gE << " "
259 << std::setw(13) << eigenEnergy[i] << " "
260 << std::setw(13) << EXPvalue[i] << "\n" << std::noshowpos;
261 }
262 }
263 }
264 if(repetition < 10000) OutSample.close();
265 if(repetition%10 == 9) {
267 std::cerr << "(total=" << repetition+1
268 << "): timeINT=" << std::setprecision(6) << (end-t_int)
269 << ", timeTOT=" << std::setprecision(6) << (end-start)
270 << ", T_construct=" << std::setprecision(6) << T_pre << "(" << std::setprecision(1) << 100*T_pre /(end-start) << "%)"
271 << ", T_diag=" << std::setprecision(6) << T_diag << "(" << std::setprecision(1) << 100*T_diag/(end-start) << "%)"
272 << ", T_process=" << std::setprecision(6) << T_post << "(" << std::setprecision(1) << 100*T_post/(end-start) << "%)"
273 << std::endl;
275 }
276 }
277
278 Finalize(argc, argv);
279 return 0;
280}
double getETtime()
Definition EnergySpectrum.c:14
std::ofstream OutMeasure[n_max+1]
Definition MeasureOfETH_CreateOutputFiles.cpp:1
int const N_ARGS
Definition generateRM.hpp:16
Calculate the microcanonical averages with respect to a given sorted vector 'eigVal'.
Definition MicroCanonicalAverage.hpp:25
MKL_INT Integer_t
Definition mytypes.hpp:359
constexpr Integer_t dim_loc
Definition setVariablesForEnsemble.cpp:36
Integer_t const num_op
Definition setVariablesForEnsemble.cpp:39
Integer_t const num_h
Definition setVariablesForEnsemble.cpp:38
Integer_t const repMin
Definition setVariablesForEnsemble.cpp:31
Integer_t const n_min
Definition setVariablesForEnsemble.cpp:28
Integer_t const repMax
Definition setVariablesForEnsemble.cpp:32
Integer_t const div
Definition setVariablesForEnsemble.cpp:29
Integer_t const dloc_op
Definition setVariablesForEnsemble.cpp:41
Integer_t const dloc_h
Definition setVariablesForEnsemble.cpp:40
Integer_t const n_max
Definition setVariablesForEnsemble.cpp:27
constexpr double Emin
Definition setVariablesForMCAverage.cpp:4
constexpr double cutoff
Definition setVariablesForMCAverage.cpp:3
constexpr double Emax
Definition setVariablesForMCAverage.cpp:5
double const dE
Definition setVariablesForMCAverage.cpp:2
Integer_t EigenExpValue(std::vector< double > &EXPvalue, std::vector< double > &Eigenvalue, Integer_t const dim, matrix< Complex_t< double > > &Hamiltonian, const matrix< Complex_t< double > > &Operator, void *GPUconf)
Definition statmech.cpp:120
Integer_t MeasureOfETH(double &Fluc_2, double &Fluc_inf, double &MaxPos, double const Emin, double const Emax, Integer_t const dim, const std::vector< double > &eigenEnergy, const std::vector< double > &EXPvalue, const std::vector< double > &MCAverage)
Definition statmech.cpp:244
double SpectralRange(double &OpMin, Integer_t const dim, matrix< Complex_t< double > > &Operator)
Definition statmech.cpp:49
std::stringstream buff("")