59 {
60 #define USAGE_opt "(Opt1).dE (Opt2).repMin (Opt3).repMax "
61 #define Nargs_opt 3
64
67 double gE, EnergyRange, OpRange, OpEigMin, OpEigMax, s;
68 double Fluc, MaxFluc, MaxPos;
69
71 std::cerr << "Error: Currently, num_h and num_op must be two." << std::endl;
72 std::exit(EX_USAGE);
73 }
74 if( !Initialize(argc, argv, Nargs_common) ) {
75 std::cerr << "Error: Initialization failed." << std::endl;
76 std::exit(EX_USAGE);
77 }
79
80
81 debug_print(
"# Checking for the directory structure.");
83 std::ofstream OutSample;
84
85
86
87
88
89#ifdef GPU
90 magma_init();
91 magma_queue_t queue = NULL;
92 magma_int_t dev = 0;
93 magma_getdevice( &dev );
94 magma_queue_create( dev, &queue );
95#else
97#endif
98
99
100 debug_print(
"# Calculating translation-invariant sectors.");
104 << "# 1.(Sample No.) 2.(Fluc_2) 3.(Fluc_infty) 4.(Pos_max_flux) 5.(ndata)\n"
105 << std::endl << std::scientific;
106 }
107
108
109
110 debug_print(
"# Calculating multiplicity of irreducible representations of SU(2) algebra.");
111 std::vector<std::vector<Integer_t>> multiplicity(
n_max+1);
112 {
114 std::vector<Integer_t> numBasisWithFixedM, spin(
n_max);
116 if(
Sector[n].momentum() == 0) dim_sub =
Sector[n].dim() -
Sector[n].parityOp().numPairs;
117 else dim_sub =
Sector[n].dim();
118
119 spin.resize(n);
120 numBasisWithFixedM.resize(n+1);
121 std::fill(numBasisWithFixedM.begin(), numBasisWithFixedM.end(), 0);
124 numUpSpins = std::accumulate(spin.begin(), spin.end(), 0);
125 numBasisWithFixedM.at(numUpSpins) += 1;
126 }
127
128 multiplicity[n].resize(n/2+1);
129 multiplicity[n][n/2] = numBasisWithFixedM[n];
130 for(
Integer_t j = n-1;j >= (n+1)/2; --j) {
131 multiplicity[n][ j-(n+1)/2 ] = numBasisWithFixedM[j] - numBasisWithFixedM[j+1];
132 }
133
134 print(numBasisWithFixedM, numBasisWithFixedM.size());
135 print(multiplicity[n], multiplicity[n].
size());
136 }
137 }
138
139
140
143 std::vector<Integer_t> NdataInShell(dim_max);
144 std::vector<double> eigenEnergy(dim_max);
145 std::vector<double> EXPvalue(dim_max);
146 std::vector<double> MCAverage(dim_max);
147 std::vector<std::tuple<double,double,Integer_t>> Data;
151 matrix<Complex_t> h_tot(dim_max, dim_max);
152 matrix<Complex_t> loc_tot(dim_max, dim_max);
153#ifndef GPU
154 #define dh_tot h_tot
155 #define dloc_tot loc_tot
156#endif
157
158
159#ifdef GPU
160
163 Integer_t const LDT = magma_roundup(dim_max, GPU_UNIT);
166 matrix_gpu<Complex_t> dh_tot(LDT, dim_max);
167 matrix_gpu<Complex_t> dloc_tot(LDT, dim_max);
168
169
170 #inlude "PBC_TI/Framework/Fragments/getAttributesOfMatrixElementsInSector.cpp"
171#endif
172
173 double start, t_int, end, temp_t;
174 double T_diag=0, T_post=0, T_pre=0;
175 init_genrand(SEED);
178 generateLocal_h( h,
dloc_h, -1);
179 generateLocal_op(loc,
dloc_op, -1);
180 }
182 std::cout << "(init_genrand): time=" << std::fixed << (end-start) << std::endl;
183
184
185
186
188 end = start;
190
191 generateLocal_h( h,
dloc_h, -1);
192 generateLocal_op(loc,
dloc_op, -1);
193 #ifdef GPU
196 #endif
197
198 if(repetition < 10000) {
200 }
202 debug_print(
"# (rep,n)=(" << repetition <<
"," << n <<
")");
203 debug_print(
"# Constructing global matrices in the sector.");
204 Data.resize(0); OpEigMin = NAN; OpEigMax = NAN;
205 for(
Integer_t Sint = n/2;Sint >= 0; --Sint) {
206 s = n/2.0 - Sint;
208 #ifdef GPU
209
210
211
212 dim_sub = constructGlobal_h( h_tot, h, s,
Sector.at(n));
213 constructGlobal_h( loc_tot, loc, s,
Sector.at(n));
214 magma_setmatrix(dim_sub, dim_sub,
sizeof(
Complex_t), &*h_tot.begin(), h_tot.LD(), dh_tot.ptr(), dh_tot.LD(), queue);
215 magma_setmatrix(dim_sub, dim_sub,
sizeof(
Complex_t), &*loc_tot.begin(), loc_tot.LD(), dloc_tot.ptr(), dh_tot.LD(), queue);
216 #else
217 dim_sub = constructGlobal_h( h_tot, h, s,
Sector.at(n));
218 constructGlobal_h( loc_tot, loc, s,
Sector.at(n));
219 #endif
221
222
223 debug_print(
"# Calculating eigenstate expectation values." << dim_sub <<
" " << dh_tot.LD());
225 info =
EigenExpValue(EXPvalue, eigenEnergy, dim_sub, dh_tot, dloc_tot, conf.queue());
226 if(info != 0) {
228 continue;
229 }
231 Data.push_back( std::tie(eigenEnergy[j], EXPvalue[j], multiplicity[n][Sint]) );
232 }
233 debug_print(
"# Calculating the spectral range of the observable.");
235 OpEigMin = std::fmin(OpEigMin, eigenEnergy[0]);
236 OpEigMax = std::fmin(OpEigMax, eigenEnergy[dim_sub-1]);
238 }
239
240 if(Data.size() != (size_t)( (n/2+1)*( (n+1)/2+1 ) )) {
241 std::cerr << "Error:: Data.size(" << Data.size() << ") != (n/2+1)*( (n+1)/2+1 ) = " << (n/2+1)*( (n+1)/2+1 ) << std::endl;
242 std::exit(1);
243 }
244
245 std::sort(Data.begin(), Data.end());
246 OpRange = OpEigMax - OpEigMin;
247
250 EnergyRange = std::get<0>(Data[Data.size()-1]) - std::get<0>(Data[0]);
251 gE = std::get<0>(Data[0]);
252 for(
Integer_t i = 0;i < Data.size(); ++i) {
253 std::get<0>(Data[i]) = (std::get<0>(Data[i]) -gE)/EnergyRange;
254 std::get<1>(Data[i]) = std::get<1>(Data[i])/OpRange;
255 }
259
260 OutMeasure[n] << std::setw(6) << repetition <<
" " << std::showpos
261 << std::setw(13) << Fluc << " "
262 << std::setw(13) << MaxFluc << " "
263 << std::setw(13) << MaxPos << " " << std::noshowpos << ndata << "\n";
264 if(repetition < 10000) {
266 OutSample << std::setw(2) << n << " " << std::showpos
267 << std::setw(13) << std::get<0>(Data[i])*EnergyRange+gE << " "
268 << std::setw(13) << std::get<0>(Data[i]) << " "
269 << std::setw(13) << std::get<1>(Data[i]) << "\n" << std::noshowpos;
270 }
271 }
272 }
273 if(repetition < 10000) OutSample.close();
274 if(repetition%10 == 9) {
276 std::cerr << "(total=" << std::setw(6) << repetition+1
277 << "): timeINT=" << std::setprecision(6) << std::setw(8) << (end-t_int)
278 << ", timeTOT=" << std::setprecision(6) << std::setw(8) << (end-start)
279 << ", T_construct=" << std::setprecision(6) << std::setw(10) << T_pre << "(" << std::setprecision(1) << 100*T_pre /(end-start) << "%)"
280 << ", T_diag=" << std::setprecision(6) << std::setw(8) << T_diag << "(" << std::setprecision(1) << 100*T_diag/(end-start) << "%)"
281 << ", T_process=" << std::setprecision(6) << std::setw(8) << T_post << "(" << std::setprecision(1) << 100*T_post/(end-start) << "%)"
282 << std::endl;
284 }
285 }
286
287 Finalize(argc, argv);
288 return 0;
289}
double getETtime()
Definition EnergySpectrum.c:14
std::ofstream OutMeasure[n_max+1]
Definition MeasureOfETH_CreateOutputFiles.cpp:1
std::vector< TransSector > Sector(n_max+1)
Definition mytypes.hpp:147
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
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 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 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
Integer_t Diagonalize(Integer_t const dim, matrix< Complex_t< double > > &Hamiltonian, std::vector< double > &Eigenvalue)
Definition statmech.cpp:56
__constant__ int size
Definition testEigenOnGPU.cu:4
void i_to_spin(int i, int *spin, int dim_loc, int n)
Definition translation.c:78