StatMech
Loading...
Searching...
No Matches
Dynamics_Deviation.cpp File Reference

Functions

__global__ void EnergyStddev_kernel (Integer_t dim, Real_t *res_d, Complex_t *Hamiltonian_d, Integer_t LDT)
 
void EnergyStddev (std::vector< double > &res, matrix_gpu< Complex_t > const &Hamiltonian_d, TransSector const &Sector, GPUconfig const &GPUconf)
 
void __global__ StatePreparation (double time, Integer_t Nstates, Integer_t *dIndex, Integer_t dim_sub, Complex_t *dState, Integer_t LDS, Complex_t *dh_tot, Integer_t LDH, double *dEigenEnergy)
 
void __global__ InfiniteTimeAverage (Integer_t const SizeDegen, Integer_t const *dDegeneracy, Integer_t const dim_sub, Complex_t *dOp_tot, Integer_t const LDH)
 
void EnergyStddev (std::vector< double > &res, matrix< Complex_t > const &Hamiltonian, TransSector const &Sector, void *GPUconf=nullptr)
 
void StatePreparation (double time, std::vector< Integer_t > &Index, Integer_t dim_sub, matrix< Complex_t > &State, matrix< Complex_t > &h_tot, std::vector< double > &eigenEnergy)
 
void InfiniteTimeAverage (std::vector< Integer_t > const &Degeneracy, Integer_t const dim_sub, matrix< Complex_t > &Op_tot)
 
int main (int argc, char **argv)
 

Function Documentation

◆ EnergyStddev() [1/2]

void EnergyStddev ( std::vector< double > &  res,
matrix< Complex_t > const &  Hamiltonian,
TransSector const &  Sector,
void *  GPUconf = nullptr 
)
116 {
117 Integer_t dim = SectorDimension(Sector);
118 res.resize(dim);
119 std::fill(res.begin(), res.end(), 0.0);
120
121 #pragma omp parallel for
122 for(size_t j = 0; j < dim; j++) {
123 for(size_t k = 0; k < j; k++)
124 res.at(j) += real(conj(Hamiltonian.at(j, k)) * Hamiltonian.at(j, k));
125 for(size_t k = j + 1; k < dim; k++)
126 res.at(j) += real(conj(Hamiltonian.at(j, k)) * Hamiltonian.at(j, k));
127 res.at(j) = sqrt(res.at(j));
128 }
129}
std::vector< TransSector > Sector(n_max+1)
MKL_INT Integer_t
Definition mytypes.hpp:359

◆ EnergyStddev() [2/2]

void EnergyStddev ( std::vector< double > &  res,
matrix_gpu< Complex_t > const &  Hamiltonian_d,
TransSector const &  Sector,
GPUconfig const &  GPUconf 
)
71 {
72 Integer_t dim = SectorDimension(Sector);
73 res.resize(dim);
74
75 matrix_gpu<Real_t> Intermediate_d(Hamiltonian_d.LD(), dim);
77 GPUconf.stream()>>>(dim, Intermediate_d.ptr(), Hamiltonian_d.ptr(),
78 Hamiltonian_d.LD());
79
80 std::vector<Real_t> ones(dim, 1.0);
81 matrix_gpu<Real_t> ones_d(dim, 1);
82 matrix_gpu<Real_t> res_d(dim, 1);
83 magma_setvector(dim, sizeof(Real_t), &*ones.begin(), 1, ones_d.ptr(), 1, GPUconf.queue());
84 gemv(MagmaNoTrans, dim, dim, Intermediate_d, ones_d, res_d, GPUconf.queue());
85 magma_getvector(dim, sizeof(Real_t), res_d.ptr(), 1, &*ones.begin(), 1, GPUconf.queue());
86 #pragma omp parallel for
87 for(size_t j = 0; j < dim; j++) res[j] = (double)sqrt(ones[j]);
88}
__global__ void EnergyStddev_kernel(Integer_t dim, Real_t *res_d, Complex_t *Hamiltonian_d, Integer_t LDT)
Definition Dynamics_Deviation.cpp:57
void dimBlock(int x, int y, int z)
Definition mytypes.hpp:291
void queue(magma_queue_t x)
Definition mytypes.hpp:297
void shared(size_t x)
Definition mytypes.hpp:296
void dimGrid(int x, int y, int z)
Definition mytypes.hpp:286
cudaStream_t stream() const
Definition mytypes.hpp:303
GPUconfig GPUconf(dim3(nBlock, nBlock, 1), dim3(nThread, nThread, 1), 0, queue)
double Real_t
Definition mytypes.hpp:37

