81 {
83 std::cerr << USAGE << std::endl;
84 std::exit(EX_USAGE);
85 }
86 if( !Initialize(argc, argv) ) {
87 std::cerr << "Error: Initialization failed." << std::endl;
88 std::exit(EX_USAGE);
89 }
90
103
105
107 double gE, EnergyRange, OpRange, OpMin;
108 double Fluc, MaxFluc, MaxPos;
109 double const cutoff = 0.45;
110 double const dE = 0.02;
113
114 std::stringstream
buff;
115
116 double start, t_int, end, temp_t;
117 double T_diag=0, T_post=0, T_pre=0;
118
119 std::string d_str1(argv[4]); d_str1 += "/Probability/"; d_str1 += QUOTE(ENSEMBLE);
120 std::string d_str2(d_str1);
122 buff.clear(std::stringstream::goodbit);
124 d_str1 +=
buff.str();
125 filesystem::create_directories(d_str1);
126
129 buff.clear(std::stringstream::goodbit);
130 buff <<
"/Structure_" <<
"Local" <<
num_h <<
"_Seed" << seed <<
"_Min" <<
n_min <<
"_Max" <<
n_max;
131 d_str2 +=
buff.str();
132 filesystem::create_directories(d_str2);
133 }
134
138 buff.clear(std::stringstream::goodbit);
139 buff <<
"/MeasureOfETH_N" << n <<
"_" <<
div <<
".txt";
140 std::string filename(d_str1); filename +=
buff.str();
143 std::cerr << "Can't open a file" << filename << "." << std::endl;
144 std::exit(EX_CANTCREAT);
145 }
146 OutMeasure[n] << std::right << std::scientific;
147 }
148
149 std::ofstream OutSample;
150
151
152
154 std::vector<Integer_t> NdataInShell(dim_max);
155 std::vector<double> MCAverage(dim_max);
156 std::vector<double> eigenEnergy(dim_max);
157 std::vector<double> EXPvalue(dim_max);
160 matrix<MKL_Complex16> h_tot(dim_max, dim_max);
161 matrix<MKL_Complex16> loc_tot(dim_max, dim_max);
162 std::cout <<
"dloc_h=" <<
dloc_h <<
", dloc_op=" <<
dloc_op <<
"\n";
163
164 init_genrand(seed);
167 generateLocal_h(h,
dloc_h, -1);
168 generateLocal_op(loc,
dloc_op, -1);
169 }
171 std::cout << "(init_genrand): time=" << std::fixed << (double)(end-start)/CLOCKS_PER_SEC << std::endl;
172 std::cerr << std::fixed << std::setprecision(6);
173
174
176 end = start;
177 std::string OutSampleFname;
179
180 generateLocal_h(h,
dloc_h, -1);
181 generateLocal_op(loc,
dloc_op, -1);
182
183 if(repetition < 10000) {
184
186 buff.clear(std::stringstream::goodbit);
187 buff <<
"/Sample_No" << repetition <<
".txt";
188 OutSampleFname = d_str2; OutSampleFname += "/RawData";
189 filesystem::create_directory(OutSampleFname);
190 OutSampleFname +=
buff.str();
191 OutSample.open(OutSampleFname);
192 if( OutSample.fail() ) {
193 std::cerr << "Can't open a file" << OutSampleFname;
194 std::exit(EX_CANTCREAT);
195 }
196 OutSample <<
"# dim_loc=" <<
dim_loc <<
", num_h=" <<
num_h <<
", num_op=" <<
num_op <<
"\n"
197 << "# 1.(System size) 2.(Energy density) 3.(Relative Pos) 4.(Exp. value)\n" << std::endl
198 << std::scientific;
199
200 }
201
202 double s;
204 dim_sub = n+1;
205 s = n/2.0;
207 constructGlobal_h( h_tot, n, s,
dim_loc, h);
208 constructGlobal_op(loc_tot, n, s,
dim_loc, loc);
210
212 info =
EigenExpValue(EXPvalue, eigenEnergy, dim_sub, h_tot, loc_tot);
213 if(info != 0) {
214 failed += 1;
216 buff.clear(std::stringstream::goodbit);
217 buff <<
"/Failed_N" << n <<
"_No" << repetition <<
".txt";
218 std::string filename(d_str1); filename +=
buff.str();
219 std::ofstream ErrFp;
220 ErrFp.open(filename);
221 if( !ErrFp.is_open() ) {
222 std::cerr << "# Warning: Can't open a file " << filename << ". Continue..." << std::endl;
223 } else {
224 ErrFp << "# info=" << info << "\n\n"
225 "# seed=" << seed <<
", div=" <<
div <<
", N=" << n <<
", repetition=" << repetition <<
"\n"
226 "# Local Hamiltonian\n";
228 ErrFp << "# Local operator\n";
230 ErrFp.close();
231 }
232 continue;
233 }
234 if(dim_sub==n+1) OpRange =
SpectralRange(OpMin, dim_sub, loc_tot);
236
238 {
239 for(
Integer_t i = 0;i < dim_sub; ++i) EXPvalue[i] /= OpRange;
240 gE = eigenEnergy[0];
241 EnergyRange = eigenEnergy[dim_sub-1] -gE;
242 for(
Integer_t i = 0;i < dim_sub; ++i) eigenEnergy[i] = (eigenEnergy[i] -gE)/EnergyRange;
243 EnergyRange /= (double)n;
244 gE /= (double)n;
245
246
247 MCAverage.resize(dim); NdataInShell.resize(dim);
248 std::fill( MCAverage.begin(), MCAverage.end(), 0.0);
249 std::fill(NdataInShell.begin(), NdataInShell.end(), 0.0);
252 }
253
254 ndata =
MeasureOfETH(Fluc, MaxFluc, MaxPos,
Emin,
Emax, dim_sub, eigenEnergy, EXPvalue, MCAverage);
255 }
257
258 OutMeasure[n] << std::setw(6) << repetition <<
" " << std::showpos
259 << std::setw(13) << Fluc << " "
260 << std::setw(13) << MaxFluc << " "
261 << std::setw(13) << MaxPos << " " << std::noshowpos << ndata << "\n";
262
263 if(repetition < 10000) {
265 assert(eigenEnergy[i] <= 1);
266 OutSample << std::setw(2) << n << " " << std::showpos
267 << std::setw(13) << eigenEnergy[i]*(double)EnergyRange +(double)gE << " "
268 << std::setw(13) << eigenEnergy[i] << " "
269 << std::setw(13) << EXPvalue[i] << " " << MCAverage[i] << " " << std::noshowpos
270 << std::scientific << std::setprecision(6) << "\n";
271 }
272 OutSample << std::endl;
273 }
274 }
275 if(repetition < 10000) {
276 OutSample.close();
278 buff.clear(std::stringstream::goodbit);
279 buff <<
"cd " << d_str2 <<
" && xz " << OutSampleFname <<
" && rm -f " << OutSampleFname <<
" 2>>error.log &";
280 std::system(
buff.str().c_str());
281 }
282 if(repetition%10 == 9) {
284 std::cerr << "(total=" << repetition+1
285 << "): timeINT=" << std::setprecision(6) << (end-t_int)
286 << ", timeTOT=" << std::setprecision(6) << (end-start)
287 << ", T_construct=" << std::setprecision(6) << T_pre << "(" << std::setprecision(1) << 100*T_pre /(end-start) << "%)"
288 << ", T_diag=" << std::setprecision(6) << T_diag << "(" << std::setprecision(1) << 100*T_diag/(end-start) << "%)"
289 << ", T_process=" << std::setprecision(6) << T_post << "(" << std::setprecision(1) << 100*T_post/(end-start) << "%)"
290 << std::endl;
292 }
293 }
294
295 Finalize(argc, argv);
296 return 0;
297}
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("")