53 {
55
58 double gE, EnergyRange, OpRange, OpMin;
59
60 if( !Initialize(argc, argv, Nargs_common) ) {
61 std::cerr << "Error: Initialization failed." << std::endl;
62 std::exit(EX_USAGE);
63 }
65
66
67 debug_print(
"# Checking for the directory structure.");
68 std::ofstream OutFs;
69
70
71
72
73
74#ifdef GPU
75 magma_init();
76 magma_queue_t queue = NULL;
77 magma_int_t dev = 0;
78 magma_getdevice( &dev );
79 magma_queue_create( dev, &queue );
80#else
82#endif
83
84
85 debug_print(
"# Calculating translation-invariant sectors.");
87
88
89
92 std::vector<Integer_t> NdataInShell(dim_max);
93 std::vector<double> eigenEnergy(dim_max);
94 std::vector<double> EXPvalue(dim_max);
97#ifndef GPU
98 matrix<Complex_t> h_tot(dim_max, dim_max);
99 matrix<Complex_t> loc_tot(dim_max, dim_max);
100 #define dh h
101 #define dloc loc
102 #define dh_tot h_tot
103 #define dloc_tot loc_tot
104#endif
105
106
107#ifdef GPU
108
111 Integer_t const LDT = magma_roundup(dim_max, GPU_UNIT);
114 matrix_gpu<Complex_t> dh_tot(LDT, dim_max);
115 matrix_gpu<Complex_t> dloc_tot(LDT, dim_max);
116
117
118
120
121#endif
122
123 double start, t_int, end, temp_t;
124 double T_diag=0, T_post=0, T_pre=0;
125 init_genrand(SEED);
128 generateLocal_h( h,
dloc_h, -1);
129 generateLocal_op(loc,
dloc_op, -1);
130 }
132 std::cout << "(init_genrand): time=" << std::fixed << (end-start) << std::endl;
133
134
135
136
138 end = start;
140
141 generateLocal_h( h,
dloc_h, -1);
142 generateLocal_op(loc,
dloc_op, -1);
145
147 #ifdef GPU
150 #endif
152
154 {
155 std::stringstream
buff;
156 buff <<
"/RawData/Sample_No" << repetition;
157 outDirName +=
buff.str();
158 outDirName = std::regex_replace(outDirName, std::regex("//"), "/");
159 filesystem::create_directories(outDirName);
160 }
161
163 debug_print(
"# (rep,n)=(" << repetition <<
"," << n <<
")");
164 debug_print(
"# Constructing global matrices in the sector.");
166 {
169 #ifdef GPU
170 magma_queue_sync(queue);
171 #endif
172 }
174
175
176
177
178
179
180
181
182
184 {
185 debug_print(
"# Calculating eigenstate expectation values.");
187 if(info != 0) {
189 continue;
190 }
191 EnergyRange = eigenEnergy[dim_sub-1] - eigenEnergy[0];
192 gE = eigenEnergy[0];
193 debug_print(
"# Calculating the spectral range of the observable.");
195 }
197
198
199
200
201
202
203
204
205
207 {
209 std::stringstream
buff(
"");
210 buff <<
"/EigenExpValue" << PRECISION <<
"_N" << n <<
".txt";
211 std::string filename(outDirName); filename +=
buff.str();
213 OutFs << std::right << std::showpos << std::scientific << std::setprecision(6);
214 OutFs << "# energyRange= " << EnergyRange << "\n"
215 << "# gE= " << gE << "\n"
216 << "# OpRange= " << OpRange << "\n"
217 << "# OpMin= " << OpMin << "\n"
218 << "# 1.(Normalized energy) 2.(Energy) 3.(Exp value)" << "\n\n";
219 for(size_t j = 0;j < dim_sub; ++j) {
220 OutFs << (eigenEnergy[j] - gE)/EnergyRange << " "
221 << eigenEnergy[j] << " "
222 << EXPvalue[j] << std::endl;
223 }
224 OutFs.close();
225 }
227 }
228 if(repetition%10 == 9) {
230 std::cerr << "(total=" << std::setw(6) << repetition+1
231 << "): timeINT=" << std::setprecision(6) << std::setw(8) << (end-t_int)
232 << ", timeTOT=" << std::setprecision(6) << std::setw(8) << (end-start)
233 << ", T_construct=" << std::setprecision(6) << std::setw(10) << T_pre << "(" << std::setprecision(1) << 100*T_pre /(end-start) << "%)"
234 << ", T_diag=" << std::setprecision(6) << std::setw(8) << T_diag << "(" << std::setprecision(1) << 100*T_diag/(end-start) << "%)"
235 << ", T_process=" << std::setprecision(6) << std::setw(8) << T_post << "(" << std::setprecision(1) << 100*T_post/(end-start) << "%)"
236 << std::endl;
237 }
238 }
239
240 Finalize(argc, argv);
241 #ifdef GPU
242 magma_finalize();
243 #endif
244 return 0;
245}
double getETtime()
Definition EnergySpectrum.c:14
std::vector< TransSector > Sector(n_max+1)
Definition mytypes.hpp:147
bool checkIsFileOpen(std::ifstream &file, std::string const &filename)
Definition file_util.hpp:22
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
Integer_t const num_op
Definition setVariablesForEnsemble.cpp:39
baseDirName
Definition setVariablesForEnsemble.cpp:50
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 dloc_op
Definition setVariablesForEnsemble.cpp:41
Integer_t const dloc_h
Definition setVariablesForEnsemble.cpp:40
Integer_t const n_max
Definition setVariablesForEnsemble.cpp:27
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
double SpectralRange(double &OpMin, Integer_t const dim, matrix< Complex_t< double > > &Operator)
Definition statmech.cpp:49
std::stringstream buff("")