◆ EnergyStddev_kernel()

__global__ void EnergyStddev_kernel ( Integer_t  dim,
Real_t res_d,
Complex_t Hamiltonian_d,
Integer_t  LDT 
)
58 {
59 int const idx = blockIdx.x * blockDim.x + threadIdx.x;
60 int const idy = blockIdx.y * blockDim.y + threadIdx.y;
61 if(idx >= dim || idy >= dim) return;
62 if(idx == idy) {
63 res_d[idx + LDT * idy] = 0;
64 return;
65 }
66 res_d[idx + LDT * idy]
67 = real(conj(Hamiltonian_d[idx + LDT * idy]) * Hamiltonian_d[idx + LDT * idy]);
68}

◆ InfiniteTimeAverage() [1/2]

void __global__ InfiniteTimeAverage ( Integer_t const  SizeDegen,
Integer_t const *  dDegeneracy,
Integer_t const  dim_sub,
Complex_t dOp_tot,
Integer_t const  LDH 
)
103 {
104 int const idx = blockIdx.x * blockDim.x + threadIdx.x;
105 int const idy = blockIdx.y * blockDim.y + threadIdx.y;
106 if(idx >= dim_sub || idy >= dim_sub) return;
107 int j, k;
108 for(j = 0; j < SizeDegen && dDegeneracy[j] <= idx; ++j) {};
109 --j;
110 for(k = 0; k < SizeDegen && dDegeneracy[k] <= idy; ++k) {};
111 --k;
112 if(j != k) dOp_tot[idx + LDH * idy] = dComplexZero<>;
113}

◆ InfiniteTimeAverage() [2/2]

void InfiniteTimeAverage ( std::vector< Integer_t > const &  Degeneracy,
Integer_t const  dim_sub,
matrix< Complex_t > &  Op_tot 
)
144 {
145 // #pragma omp parallel for
146 for(size_t idx = 0; idx < dim_sub; ++idx) {
147 for(size_t idy = 0; idy < idx; ++idy) {
148 int j, k;
149 for(j = 0; j < Degeneracy.size() && Degeneracy[j] <= idx; ++j) {};
150 --j;
151 for(k = 0; k < Degeneracy.size() && Degeneracy[k] <= idy; ++k) {};
152 --k;
153 if(j != k) {
154 Op_tot.at(idx, idy) = ComplexZero<>;
155 Op_tot.at(idy, idx) = ComplexZero<>;
156 }
157 else { std::cout << idx << " " << idy << " " << j << " " << k << std::endl; }
158 }
159 }
160}

◆ main()

