84 {
85 #define USAGE_commom "Usage: 1.This 2.n_max 3.n_min 4.division No. 5.Output dir "
86 #define Nargs_common 5
87 #define USAGE_opt "(Opt1).dE (Opt2).repMin (Opt3).repMax "
88 #define Nargs_opt 3
91
94 double gE, EnergyRange, OpRange, OpMin;
95 double Fluc, MaxFluc, MaxPos;
97
98 debug_print(
"# Checking for the directory structure.");
100 std::ofstream OutSample;
101
102
103
104
105
106#ifdef GPU
107 magma_init();
108 magma_queue_t queue = NULL;
109 magma_int_t dev = 0;
110 magma_getdevice( &dev );
111 magma_queue_create( dev, &queue );
112#else
114#endif
115
116
117 debug_print(
"# Calculating translation-invariant sectors.");
121 << "# 1.(Sample No.) 2.(Fluc_2) 3.(Fluc_infty) 4.(Pos_max_flux) 5.(ndata)\n"
122 << std::endl << std::scientific;
123 }
124
125
126
129 std::vector<Integer_t> NdataInShell(dim_max);
130 std::vector<double> eigenEnergy(dim_max);
131 std::vector<double> EXPvalue(dim_max);
132 std::vector<double> MCAverage(dim_max);
133#ifndef GPU
134 matrix<Complex_t> h_tot(dim_max, dim_max);
135 matrix<Complex_t> loc_tot(dim_max, dim_max);
136 #define dh_tot h_tot
137 #define dloc_tot loc_tot
138#endif
139
140
141#ifdef GPU
142
145 Integer_t const LDT = magma_roundup(dim_max, GPU_UNIT);
146 matrix_gpu<Complex_t> dh_tot(LDT, dim_max);
147 matrix_gpu<Complex_t> dloc_tot(LDT, dim_max);
148
149
150
152
153#endif
154
155 double start, t_int, end, temp_t;
156 double T_diag=0, T_post=0, T_pre=0;
157 init_genrand(SEED);
161 RandomMatrix_GUE(h_tot,
Sector[n].dim());
162 RandomMatrix_GUE(loc_tot,
Sector[n].dim());
163 }
164 }
166 std::cout << "(init_genrand): time=" << std::fixed << (end-start) << std::endl;
167
168
169
170
172 end = start;
174
175 #if !defined(NDEBUG) && defined(__linux__)
177 std::cerr << "# (GPU, rep= " << std::setw(6) << repetition
185 << std::endl;
186 #endif
187
188 if(repetition < 10000) {
190 }
192 debug_print(
"# (rep,n)=(" << repetition <<
"," << n <<
")");
193 debug_print(
"# Constructing global matrices in the sector.");
194 dim_sub =
Sector[n].dim();
196 {
197 RandomMatrix_GUE(h_tot, dim_sub);
198 RandomMatrix_GUE(loc_tot, dim_sub);
199 #ifdef GPU
200 magma_setmatrix(dim_sub, dim_sub,
sizeof(
Complex_t), &*h_tot.begin(), dim_sub, dh_tot.ptr(), dim_sub,
GPUconf.
queue());
201 magma_setmatrix(dim_sub, dim_sub,
sizeof(
Complex_t), &*loc_tot.begin(), dim_sub, dloc_tot.ptr(), dim_sub,
GPUconf.
queue());
202 #endif
203 }
205
206 debug_print(
"# Calculating eigenstate expectation values.");
209 if(info != 0) {
210 failed += 1;
211 std::stringstream
buff(
"");
212 buff <<
"/Failed " << PRECISION <<
"_N" << n <<
"_No" << repetition <<
".txt";
214 std::ofstream ErrFs;
215 ErrFs.open(filename);
216 if( !ErrFs.is_open() ) {
217 std::cerr << "# Warning: Can't open a file " << filename << ". Continue..." << std::endl;
218 } else {
219 ErrFs << "# info=" << info << "\n\n"
220 "# N=" << n << ", repetition=" << repetition << "\n";
221 if(dim_sub < 20) {
222 ErrFs << "# Total Hamiltonian\n";
223 dh_tot.print( ErrFs,dim_sub,dim_sub,
"All",
GPUconf);
224 ErrFs << "# Total operator\n";
225 dloc_tot.print(ErrFs,dim_sub,dim_sub,
"All",
GPUconf);
226 }
227 ErrFs.close();
228 }
229 continue;
230 }
231 debug_print(
"# Calculating the spectral range of the observable.");
234
237 {
238 EnergyRange = eigenEnergy[dim_sub-1] -eigenEnergy[0];
239 gE = eigenEnergy[0];
241 eigenEnergy[i] = (eigenEnergy[i] -gE)/EnergyRange;
242 EXPvalue[i] /= OpRange;
243 }
244
245
246 MCAverage.resize(dim_sub); NdataInShell.resize(dim_sub);
247 std::fill( MCAverage.begin(), MCAverage.end(), 0.0);
248 std::fill(NdataInShell.begin(), NdataInShell.end(), 0.0);
251 }
252
253 ndata =
MeasureOfETH(Fluc, MaxFluc, MaxPos,
Emin,
Emax, dim_sub, eigenEnergy, EXPvalue, MCAverage);
254 }
256
257 OutMeasure[n] << std::setw(6) << repetition <<
" " << std::showpos
258 << std::setw(13) << Fluc << " "
259 << std::setw(13) << MaxFluc << " "
260 << std::setw(13) << MaxPos << " " << std::noshowpos << ndata << "\n";
261 if(repetition < 10000) {
263 OutSample << std::setw(2) << n << " " << std::showpos
264 << std::setw(13) << eigenEnergy[i]*EnergyRange+gE << " "
265 << std::setw(13) << eigenEnergy[i] << " "
266 << std::setw(13) << EXPvalue[i] << "\n" << std::noshowpos;
267 }
268 }
269 }
270 if(repetition < 10000) OutSample.close();
271 if(repetition%10 == 9) {
273 std::cerr << "(total=" << std::setw(6) << repetition+1
274 << "): timeINT=" << std::setprecision(6) << std::setw(8) << (end-t_int)
275 << ", timeTOT=" << std::setprecision(6) << std::setw(8) << (end-start)
276 << ", T_construct=" << std::setprecision(6) << std::setw(10) << T_pre << "(" << std::setprecision(1) << 100*T_pre /(end-start) << "%)"
277 << ", T_diag=" << std::setprecision(6) << std::setw(8) << T_diag << "(" << std::setprecision(1) << 100*T_diag/(end-start) << "%)"
278 << ", T_process=" << std::setprecision(6) << std::setw(8) << T_post << "(" << std::setprecision(1) << 100*T_post/(end-start) << "%)"
279 << std::endl;
281 }
282 }
283
284 return 0;
285}
double getETtime()
Definition EnergySpectrum.c:14
std::ofstream OutMeasure[n_max+1]
Definition MeasureOfETH_CreateOutputFiles.cpp:1
statm_t Usage
Definition Fluc_randHOp.cpp:55
void read_off_memory_status(statm_t &result)
Definition Fluc_randHOp.cpp:98
std::vector< TransSector > Sector(n_max+1)
Definition mytypes.hpp:147
void queue(magma_queue_t x)
Definition mytypes.hpp:297
Calculate the microcanonical averages with respect to a given sorted vector 'eigVal'.
Definition MicroCanonicalAverage.hpp:25
debug_print("# Determining GPU configuration.")
GPUconfig GPUconf(dim3(nBlock, nBlock, 1), dim3(nThread, nThread, 1), 0, queue)
MKL_INT Integer_t
Definition mytypes.hpp:359
baseDirName
Definition setVariablesForEnsemble.cpp:50
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 n_max
Definition setVariablesForEnsemble.cpp:27
constexpr double Emin
Definition setVariablesForMCAverage.cpp:4
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
unsigned long dt
Definition Fluc_randHOp.cpp:95
unsigned long lib
Definition Fluc_randHOp.cpp:95
unsigned long text
Definition Fluc_randHOp.cpp:95
unsigned long resident
Definition Fluc_randHOp.cpp:95
unsigned long share
Definition Fluc_randHOp.cpp:95
unsigned long size
Definition Fluc_randHOp.cpp:95
unsigned long data
Definition Fluc_randHOp.cpp:95
std::stringstream buff("")