int main ( int  argc,
char **  argv 
)
163 {
165 double const dE = (argc >= Nargs_base + 1) ? std::atof(argv[Nargs_base]) : 0.02;
166
167 Integer_t dim_sub; //全ヒルベルト空間の次元
168 Integer_t info, failed = 0; // カウンタ
169 double gE, energyRange, OpRange, OpMin, sum;
170 constexpr double precision = 1.0E-7;
171
172 if(!Initialize(argc, argv, Nargs_common)) {
173 std::cerr << "Error: Initialization failed." << std::endl;
174 std::exit(EX_USAGE);
175 }
176 debug_print("# Successfully initialized.");
177
178 //******************** Check for the directory structure ********************
179 debug_print("# Checking for the directory structure.");
180 std::ofstream OutFs;
181 //******************** (END) Check for the directory structure ********************
182
183 //***************************************************************************
184 //******************** Allocation & Initialization **************************
185 //***************************************************************************
186#ifdef GPU
187 magma_init();
188 magma_queue_t queue = NULL;
189 magma_int_t dev = 0;
190 magma_getdevice(&dev);
191 magma_queue_create(dev, &queue);
192#else
193 void* GPUconf = nullptr;
194#endif
195
196 //******************** Translation invariance ********************
197 debug_print("# Calculating translation-invariant sectors.");
199 //******************** (END)Translation invariance ********************
200
201 //********** Allocate CPU memories **********//
202 debug_print("# Allocating CPU memories.");
203 double time;
204 constexpr double Tmax = 100000;
205 constexpr Integer_t Nstep = 1000 + 1;
206 Integer_t const dim_max = SectorDimension(Sector[n_max]);
207 Integer_t NdataInShell, Id;
208 double MCAverage, shellWidth;
209
210 std::vector<Integer_t> Index(dim_max);
211 std::vector<Integer_t> Degeneracy(dim_max);
212 std::vector<double> eigenEnergy(dim_max);
213 std::vector<double> EXPvalue(dim_max);
214 std::vector<double> energyExpValue(dim_max);
215 std::vector<double> energyStddev(dim_max);
216 std::vector<Complex_t> ComplexVector_temp(dim_max);
217 matrix<Complex_t> h(dloc_h, dloc_h);
218 matrix<Complex_t> loc(dloc_op, dloc_op);
219 matrix<Complex_t> Dynamics(dim_max, Nstep + 1);
220#ifndef GPU
221 matrix<Complex_t> h_tot(dim_max, dim_max);
222 matrix<Complex_t> loc_tot(dim_max, dim_max);
223 matrix<Complex_t> State(dim_max, dim_max);
224 #define dh h
225 #define dloc loc
226 #define dh_tot h_tot
227 #define dloc_tot loc_tot
228 #define dState State
229#endif
230 //********** (END) Allocate CPU memories **********//
231
232#ifdef GPU
233 //********** Allocate GPU memories **********//
234 debug_print("# Allocating GPU memories.");
235 constexpr Integer_t GPU_UNIT = 32;
236 Integer_t const LDT = magma_roundup(dim_max, GPU_UNIT);
237 std::vector<Complex_t> tempVector(dim_max);
238 matrix_gpu<Complex_t> dh(dloc_h, dloc_h);
239 matrix_gpu<Complex_t> dloc(dloc_op, dloc_op);
240 matrix_gpu<Complex_t> dh_tot(LDT, dim_max);
241 matrix_gpu<Complex_t> dloc_tot(LDT, dim_max);
242 matrix_gpu<Complex_t> dState(LDT, dim_max);
243 matrix_gpu<Integer_t> dIndex(dim_max, 1);
244 matrix_gpu<Integer_t> dDegeneracy(dim_max + 1, 1);
245 matrix_gpu<double> dEigenEnergy(dim_max, 1);
246 matrix_gpu<Complex_t> dDynamics(LDT, Nstep + 1);
247 matrix_gpu<Complex_t> dComplexMatrix_temp1(LDT, dim_max);
248 matrix_gpu<Complex_t> dComplexMatrix_temp2(LDT, dim_max);
249 //********** (END) Allocate GPU memories **********//
250
251 //********** Determine GPU configuration **********//
253 //********** (END) Determine GPU configuration **********//
254#endif // #ifdef GPU
255
256 double start, t_int, end, temp_t;
257 double T_diag = 0, T_post = 0, T_pre = 0;
258 init_genrand(SEED);
259 start = getETtime();
260 for(Integer_t repetition = 0; repetition < repMin; ++repetition) {
261 generateLocal_h(h, dloc_h, -1);
262 generateLocal_op(loc, dloc_op, -1);
263 }
264 end = getETtime();
265 std::cout << "(init_genrand): time=" << std::fixed << (end - start) << std::endl;
266 //***************************************************************************
267 //******************** (END) Allocation & Initialization ********************
268 //***************************************************************************
269
270 start = getETtime();
271 end = start;
272 for(Integer_t repetition = repMin; repetition <= repMax; ++repetition) {
273 // 局所ハミルトニアンと局所物理量をランダムにとる ******************************//
274 generateLocal_h(h, dloc_h, -1);
275 generateLocal_op(loc, dloc_op, -1);
276
277 std::cout << "# rep=" << repetition << std::endl;
278 h.print(dloc_h, dloc_h);
279 loc.print(dloc_op, dloc_op);
280
281 debug_print("# Seting matrix to GPU.");
282#ifdef GPU
283 magma_setmatrix(dloc_h, dloc_h, sizeof(Complex_t), &*h.begin(), dloc_h, dh.ptr(), dloc_h,
284 queue);
285 magma_setmatrix(dloc_op, dloc_op, sizeof(Complex_t), &*loc.begin(), dloc_op, dloc.ptr(),
286 dloc_op, queue);
287 // magma_zprint_gpu(dloc_h, dloc_h, dh.ptr(), dh.LD(), queue);
288 // magma_zprint_gpu(dloc_op, dloc_op, dloc.ptr(), dloc.LD(), queue);
289#endif
290
291 std::string outDirName(baseDirName);
292 {
293 std::stringstream buff;
294 buff << "/RawData/Sample_No" << repetition;
295 outDirName += buff.str();
296 outDirName = std::regex_replace(outDirName, std::regex("//"), "/");
297 filesystem::create_directories(outDirName);
298 }
299
300 // for(size_t n = n_max;n >= n_min; --n) {
301 for(size_t n = n_min; n <= n_max; ++n) {
302 debug_print("# (rep,n)=(" << repetition << "," << n << ")");
303 dim_sub = SectorDimension(Sector[n]);
304 ComplexVector_temp.resize(dim_sub);
305 energyExpValue.resize(dim_sub);
306 energyExpValue.resize(dim_sub);
307
308 debug_print("# Constructing global matrices in the sector.");
309 temp_t = getETtime();
310 {
311 dim_sub = constructGlobal_h(dh_tot, dh, num_h, Sector.at(n), GPUconf);
312 constructGlobal_op(dloc_tot, dloc, num_op, Sector.at(n), GPUconf);
313#ifdef GPU
314 magma_queue_sync(GPUconf.queue());
315#endif
316 }
317 {
318#ifdef GPU
319 magma_getvector(dim_sub, sizeof(Complex_t), dh_tot.ptr(), dh_tot.LD() + 1,
320 &*ComplexVector_temp.begin(), 1, queue);
321#endif
322#pragma omp parallel for
323 for(size_t j = 0; j < dim_sub; j++) {
324#ifdef GPU
325 energyExpValue.at(j) = real(ComplexVector_temp.at(j));
326#else
327 energyExpValue.at(j) = real(h_tot.at(j, j));
328#endif
329 }
330 EnergyStddev(energyStddev, dh_tot, Sector.at(n), GPUconf);
331 }
332 T_pre += getETtime() - temp_t;
333
334 // magma_queue_sync(queue);
335 // std::cerr << "(N=" << n << ") isnan_kernel(dh_tot) before" << std::endl;
336 // isnan_kernel<<<GPUconf.dimGrid(),GPUconf.dimBlock(),GPUconf.shared(),GPUconf.stream()>>>(dim_sub, dh_tot.ptr(), dh_tot.LD());
337 // magma_queue_sync(queue);
338 // std::cerr << "(N=" << n << ") isnan_kernel(dloc_tot) before" << std::endl;
339 // isnan_kernel<<<GPUconf.dimGrid(),GPUconf.dimBlock(),GPUconf.shared(),GPUconf.stream()>>>(dim_sub, dloc_tot.ptr(), dloc_tot.LD());
340 // temp_t = getETtime();
341 {
342 debug_print("# Calculating eigenstate matrix elements.");
343 info = EigenMatrixElements(eigenEnergy, dim_sub, dh_tot, dloc_tot, GPUconf);
344 if(info != 0) {
346 continue;
347 }
348#ifdef GPU
349 magma_getvector(dim_sub, sizeof(Complex_t), dloc_tot.ptr(), dloc_tot.LD() + 1,
350 &*tempVector.begin(), 1, queue);
351 for(size_t j = 0; j < dim_sub; ++j) EXPvalue[j] = (double)real(tempVector.at(j));
352#else
353 for(size_t j = 0; j < dim_sub; ++j) EXPvalue[j] = real(loc_tot.at(j, j));
354#endif
355 energyRange = eigenEnergy[dim_sub - 1] - eigenEnergy[0];
356 gE = eigenEnergy[0];
357#pragma omp parallel for
358 for(size_t j = 0; j < dim_sub; ++j) {
359 eigenEnergy[j] = (eigenEnergy[j] - gE) / energyRange;
360 energyExpValue[j] = (energyExpValue[j] - gE) / energyRange;
361 energyStddev[j] = energyStddev[j] / energyRange;
362 }
363 }
364 T_diag += getETtime() - temp_t;
365 // magma_queue_sync(queue);
366 // std::cerr << "(N=" << n << ") isnan_kernel(dh_tot) after" << std::endl;
367 // isnan_kernel<<<GPUconf.dimGrid(),GPUconf.dimBlock(),GPUconf.shared(),GPUconf.stream()>>>(dim_sub, dh_tot.ptr(), dh_tot.LD());
368 // magma_queue_sync(queue);
369 // std::cerr << "(N=" << n << ") isnan_kernel(dloc_tot) after" << std::endl;
370 // isnan_kernel<<<GPUconf.dimGrid(),GPUconf.dimBlock(),GPUconf.shared(),GPUconf.stream()>>>(dim_sub, dloc_tot.ptr(), dloc_tot.LD());
371
372 Degeneracy.resize(0);
373 Degeneracy.push_back(0);
374 for(size_t j = 1; j < dim_sub; ++j) {
375 if(eigenEnergy[j] - eigenEnergy[j - 1] >= precision) Degeneracy.push_back(j);
376 }
377 Degeneracy.push_back(dim_sub);
378 // print(Degeneracy, Degeneracy.size());
379
380 Index.resize(dim_sub);
381 std::iota(Index.begin(), Index.end(), 0);
382 std::sort(Index.begin(), Index.end(), [&energyExpValue](size_t x, size_t y) {
383 return energyExpValue[x] < energyExpValue[y];
384 });
385 // print(Index, Index.size());
386
387#ifdef GPU
388 magma_setvector(Degeneracy.size(), sizeof(Integer_t), &*Degeneracy.begin(), 1,
389 dDegeneracy.ptr(), 1, queue);
390 magma_setvector(Index.size(), sizeof(Integer_t), &*Index.begin(), 1, dIndex.ptr(), 1,
391 queue);
392 magma_setvector(dim_sub, sizeof(double), &*eigenEnergy.begin(), 1, dEigenEnergy.ptr(),
393 1, queue);
394 magma_queue_sync(queue);
395#endif
396
397 for(size_t p = 0; p < Nstep; ++p) {
398 time = (Tmax * p) / (double)(Nstep - 1);
399#ifdef GPU
401 GPUconf.stream()>>>(time, Index.size(), dIndex.ptr(), dim_sub,
402 dState.ptr(), dState.LD(), dh_tot.ptr(),
403 dh_tot.LD(), dEigenEnergy.ptr());
404 magma_queue_sync(queue);
405#else
406 StatePreparation(time, Index, dim_sub, State, h_tot, eigenEnergy);
407#endif
408#ifdef GPU
409 matrixProduct_hemm(MagmaLeft, MagmaUpper, dim_sub, Index.size(), dloc_tot, dState,
410 dComplexMatrix_temp1, queue);
411 matrixProduct_gemm(MagmaConjTrans, MagmaNoTrans, Index.size(), Index.size(),
412 dim_sub, dState, dComplexMatrix_temp1, dComplexMatrix_temp2,
413 queue);
414 magma_copyvector(Index.size(), sizeof(Complex_t), dComplexMatrix_temp2.ptr(),
415 dComplexMatrix_temp2.LD() + 1,
416 dDynamics.ptr() + dDynamics.LD() * p, 1, queue);
417#else
418 for(size_t j = 0; j < Index.size(); j++) {
419 Id = Index.at(j);
420 Dynamics.at(j, p)
421 = ComplexOne<> * QuantumExpValue_he(dim_sub, State.begin() + State.LD() * j, dloc_tot, ComplexVector_temp);
422 }
423#endif
424 }
425
426 // Calculate Infinite time average.
427 {
428 debug_print("# Calculating the infinite time average.");
429#ifdef GPU
431 GPUconf.stream()>>>(0, Index.size(), dIndex.ptr(), dim_sub,
432 dState.ptr(), dState.LD(), dh_tot.ptr(),
433 dh_tot.LD(), dEigenEnergy.ptr());
434 magma_queue_sync(queue);
435#else
436 StatePreparation(0, Index, dim_sub, State, h_tot, eigenEnergy);
437#endif
438
439#ifdef GPU
440 magma_copymatrix(dim_sub, dim_sub, sizeof(Complex_t), dloc_tot.ptr(), dloc_tot.LD(),
441 dh_tot.ptr(), dh_tot.LD(), queue);
442 magma_queue_sync(queue);
443#else
444 #pragma omp parallel for
445 for(Integer_t j = 0; j < dim_sub; ++j)
446 for(Integer_t k = 0; k < dim_sub; ++k) h_tot.at(j, k) = loc_tot.at(j, k);
447#endif
448
449#ifdef GPU
451 GPUconf.stream()>>>(Degeneracy.size(), dDegeneracy.ptr(),
452 dim_sub, dloc_tot.ptr(), dloc_tot.LD());
453 magma_queue_sync(queue);
454#else
455 InfiniteTimeAverage(Degeneracy, dim_sub, loc_tot);
456 // loc_tot.print(dim_sub,dim_sub);
457#endif
458
459#ifdef GPU
460 matrixProduct_hemm(MagmaLeft, MagmaUpper, dim_sub, Index.size(), dloc_tot, dState,
461 dComplexMatrix_temp1, queue);
462 matrixProduct_gemm(MagmaConjTrans, MagmaNoTrans, Index.size(), Index.size(),
463 dim_sub, dState, dComplexMatrix_temp1, dComplexMatrix_temp2,
464 queue);
465 magma_copyvector(Index.size(), sizeof(Complex_t), dComplexMatrix_temp2.ptr(),
466 dComplexMatrix_temp2.LD() + 1,
467 dDynamics.ptr() + dDynamics.LD() * Nstep, 1, queue);
468#else
469 for(size_t j = 0; j < Index.size(); j++) {
470 Id = Index.at(j);
471 Dynamics.at(j, Nstep)
472 = ComplexOne<> * QuantumExpValue_he(dim_sub, State.begin() + State.LD() * j, loc_tot, ComplexVector_temp);
473 }
474#endif
475 }
476
477#ifdef GPU
478 magma_getmatrix(Index.size(), Nstep + 1, sizeof(Complex_t), dDynamics.ptr(),
479 dDynamics.LD(), &*Dynamics.begin(), Dynamics.LD(), queue);
480 magma_queue_sync(queue);
481#endif
482
483 temp_t = getETtime();
484 { OpRange = SpectralRange(OpMin, dim_sub, dh_tot); }
485 T_diag += getETtime() - temp_t;
486
487 temp_t = getETtime();
488 {
489 debug_print("# Writing results to a file.");
490 std::stringstream buff("");
491 buff << "/FockStateDynamics" << PRECISION << "_N" << n << ".txt";
492 std::string filename(outDirName);
493 filename += buff.str();
494 OutFs.open(filename);
495 checkIsFileOpen(OutFs, filename);
496 OutFs << std::right << std::showpos << std::scientific << std::setprecision(6);
497 OutFs << "# energyRange= " << energyRange << "\n"
498 << "# gE= " << gE << "\n"
499 << "# OpRange= " << OpRange << "\n"
500 << "# OpMin= " << OpMin << "\n"
501 << "# 1.(State No.) 2.(Normalized energy) 3.(Normalized Energy Stddev) "
502 "4.(Normalized MCAverage) 5.(Normalized Cumulative ExpVal at T=1000) "
503 "6.(at T=5000) 7.(at T=10000) 8.(at T=Infty)"
504 << "\n\n";
505 for(size_t j = 0; j < Index.size(); j++) {
506 Id = Index.at(j);
507 shellWidth = dE;
508 MCAverage = MicroCanonicalAverage(NdataInShell, energyExpValue[Id], shellWidth,
509 dim_sub, eigenEnergy, EXPvalue);
510 for(size_t k = 1; isnan(MCAverage); ++k) {
511 shellWidth = k * energyStddev[Id];
512 MCAverage
513 = MicroCanonicalAverage(NdataInShell, energyExpValue[Id], shellWidth,
514 dim_sub, eigenEnergy, EXPvalue);
515 }
516
517 OutFs << Id << " " << energyExpValue[Id] << " " << energyStddev[Id] << " "
518 << (MCAverage - OpMin) / OpRange << " ";
519 size_t p = 0;
520 sum = 0;
521 for(; p <= (Nstep - 1) / 100; ++p) sum += real(Dynamics.at(j, p));
522 OutFs << (sum / (double)(p + 1) - OpMin) / OpRange << " ";
523 for(; p <= (Nstep - 1) / 10; ++p) sum += real(Dynamics.at(j, p));
524 OutFs << (sum / (double)(p + 1) - OpMin) / OpRange << " ";
525 for(; p <= (Nstep - 1); ++p) sum += real(Dynamics.at(j, p));
526 OutFs << (sum / (double)(p + 1) - OpMin) / OpRange << " ";
527 OutFs << (real(Dynamics.at(j, Nstep)) - OpMin) / OpRange << std::endl;
528 }
529 OutFs.close();
530 }
531 T_post += getETtime() - temp_t;
532 }
533 if(repetition % 10 == 9) {
534 t_int = end;
535 end = getETtime();
536 std::cerr << "(total=" << std::setw(6) << repetition + 1
537 << "): timeINT=" << std::setprecision(6) << std::setw(8) << (end - t_int)
538 << ", timeTOT=" << std::setprecision(6) << std::setw(8) << (end - start)
539 << ", T_construct=" << std::setprecision(6) << std::setw(10) << T_pre << "("
540 << std::setprecision(1) << 100 * T_pre / (end - start) << "%)"
541 << ", T_diag=" << std::setprecision(6) << std::setw(8) << T_diag << "("
542 << std::setprecision(1) << 100 * T_diag / (end - start) << "%)"
543 << ", T_process=" << std::setprecision(6) << std::setw(8) << T_post << "("
544 << std::setprecision(1) << 100 * T_post / (end - start) << "%)" << std::endl;
545 }
546 }
547
548 Finalize(argc, argv);
549#ifdef GPU
550 magma_finalize();
551#endif
552 return 0;
553}
void __global__ StatePreparation(double time, Integer_t Nstates, Integer_t *dIndex, Integer_t dim_sub, Complex_t *dState, Integer_t LDS, Complex_t *dh_tot, Integer_t LDH, double *dEigenEnergy)
Definition Dynamics_Deviation.cpp:90
void EnergyStddev(std::vector< double > &res, matrix_gpu< Complex_t > const &Hamiltonian_d, TransSector const &Sector, GPUconfig const &GPUconf)
Definition Dynamics_Deviation.cpp:70
void __global__ InfiniteTimeAverage(Integer_t const SizeDegen, Integer_t const *dDegeneracy, Integer_t const dim_sub, Complex_t *dOp_tot, Integer_t const LDH)
Definition Dynamics_Deviation.cpp:101
double getETtime()
Definition EnergySpectrum.c:14
Definition mytypes.hpp:147
Calculate the microcanonical averages with respect to a given sorted vector 'eigVal'.
Definition MicroCanonicalAverage.hpp:25
bool checkIsFileOpen(std::ifstream &file, std::string const &filename)
Definition file_util.hpp:22
debug_print("# Determining GPU configuration.")
Integer_t const num_op
Definition setVariablesForEnsemble.cpp:39
baseDirName
Definition setVariablesForEnsemble.cpp:50
constexpr int Nargs_base
Definition setVariablesForEnsemble.cpp:13
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
double const dE
Definition setVariablesForMCAverage.cpp:2
double SpectralRange(double &OpMin, Integer_t const dim, matrix< Complex_t< double > > &Operator)
Definition statmech.cpp:49
Integer_t EigenMatrixElements(std::vector< double > &Eigenvalue, Integer_t const dim, matrix< Complex_t< double > > &Hamiltonian, matrix< Complex_t< double > > &Operator, void *GPUconf)
Definition statmech.cpp:89
std::stringstream buff("")

◆ StatePreparation() [1/2]

void __global__ StatePreparation ( double  time,
Integer_t  Nstates,
Integer_t dIndex,
Integer_t  dim_sub,
Complex_t dState,
Integer_t  LDS,
Complex_t dh_tot,
Integer_t  LDH,
double *  dEigenEnergy 
)
92 {
93 int const idx = blockIdx.x * blockDim.x + threadIdx.x;
94 int const idy = blockIdx.y * blockDim.y + threadIdx.y;
95 if(idx >= dim_sub || idy >= Nstates) return;
96 Integer_t stateId = dIndex[idy];
97 Real_t phase = -dEigenEnergy[idx] * time;
98 dState[idx + LDS * idy] = conj(dh_tot[stateId + LDH * idx]) * MAGMA_CEXP(phase);
99}
__device__ Complex_t< double > MAGMA_CEXP(Real_t theta)
Definition generateRM.cuh:132

◆ StatePreparation() [2/2]

void StatePreparation ( double  time,
std::vector< Integer_t > &  Index,
Integer_t  dim_sub,
matrix< Complex_t > &  State,
matrix< Complex_t > &  h_tot,
std::vector< double > &  eigenEnergy 
)
133 {
134 #pragma omp parallel for
135 for(size_t k = 0; k < dim_sub; k++) {
136 Complex_t phase = -ComplexI<> * eigenEnergy[k] * time;
137 for(size_t j = 0; j < Index.size(); j++) {
138 State.at(k, j) = conj(h_tot.at(Index[j], k)) * std::exp(phase);
139 }
140 }
141}