VMPS++
Loading...
Searching...
No Matches
GreenPropagator.h
Go to the documentation of this file.
1#ifndef GREEN_PROPAGATOR
2#define GREEN_PROPAGATOR
3
4#ifdef GREENPROPAGATOR_USE_GAUSSIAN_QUADRATURE
5#include "SuperQuadrator.h"
6//#else
7//#include "Quadrator.h"
8#endif
9
12#include "IntervalIterator.h"
13#include "ComplexInterpolGSL.h"
14
15#ifdef GREENPROPAGATOR_USE_HDF5
16#include "HDF5Interface.h"
17#endif
18
19#include <unsupported/Eigen/FFT>
20#include "gsl_integration.h" // from TOOLS
21#include "ooura_integration.h" // from TOOLS
22
29
30std::ostream& operator<< (std::ostream& s, GREEN_INTEGRATION GI)
31{
32 if (GI==DIRECT) {s << "DIRECT";}
33 else if (GI==INTERP) {s << "INTERP";}
34 else if (GI==OOURA ) {s << "OOURA" ;}
35 return s;
36}
37
40{
41 static double tmax;
42
43 static double damping (double tval) {return lorentz(tval);};
44
45 static double gauss (double tval) {return exp(-pow(2.*tval/tmax,2));};
46 static double lorentz (double tval) {return exp(-4.*tval/tmax);};
47};
49
51VectorXcd FT_interpol (const VectorXd &tvals, const VectorXcd &fvals, bool USE_QAWO, double wmin, double wmax, int wpoints)
52{
53 VectorXcd res(wpoints);
54
55 IntervalIterator w(wmin,wmax,wpoints);
56 for (w=w.begin(); w!=w.end(); ++w)
57 {
58 double wval = *w;
59 ComplexInterpol Interp(tvals);
60
61 for (int it=0; it<tvals.rows(); ++it)
62 {
63 double tval = tvals(it);
64 complex<double> Gval = (USE_QAWO)? fvals(it) : exp(+1.i*wval*tval) * fvals(it);
65 Interp.insert(it,Gval);
66 }
67 Interp.set_splines();
68
69 if (USE_QAWO)
70 {
71 gsl_function_pp FpRe([=](double t)->double{return Interp.quick_evaluateRe(t);});
72 gsl_function_pp FpIm([=](double t)->double{return Interp.quick_evaluateIm(t);});
73 gsl_function * FRe = static_cast<gsl_function*>(&FpRe);
74 gsl_function * FIm = static_cast<gsl_function*>(&FpIm);
75
76 res(w.index()) = fouriergrate(*FRe, *FIm, tvals(0),tvals(tvals.rows()-1), 1e-5,1e-5, wval);
77 }
78 else
79 {
80 res(w.index()) = Interp.integrate();
81 }
82 Interp.kill_splines();
83 }
84 return res;
85}
86
88{
90
91 GreenPropagatorLog (int Nt, int L, string logfolder_input)
92 :logfolder(logfolder_input)
93 {
94 Entropy.resize(Nt,L-1); Entropy.setZero();
95 DeltaS.resize(Nt,L-1); Entropy.setZero();
96 VarE.resize(Nt,L); VarE.setZero();
97 TwoSite.resize(Nt,L-1); TwoSite.setZero();
98 dimK2avg.resize(Nt,1); dimK2avg.setZero();
99 dimK1avg.resize(Nt,1); dimK1avg.setZero();
100 dimK0avg.resize(Nt,1); dimK0avg.setZero();
101 dur_tstep.resize(Nt,1); dur_tstep.setZero();
102 taxis.resize(Nt,1); taxis.setZero();
103 };
104
105 void save (string label) const
106 {
107 #ifdef GREENPROPAGATOR_USE_HDF5
108 HDF5Interface target(label+".log.h5",WRITE);
109 target.save_matrix(Entropy,"Entropy","");
110 target.save_matrix(DeltaS,"DeltaS","");
111 target.save_matrix(VarE,"VarE","");
112 target.save_matrix(TwoSite,"TwoSite","");
113 target.save_matrix(dimK2avg,"dimK2avg","");
114 target.save_matrix(dimK1avg,"dimK1avg","");
115 target.save_matrix(dimK0avg,"dimK0avg","");
116 target.save_matrix(dur_tstep,"dur_tstep","");
117 target.save_matrix(taxis,"taxis","");
118 target.close();
119 #endif
120 };
121
122 string logfolder = "./";
124};
125
126template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
128{
129public:
130
132
133 // BASIC CONSTRUCTOR
145 GreenPropagator (string label_input,
146 double tmax_input, int Nt_input,
147 int Ns_input=1,
148 double wmin_input=-10., double wmax_input=10., int Nw_input=501,
149 Q_RANGE Q_RANGE_CHOICE_input=MPI_PPI, int Nq_input=501,
150 GREEN_INTEGRATION GREENINT=OOURA)
151 :label(label_input), tmax(tmax_input), Nt(Nt_input),
152 Ns(Ns_input),
153 wmin(wmin_input), wmax(wmax_input), Nw(Nw_input),
154 Q_RANGE_CHOICE(Q_RANGE_CHOICE_input), Nq(Nq_input),
155 GREENINT_CHOICE(GREENINT)
156 {
157 #ifndef GREENPROPAGATOR_USE_GAUSSIAN_QUADRATURE
158 assert(GREENINT!=DIRECT);
159 #endif
163 }
164
165 void set_Lcell (int Lcell_input) {Lcell = Lcell_input;};
166
167 // LOADING CONSTRUCTORS FOLLOW:
168
169 // LOAD: MATRIX, NO CELL
180 GreenPropagator (string label_input, int Lcell_input, double tmax_input, const MatrixXcd &Gtx_input, GREEN_INTEGRATION GREENINT=OOURA)
181 :label(label_input), Lcell(Lcell_input), Ncells(1), Ns(1), tmax(tmax_input), GREENINT_CHOICE(GREENINT), Nq(501)
182 {
183 Gtx = Gtx_input;
184
185 #ifdef GREENPROPAGATOR_USE_GAUSSIAN_QUADRATURE
186 Nt = (GREENINT==DIRECT)? Gtx.rows():Gtx.rows()-1;
187 #else
188 assert(GREENINT!=DIRECT);
189 Nt = Gtx.rows()-1;
190 #endif
192
195
196 for (int l=0; l<Lhetero; ++l)
197 {
198 if (xvals[l] == 0) Gloct = Gtx.col(l);
199 }
200
203 }
204
205 // LOAD: MATRIX, CELL
215 GreenPropagator (string label_input, int Lcell_input, int Ncells_input, int Ns_input, double tmax_input, const vector<vector<MatrixXcd>> &Gtx_input,
216 Q_RANGE Q_RANGE_CHOICE_input=MPI_PPI, int Nq_input=501, GREEN_INTEGRATION GREENINT=OOURA)
217 :label(label_input), Lcell(Lcell_input), Ncells(Ncells_input), Ns(Ns_input), tmax(tmax_input), GREENINT_CHOICE(GREENINT), Q_RANGE_CHOICE(Q_RANGE_CHOICE_input)
218 {
219 GtxCell.resize(Lcell); for (int i=0; i<Lcell; ++i) GtxCell[i].resize(Lcell);
220
221 for (int i=0; i<Lcell; ++i)
222 for (int j=0; j<Lcell; ++j)
223 {
224 GtxCell[i][j] = Gtx_input[i][j];
225 }
226
227 #ifdef GREENPROPAGATOR_USE_GAUSSIAN_QUADRATURE
228 Nt = (GREENINT==DIRECT)? GtxCell[0][0].rows():GtxCell[0][0].rows()-1;
229 #else
230 assert(GREENINT!=DIRECT);
231 Nt = GtxCell[0][0].rows()-1;
232 #endif
233 Ncells = GtxCell[0][0].cols();
234 Nq = Nq_input;
236
239
240 GloctCell.resize(Lcell);
241 for (int i=0; i<Lcell; ++i)
242 for (int n=0; n<Ncells; ++n)
243 {
244 if (dcell[n*Lcell] == 0) GloctCell[i] = GtxCell[i][i].col(n);
245 }
246
249 if (CHOSEN_VERBOSITY>DMRG::VERBOSITY::SILENT) lout << termcolor::green << "loading from matrix " << label_input << " successful!" << termcolor::reset << endl;
250 }
251
252// // LOAD: HDF5, NO CELL
253// /**
254// Reads G(t,x) with unit cell resolution from file, so that G(ω,q) can be recalculated.
255// \param label_input : prefix for saved files (e.g. type of Green's function)
256// \param Lcell_input : unit cell length
257// \param tmax_input : maximal propagation time
258// \param files : input vector of files, a sum is performed over all data
259// \param Q_RANGE_CHOICE_input : choose the q-range (-π to π, 0 to 2π)
260// \param Nq_input : amount of momentum points (Note: the first point is repeated at the output)
261// \param GAUSSINT : if \p true, compute Gaussian integration weights for the cutoff function
262// */
263// GreenPropagator (string label_input, int Lcell_input, double tmax_input, const vector<string> &files,
264// Q_RANGE Q_RANGE_CHOICE_input=MPI_PPI, int Nq_input=501, GREEN_INTEGRATION GREENINT=OOURA)
265// :label(label_input), Lcell(Lcell_input), tmax(tmax_input), GREENINT_CHOICE(GREENINT), Q_RANGE_CHOICE(Q_RANGE_CHOICE_input)
266// {
267// #ifdef GREENPROPAGATOR_USE_HDF5
268// for (const auto &file:files)
269// {
270// MatrixXd MtmpRe, MtmpIm;
271// HDF5Interface Reader(file+".h5",READ);
272// Reader.load_matrix(MtmpRe,"txRe","G");
273// Reader.load_matrix(MtmpIm,"txIm","G");
274// Reader.close();
275//
276// if (Gtx.size() == 0)
277// {
278// Gtx = MtmpRe+1.i*MtmpIm;
279// }
280// else
281// {
282// Gtx += MtmpRe+1.i*MtmpIm;
283// }
284// }
285// #endif
286//
287// Ncells = 1;
288// #ifdef GREENPROPAGATOR_USE_GAUSSIAN_QUADRATURE
289// Nt = (GREENINT==DIRECT)? Gtx.rows():Gtx.rows()-1;
290// #else
291// assert(GREENINT!=DIRECT);
292// Nt = Gtx.rows()-1;
293// #endif
294// Nq = Nq_input;
295// Lhetero = Lcell;
296//
297// make_xarrays(Lhetero,Lcell,Ncells,Ns);
298// set_qlims(Q_RANGE_CHOICE);
299//
300// for (int l=0; l<Lhetero; ++l)
301// {
302// if (xvals[l] == 0) Gloct = Gtx.col(l);
303// }
304//
305// GreenPropagatorGlobal::tmax = tmax;
306// calc_intweights();
307// }
308
309 // LOAD: HDF5, CELL
321 GreenPropagator (string label_input, int Lcell_input, int Ncells_input, int Ns_input, double tmax_input, const vector<string> &files,
322 Q_RANGE Q_RANGE_CHOICE_input=MPI_PPI, int Nq_input=501, GREEN_INTEGRATION GREENINT=OOURA)
323 :label(label_input), Lcell(Lcell_input), Ncells(Ncells_input), Ns(Ns_input), tmax(tmax_input), GREENINT_CHOICE(GREENINT), Q_RANGE_CHOICE(Q_RANGE_CHOICE_input)
324 {
325 GtxCell.resize(Lcell); for (int i=0; i<Lcell; ++i) {GtxCell[i].resize(Lcell);}
326 #ifdef GREENPROPAGATOR_USE_HDF5
327 for (const auto &file:files)
328 for (int i=0; i<Lcell; ++i)
329 for (int j=0; j<Lcell; ++j)
330 {
331 MatrixXd MtmpRe, MtmpIm;
332 HDF5Interface Reader(file+".h5",READ);
333 string Gstring = (i<10 and j<10)?make_string("G",i,j):make_string("G",i,"_",j);
334 Reader.load_matrix(MtmpRe,"txRe",Gstring);
335 Reader.load_matrix(MtmpIm,"txIm",Gstring);
336 Reader.close();
337
338 if (GtxCell[i][j].size() == 0)
339 {
340 GtxCell[i][j] = MtmpRe+1.i*MtmpIm;
341 }
342 else
343 {
344 GtxCell[i][j] += MtmpRe+1.i*MtmpIm;
345 }
346 }
347 #endif
348
349 #ifdef GREENPROPAGATOR_USE_GAUSSIAN_QUADRATURE
350 Nt = (GREENINT==DIRECT)? GtxCell[0][0].rows():GtxCell[0][0].rows()-1;
351 #else
352 assert(GREENINT!=DIRECT);
353 Nt = GtxCell[0][0].rows()-1;
354 #endif
355 Ncells = GtxCell[0][0].cols();
356 Nq = Nq_input;
358
361
362 GloctCell.resize(Lcell);
363 for (int i=0; i<Lcell; ++i)
364 for (int n=0; n<Ncells; ++n)
365 {
366 if (dcellFT[n*Lcell] == 0)
367 {
368 GloctCell[i] = GtxCell[i][i].col(n);
369 }
370 }
371
374 if (CHOSEN_VERBOSITY>DMRG::VERBOSITY::SILENT) lout << termcolor::green << "loading from file " << label_input << " successful!" << termcolor::reset << endl;
375 }
376
385// void compute (const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhi, Mps<Symmetry,complex<double>> &OxPhi0,
386// double Eg, bool TIME_FORWARDS = true);
387
397 void compute_cell (const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhiBra, const vector<Mps<Symmetry,complex<double>>> &OxPhiKet,
398 double Eg, bool TIME_FORWARDS = true, bool COUNTERPROPAGATE = true, int x0=0);
399
400 void compute_one (int j0, const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhi, double Eg, bool TIME_FORWARDS = true);
401
402// void compute_thermal (const Hamiltonian &H, const vector<Mpo<Symmetry,MpoScalar>> &Odag, const Mps<Symmetry,complex<double>> &Phi,
403// Mps<Symmetry,complex<double>> &OxPhi0, bool TIME_FORWARDS);
404 void compute_thermal_cell (const Hamiltonian &H, const vector<Mpo<Symmetry,MpoScalar>> &Odag, const Mps<Symmetry,complex<double>> &Phi,
405 vector<Mps<Symmetry,complex<double>>> &OxPhi0, bool TIME_FORWARDS);
406
413 void recalc_FTw (double wmin_new, double wmax_new, int Nw_new=501);
414
415 void recalc_FTwCell (double wmin_new, double wmax_new, int Nw_new=501, bool TRANSPOSE=false);
416
424 void set_measurement (const vector<Mpo<Symmetry,MpoScalar>> &Measure_input, int Lcell, int measure_interval_input=10,
425 string measure_name_input="M", string measure_subfolder_input=".")
426 {
427 Measure = Measure_input;
428 measure_interval = measure_interval_input;
429 measure_name = measure_name_input;
430 measure_subfolder = measure_subfolder_input;
431 Measurement.resize(Lcell);
432 }
433
435 void save (bool IGNORE_TX = false) const;
436
437 void save_GtqCell() const;
438
444// double integrate_Glocw (double mu, int Nint = 1000);
445
451 double integrate_Glocw_cell (double mu, int Nint = 1000);
452
453 inline MatrixXcd get_Gtx() const {return Gtx;}
454
455 inline vector<vector<MatrixXcd>> get_GtxCell() const {return GtxCell;}
456
457 inline vector<VectorXcd> get_GlocwCell() const {return GlocwCell;}
458
459 inline void set_verbosity (DMRG::VERBOSITY::OPTION VERBOSITY) {CHOSEN_VERBOSITY = VERBOSITY;};
460
465// void FT_allSites (bool TW_FIRST_XQ_SECOND = true);
466
467 ArrayXcd FTloc_tw (const VectorXcd &Gloct, const ArrayXd &wvals);
468
469 inline void set_OxPhiFull (const vector<Mps<Symmetry,complex<double>>> &OxPhiFull_input) {OxPhiFull = OxPhiFull_input;}
470
471 inline void set_Qmulti (int NQ_input) {NQ = NQ_input;}
472
473 string INTinfo() const;
474 string xinfo() const;
475 string qinfo() const;
476 string tinfo() const;
477 string winfo() const; // w=ω
478 string xt_info() const;
479 string xtINTqw_info() const;
480 string xtq_info() const;
481 void print_starttext() const;
482
483 ArrayXd ncell;
484 double mu = std::nan("0");
485
486 void set_tol_DeltaS (double x) {tol_DeltaS = x;};
487 void set_lim_Nsv (size_t x) {lim_Nsv = x;};
488 void set_tol_compr (double x) {tol_compr = x;};
489 void set_h_ooura (double x) {h_ooura = x;};
490 void set_log (string logfolder_input="./") {SAVE_LOG = true; logfolder = logfolder_input;}
491 void set_dLphys (int x) {dLphys = x;};
492 bool USE_QAWO = false;
493
494 vector<vector<MatrixXcd>> get_GwqCell() const {return GwqCell;};
495
496 void FTcell_xq (bool TRANSPOSE = false);
497
498 void set_Oshift (vector<MpoScalar> Oshift_input) {Oshift = Oshift_input;};
499
500private:
501
502 string label;
503
504 int Nt, Nw, Nq;
505 int NQ = 0;
506 double tmax, wmin, wmax, qmin, qmax;
509 int dLphys = 1;
510 int j0 = -1;
511
512 double tol_compr = 1e-4; // compression tolerance during time propagation
513 double tol_Lanczos = 1e-7; // 1e-7 seems sufficient; increase to 1e-8 for higher accuracy
514 double tol_DeltaS = 1e-3; // 1e-3 seems good, maybe 1e-2 still okay
515 size_t lim_Nsv = 500ul;
516 double h_ooura = 0.001; // stepsize for Ooura integration if GREENINT_CHOICE == OOURA; smaller = more accurate & slower
518 bool SAVE_LOG = false;
519
521
522 #ifdef GREENPROPAGATOR_USE_GAUSSIAN_QUADRATURE
523 SuperQuadrator<GAUSS_LEGENDRE> TimeIntegrator;
524 #endif
525
528
529 vector<double> xvals; // site labels: relative distance from excitation centre in sites
530 vector<int> xinds; // site indices from 0 to Lhetero-1
531 vector<int> dcell; // relative distance from excitation centre in unit cells
532 vector<int> icell; // site indices within unit cell
533 vector<int> dcellFT;
534
535 vector<Mps<Symmetry,complex<double>>> OxPhiFull;
536 vector<MpoScalar> Oshift;
537
538 MatrixXcd Gtx, Gwx, Gtq, Gwq;
539 VectorXcd Gloct, Glocw, G0q, G0x;
540
541 // SU(2) Qmultitarget
542 vector<MatrixXcd> GtxQmulti, GtqQmulti, GwqQmulti;
543 vector<VectorXcd> GloctQmulti, GlocwQmulti, G0qQmulti;
544
545 vector<vector<MatrixXcd>> GtxCell, GwxCell, GtqCell, GwqCell;
546 vector<vector<VectorXcd>> G0qCell, G0xCell;
547 vector<VectorXcd> GloctCell, GlocwCell;
548
549 void calc_Green (const int &tindex, const complex<double> &phase,
550 const vector<Mps<Symmetry,complex<double>>> &OxPhi, const Mps<Symmetry,complex<double>> &Psi);
551
552 void calc_GreenCell (const int &tindex, const complex<double> &phase,
553 const vector<Mps<Symmetry,complex<double>>> &OxPhi, const vector<Mps<Symmetry,complex<double>>> &Psi, int x0=0);
554
555 void calc_GreenCell (const int &tindex, const complex<double> &phase,
556 const std::array<vector<Mps<Symmetry,complex<double>>>,2> &Psi);
557
558 void calc_Green_thermal (const int &tindex, const vector<Mpo<Symmetry,MpoScalar>> &Ox,
559 const Mps<Symmetry,complex<double>> &Phi, const Mps<Symmetry,complex<double>> &Psi);
560
561 void calc_GreenCell_thermal (const int &tindex, const vector<Mpo<Symmetry,MpoScalar>> &Ox, const vector<Mps<Symmetry,complex<double>>> &Psi);
562
563 void calc_intweights();
564 void make_xarrays (int Lhetero_input, int Lcell_input, int Ncells_input, int Ns=1, bool PRINT=false);
565 void set_qlims (Q_RANGE CHOICE);
566
567// void propagate (const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhi, Mps<Symmetry,complex<double>> &OxPhi0,
568// double Eg, bool TIME_FORWARDS);
569 void propagate_cell (int x0, const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhi, double Eg, bool TIME_FORWARDS=true);
570 void propagate_one (int j0, const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhi, double Eg, bool TIME_FORWARDS=true);
571 void counterpropagate_cell (const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhiBra, const vector<Mps<Symmetry,complex<double>>> &OxPhiKet, double Eg, bool TIME_FORWARDS=true);
572
573// void propagate_thermal (const Hamiltonian &H, const vector<Mpo<Symmetry,MpoScalar>> &Ox, Mps<Symmetry,complex<double>> Phi,
574// Mps<Symmetry,complex<double>> &OxPhi0, bool TIME_FORWARDS);
575 void propagate_thermal_cell (const Hamiltonian &H, const vector<Mpo<Symmetry,MpoScalar>> &Ox, Mps<Symmetry,complex<double>> Phi,
576 vector<Mps<Symmetry,complex<double>>> &OxPhi0, bool TIME_FORWARDS);
577
578// void FT_xq (const MatrixXcd &Gtx, MatrixXcd &Gtq);
579 void FT_tw (const MatrixXcd &Gtq, MatrixXcd &Gwq, VectorXcd &G0q, VectorXcd &Glocw);
580 void FTcell_tw();
581
582 void FTcellww_xq (bool TRANSPOSE = false);
583 void FTcellxx_tw();
584// void FTww_xq (const MatrixXcd &Gwx, const MatrixXcd &G0x, MatrixXcd &Gwq, VectorXcd &G0q);
585 void FTxx_tw (const MatrixXcd &Gtx, MatrixXcd &Gwx, VectorXcd &G0x, VectorXcd &Glocw);
586
587 vector<Mpo<Symmetry,MpoScalar>> Measure;
588 void measure_wavepacket (const Mps<Symmetry,complex<double>> &Psi, double tval, int i=0);
591 vector<MatrixXd> Measurement;
592
594 string logfolder = "./";
595 void save_log (int i, int tindex, double tval, const Mps<Symmetry,complex<double>> &Psi,
596 const TDVPPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar,Mps<Symmetry,complex<double>>> &TDVP,
597 const EntropyObserver<Mps<Symmetry,complex<double>>> &Sobs,
598 const vector<bool> &TWO_SITE);
599};
600
601//template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
602//void GreenPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar>::
603//compute (const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhi,
604// Mps<Symmetry,complex<double>> &OxPhi0, double Eg, bool TIME_FORWARDS)
605//{
606// print_starttext();
607//
608// Lcell = max(OxPhi0.Boundaries.length(),1ul);
609// Lhetero = H.length();
610// Ncells = Lhetero/Lcell;
612//
613// if (Q_RANGE_CHOICE == MPI_PPI) assert(Lhetero%2 == 0 and "Please use an even number of sites in the heterogenic region!");
614// assert(Lhetero%Lcell == 0 and "The heterogenic region is not commensurable with the length of the unit cell!");
615//
616// if (Q_RANGE_CHOICE == MPI_PPI) assert(Ncells%2 == 0 and "Please use an even number of unit cells!");
617//
618// make_xarrays(Lhetero,Lcell,Ncells,Ns);
620//
621// propagate(H, OxPhi, OxPhi0, Eg, TIME_FORWARDS);
622//
623// if (NQ == 0)
624// {
625// FT_xq(Gtx,Gtq);
626// FT_tw(Gtq,Gwq,G0q,Glocw);
627// }
628// else
629// {
630// for (int iQ=0; iQ<NQ; ++iQ)
631// {
632// GtqQmulti.resize(NQ);
633// FT_xq(GtxQmulti[iQ],GtqQmulti[iQ]);
634// GwqQmulti.resize(NQ);
635// G0qQmulti.resize(NQ);
636// GlocwQmulti.resize(NQ);
637// FT_tw(GtqQmulti[iQ],GwqQmulti[iQ],G0qQmulti[iQ],GlocwQmulti[iQ]);
638// }
639// }
640//}
641
642//template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
643//void GreenPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar>::
644//propagate (const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhi, Mps<Symmetry,complex<double>> &OxPhi0, double Eg, bool TIME_FORWARDS)
645//{
646// double tsign = (TIME_FORWARDS==true)? -1.:+1.;
647//
648// Mps<Symmetry,complex<double>> Psi = OxPhi0;
649// Psi.eps_truncWeight = tol_compr;
650// Psi.max_Nsv = max(Psi.calc_Mmax(),500ul);
651//
652// TDVPPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar,Mps<Symmetry,complex<double>>> TDVP(H, Psi);
653// EntropyObserver<Mps<Symmetry,complex<double>>> Sobs(Lhetero, Nt, CHOSEN_VERBOSITY, tol_DeltaS);
654// vector<bool> TWO_SITE = Sobs.TWO_SITE(0, Psi, 1.);
655// if (CHOSEN_VERBOSITY > DMRG::VERBOSITY::ON_EXIT) lout << endl;
656//
657// Gtx.resize(Nt,Lhetero); Gtx.setZero();
658// Gloct.resize(Nt); Gloct.setZero();
659//
660// if (NQ>0)
661// {
662// GtxQmulti.resize(NQ);
663// for (int i=0; i<NQ; ++i) {GtxQmulti[i].resize(Nt,Lhetero); GtxQmulti[i].setZero();}
664// GloctQmulti.resize(NQ);
665// for (int i=0; i<NQ; ++i) {GloctQmulti[i].resize(Nt); GloctQmulti[i].setZero();}
666// }
667//
668// IntervalIterator t(0.,tmax,Nt);
669// double tval = 0.;
670//
671// if (SAVE_LOG) log = GreenPropagatorLog(Nt,Lhetero,logfolder);
672//
673// // measure wavepacket at t=0
674// measure_wavepacket(Psi,0);
675//
676// Stopwatch<> TpropTimer;
677// for (t=t.begin(); t!=t.end(); ++t)
678// {
679// Stopwatch<> StepTimer;
680// // 1. propagate
681// //----------------------------------------------------------------------------------------
682// if (tsteps(t.index()) != 0.)
683// TDVP.t_step_adaptive(H, Psi, 1.i*tsign*tsteps(t.index()), TWO_SITE, 1,tol_Lanczos);
684// //----------------------------------------------------------------------------------------
685// tval = tsteps.head(t.index()+1).sum();
686// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("time step") << endl;
687//
688// if (Psi.get_truncWeight().sum() > 0.5*tol_compr)
689// {
690// Psi.max_Nsv = min(static_cast<size_t>(max(Psi.max_Nsv*1.1, Psi.max_Nsv+1.)),lim_Nsv);
691// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
692// {
693// lout << termcolor::yellow << "Setting Psi.max_Nsv to " << Psi.max_Nsv << termcolor::reset << endl;
694// }
695// }
696//
697// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
698// {
699// lout << TDVP.info() << endl;
700// lout << Psi.info() << endl;
701// lout << "propagated to: t=" << tval << ", stepsize=" << tsteps(t.index()) << ", step#" << t.index()+1 << "/" << Nt << endl;
702// }
703//
704// // 2. measure
705// // 2.1. Green's function
706// calc_Green(t.index(), -1.i*exp(-1.i*tsign*Eg*tval), OxPhi, Psi);
707// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("G(t,x) calculation") << endl;
708//
709// // 2.2. measure wavepacket at t
710// if (Measure.size() != 0)
711// {
712// if ((t.index()-1)%measure_interval == 0 and t.index() > 1) measure_wavepacket(Psi,tval);
713// }
714// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("wavepacket measurement") << endl;
715//
716// // 3. check entropy increase
717// auto PsiTmp = Psi; PsiTmp.entropy_skim();
718// double r = (t.index()==0)? 1.:tsteps(t.index()-1)/tsteps(t.index());
719// // If INTERP is used, G(t=0) is used in the first step and t.index()==1 is the first real propagation step.
720// // Force 2-site here algorithm for better accuracay:
721// vector<size_t> true_overrides;
722// if (GREENINT_CHOICE != DIRECT and t.index() == 1)
723// {
724// true_overrides.resize(Lhetero-1);
725// iota(true_overrides.begin(), true_overrides.end(), 0);
726// }
727// TWO_SITE = Sobs.TWO_SITE(t.index(), PsiTmp, r, true_overrides);
728// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("entropy calculation") << endl;
729//
730// save_log(0,t.index(),tval,PsiTmp,TDVP,Sobs,TWO_SITE);
731//
732// // final info
733// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
734// {
735// lout << TpropTimer.info("total running time",false) << endl;
736// lout << endl;
737// }
738// }
739//
740// // measure wavepacket at t=t_end
741// if (Measure.size() != 0)
742// {
743// measure_wavepacket(Psi,tval);
744// }
745//}
746
747//template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
748//void GreenPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar>::
749//compute_thermal (const Hamiltonian &H, const vector<Mpo<Symmetry,MpoScalar>> &Odag, const Mps<Symmetry,complex<double>> &Phi,
750// Mps<Symmetry,complex<double>> &OxPhi0, bool TIME_FORWARDS)
751//{
752// print_starttext();
753// assert(H.volume()/H.length()==1 or H.volume()/H.length()==2);
754//
755// Lcell = max(OxPhi0.Boundaries.length(),1ul);
756// dLphys = (H.volume()/H.length()==2)? 1:2;
757// Lhetero = (dLphys==1)? H.length():H.length()/2;
758// Ncells = Lhetero/Lcell;
760//
761// if (Q_RANGE_CHOICE == MPI_PPI) assert(Lhetero%2 == 0 and "Please use an even number of sites in the heterogenic region!");
762// assert(Lhetero%Lcell == 0 and "The heterogenic region is not commensurable with the length of the unit cell!");
763//
764// if (Q_RANGE_CHOICE == MPI_PPI) assert(Ncells%2 == 0 and "Please use an even number of unit cells!");
765//
766// make_xarrays(Lhetero,Lcell,Ncells,Ns);
768//
769// propagate_thermal(H, Odag, Phi, OxPhi0, TIME_FORWARDS);
770//
771// if (NQ == 0)
772// {
773// FT_xq(Gtx,Gtq);
774// FT_tw(Gtq,Gwq,G0q,Glocw);
775// }
776// else
777// {
778// for (int iQ=0; iQ<NQ; ++iQ)
779// {
780// GtqQmulti.resize(NQ);
781// FT_xq(GtxQmulti[iQ],GtqQmulti[iQ]);
782// GwqQmulti.resize(NQ);
783// G0qQmulti.resize(NQ);
784// GlocwQmulti.resize(NQ);
785// FT_tw(GtqQmulti[iQ],GwqQmulti[iQ],G0qQmulti[iQ],GlocwQmulti[iQ]);
786// }
787// }
788//}
789
790//template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
791//void GreenPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar>::
792//propagate_thermal (const Hamiltonian &H, const vector<Mpo<Symmetry,MpoScalar>> &Odag, Mps<Symmetry,complex<double>> Phi,
793// Mps<Symmetry,complex<double>> &OxPhi0, bool TIME_FORWARDS)
794//{
795// double tsign = (TIME_FORWARDS==true)? -1.:+1.;
796//
797// Mps<Symmetry,complex<double>> Psi = OxPhi0;
798// Psi.eps_truncWeight = tol_compr;
799// Psi.max_Nsv = max(Psi.calc_Mmax(),min(500ul,lim_Nsv));
800//
801// TDVPPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar,Mps<Symmetry,complex<double>>> TDVPket(H,Psi);
802// EntropyObserver<Mps<Symmetry,complex<double>>> SobsKet(H.length(), Nt, CHOSEN_VERBOSITY, tol_DeltaS);
803// vector<bool> TWO_SITE_KET = SobsKet.TWO_SITE(0, Psi, 1.);
804//
805// TDVPPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar,Mps<Symmetry,complex<double>>> TDVPbra(H,Phi);
806// EntropyObserver<Mps<Symmetry,complex<double>>> SobsBra(H.length(), Nt, CHOSEN_VERBOSITY, tol_DeltaS);
807// vector<bool> TWO_SITE_BRA = SobsBra.TWO_SITE(0, Phi, 1.);
808//
809// if (CHOSEN_VERBOSITY > DMRG::VERBOSITY::ON_EXIT) lout << endl;
810//
811// Gtx.resize(Nt,Lhetero); Gtx.setZero();
812// Gloct.resize(Nt); Gloct.setZero();
813//
814// if (NQ>0)
815// {
816// GtxQmulti.resize(NQ);
817// for (int i=0; i<NQ; ++i) {GtxQmulti[i].resize(Nt,Lhetero); GtxQmulti[i].setZero();}
818// GloctQmulti.resize(NQ);
819// for (int i=0; i<NQ; ++i) {GloctQmulti[i].resize(Nt); GloctQmulti[i].setZero();}
820// }
821//
822// IntervalIterator t(0.,tmax,Nt);
823// double tval = 0.;
824//
825// if (SAVE_LOG) log = GreenPropagatorLog(Nt,Lhetero,logfolder);
826//
827// // measure wavepacket at t=0
828// measure_wavepacket(Psi,0);
829//
830// Stopwatch<> TpropTimer;
831// for (t=t.begin(); t!=t.end(); ++t)
832// {
833// Stopwatch<> StepTimer;
834// // 1. propagate
835// //----------------------------------------------------------------------------------------
836// if (tsteps(t.index()) != 0.)
837// {
838// #pragma omp parallel sections
839// {
840// #pragma omp section
841// {
842// TDVPket.t_step_adaptive(H, Psi, 1.i*tsign*tsteps(t.index()), TWO_SITE_KET, 1,tol_Lanczos);
843// }
844// #pragma omp section
845// {
846// // Note: time direction will flipped via taking the adjoint
847// TDVPbra.t_step_adaptive(H, Phi, 1.i*tsign*tsteps(t.index()), TWO_SITE_BRA, 1,tol_Lanczos);
848// }
849// }
850// }
851// //----------------------------------------------------------------------------------------
852// tval = tsteps.head(t.index()+1).sum();
853// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("time step") << endl;
854//
855// // 2.1 increase bond dimension of Psi
856// if (Psi.get_truncWeight().sum() > 0.5*tol_compr)
857// {
858// Psi.max_Nsv = min(static_cast<size_t>(max(Psi.max_Nsv*1.1, Psi.max_Nsv+1.)),lim_Nsv);
859// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
860// {
861// lout << termcolor::yellow << "Setting Psi.max_Nsv to " << Psi.max_Nsv << termcolor::reset << endl;
862// }
863// }
864//
865// // 2.2 increase bond dimension of Phi
866// if (Phi.get_truncWeight().sum() > 0.5*tol_compr)
867// {
868// Phi.max_Nsv = min(static_cast<size_t>(max(Phi.max_Nsv*1.1, Phi.max_Nsv+1.)),lim_Nsv);
869// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
870// {
871// lout << termcolor::yellow << "Setting Phi.max_Nsv to " << Phi.max_Nsv << termcolor::reset << endl;
872// }
873// }
874//
875// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
876// {
877// lout << "KET: " << TDVPket.info() << endl;
878// lout << "KET: " << Psi.info() << endl;
879// lout << "BRA: " << TDVPbra.info() << endl;
880// lout << "BRA: " << Phi.info() << endl;
881// lout << "propagated to: t=" << tval << ", stepsize=" << tsteps(t.index()) << ", step#" << t.index()+1 << "/" << Nt << endl;
882// }
883//
884// // 3. measure
885// // 3.1. Green's function
886// calc_Green_thermal(t.index(), Odag, Phi, Psi);
887// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("G(t,x) calculation") << endl;
888//
889// // 3.2. measure wavepacket at t
890// if (Measure.size() != 0)
891// {
892// if ((t.index()-1)%measure_interval == 0 and t.index() > 1) measure_wavepacket(Psi,tval);
893// }
894// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("wavepacket measurement") << endl;
895//
896// // 4.1. check entropy increase of Psi
897// auto PsiTmp = Psi; PsiTmp.entropy_skim();
898// double r = (t.index()==0)? 1.:tsteps(t.index()-1)/tsteps(t.index());
899// // If INTERP is used, G(t=0) is used in the first step and t.index()==1 is the first real propagation step.
900// // Force 2-site here algorithm for better accuracay:
901// vector<size_t> true_overrides_ket;
902// if (GREENINT_CHOICE != DIRECT and t.index() == 1)
903// {
904// true_overrides_ket.resize(H.length()-1);
905// iota(true_overrides_ket.begin(), true_overrides_ket.end(), 0);
906// }
907// TWO_SITE_KET = SobsKet.TWO_SITE(t.index(), PsiTmp, r, true_overrides_ket);
908//
909// // 4.1. check entropy increase of Phi
910// auto PhiTmp = Phi; PhiTmp.entropy_skim();
911// r = (t.index()==0)? 1.:tsteps(t.index()-1)/tsteps(t.index());
912// // If INTERP is used, G(t=0) is used in the first step and t.index()==1 is the first real propagation step.
913// // Force 2-site here algorithm for better accuracay:
914// vector<size_t> true_overrides_bra;
915// if (GREENINT_CHOICE != DIRECT and t.index() == 1)
916// {
917// true_overrides_bra.resize(H.length()-1);
918// iota(true_overrides_bra.begin(), true_overrides_bra.end(), 0);
919// }
920// TWO_SITE_BRA = SobsBra.TWO_SITE(t.index(), PhiTmp, r, true_overrides_bra);
921//
922// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("entropy calculation") << endl;
923// save_log(0,t.index(),tval,PsiTmp,TDVPket,SobsKet,TWO_SITE_KET);
924//
925// // final info
926// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
927// {
928// lout << TpropTimer.info("total running time",false) << endl;
929// lout << endl;
930// }
931// }
932//
933// // measure wavepacket at t=t_end
934// if (Measure.size() != 0)
935// {
936// measure_wavepacket(Psi,tval);
937// }
938//}
939
940template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
942compute_cell (const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhiBra, const vector<Mps<Symmetry,complex<double>>> &OxPhiKet, double Eg, bool TIME_FORWARDS, bool COUNTERPROPAGATE, int x0)
943{
944 print_starttext();
945
946 if (!OxPhiKet[0].Boundaries.IS_TRIVIAL()) // IBC
947 {
948 Lcell = OxPhiKet.size();
949 Lhetero = H.length();
950 Ncells = Lhetero/Lcell;
951 }
952 else // OBC: Ncells must be set!
953 {
954 Lhetero = H.length();
955 Ncells = Lhetero/Lcell;
956 }
957 lout << "Lcell=" << Lcell << ", Lhetero=" << Lhetero << ", Ncells=" << Ncells << ", Ns=" << Ns << endl;
958
959 assert(Lhetero%Lcell == 0);
960
961// calc_intweights();
962 make_xarrays(Lhetero,Lcell,Ncells,Ns);
963
964 GtxCell.resize(Lcell);
965 for (int i=0; i<Lcell; ++i)
966 {
967 GtxCell[i].resize(Lcell);
968 }
969 for (int i=0; i<Lcell; ++i)
970 for (int j=0; j<Lcell; ++j)
971 {
972 GtxCell[i][j].resize(Nt,Ncells);
973 GtxCell[i][j].setZero();
974 }
975
976 GloctCell.resize(Lcell);
977 for (int i=0; i<Lcell; ++i)
978 {
979 GloctCell[i].resize(Nt);
980 GloctCell[i].setZero();
981 }
982
983 if (OxPhiKet[0].Boundaries.IS_TRIVIAL() or COUNTERPROPAGATE == false)
984 {
985 #pragma omp critical
986 {
987 lout << termcolor::blue << label << ": using usual propagation algorithm, best with Lcell=" << Lcell << " threads" << termcolor::reset << endl;
988 #ifdef _OPENMP
989 lout << termcolor::blue << "current OMP threads=" << omp_get_max_threads() << termcolor::reset << endl;
990 #endif
991 }
992 propagate_cell(x0, H, OxPhiKet, Eg, TIME_FORWARDS);
993 }
994 else
995 {
996 #pragma omp critical
997 {
998 lout << termcolor::blue << label << ": using counterpropagation algorithm, best with 2*Lcell=" << 2*Lcell << " threads" << termcolor::reset << endl;
999 #ifdef _OPENMP
1000 lout << termcolor::blue << "current OMP threads=" << omp_get_max_threads() << termcolor::reset << endl;
1001 #endif
1002 }
1003 counterpropagate_cell(H, OxPhiBra, OxPhiKet, Eg, TIME_FORWARDS);
1004 }
1005
1006// FTcell_xq();
1007// FTcell_tw();
1008 FTcellxx_tw();
1009 FTcellww_xq((TIME_FORWARDS)?false:true);
1010}
1011
1012template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1014propagate_cell (int x0, const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhi, double Eg, bool TIME_FORWARDS)
1015{
1016 double tsign = (TIME_FORWARDS==true)? -1.:+1.;
1017
1018 vector<Mps<Symmetry,complex<double>>> Psi(Lcell);
1019 for (int i=0; i<Lcell; ++i)
1020 {
1021 Psi[i] = OxPhi[x0+i];
1022 Psi[i].eps_truncWeight = tol_compr;
1023 Psi[i].max_Nsv = max(Psi[i].calc_Mmax(),lim_Nsv);
1024 }
1025
1026 vector<TDVPPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar,Mps<Symmetry,complex<double>>>> TDVP(Lcell);
1027 for (int i=0; i<Lcell; ++i)
1028 {
1030 }
1031
1032 vector<EntropyObserver<Mps<Symmetry,complex<double>>>> Sobs(Lcell);
1033 vector<vector<bool>> TWO_SITE(Lcell);
1034 for (int i=0; i<Lcell; ++i)
1035 {
1036 DMRG::VERBOSITY::OPTION VERB = (i==0)? CHOSEN_VERBOSITY:DMRG::VERBOSITY::SILENT;
1037 Sobs[i] = EntropyObserver<Mps<Symmetry,complex<double>>>(Lhetero, Nt, VERB, tol_DeltaS);
1038 TWO_SITE[i] = Sobs[i].TWO_SITE(0, Psi[i], 1.); // {}, {0ul,size_t(Lhetero)-2ul}
1039 }
1040 if (CHOSEN_VERBOSITY > DMRG::VERBOSITY::ON_EXIT) lout << endl;
1041
1042 IntervalIterator t(0.,tmax,Nt);
1043 double tval = 0.;
1044
1045 if (SAVE_LOG) log = GreenPropagatorLog(Nt,Lhetero,logfolder);
1046
1047 // 0.1. measure wavepacket at t=0
1048 for (int i=0; i<Lcell; ++i)
1049 {
1050 measure_wavepacket(Psi[i],0,i);
1051 }
1052
1053 // 0.2. if no (open) integration weights, calculate G at t=0
1054 if (GREENINT_CHOICE != DIRECT)
1055 {
1056 Stopwatch<> StepTimer;
1057 calc_GreenCell(0, -1.i*exp(-1.i*tsign*Eg*tval), OxPhi, Psi, x0);
1058 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1059 {
1060 lout << StepTimer.info("G(t,x) calculation") << endl;
1061 lout << endl;
1062 }
1063 }
1064
1065 Stopwatch<> TpropTimer;
1066 for (t=t.begin(); t!=t.end(); ++t)
1067 {
1068 Stopwatch<> StepTimer;
1069
1070 // 1. propagate
1071 #pragma omp parallel for
1072 for (int i=0; i<Lcell; ++i)
1073 {
1074 if (tsteps(t.index()) != 0.)
1075 {
1076 //-------------------------------------------------------------------------------------------------
1077 TDVP[i].t_step_adaptive(H, Psi[i], 1.i*tsign*tsteps(t.index()), TWO_SITE[i], 1,tol_Lanczos);
1078 //-------------------------------------------------------------------------------------------------
1079 }
1080
1081 /*if (Psi[i].get_truncWeight().sum() > 0.5*tol_compr)
1082 {
1083 Psi[i].max_Nsv = min(static_cast<size_t>(max(Psi[i].max_Nsv*1.1, Psi[i].max_Nsv+1.)),lim_Nsv);
1084 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE and i==0)
1085 {
1086 lout << termcolor::yellow << "Setting Psi.max_Nsv to " << Psi[i].max_Nsv << termcolor::reset << endl;
1087 }
1088 }*/
1089 }
1090 tval = tsteps.head(t.index()+1).sum();
1091 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("time step") << endl;
1092
1093 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1094 {
1095 lout << TDVP[0].info() << endl;
1096 lout << Psi[0].info() << endl;
1097 lout << termcolor::blue << "propagated to: t=" << tval << ", stepsize=" << tsteps(t.index()) << ", step#" << t.index()+1 << "/" << Nt << termcolor::reset << endl;
1098 }
1099
1100 // 2. measure
1101 // 2.1. Green's function
1102 calc_GreenCell(t.index(), -1.i*exp(-1.i*tsign*Eg*tval), OxPhi, Psi, x0);
1103 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("G(t,x) calculation") << endl;
1104 // 2.2. measure wavepacket at t
1105 if (Measure.size() != 0)
1106 {
1107 #pragma omp parallel for
1108 for (int i=0; i<Lcell; ++i)
1109 {
1110 if ((t.index()-1)%measure_interval == 0 and t.index() > 1) measure_wavepacket(Psi[i],tval,i);
1111 }
1112 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("wavepacket measurement") << endl;
1113 }
1114
1115 // 3. check entropy increase
1116 #pragma omp parallel for
1117 for (int i=0; i<Lcell; ++i)
1118 {
1119 auto PsiTmp = Psi[i]; PsiTmp.entropy_skim();
1120 double r = (t.index()==0)? 1.:tsteps(t.index()-1)/tsteps(t.index());
1121 TWO_SITE[i] = Sobs[i].TWO_SITE(t.index(), PsiTmp, r); // {}, {0ul,size_t(Lhetero)-2ul}
1122 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE and i==0) lout << StepTimer.info("entropy calculation") << endl;
1123
1124 save_log(i,t.index(),tval,PsiTmp,TDVP[i],Sobs[i],TWO_SITE[i]);
1125 }
1126
1127 // final info
1128 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1129 {
1130 lout << TpropTimer.info("total running time",false) << endl;
1131 lout << endl;
1132 }
1133 }
1134
1135 // measure wavepacket at t=t_end
1136 if (Measure.size() != 0)
1137 {
1138 #pragma omp parallel for
1139 for (int i=0; i<Lcell; ++i)
1140 {
1141 measure_wavepacket(Psi[i],tval,i);
1142 }
1143 }
1144}
1145
1146template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1148compute_one (int j0_input, const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhi, double Eg, bool TIME_FORWARDS)
1149{
1150 j0 = j0_input;
1151 assert(OxPhi[0].Boundaries.IS_TRIVIAL());
1152 print_starttext();
1153
1154 Lcell = OxPhi.size();
1155 Lhetero = H.length();
1156 assert(OxPhi.size() == H.length());
1157 Ncells = 1;
1158
1159 make_xarrays(Lhetero,Lcell,Ncells,Ns);
1160
1161 Gtx.resize(Nt,Lhetero);
1162 Gtx.setZero();
1163
1164 Gloct.resize(Nt);
1165 Gloct.setZero();
1166
1167 propagate_one(j0, H, OxPhi, Eg, TIME_FORWARDS);
1168
1169 FTxx_tw(Gtx, Gwx, G0x, Glocw);
1170}
1171
1172template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1174propagate_one (int j0, const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhi, double Eg, bool TIME_FORWARDS)
1175{
1176 double tsign = (TIME_FORWARDS==true)? -1.:+1.;
1177
1179 Psi = OxPhi[j0];
1180 Psi.eps_truncWeight = tol_compr;
1181 Psi.max_Nsv = max(Psi.calc_Mmax(),lim_Nsv);
1182
1185
1187 vector<bool> TWO_SITE;
1188 DMRG::VERBOSITY::OPTION VERB = CHOSEN_VERBOSITY;
1189 Sobs = EntropyObserver<Mps<Symmetry,complex<double>>>(Lhetero, Nt, VERB, tol_DeltaS);
1190 TWO_SITE = Sobs.TWO_SITE(0, Psi, 1.);
1191 if (CHOSEN_VERBOSITY > DMRG::VERBOSITY::ON_EXIT) lout << endl;
1192
1193 IntervalIterator t(0.,tmax,Nt);
1194 double tval = 0.;
1195
1196 if (SAVE_LOG) log = GreenPropagatorLog(Nt,Lhetero,logfolder);
1197
1198 // 0.1. measure wavepacket at t=0
1199 measure_wavepacket(Psi,0,0);
1200
1201 // 0.2. if no (open) integration weights, calculate G at t=0
1202 if (GREENINT_CHOICE != DIRECT)
1203 {
1204 Stopwatch<> StepTimer;
1205 calc_Green(0, -1.i*exp(-1.i*tsign*Eg*tval), OxPhi, Psi);
1206 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1207 {
1208 lout << StepTimer.info("G(t,x) calculation") << endl;
1209 lout << endl;
1210 }
1211 }
1212
1213 Stopwatch<> TpropTimer;
1214 for (t=t.begin(); t!=t.end(); ++t)
1215 {
1216 Stopwatch<> StepTimer;
1217
1218 // 1. propagate
1219 if (tsteps(t.index()) != 0.)
1220 {
1221 //-------------------------------------------------------------------------------------------------
1222 TDVP.t_step_adaptive(H, Psi, 1.i*tsign*tsteps(t.index()), TWO_SITE, 1,tol_Lanczos);
1223 //-------------------------------------------------------------------------------------------------
1224 }
1225
1226 if (Psi.get_truncWeight().sum() > 0.5*tol_compr)
1227 {
1228 Psi.max_Nsv = min(static_cast<size_t>(max(Psi.max_Nsv*1.1, Psi.max_Nsv+1.)),lim_Nsv);
1229 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1230 {
1231 lout << termcolor::yellow << "Setting Psi.max_Nsv to " << Psi.max_Nsv << termcolor::reset << endl;
1232 }
1233 }
1234 tval = tsteps.head(t.index()+1).sum();
1235 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("time step") << endl;
1236
1237 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1238 {
1239 lout << TDVP.info() << endl;
1240 lout << Psi.info() << endl;
1241 lout << termcolor::blue << "propagated to: t=" << tval << ", stepsize=" << tsteps(t.index()) << ", step#" << t.index()+1 << "/" << Nt << termcolor::reset << endl;
1242 }
1243
1244 // 2. measure
1245 // 2.1. Green's function
1246 calc_Green(t.index(), -1.i*exp(-1.i*tsign*Eg*tval), OxPhi, Psi);
1247 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("G(t,x) calculation") << endl;
1248 // 2.2. measure wavepacket at t
1249 if (Measure.size() != 0)
1250 {
1251 if ((t.index()-1)%measure_interval == 0 and t.index() > 1) measure_wavepacket(Psi,tval,0);
1252 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("wavepacket measurement") << endl;
1253 }
1254
1255 // 3. check entropy increase
1256 auto PsiTmp = Psi; PsiTmp.entropy_skim();
1257 double r = (t.index()==0)? 1.:tsteps(t.index()-1)/tsteps(t.index());
1258 TWO_SITE = Sobs.TWO_SITE(t.index(), PsiTmp, r); // {}, {0ul,size_t(Lhetero)-2ul}
1259 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("entropy calculation") << endl;
1260
1261 save_log(0,t.index(),tval,PsiTmp,TDVP,Sobs,TWO_SITE);
1262
1263 // final info
1264 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1265 {
1266 lout << TpropTimer.info("total running time",false) << endl;
1267 lout << endl;
1268 }
1269 }
1270
1271 // measure wavepacket at t=t_end
1272 if (Measure.size() != 0)
1273 {
1274 measure_wavepacket(Psi,tval,0);
1275 }
1276}
1277
1278template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1280counterpropagate_cell (const Hamiltonian &H, const vector<Mps<Symmetry,complex<double>>> &OxPhiBra, const vector<Mps<Symmetry,complex<double>>> &OxPhiKet, double Eg, bool TIME_FORWARDS)
1281{
1282 double tsign = (TIME_FORWARDS==true)? -1.:+1.;
1283 std::array<double,2> zfac;
1284 zfac[0] = +1.; // forw propagation
1285 zfac[1] = -1.; // back propagation
1286
1287 std::array<vector<Mps<Symmetry,complex<double>>>,2> Psi;
1288 for (int z=0; z<2; ++z)
1289 {
1290 Psi[z].resize(Lcell);
1291 for (int i=0; i<Lcell; ++i)
1292 {
1293 Psi[z][i] = (z==0)? OxPhiKet[i] : OxPhiBra[i];
1294 Psi[z][i].eps_truncWeight = tol_compr;
1295 Psi[z][i].max_Nsv = max(Psi[z][i].calc_Mmax(),lim_Nsv);
1296 }
1297 }
1298
1299 std::array<vector<TDVPPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar,Mps<Symmetry,complex<double>>>>,2> TDVP;
1300 for (int z=0; z<2; ++z)
1301 {
1302 TDVP[z].resize(Lcell);
1303 for (int i=0; i<Lcell; ++i)
1304 {
1306 }
1307 }
1308 std::array<vector<EntropyObserver<Mps<Symmetry,complex<double>>>>,2> Sobs;
1309 std::array<vector<vector<bool>>,2> TWO_SITE;
1310 for (int z=0; z<2; ++z)
1311 {
1312 Sobs[z].resize(Lcell);
1313 TWO_SITE[z].resize(Lcell);
1314
1315 for (int i=0; i<Lcell; ++i)
1316 {
1317 DMRG::VERBOSITY::OPTION VERB = (i==0 and z==0)? CHOSEN_VERBOSITY:DMRG::VERBOSITY::SILENT;
1318 Sobs[z][i] = EntropyObserver<Mps<Symmetry,complex<double>>>(Lhetero, Nt, VERB, tol_DeltaS);
1319 TWO_SITE[z][i] = Sobs[z][i].TWO_SITE(0, Psi[z][i]);
1320 }
1321 }
1322 if (CHOSEN_VERBOSITY > DMRG::VERBOSITY::ON_EXIT) lout << endl;
1323
1324 IntervalIterator t(0.,tmax,Nt);
1325 double tval = 0.;
1326
1327 if (SAVE_LOG) log = GreenPropagatorLog(Nt,Lhetero,logfolder);
1328
1329 // 0.1. measure wavepacket at t=0
1330 if (Measure.size() != 0)
1331 {
1332 for (int i=0; i<Lcell; ++i)
1333 {
1334 measure_wavepacket(Psi[0][i],0,i);
1335 }
1336 }
1337
1338 // 0.2. if no (open) integration weights, calculate G at t=0
1339 if (GREENINT_CHOICE != DIRECT)
1340 {
1341 Stopwatch<> StepTimer;
1342// lout << termcolor::blue << "phase=" << -1.i*exp(-1.i*tsign*Eg*tval) << termcolor::reset << endl;
1343 calc_GreenCell(0, -1.i*exp(-1.i*tsign*Eg*tval), Psi);
1344 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1345 {
1346 lout << StepTimer.info("G(t,x) calculation") << endl;
1347 lout << endl;
1348 }
1349 }
1350
1351 Stopwatch<> TpropTimer;
1352 for (t=t.begin(); t!=t.end(); ++t)
1353 {
1354 Stopwatch<> StepTimer;
1355
1356 // 1. propagate
1357 #pragma omp parallel for collapse(2)
1358 for (int z=0; z<2; ++z)
1359 for (int i=0; i<Lcell; ++i)
1360 {
1361 if (tsteps(t.index()) != 0.)
1362 {
1363 //---------------------------------------------------------------------------------------------------------------
1364 TDVP[z][i].t_step_adaptive(H, Psi[z][i], 0.5*1.i*zfac[z]*tsign*tsteps(t.index()), TWO_SITE[z][i], 1,tol_Lanczos);
1365 // #pragma omp critical
1366 // {
1367 // cout << "z=" << z << ", i=" << i << ", norm=" << Psi[z][i].squaredNorm() << ", E=" << avg_hetero(Psi[z][i], H, Psi[z][i], true) << endl;
1368 // }
1369 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::STEPWISE and i==0 and z==0)
1370 {
1371 std::streamsize ss = std::cout.precision();
1372 lout << "δE=" << setprecision(4) << TDVP[z][i].get_deltaE().transpose() << setprecision(ss) << endl;
1373 }
1374 }
1375 //---------------------------------------------------------------------------------------------------------------
1376
1377 /*if (Psi[z][i].get_truncWeight().sum() > 0.5*tol_compr)
1378 {
1379 Psi[z][i].max_Nsv = min(static_cast<size_t>(max(Psi[z][i].max_Nsv*1.1, Psi[z][i].max_Nsv+1.)),lim_Nsv);
1380 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE and i==0 and z==0)
1381 {
1382 lout << termcolor::yellow << "Setting Psi.max_Nsv to " << Psi[z][i].max_Nsv << termcolor::reset << endl;
1383 }
1384 }*/
1385 }
1386 tval = tsteps.head(t.index()+1).sum();
1387 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("time step") << endl;
1388
1389 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1390 {
1391 lout << TDVP[0][0].info() << endl;
1392 lout << Psi[0][0].info() << endl;
1393 lout << termcolor::blue
1394 << "propagated to: t=0.5*" << tval << "=" << 0.5*tval
1395 << ", stepsize=0.5*" << tsteps(t.index()) << "=" << 0.5*tsteps(t.index())
1396 << ", step#" << t.index()+1 << "/" << Nt
1397 << termcolor::reset << endl;
1398 }
1399
1400 // 2. measure
1401 // 2.1. Green's function
1402 //----------------------------------------------------------
1403// lout << termcolor::blue << "phase=" << -1.i*exp(-1.i*tsign*Eg*tval) << termcolor::reset << endl;
1404 calc_GreenCell(t.index(), -1.i*exp(-1.i*tsign*Eg*tval), Psi);
1405 //----------------------------------------------------------
1406 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("G(t,x) calculation") << endl;
1407 // 2.2. measure wavepacket at t
1408 if (Measure.size() != 0)
1409 {
1410 #pragma omp parallel for
1411 for (int i=0; i<Lcell; ++i)
1412 {
1413 if ((t.index()-1)%measure_interval == 0 and t.index() > 1)
1414 {
1415 measure_wavepacket(Psi[0][i],0.5*tval,i);
1416 }
1417 }
1418 }
1419 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("wavepacket measurement") << endl;
1420
1421 // 3. check entropy increase
1422 #pragma omp parallel for collapse(2)
1423 for (int z=0; z<2; ++z)
1424 for (int i=0; i<Lcell; ++i)
1425 {
1426 auto PsiTmp = Psi[z][i]; PsiTmp.entropy_skim();
1427 double r = (t.index()==0)? 1.:tsteps(t.index()-1)/tsteps(t.index());
1428// // possible override: always 2-site near excitation centre:
1429// vector<size_t> overrides = {0ul, size_t(Lhetero-2)};
1430 TWO_SITE[z][i] = Sobs[z][i].TWO_SITE(t.index(), PsiTmp, r);
1431
1432 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE and i==0 and z==0) lout << StepTimer.info("entropy calculation") << endl;
1433
1434 if (z==0) save_log(i,t.index(),0.5*tval,PsiTmp,TDVP[z][i],Sobs[z][i],TWO_SITE[z][i]);
1435 }
1436
1437 // final info
1438 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1439 {
1440 lout << TpropTimer.info("total running time",false) << endl;
1441 lout << endl;
1442 }
1443 }
1444
1445 // measure wavepacket at t=t_end
1446 if (Measure.size() != 0)
1447 {
1448 #pragma omp parallel for
1449 for (int i=0; i<Lcell; ++i)
1450 {
1451 measure_wavepacket(Psi[0][i],0.5*tval,i);
1452 }
1453 }
1454}
1455
1456template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1458compute_thermal_cell (const Hamiltonian &H, const vector<Mpo<Symmetry,MpoScalar>> &Odag, const Mps<Symmetry,complex<double>> &Phi,
1459 vector<Mps<Symmetry,complex<double>>> &OxPhi0, bool TIME_FORWARDS)
1460{
1461 print_starttext();
1462 assert(H.volume()/H.length()==1 or H.volume()/H.length()==2);
1463
1464 Lcell = OxPhi0.size();
1465 dLphys = (H.volume()/H.length()==2)? 1:2;
1466 Lhetero = (dLphys==1)? H.length():H.length()/2;
1467 Ncells = Lhetero/Lcell;
1468// cout << "Lcell=" << Lcell << ", Lhetero=" << Lhetero << ", Ncells=" << Ncells << ", dLphys=" << dLphys << endl;
1469
1470 assert(Lhetero%Lcell == 0);
1471
1472// calc_intweights();
1473 make_xarrays(Lhetero,Lcell,Ncells,Ns);
1474
1475 GtxCell.resize(Lcell);
1476 for (int i=0; i<Lcell; ++i)
1477 {
1478 GtxCell[i].resize(Lcell);
1479 }
1480 for (int i=0; i<Lcell; ++i)
1481 for (int j=0; j<Lcell; ++j)
1482 {
1483 GtxCell[i][j].resize(Nt,Ncells);
1484 GtxCell[i][j].setZero();
1485 }
1486
1487 GloctCell.resize(Lcell);
1488 for (int i=0; i<Lcell; ++i)
1489 {
1490 GloctCell[i].resize(Nt);
1491 GloctCell[i].setZero();
1492 }
1493
1494 propagate_thermal_cell(H, Odag, Phi, OxPhi0, TIME_FORWARDS);
1495
1496// FTcell_xq();
1497// FTcell_tw();
1498 FTcellxx_tw();
1499 FTcellww_xq((TIME_FORWARDS)?false:true);
1500}
1501
1502template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1504propagate_thermal_cell (const Hamiltonian &H, const vector<Mpo<Symmetry,MpoScalar>> &Odag, Mps<Symmetry,complex<double>> Phi,
1505 vector<Mps<Symmetry,complex<double>>> &OxPhi0, bool TIME_FORWARDS)
1506{
1507 double tsign = (TIME_FORWARDS==true)? -1.:+1.;
1508
1509 vector<Mps<Symmetry,complex<double>>> Psi(Lcell+1);
1510 for (int i=0; i<Lcell+1; ++i)
1511 {
1512 Psi[i] = (i==Lcell)? Phi : OxPhi0[i]; // Phi = Psi[Lcell]
1513 Psi[i].eps_truncWeight = tol_compr;
1514 Psi[i].max_Nsv = max(Psi[i].calc_Mmax(),lim_Nsv);
1515 }
1516
1517 vector<TDVPPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar,Mps<Symmetry,complex<double>>>> TDVP(Lcell+1);
1518 for (int i=0; i<Lcell+1; ++i)
1519 {
1521 }
1522// vector<TDVPPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar,Mps<Symmetry,complex<double>>>> TDVPa(Lcell+1);
1523// for (int i=0; i<Lcell+1; ++i)
1524// {
1525// TDVPa[i] = TDVPPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar,Mps<Symmetry,complex<double>>>(Ha,Psi[i]);
1526// }
1527 vector<EntropyObserver<Mps<Symmetry,complex<double>>>> Sobs(Lcell+1);
1528 vector<vector<bool>> TWO_SITE(Lcell+1);
1529 for (int i=0; i<Lcell+1; ++i)
1530 {
1531 DMRG::VERBOSITY::OPTION VERB = (i==0)? CHOSEN_VERBOSITY:DMRG::VERBOSITY::SILENT;
1532 Sobs[i] = EntropyObserver<Mps<Symmetry,complex<double>>>(H.length(), Nt, VERB, tol_DeltaS);
1533 TWO_SITE[i] = Sobs[i].TWO_SITE(0, Psi[i], 1.); // {}, {0ul,size_t(Lhetero)-2ul}
1534 }
1535 if (CHOSEN_VERBOSITY > DMRG::VERBOSITY::ON_EXIT) lout << endl;
1536
1537 IntervalIterator t(0.,tmax,Nt);
1538 double tval = 0.;
1539
1540 if (SAVE_LOG) log = GreenPropagatorLog(Nt,Lhetero,logfolder);
1541
1542 // 0.1. measure wavepacket at t=0
1543 for (int i=0; i<Lcell; ++i)
1544 {
1545 measure_wavepacket(Psi[i],0,i);
1546 }
1547
1548 // 0.2. if no (open) integration weights, calculate G at t=0
1549 if (GREENINT_CHOICE != DIRECT)
1550 {
1551 Stopwatch<> StepTimer;
1552 calc_GreenCell_thermal(0, Odag, Psi);
1553 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1554 {
1555 lout << StepTimer.info("G(t,x) calculation") << endl;
1556 lout << endl;
1557 }
1558 }
1559
1560 Stopwatch<> TpropTimer;
1561 for (t=t.begin(); t!=t.end(); ++t)
1562 {
1563 Stopwatch<> StepTimer;
1564
1565 // 1. propagate
1566 #pragma omp parallel for
1567 for (int i=0; i<Lcell+1; ++i)
1568 {
1569 //-------------------------------------------------------------------------------------------------
1570 if (tsteps(t.index()) != 0.)
1571 {
1572 TDVP[i].t_step_adaptive(H, Psi[i], 1.i*tsign*tsteps(t.index()), TWO_SITE[i], 1,tol_Lanczos);
1573 }
1574 //-------------------------------------------------------------------------------------------------
1575
1576 /*if (Psi[i].get_truncWeight().sum() > 0.5*tol_compr)
1577 {
1578 Psi[i].max_Nsv = min(static_cast<size_t>(max(Psi[i].max_Nsv*1.1, Psi[i].max_Nsv+1.)),lim_Nsv);
1579 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE and i==0)
1580 {
1581 lout << termcolor::yellow << "Setting Psi.max_Nsv to " << Psi[i].max_Nsv << termcolor::reset << endl;
1582 }
1583 }*/
1584 }
1585 tval = tsteps.head(t.index()+1).sum();
1586 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("time step") << endl;
1587
1588 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1589 {
1590 lout << "KET: " << TDVP[0].info() << endl;
1591 lout << "KET: " << Psi[0].info() << endl;
1592 lout << "BRA: " << TDVP[Lcell].info() << endl;
1593 lout << "BRA: " << Psi[Lcell].info() << endl;
1594 lout << termcolor::blue
1595 << "propagated to: t=" << tval << ", stepsize=" << tsteps(t.index()) << ", step#" << t.index()+1 << "/" << Nt
1596 << termcolor::reset << endl;
1597 }
1598
1599 // 2. measure
1600 // 2.1. Green's function
1601 calc_GreenCell_thermal(t.index(), Odag, Psi);
1602 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("G(t,x) calculation") << endl;
1603 // 2.2. measure wavepacket at t
1604 if (Measure.size() != 0)
1605 {
1606 #pragma omp parallel for
1607 for (int i=0; i<Lcell; ++i)
1608 {
1609 if ((t.index()-1)%measure_interval == 0 and t.index() > 1) measure_wavepacket(Psi[i],tval,i);
1610 }
1611 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE) lout << StepTimer.info("wavepacket measurement") << endl;
1612 }
1613
1614 // 3. check entropy increase
1615 #pragma omp parallel for
1616 for (int i=0; i<Lcell+1; ++i)
1617 {
1618 auto PsiTmp = Psi[i]; PsiTmp.entropy_skim();
1619 double r = (t.index()==0)? 1.:tsteps(t.index()-1)/tsteps(t.index());
1620 TWO_SITE[i] = Sobs[i].TWO_SITE(t.index(), PsiTmp, r); // {}, {0ul,size_t(Lhetero)-2ul}
1621 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE and i==0)
1622 lout << StepTimer.info("entropy calculation") << endl;
1623
1624 save_log(i,t.index(),tval,PsiTmp,TDVP[i],Sobs[i],TWO_SITE[i]);
1625 }
1626
1627 // final info
1628 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
1629 {
1630 lout << TpropTimer.info("total running time",false) << endl;
1631 lout << endl;
1632 }
1633 }
1634
1635 // measure wavepacket at t=t_end
1636 if (Measure.size() != 0)
1637 {
1638 #pragma omp parallel for
1639 for (int i=0; i<Lcell; ++i)
1640 {
1641 measure_wavepacket(Psi[i],tval,i);
1642 }
1643 }
1644}
1645
1646//template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1647//void GreenPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar>::
1648//calc_Green_thermal (const int &tindex, const vector<Mpo<Symmetry,MpoScalar>> &Odag,
1649// const Mps<Symmetry,complex<double>> &Phi, const Mps<Symmetry,complex<double>> &Psi)
1650//{
1651// assert(Psi.Boundaries.IS_TRIVIAL());
1652//
1653// #pragma omp parallel for
1654// for (size_t l=0; l<Lhetero; ++l)
1655// {
1659//
1660// Gtx(tindex,l) = -1.i * avg(Phi, Odag[l], Psi);
1661//
1666// }
1667//
1668// for (size_t l=0; l<Lhetero; ++l)
1669// {
1670// if (xvals[l] == 0)
1671// {
1672// Gloct(tindex) = Gtx(tindex,l); // save local Green's function
1673// }
1674// }
1675//}
1676
1677// used in propagate_one
1678template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1680calc_Green (const int &tindex, const complex<double> &phase, const vector<Mps<Symmetry,complex<double>>> &OxPhi, const Mps<Symmetry,complex<double>> &Psi)
1681{
1682 //variant: Don't use cell shift, OxPhiFull must be of length Lhetero
1683 if (OxPhiFull.size() > 0)
1684 {
1685 if (NQ == 0)
1686 {
1687 #pragma omp parallel for
1688 for (size_t l=0; l<Lhetero; ++l)
1689 {
1690 Gtx(tindex,l) = phase * dot(OxPhiFull[l], Psi);
1691 }
1692 }
1693 // SU(2) Qmultitarget
1694 else
1695 {
1696 #pragma omp parallel for
1697 for (size_t l=0; l<Lhetero; ++l)
1698 {
1699 auto dotres = dot_green(OxPhiFull[l], Psi);
1700 for (size_t iQ=0; iQ<GtxQmulti.size(); ++iQ)
1701 {
1702 GtxQmulti[iQ](tindex,l) = phase * dotres[iQ];
1703 }
1704 }
1705 }
1706 }
1707 // variant: Use cell shift
1708 else
1709 {
1710 #pragma omp parallel for
1711 for (size_t l=0; l<Lhetero; ++l)
1712 {
1713 Gtx(tindex,l) = phase * dot_hetero(OxPhi[icell[l]], Psi, dcell[l]);
1714 }
1715 }
1716
1717 for (size_t l=0; l<Lhetero; ++l)
1718 {
1719 if (xvals[l] == 0)
1720 {
1721 if (NQ == 0)
1722 {
1723 Gloct(tindex) = Gtx(tindex,l); // save local Green's function
1724 }
1725 else
1726 {
1727 for (size_t iQ=0; iQ<GtxQmulti.size(); ++iQ)
1728 {
1729 GloctQmulti[iQ](tindex) = GtxQmulti[iQ](tindex,l);
1730 }
1731 }
1732 }
1733 }
1734
1735// for (size_t l=0; l<Lhetero; ++l)
1736// {
1737// cout << "l=" << l << ", " << Gtx(tindex,l) << ", " << Gtx_(tindex,l) << ", diff=" << abs(Gtx(tindex,l)-Gtx_(tindex,l)) << endl;
1738// }
1739// cout << termcolor::blue << "total diff = " << (Gtx.row(tindex)-Gtx_.row(tindex)).norm() << termcolor::reset << endl;
1740}
1741
1742// used in propagate
1743template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1745calc_GreenCell (const int &tindex,
1746 const complex<double> &phase,
1747 const vector<Mps<Symmetry,complex<double>>> &OxPhi,
1748 const vector<Mps<Symmetry,complex<double>>> &Psi,
1749 int x0)
1750{
1751 //variant: Don't use cell shift, OxPhiFull must be of length Lhetero
1752// if (Psi[0].Boundaries.IS_TRIVIAL())
1753 if (OxPhiFull.size() > 0)
1754 {
1755 #pragma omp parallel for collapse(3)
1756 for (size_t n=0; n<Ncells; ++n)
1757 for (size_t i=0; i<Lcell; ++i)
1758 for (size_t j=0; j<Lcell; ++j)
1759 {
1760 GtxCell[i][j](tindex,n) = phase * dot(OxPhiFull[n*Lcell+i], Psi[j]);
1761
1762// if (Oshift.size() != 0)
1763// {
1764// GtxCell[i][j](tindex,n) += Oshift[n*Lcell+i] * Oshift[x0+j];
1765// }
1766 }
1767 }
1768 // variant: Use cell shift
1769 else
1770 {
1771 #pragma omp parallel for collapse(3)
1772 for (size_t i=0; i<Lcell; ++i)
1773 for (size_t j=0; j<Lcell; ++j)
1774 for (size_t n=0; n<Ncells; ++n)
1775 {
1776 GtxCell[i][j](tindex,n) = phase * dot_hetero(OxPhi[i], Psi[j], dcell[n*Lcell]);
1777 }
1778// #pragma omp parallel for collapse(3)
1779// for (size_t n=0; n<Ncells; ++n)
1780// for (size_t i=0; i<Lcell; ++i)
1781// for (size_t j=0; j<Lcell; ++j)
1782// {
1783// GtxCell[i][j](tindex,n) = phase * dot_hetero(OxPhiFull[n*Lcell+i], Psi[j]);
1784// }
1785 }
1786
1787 for (size_t i=0; i<Lcell; ++i)
1788 for (size_t n=0; n<Ncells; ++n)
1789 {
1790 if (dcell[n*Lcell] == 0)
1791 {
1792 GloctCell[i](tindex) = GtxCell[i][i](tindex,n); // save local Green's function
1793 }
1794 }
1795}
1796
1797// used in counterpropagate
1798template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1800calc_GreenCell (const int &tindex,
1801 const complex<double> &phase,
1802 const std::array<vector<Mps<Symmetry,complex<double>>>,2> &Psi)
1803{
1804// cout << "phase=" << phase << endl;
1805// #pragma omp parallel for collapse(3)
1806 for (size_t i=0; i<Lcell; ++i)
1807 for (size_t j=0; j<Lcell; ++j)
1808 for (size_t n=0; n<Ncells; ++n)
1809 {
1810 GtxCell[i][j](tindex,n) = phase * dot_hetero(Psi[1][i], Psi[0][j], dcell[n*Lcell]);
1811// #pragma omp critical
1812// {
1813// cout << "i=" << i << ", j=" << j << ", n=" << n << ", dcell=" << dcell[n*Lcell] << ", dot=" << dot_hetero(Psi[1][i], Psi[0][j], dcell[n*Lcell]) << ", G=" << GtxCell[i][j](tindex,n) << endl;
1814// }
1815 }
1816
1817 for (size_t i=0; i<Lcell; ++i)
1818 for (size_t n=0; n<Ncells; ++n)
1819 {
1820 if (dcell[n*Lcell] == 0)
1821 {
1822 GloctCell[i](tindex) = GtxCell[i][i](tindex,n); // save local Green's function
1823 }
1824 }
1825}
1826
1827template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1829calc_GreenCell_thermal (const int &tindex, const vector<Mpo<Symmetry,MpoScalar>> &Odag, const vector<Mps<Symmetry,complex<double>>> &Psi)
1830{
1831 for (size_t i=0; i<Lcell+1; ++i) assert(Psi[i].Boundaries.IS_TRIVIAL());
1832
1833 #pragma omp parallel for collapse(3)
1834 for (size_t n=0; n<Ncells; ++n)
1835 for (size_t i=0; i<Lcell; ++i)
1836 for (size_t j=0; j<Lcell; ++j)
1837 {
1838// Mps<Symmetry,complex<double>> OxPhi;
1839// OxV_exact(Ox[n*Lcell+i], Psi[Lcell], OxPhi, 2., DMRG::VERBOSITY::SILENT); // Phi = Psi[Lcell]
1840// GtxCell[i][j](tindex,n) = -1.i*dot(OxPhi,Psi[j]);
1841
1842 GtxCell[i][j](tindex,n) = -1.i * avg(Psi[Lcell], Odag[n*Lcell+i], Psi[j]); // Phi = Psi[Lcell]
1843
1844// #pragma omp critial
1845// {
1846// lout << "G1=" << conj(avg(Psi[j], Ox[n*Lcell+i], Psi[Lcell])) << ", G2=" << dot(OxPhi,Psi[j]) << endl;
1847// }
1848 }
1849
1850 for (size_t i=0; i<Lcell; ++i)
1851 for (size_t n=0; n<Ncells; ++n)
1852 {
1853 if (dcell[n*Lcell] == 0)
1854 {
1855 GloctCell[i](tindex) = GtxCell[i][i](tindex,n); // save local Green's function
1856 }
1857 }
1858}
1859
1860template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1862measure_wavepacket (const Mps<Symmetry,complex<double>> &Psi, double tval, int icell)
1863{
1864 if (Measure.size() != 0)
1865 {
1866// cout << termcolor::yellow << "in measure: t=" << tval << ", info=" << info << termcolor::reset << endl;
1867 double norm = Psi.squaredNorm();
1868 ArrayXd res(Measure.size());
1869
1870 #pragma omp parallel for
1871 for (size_t l=0; l<Measure.size(); ++l)
1872 {
1873// cout << "measurement l=" << l << ": " << Psi.info() << endl;
1874// cout << Measure[l].info() << endl;
1875 if (Psi.Boundaries.IS_TRIVIAL())
1876 {
1877 res(l) = isReal(avg(Psi, Measure[l], Psi)) / norm;
1878 }
1879 else
1880 {
1881 res(l) = isReal(avg_hetero(Psi, Measure[l], Psi, false, 1ul, Measure[l].Qtarget())) / norm;
1882 }
1883 }
1884
1885// ofstream Filer(make_string(measure_subfolder,"/",label,"_Op=",measure_name,"_",info,xinfo(),"_t=",tval,".dat"));
1887// for (size_t l=0; l<Measure.size(); ++l)
1888// {
1889// Filer << xvals[l] << "\t" << res(l) << endl;
1890// }
1891// Filer.close();
1892
1893 Measurement[icell].conservativeResize(Measurement[icell].rows()+1, Measure.size());
1894 Measurement[icell].row(Measurement[icell].rows()-1) = res;
1895 }
1896}
1897
1898template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1900make_xarrays (int Lhetero_input, int Lcell_input, int Ncells_input, int Ns, bool PRINT)
1901{
1902 xinds.resize(Lhetero_input);
1903 xvals.resize(Lhetero_input);
1904
1905 iota(begin(xinds),end(xinds),0);
1906
1907 int x0 = Lhetero_input/2; // first site of central unit cell
1908 if (PRINT and CHOSEN_VERBOSITY > DMRG::VERBOSITY::SILENT) lout << "make_xarrays: x0=" << x0 << endl;
1909
1910 for (int ix=0; ix<xinds.size(); ++ix)
1911 {
1912 xvals[ix] = static_cast<double>(xinds[ix]-x0);
1913 }
1914
1915 for (int d=0; d<Ncells_input; ++d)
1916 for (int i=0; i<Lcell_input; ++i)
1917 {
1918 icell.push_back(i);
1919 dcell.push_back(d);
1920 }
1921
1922 for (int d=0; d<Ncells_input*Ns; ++d)
1923 for (int i=0; i<Lcell_input/Ns; ++i)
1924 {
1925 dcellFT.push_back(d);
1926 }
1927
1928 for (int i=0; i<Lhetero_input; ++i)
1929 {
1930 dcell[i] -= x0/Lcell_input;
1931 dcellFT[i] -= x0/Lcell_input*Ns;
1932 }
1933
1934 if (PRINT and CHOSEN_VERBOSITY > DMRG::VERBOSITY::SILENT)
1935 for (int i=0; i<Lhetero; ++i)
1936 {
1937 lout << "i=" << xinds[i] << ", x=" << xvals[i] << ", icell=" << icell[i] << ", dcell=" << dcell[i] << ", dcellFT=" << dcellFT[i] << endl;
1938 }
1939}
1940
1941template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1943set_qlims (Q_RANGE CHOICE)
1944{
1945 if (CHOICE == MPI_PPI)
1946 {
1947 qmin = -M_PI;
1948 qmax = +M_PI;
1949 }
1950 else if (CHOICE == ZERO_2PI)
1951 {
1952 qmin = 0.;
1953 qmax = 2.*M_PI;
1954 }
1955}
1956
1957template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1959save_log (int i, int tindex, double tval, const Mps<Symmetry,complex<double>> &Psi, const TDVPPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar,Mps<Symmetry,complex<double>>> &TDVP, const EntropyObserver<Mps<Symmetry,complex<double>>> &Sobs, const vector<bool> &TWO_SITE)
1960{
1961 if (SAVE_LOG)
1962 {
1963 log.Entropy.row(tindex) = Psi.entropy();
1964 log.VarE.row(tindex) = TDVP.get_deltaE();
1965 for (int l=0; l<TWO_SITE.size(); ++l) log.TwoSite(tindex,l) = int(TWO_SITE[l]);
1966 log.DeltaS = Sobs.get_DeltaSb();
1967 log.taxis(tindex,0) = tval;
1968 log.dur_tstep(tindex,0) = TDVP.get_t_tot();
1969
1970 log.dimK2avg(tindex,0) = 0;
1971 for (int i=0; i<TDVP.get_dimK2_log().size(); ++i)
1972 {
1973 log.dimK2avg(tindex,0) += double(TDVP.get_dimK2_log()[i])/TDVP.get_dimK2_log().size();
1974 }
1975
1976 log.dimK1avg(tindex,0) = 0;
1977 for (int i=0; i<TDVP.get_dimK1_log().size(); ++i)
1978 {
1979 log.dimK1avg(tindex,0) += double(TDVP.get_dimK1_log()[i])/TDVP.get_dimK1_log().size();
1980 }
1981
1982 log.dimK0avg(tindex,0) = 0;
1983 for (int i=0; i<TDVP.get_dimK0_log().size(); ++i)
1984 {
1985 log.dimK0avg(tindex,0) += double(TDVP.get_dimK0_log()[i])/TDVP.get_dimK0_log().size();
1986 }
1987
1988 log.save(make_string(label,"_i=",i,"_",xt_info()));
1989 }
1990}
1991
1992template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
1995{
1996 Stopwatch<> Watch;
1997
1998 #ifdef GREENPROPAGATOR_USE_GAUSSIAN_QUADRATURE
1999 if (GREENINT_CHOICE == DIRECT)
2000 {
2001 TimeIntegrator = SuperQuadrator<GAUSS_LEGENDRE>(GreenPropagatorGlobal::damping,0.,tmax,Nt);
2002 tvals = TimeIntegrator.get_abscissa();
2003 weights = TimeIntegrator.get_weights();
2004 tsteps = TimeIntegrator.get_steps();
2005
2006// ofstream Filer(make_string("weights_",tinfo(),".dat"));
2007// for (int i=0; i<Nt; ++i)
2008// {
2009// Filer << tvals(i) << "\t" << weights(i) << endl;
2010// }
2011// Filer.close();
2012
2013 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
2014 {
2015 double erf2 = 0.995322265018952734162069256367252928610891797040060076738; // Mathematica♥♥♥
2016 double integral = 0.25*sqrt(M_PI)*erf2*tmax;
2017 double diff = abs(weights.sum()-integral);
2018 #pragma omp critical
2019 {
2020 if (diff < 1e-5) cout << termcolor::green;
2021 else if (diff < 1e-1 and diff >= 1e-5) cout << termcolor::yellow;
2022 else cout << termcolor::red;
2023 lout << setprecision(14)
2024 << "integration weight test: ∫w(t)dt=" << weights.sum()
2025 << ", analytical=" << integral
2026 << ", diff=" << abs(weights.sum()-integral)
2027 << setprecision(6);
2028 cout << termcolor::reset;
2029 lout << endl;
2030 }
2031 }
2032 }
2033 else
2034 #endif
2035 {
2036 double dt = tmax/Nt;
2037 Nt += 1;
2038
2039 tvals.resize(Nt);
2040 for (int i=0; i<Nt; ++i) tvals(i) = i*dt;
2041
2042 weights.resize(Nt); weights = 1.;
2043 tsteps.resize(Nt); tsteps = dt; tsteps(0) = 0;
2044 }
2045
2046 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
2047 {
2048 #pragma omp critical
2049 {
2050 lout << Watch.info("integration weights") << endl;
2051 }
2052 }
2053}
2054
2055//template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2056//void GreenPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar>::
2057//FT_xq (const MatrixXcd &Gtx, MatrixXcd &Gtq)
2058//{
2059// IntervalIterator q(qmin,qmax,Nq);
2060// ArrayXd qvals = q.get_abscissa();
2061// Gtq.resize(Nt,Nq); Gtq.setZero();
2062//
2063// Stopwatch<> FourierWatch;
2064//
2082//
2083// // Explicit FT
2084// for (int iq=0; iq<Nq; ++iq)
2085// for (int ix=0; ix<Gtx.cols(); ++ix)
2086// {
2087// Gtq.col(iq) += Gtx.col(ix) * exp(-1.i*qvals(iq)*xvals[ix]);
2088// }
2089//
2090// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
2091// {
2092// lout << FourierWatch.info("FT x→q (const q)") << endl;
2093// }
2094//}
2095
2096template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2098FTcell_xq (bool TRANSPOSE)
2099{
2100 IntervalIterator q(qmin,qmax,Nq);
2101 ArrayXd qvals = q.get_abscissa();
2102
2103 int Ls = Lcell/Ns;
2104
2105 GtqCell.resize(Lcell);
2106 for (int i=0; i<Lcell; ++i) GtqCell[i].resize(Lcell);
2107
2108 Stopwatch<> FourierWatch;
2109
2110 for (int i=0; i<Lcell; ++i)
2111 for (int j=0; j<Lcell; ++j)
2112 {
2113 GtqCell[i][j].resize(Nt,Nq); GtqCell[i][j].setZero();
2114
2115 for (int iq=0; iq<Nq; ++iq)
2116 for (int n=0; n<Ncells; ++n)
2117 {
2118 //GtqCell[i][j].col(iq) += GtxCell[i][j].col(n) * exp(-1.i*qvals(iq)*double(dcell[n*Lcell]));
2119 if (TRANSPOSE)
2120 {
2121 GtqCell[i][j].col(iq) += GtxCell[i][j].col(n) * exp(+1.i*qvals(iq)*double(dcellFT[n*Lcell]+(j-i)/Ls));
2122 }
2123 else
2124 {
2125 GtqCell[i][j].col(iq) += GtxCell[i][j].col(n) * exp(-1.i*qvals(iq)*double(dcellFT[n*Lcell]+(i-j)/Ls));
2126 }
2127 }
2128 }
2129
2130 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
2131 {
2132 lout << FourierWatch.info(label+" FT intercell x→q (const t)") << endl;
2133 }
2134}
2135
2136// //-----old version before Ns-----
2137//template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2138//void GreenPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar>::
2139//FTcellww_xq (bool TRANSPOSE)
2140//{
2141// IntervalIterator q(qmin,qmax,Nq);
2142// ArrayXd qvals = q.get_abscissa();
2143//
2144// GwqCell.resize(Lcell);
2145// for (int i=0; i<Lcell; ++i) GwqCell[i].resize(Lcell);
2146//
2147// G0qCell.resize(Lcell);
2148// for (int i=0; i<Lcell; ++i) G0qCell[i].resize(Lcell);
2149//
2150// Stopwatch<> FourierWatch;
2151//
2152// for (int i=0; i<Lcell; ++i)
2153// for (int j=0; j<Lcell; ++j)
2154// {
2155// GwqCell[i][j].resize(Nw,Nq); GwqCell[i][j].setZero();
2156// G0qCell[i][j].resize(Nq); G0qCell[i][j].setZero();
2157//
2158// for (int iq=0; iq<Nq; ++iq)
2159// for (int n=0; n<Ncells; ++n)
2160// {
2161// if (TRANSPOSE)
2162// {
2163// GwqCell[i][j].col(iq) += GwxCell[j][i].col(n) * exp(+1.i*qvals(iq)*double(dcell[n*Lcell]));
2164// G0qCell[i][j](iq) += G0xCell[j][i](n) * exp(+1.i*qvals(iq)*double(dcell[n*Lcell]));
2165// }
2166// else
2167// {
2168// GwqCell[i][j].col(iq) += GwxCell[i][j].col(n) * exp(-1.i*qvals(iq)*double(dcell[n*Lcell]));
2169// G0qCell[i][j](iq) += G0xCell[i][j](n) * exp(-1.i*qvals(iq)*double(dcell[n*Lcell]));
2170// }
2171// }
2172// }
2173//
2174// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
2175// {
2176// lout << FourierWatch.info(label+" FT intercell x→q (const ω)") << endl;
2177// }
2178//}
2179
2180template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2182FTcellww_xq (bool TRANSPOSE)
2183{
2184 IntervalIterator q(qmin,qmax,Nq);
2185 ArrayXd qvals = q.get_abscissa();
2186
2187 int Ls = Lcell/Ns;
2188
2189 GwqCell.resize(Ls);
2190 for (int i=0; i<Ls; ++i) GwqCell[i].resize(Ls);
2191
2192 G0qCell.resize(Ls);
2193 for (int i=0; i<Ls; ++i) G0qCell[i].resize(Ls);
2194
2195 Stopwatch<> FourierWatch;
2196
2197 for (int i=0; i<Ls; ++i)
2198 for (int j=0; j<Ls; ++j)
2199 {
2200 GwqCell[i][j].resize(Nw,Nq); GwqCell[i][j].setZero();
2201 G0qCell[i][j].resize(Nq); G0qCell[i][j].setZero();
2202 }
2203
2204 for (int i=0; i<Lcell; ++i)
2205 for (int j=0; j<Lcell; ++j)
2206 {
2207
2208 for (int n=0; n<Ncells; ++n)
2209 {
2210// cout << "i=" << i << ", j=" << j << ", n=" << n << ", d=" << dcell[n*Lcell] << ", i_=" << (n*Lcell+i)%Ls << ", j_=" << (n*Lcell+j)%Ls << ", n_=" << n*Lcell << ", dFT=" << dcellFT[n*Lcell]+(i-j)/Ls << endl;
2211 for (int iq=0; iq<Nq; ++iq)
2212 {
2213 if (TRANSPOSE)
2214 {
2215 GwqCell[(n*Lcell+i)%Ls][(n*Lcell+j)%Ls].col(iq) += GwxCell[j][i].col(n) * exp(+1.i*qvals(iq)*double(dcellFT[n*Lcell]+(j-i)/Ls));
2216 G0qCell[(n*Lcell+i)%Ls][(n*Lcell+j)%Ls](iq) += G0xCell[j][i] (n) * exp(+1.i*qvals(iq)*double(dcellFT[n*Lcell]+(j-i)/Ls));
2217 }
2218 else
2219 {
2220 GwqCell[(n*Lcell+i)%Ls][(n*Lcell+j)%Ls].col(iq) += GwxCell[i][j].col(n) * exp(-1.i*qvals(iq)*double(dcellFT[n*Lcell]+(i-j)/Ls));
2221 G0qCell[(n*Lcell+i)%Ls][(n*Lcell+j)%Ls](iq) += G0xCell[i][j] (n) * exp(-1.i*qvals(iq)*double(dcellFT[n*Lcell]+(i-j)/Ls));
2222 }
2223 }
2224 }
2225 }
2226
2227 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
2228 {
2229 lout << FourierWatch.info(label+" FT intercell x→q (const ω)") << endl;
2230 }
2231}
2232
2233template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2235FT_tw (const MatrixXcd &Gtq, MatrixXcd &Gwq, VectorXcd &G0q, VectorXcd &Glocw)
2236{
2237 IntervalIterator w(wmin,wmax,Nw);
2238 ArrayXd wvals = w.get_abscissa();
2239 Gwq.resize(Nw,Nq); Gwq.setZero();
2240 G0q.resize(Nq); G0q.setZero();
2241
2242 Stopwatch<> FourierWatch;
2243
2244 if (GREENINT_CHOICE == DIRECT)
2245 {
2246 for (int iw=0; iw<wvals.rows(); ++iw)
2247 {
2248 double wval = wvals(iw);
2249
2250 for (int it=0; it<tvals.rows(); ++it)
2251 {
2252 double tval = tvals(it);
2253 // If Gaussian integration is employed, the damping is already included in the weights
2254 Gwq.row(iw) += weights(it) * exp(+1.i*wval*tval) * Gtq.row(it);
2255 }
2256 }
2257 }
2258 else if (GREENINT_CHOICE == INTERP)
2259 {
2260// for (int iw=0; iw<wvals.rows(); ++iw)
2261// {
2262// double wval = wvals(iw);
2263//
2264// for (int iq=0; iq<Nq; ++iq)
2265// {
2266// ComplexInterpol Gtq_interp(tvals);
2267// for (int it=0; it<tvals.rows(); ++it)
2268// {
2269// double tval = tvals(it);
2270// complex<double> Gval = exp(+1.i*wval*tval) * GreenPropagatorGlobal::damping(tval) * Gtq(it,iq);
2271// Gtq_interp.insert(it,Gval);
2272// }
2273// Gwq(iw,iq) += Gtq_interp.integrate();
2274// Gtq_interp.kill_splines();
2275// }
2276// }
2277 #pragma omp parallel for
2278 for (int iq=0; iq<Nq; ++iq)
2279 {
2280 VectorXcd fvals = Gtq.col(iq);
2281 for (int it=0; it<tvals.rows(); ++it) fvals(it) *= GreenPropagatorGlobal::damping(tvals(it));
2282 Gwq.col(iq) = ::FT_interpol(tvals,fvals,USE_QAWO,wmin,wmax,Nw);
2283 }
2284 }
2285 else if (GREENINT_CHOICE == OOURA)
2286 {
2287 #pragma omp parallel for
2288 for (int iq=0; iq<Nq; ++iq)
2289 {
2290 VectorXcd fvals = Gtq.col(iq);
2291 for (int it=0; it<tvals.rows(); ++it) fvals(it) *= GreenPropagatorGlobal::damping(tvals(it));
2292 Gwq.col(iq) = Ooura::FT(tvals,fvals,h_ooura,wmin,wmax,Nw);
2293 }
2294 }
2295
2296 if (GREENINT_CHOICE == DIRECT)
2297 {
2298 for (int it=0; it<tvals.rows(); ++it)
2299 {
2300 double tval = tvals(it);
2301 // If Gaussian integration is employed, the damping is already included in the weights
2302 G0q += weights(it) * Gtq.row(it);
2303 }
2304 }
2305 else if (GREENINT_CHOICE == INTERP or GREENINT_CHOICE == OOURA)
2306 {
2307 for (int iq=0; iq<Nq; ++iq)
2308 {
2309 ComplexInterpol Gtq_interp(tvals);
2310 for (int it=0; it<tvals.rows(); ++it)
2311 {
2312 double tval = tvals(it);
2313 complex<double> Gval = GreenPropagatorGlobal::damping(tval) * Gtq(it,iq);
2314 Gtq_interp.insert(it,Gval);
2315 }
2316 G0q(iq) += Gtq_interp.integrate();
2317 Gtq_interp.kill_splines();
2318 }
2319 }
2320
2321 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::ON_EXIT)
2322 {
2323 lout << FourierWatch.info(label+" FT t→ω (const q)");
2324 if (GREENINT_CHOICE == INTERP) lout << boolalpha << ", USE_QAWO=" << USE_QAWO;
2325 lout << endl;
2326 }
2327
2328 // Calculate FT of local Green's function
2329 Glocw = FTloc_tw(Gloct,wvals);
2330}
2331
2332template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2334FTxx_tw (const MatrixXcd &Gtx, MatrixXcd &Gwx, VectorXcd &G0x, VectorXcd &Glocw)
2335{
2336 IntervalIterator w(wmin,wmax,Nw);
2337 ArrayXd wvals = w.get_abscissa();
2338 int Nx = Gtx.cols();
2339 Gwx.resize(Nw,Nx); Gwx.setZero();
2340 G0x.resize(Nx); G0x.setZero();
2341
2342 Stopwatch<> FourierWatch;
2343
2344 if (GREENINT_CHOICE == DIRECT)
2345 {
2346 for (int iw=0; iw<wvals.rows(); ++iw)
2347 {
2348 double wval = wvals(iw);
2349
2350 for (int it=0; it<tvals.rows(); ++it)
2351 {
2352 double tval = tvals(it);
2353 // If Gaussian integration is employed, the damping is already included in the weights
2354 Gwx.row(iw) += weights(it) * exp(+1.i*wval*tval) * Gtx.row(it);
2355 }
2356 }
2357 }
2358 else if (GREENINT_CHOICE == INTERP)
2359 {
2360 #pragma omp parallel for
2361 for (int ix=0; ix<Nx; ++ix)
2362 {
2363 VectorXcd fvals = Gtx.col(ix);
2364 for (int it=0; it<tvals.rows(); ++it) fvals(it) *= GreenPropagatorGlobal::damping(tvals(it));
2365 Gwx.col(ix) = ::FT_interpol(tvals,fvals,USE_QAWO,wmin,wmax,Nw);
2366 }
2367 }
2368 else if (GREENINT_CHOICE == OOURA)
2369 {
2370 #pragma omp parallel for
2371 for (int ix=0; ix<Nx; ++ix)
2372 {
2373 VectorXcd fvals = Gtx.col(ix);
2374 for (int it=0; it<tvals.rows(); ++it) fvals(it) *= GreenPropagatorGlobal::damping(tvals(it));
2375 Gwx.col(ix) = Ooura::FT(tvals,fvals,h_ooura,wmin,wmax,Nw);
2376 }
2377 }
2378
2379 if (GREENINT_CHOICE == DIRECT)
2380 {
2381 for (int it=0; it<tvals.rows(); ++it)
2382 {
2383 double tval = tvals(it);
2384 // If Gaussian integration is employed, the damping is already included in the weights
2385 G0x += weights(it) * Gtx.row(it);
2386 }
2387 }
2388 else if (GREENINT_CHOICE == INTERP or GREENINT_CHOICE == OOURA)
2389 {
2390 for (int ix=0; ix<Nx; ++ix)
2391 {
2392 ComplexInterpol Gtx_interp(tvals);
2393 for (int it=0; it<tvals.rows(); ++it)
2394 {
2395 double tval = tvals(it);
2396 complex<double> Gval = GreenPropagatorGlobal::damping(tval) * Gtx(it,ix);
2397 Gtx_interp.insert(it,Gval);
2398 }
2399 G0x(ix) += Gtx_interp.integrate();
2400 Gtx_interp.kill_splines();
2401 }
2402 }
2403
2404 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::ON_EXIT)
2405 {
2406 lout << FourierWatch.info(label+" FT t→ω (const x)");
2407 if (GREENINT_CHOICE == INTERP) lout << boolalpha << ", USE_QAWO=" << USE_QAWO;
2408 lout << endl;
2409 }
2410
2411 // Calculate FT of local Green's function
2412 Glocw = FTloc_tw(Gloct,wvals);
2413}
2414
2415//template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2416//void GreenPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar>::
2417//FTww_xq (const MatrixXcd &Gwx, const MatrixXcd &G0x, MatrixXcd &Gwq, VectorXcd &G0q)
2418//{
2419// IntervalIterator q(qmin,qmax,Nq);
2420// int Nx = Gwx.cols();
2421// ArrayXd qvals = q.get_abscissa();
2422// Gwq.resize(Nw,Nq); Gwq.setZero();
2423// G0q.resize(Nq); G0q.setZero();
2424//
2425// Stopwatch<> FourierWatch;
2426//
2427// // Explicit FT
2428// for (int iq=0; iq<Nq; ++iq)
2429// for (int ix=0; ix<Nx; ++ix)
2430// {
2431// Gtq.col(iq) += Gtx.col(ix) * exp(-1.i*qvals(iq)*xvals[ix]);
2432// G0q(iq) += G0x(ix) * exp(-1.i*qvals(iq)*xvals[ix]);
2433// }
2434//
2435// if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::HALFSWEEPWISE)
2436// {
2437// lout << FourierWatch.info("FT x→q (const ω)") << endl;
2438// }
2439//}
2440
2441template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2443FTcell_tw()
2444{
2445 IntervalIterator w(wmin,wmax,Nw);
2446 ArrayXd wvals = w.get_abscissa();
2447
2448 GwqCell.resize(Lcell); for (int i=0; i<Lcell; ++i) GwqCell[i].resize(Lcell);
2449 G0qCell.resize(Lcell); for (int i=0; i<Lcell; ++i) G0qCell[i].resize(Lcell);
2450 GlocwCell.resize(Lcell);
2451
2452 Stopwatch<> FourierWatch;
2453
2454 for (int i=0; i<Lcell; ++i)
2455 for (int j=0; j<Lcell; ++j)
2456 {
2457 GwqCell[i][j].resize(Nw,Nq); GwqCell[i][j].setZero();
2458
2459 if (GREENINT_CHOICE == DIRECT)
2460 {
2461 for (int iw=0; iw<wvals.rows(); ++iw)
2462 {
2463 double wval = wvals(iw);
2464
2465 for (int it=0; it<tvals.rows(); ++it)
2466 {
2467 double tval = tvals(it);
2468 // If Gaussian integration is employed, the damping is already included in the weights
2469 GwqCell[i][j].row(iw) += weights(it) * exp(+1.i*wval*tval) * GtqCell[i][j].row(it);
2470 }
2471 }
2472 }
2473 else if (GREENINT_CHOICE == INTERP)
2474 {
2475 #pragma omp parallel for
2476 for (int iq=0; iq<Nq; ++iq)
2477 {
2478 VectorXcd fvals = GtqCell[i][j].col(iq);
2479 for (int it=0; it<tvals.rows(); ++it) fvals(it) *= GreenPropagatorGlobal::damping(tvals(it));
2480 GwqCell[i][j].col(iq) = ::FT_interpol(tvals,fvals,USE_QAWO,wmin,wmax,Nw);
2481 }
2482 }
2483 else if (GREENINT_CHOICE == OOURA)
2484 {
2485 #pragma omp parallel for
2486 for (int iq=0; iq<Nq; ++iq)
2487 {
2488 VectorXcd fvals = GtqCell[i][j].col(iq);
2489 for (int it=0; it<tvals.rows(); ++it) fvals(it) *= GreenPropagatorGlobal::damping(tvals(it));
2490 GwqCell[i][j].col(iq) = Ooura::FT(tvals,fvals,h_ooura,wmin,wmax,Nw);
2491 }
2492 }
2493
2494 G0qCell[i][j].resize(Nq); G0qCell[i][j].setZero();
2495
2496 if (GREENINT_CHOICE == DIRECT)
2497 {
2498 for (int it=0; it<tvals.rows(); ++it)
2499 {
2500 double tval = tvals(it);
2501 // If Gaussian integration is employed, the damping is already included in the weights
2502 G0qCell[i][j] += weights(it) * GtqCell[i][j].row(it);
2503 }
2504 }
2505 else if (GREENINT_CHOICE == INTERP or GREENINT_CHOICE == OOURA)
2506 {
2507 for (int iq=0; iq<Nq; ++iq)
2508 {
2509 ComplexInterpol Gtq_interp(tvals);
2510 for (int it=0; it<tvals.rows(); ++it)
2511 {
2512 double tval = tvals(it);
2513 complex<double> Gval = GreenPropagatorGlobal::damping(tval) * GtqCell[i][j](it,iq);
2514 Gtq_interp.insert(it,Gval);
2515 }
2516 G0qCell[i][j](iq) += Gtq_interp.integrate();
2517 Gtq_interp.kill_splines();
2518 }
2519 }
2520
2521 // Calculate local Green's function
2522 if (i==j)
2523 {
2524 GlocwCell[i] = FTloc_tw(GloctCell[i],wvals);
2525 }
2526 }
2527
2528 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::ON_EXIT)
2529 {
2530 lout << FourierWatch.info(make_string(label+" FT intercell t→ω (const q), ωmin=",wmin,", ωmax=",wmax,", Nω=",Nw));
2531 if (GREENINT_CHOICE == INTERP) lout << boolalpha << ", USE_QAWO=" << USE_QAWO;
2532 lout << endl;
2533 }
2534}
2535
2536template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2539{
2540 IntervalIterator w(wmin,wmax,Nw);
2541 ArrayXd wvals = w.get_abscissa();
2542
2543 GwxCell.resize(Lcell); for (int i=0; i<Lcell; ++i) GwxCell[i].resize(Lcell);
2544 G0xCell.resize(Lcell); for (int i=0; i<Lcell; ++i) G0xCell[i].resize(Lcell);
2545 GlocwCell.resize(Lcell);
2546 int Nx = GtxCell[0][0].cols();
2547
2548 Stopwatch<> FourierWatch;
2549
2550 for (int i=0; i<Lcell; ++i)
2551 for (int j=0; j<Lcell; ++j)
2552 {
2553 GwxCell[i][j].resize(Nw,Nx); GwxCell[i][j].setZero();
2554
2555 if (GREENINT_CHOICE == DIRECT)
2556 {
2557 for (int iw=0; iw<wvals.rows(); ++iw)
2558 {
2559 double wval = wvals(iw);
2560
2561 for (int it=0; it<tvals.rows(); ++it)
2562 {
2563 double tval = tvals(it);
2564 // If Gaussian integration is employed, the damping is already included in the weights
2565 GwxCell[i][j].row(iw) += weights(it) * exp(+1.i*wval*tval) * GtxCell[i][j].row(it);
2566 }
2567 }
2568 }
2569 else if (GREENINT_CHOICE == INTERP)
2570 {
2571 #pragma omp parallel for
2572 for (int ix=0; ix<Nx; ++ix)
2573 {
2574 VectorXcd fvals = GtxCell[i][j].col(ix);
2575 for (int it=0; it<tvals.rows(); ++it) fvals(it) *= GreenPropagatorGlobal::damping(tvals(it));
2576 GwxCell[i][j].col(ix) = ::FT_interpol(tvals,fvals,USE_QAWO,wmin,wmax,Nw);
2577 }
2578 }
2579 else if (GREENINT_CHOICE == OOURA)
2580 {
2581 #pragma omp parallel for
2582 for (int ix=0; ix<Nx; ++ix)
2583 {
2584 VectorXcd fvals = GtxCell[i][j].col(ix);
2585 for (int it=0; it<tvals.rows(); ++it) fvals(it) *= GreenPropagatorGlobal::damping(tvals(it));
2586 GwxCell[i][j].col(ix) = Ooura::FT(tvals,fvals,h_ooura,wmin,wmax,Nw);
2587 }
2588 }
2589
2590 G0xCell[i][j].resize(Nx); G0xCell[i][j].setZero();
2591
2592 if (GREENINT_CHOICE == DIRECT)
2593 {
2594 for (int it=0; it<tvals.rows(); ++it)
2595 {
2596 double tval = tvals(it);
2597 // If Gaussian integration is employed, the damping is already included in the weights
2598 G0xCell[i][j] += weights(it) * GtxCell[i][j].row(it);
2599 }
2600 }
2601 else if (GREENINT_CHOICE == INTERP or GREENINT_CHOICE == OOURA)
2602 {
2603 for (int ix=0; ix<Nx; ++ix)
2604 {
2605 ComplexInterpol Gtx_interp(tvals);
2606 for (int it=0; it<tvals.rows(); ++it)
2607 {
2608 double tval = tvals(it);
2609 complex<double> Gval = GreenPropagatorGlobal::damping(tval)* GtxCell[i][j](it,ix);
2610 Gtx_interp.insert(it,Gval);
2611 }
2612 G0xCell[i][j](ix) += Gtx_interp.integrate();
2613 Gtx_interp.kill_splines();
2614 }
2615 }
2616
2617 // Calculate local Green's function
2618 if (i==j)
2619 {
2620 GlocwCell[i] = FTloc_tw(GloctCell[i],wvals);
2621 }
2622 }
2623
2624 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::ON_EXIT)
2625 {
2626 lout << FourierWatch.info(make_string(label+" FT intercell t→ω (const x), ωmin=",wmin,", ωmax=",wmax,", Nω=",Nw));
2627 if (GREENINT_CHOICE == INTERP) lout << boolalpha << ", USE_QAWO=" << USE_QAWO;
2628 lout << endl;
2629 }
2630}
2631
2632template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2634FTloc_tw (const VectorXcd &Gloct_in, const ArrayXd &wvals)
2635{
2636 ArrayXcd Glocw_out(wvals.rows()); Glocw_out.setZero();
2637
2638 Stopwatch<> FourierWatch;
2639
2640 // Use normal summation to transform from t to w
2641 if (GREENINT_CHOICE == DIRECT)
2642 {
2643 for (int iw=0; iw<wvals.rows(); ++iw)
2644 {
2645 double wval = wvals(iw);
2646
2647 for (int it=0; it<tvals.rows(); ++it)
2648 {
2649 double tval = tvals(it);
2650 // If Gaussian integration is employed, the damping is already included in the weights
2651 Glocw_out(iw) += weights(it) * exp(+1.i*wval*tval) * Gloct_in(it);
2652 }
2653 }
2654 }
2655 else if (GREENINT_CHOICE == INTERP)
2656 {
2657 VectorXcd fvals = Gloct_in;
2658 for (int it=0; it<tvals.rows(); ++it) fvals(it) *= GreenPropagatorGlobal::damping(tvals(it));
2659 Glocw_out = ::FT_interpol(tvals, fvals, USE_QAWO, wvals(0), wvals(wvals.rows()-1), wvals.rows());
2660 }
2661 else if (GREENINT_CHOICE == OOURA)
2662 {
2663 VectorXcd fvals = Gloct_in;
2664 for (int it=0; it<tvals.rows(); ++it) fvals(it) *= GreenPropagatorGlobal::damping(tvals(it));
2665 Glocw_out = Ooura::FT(tvals, fvals, h_ooura, wvals(0), wvals(wvals.rows()-1), wvals.rows());
2666 }
2667
2668 return Glocw_out;
2669}
2670
2671//template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2672//void GreenPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar>::
2673//FT_allSites (bool TW_FIRST_XQ_SECOND)
2674//{
2675// IntervalIterator q(qmin,qmax,Nq);
2676// ArrayXd qvals = q.get_abscissa();
2677//
2678// Stopwatch<> FourierWatch;
2679//
2680// if (TW_FIRST_XQ_SECOND)
2681// {
2682// Gwq.resize(Nw,Nq); Gwq.setZero();
2683// G0q.resize(Nq); G0q.setZero();
2684//
2685// FTcellxx_tw();
2686//
2687// for (int iq=0; iq<Nq; ++iq)
2688// {
2689// for (int n=0; n<Ncells; ++n)
2690// for (int i=0; i<Lcell; ++i)
2691// for (int j=0; j<Lcell; ++j)
2692// {
2693// Gwq.col(iq) += 1./Lcell * GwxCell[i][j].col(n) * exp(-1.i*qvals(iq)*double(Lcell)*double(dcell[n*Lcell])) * exp(-1.i*qvals(iq)*double(i-j));
2694// G0q(iq) += 1./Lcell * G0xCell[i][j](n) * exp(-1.i*qvals(iq)*double(Lcell)*double(dcell[n*Lcell])) * exp(-1.i*qvals(iq)*double(i-j));
2695// }
2696// }
2697//
2698// Glocw = GlocwCell[0];
2699//
2700// lout << FourierWatch.info(label+" FT all sites x→q (const ω)");
2701// if (GREENINT_CHOICE == INTERP) lout << boolalpha << ", USE_QAWO=" << USE_QAWO;
2702// lout << endl;
2703// }
2704// else
2705// {
2706// Gtq.resize(Nt,Nq); Gtq.setZero();
2707//
2708// for (int iq=0; iq<Nq; ++iq)
2709// {
2710// for (int n=0; n<Ncells; ++n)
2711// for (int i=0; i<Lcell; ++i)
2712// for (int j=0; j<Lcell; ++j)
2713// {
2714// Gtq.col(iq) += 1./Lcell * GtxCell[i][j].col(n) * exp(-1.i*qvals(iq)*double(Lcell)*double(dcell[n*Lcell])) * exp(-1.i*qvals(iq)*double(i-j));
2715// }
2716// }
2717//
2718// lout << FourierWatch.info(label+" FT all sites x→q (const t)") << endl;
2719//
2720// Gloct.resize(Nt);
2721// Gloct = GloctCell[0];
2722//
2723// FT_tw(Gtq,Gwq,G0q,Glocw);
2724// }
2725//}
2726
2727template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2729recalc_FTw (double wmin_new, double wmax_new, int Nw_new)
2730{
2731 wmin = wmin_new;
2732 wmax = wmax_new;
2733 Nw = Nw_new;
2734
2735 if (NQ == 0)
2736 {
2737// FT_xq(Gtx,Gtq);
2738// FT_tw(Gtq,Gwq,G0q,Glocw);
2739
2740 FTxx_tw(Gtx,Gwx,G0x,Glocw);
2741// FTww_xq(Gwx,G0x,Gwq,G0q);
2742 }
2743// else
2744// {
2745// for (int iQ=0; iQ<NQ; ++iQ)
2746// {
2747// GtqQmulti.resize(NQ);
2748// FT_xq(GtxQmulti[iQ],GtqQmulti[iQ]);
2749// GwqQmulti.resize(NQ);
2750// G0qQmulti.resize(NQ);
2751// GlocwQmulti.resize(NQ);
2752// FT_tw(GtqQmulti[iQ],GwqQmulti[iQ],G0qQmulti[iQ],GlocwQmulti[iQ]);
2753// }
2754// }
2755}
2756
2757template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2759recalc_FTwCell (double wmin_new, double wmax_new, int Nw_new, bool TRANSPOSE)
2760{
2761 wmin = wmin_new;
2762 wmax = wmax_new;
2763 Nw = Nw_new;
2764
2765// FTcell_xq();
2766// FTcell_tw();
2767 FTcellxx_tw();
2768 FTcellww_xq(TRANSPOSE);
2769}
2770
2771//template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2772//double GreenPropagator<Hamiltonian,Symmetry,MpoScalar,TimeScalar>::
2773//integrate_Glocw (double mu, int Nint)
2774//{
2775// Quadrator<GAUSS_LEGENDRE> Q;
2776//
2777// ArrayXd wabscissa(Nint);
2778// for (int i=0; i<Nint; ++i) {wabscissa(i) = Q.abscissa(i,wmin,mu,Nint);}
2779//
2780// ArrayXd QDOS = -1.*M_1_PI * FTloc_tw(Gloct,wabscissa).imag();
2781//
2782// return (Q.get_weights(wmin,mu,Nint) * QDOS).sum();
2783//}
2784
2785template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2787integrate_Glocw_cell (double mu, int Nint)
2788{
2789// Quadrator<GAUSS_LEGENDRE> Q;
2790//
2791// ArrayXd wabscissa(Nint);
2792// for (int i=0; i<Nint; ++i) {wabscissa(i) = Q.abscissa(i,wmin,mu,Nint);}
2793//
2794// ArrayXd QDOS = -1.*M_1_PI * FTloc_tw(GloctCell[0],wabscissa).imag();
2795// for (int b=1; b<Lcell; ++b)
2796// {
2797// QDOS += -1.*M_1_PI * FTloc_tw(GloctCell[b],wabscissa).imag();
2798// }
2799//
2800// return (Q.get_weights(wmin,mu,Nint) * QDOS).sum();
2801
2802 IntervalIterator w(wmin,wmax,GlocwCell[0].rows());
2803 VectorXd QDOS = -M_1_PI * GlocwCell[0].imag();
2804 for (int b=1; b<Lcell/Ns; ++b)
2805 {
2806 QDOS += -M_1_PI * GlocwCell[b].imag();
2807 }
2808 QDOS /= (Lcell/Ns);
2809
2810 Interpol<GSL> QDOSinterpol(w.get_abscissa());
2811 QDOSinterpol = QDOS;
2812
2813 double res ;
2814 if ((abs(mu-wmin)<::mynumeric_limits<double>::epsilon()))
2815 {
2816 res = 0.;
2817 }
2818 else if ((abs(mu-wmax)<::mynumeric_limits<double>::epsilon()))
2819 {
2820 res = Hamiltonian::spinfac * QDOSinterpol.integrate();
2821 }
2822 else
2823 {
2824 res = Hamiltonian::spinfac * QDOSinterpol.integrate(mu);
2825 }
2826 return res;
2827}
2828
2829template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2831INTinfo() const
2832{
2833 stringstream ss;
2834 ss << "INT=" << GREENINT_CHOICE;
2835 return ss.str();
2836}
2837
2838
2839template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2841xinfo() const
2842{
2843 stringstream ss;
2844 if (j0==-1)
2845 {
2846 ss << "L=" << Lcell << "x" << Ncells;
2847 }
2848 else
2849 {
2850 ss << "L=" << Lhetero << "_j0=" << j0;
2851 }
2852 if (dLphys==2) ss << "_dLphys=" << dLphys;
2853 return ss.str();
2854}
2855
2856template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2858qinfo() const
2859{
2860 stringstream ss;
2861 int qmin_pi, qmax_pi;
2862 if (Q_RANGE_CHOICE==MPI_PPI) {qmin_pi=-1; qmax_pi=1;}
2863 else if (Q_RANGE_CHOICE==ZERO_2PI) {qmin_pi=0; qmax_pi=2;}
2864 ss << "qmin=" << qmin_pi << "_qmax=" << qmax_pi;
2865 return ss.str();
2866}
2867
2868template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2870tinfo() const
2871{
2872 stringstream ss;
2873 ss << "tmax=" << tmax;
2874 return ss.str();
2875}
2876
2877template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2879winfo() const
2880{
2881 stringstream ss;
2882 ss << "wmin=" << wmin << "_wmax=" << wmax;
2883 if (j0 == -1) ss << "_Ns=" << Ns;
2884// << "_Nw=" << Nw;
2885 return ss.str();
2886}
2887
2888template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2890xt_info() const
2891{
2892 return xinfo() + "_" + tinfo();
2893}
2894
2895template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2897xtINTqw_info() const
2898{
2899 return xinfo() + "_" + tinfo() + "_" + INTinfo() + "_" + qinfo() + "_" + winfo();
2900}
2901
2902template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2904xtq_info() const
2905{
2906 return xinfo() + "_" + tinfo() + "_" + qinfo();
2907}
2908
2909template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2911print_starttext() const
2912{
2913 if (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::ON_EXIT)
2914 {
2915 #pragma omp critical
2916 {
2917 lout << "tmax=" << tmax
2918 << ", tpoints=" << Nt
2919 << ", max(tstep)=" << tsteps.maxCoeff()
2920 << ", tol_compr=" << tol_compr
2921 << ", tol_Lanczos=" << tol_Lanczos
2922 << ", tol_DeltaS=" << tol_DeltaS
2923 << ", INT=" << GREENINT_CHOICE;
2924 lout << endl;
2925 lout << endl << termcolor::colorize << termcolor::bold
2926 << "———————————————————————————————————"
2927 << " GreenPropagator "
2928 << label
2929 << " ———————————————————————————————————"
2930 << termcolor::reset << endl << endl;
2931 }
2932 }
2933}
2934
2935template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
2937save (bool IGNORE_TX) const
2938{
2939 #pragma omp critical
2940 {
2941 bool PRINT = (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::ON_EXIT)? true:false;
2942
2943 IntervalIterator w(wmin,wmax,Nw);
2944 ArrayXd wvals = w.get_abscissa();
2945
2946 if (!IGNORE_TX)
2947 {
2948 #ifdef GREENPROPAGATOR_USE_HDF5
2949 lout << "tx-file: " << label+"_"+xt_info()+".h5" << endl;
2950 HDF5Interface target_tx(label+"_"+xt_info()+".h5",WRITE);
2951 target_tx.create_group("G");
2952 if (NQ>0)
2953 {
2954 for (int iQ=0; iQ<NQ; ++iQ)
2955 {
2956 stringstream ss; ss << ".Q" << iQ;
2957 target_tx.create_group("G"); target_tx.create_group("G"+ss.str());
2958 }
2959 }
2960 //---
2961 target_tx.create_group("tinfo");
2962 target_tx.save_vector(VectorXd(tvals),"tvals","tinfo");
2963 target_tx.save_vector(VectorXd(weights),"weights","tinfo");
2964 target_tx.save_vector(VectorXd(tsteps),"tsteps","tinfo");
2965 target_tx.save_scalar(tmax,"tmax","tinfo");
2966 //---
2967 #endif
2968
2969 if (GtxCell.size() > 0)
2970 {
2971 for (int i=0; i<Lcell; ++i)
2972 for (int j=0; j<Lcell; ++j)
2973 {
2974 string Gstring = (i<10 and j<10)? make_string("G",i,j) : make_string("G",i,"_",j);
2975 #ifdef GREENPROPAGATOR_USE_HDF5
2976 if (PRINT) lout << label << " saving " << Gstring << "[txRe], " << Gstring << "[txIm] " << endl;
2977 target_tx.create_group(Gstring);
2978 target_tx.save_matrix(MatrixXd(GtxCell[i][j].real()),"txRe",Gstring);
2979 target_tx.save_matrix(MatrixXd(GtxCell[i][j].imag()),"txIm",Gstring);
2980 #else
2981 saveMatrix(GtxCell[i][j].real(), make_string(label,"_G=txRe_i=",i,"_j=",j,"_",xt_info(),".dat"), PRINT);
2982 saveMatrix(GtxCell[i][j].imag(), make_string(label,"_G=txIm_i=",i,"_j=",j,"_",xt_info(),".dat"), PRINT);
2983 #endif
2984 }
2985 }
2986
2987 if (GloctCell.size() > 0)
2988 {
2989 for (int i=0; i<Lcell; ++i)
2990 {
2991 string Gstring = make_string("G",i);
2992 #ifdef GREENPROPAGATOR_USE_HDF5
2993 target_tx.create_group(Gstring);
2994 target_tx.save_vector(VectorXd(GloctCell[i].real()),"t0Re",Gstring);
2995 target_tx.save_vector(VectorXd(GloctCell[i].imag()),"t0Im",Gstring);
2996 #else
2997 save_xy(tvals, GloctCell[i].real(), GloctCell[i].imag(), make_string(label,"_G=t0_i=",i,"_",xt_info(),".dat"), PRINT);
2998 #endif
2999 }
3000 }
3001
3002 if (Gtx.size() > 0)
3003 {
3004 #ifdef GREENPROPAGATOR_USE_HDF5
3005 if (PRINT) lout << label << " saving G[txRe], G[txIm]" << endl;
3006 target_tx.save_matrix(MatrixXd(Gtx.real()),"txRe","G");
3007 target_tx.save_matrix(MatrixXd(Gtx.imag()),"txIm","G");
3008 #else
3009 saveMatrix(Gtx.real(), label+"_G=txRe_"+xt_info()+".dat", PRINT);
3010 saveMatrix(Gtx.imag(), label+"_G=txIm_"+xt_info()+".dat", PRINT);
3011 #endif
3012 }
3013
3014 #ifdef GREENPROPAGATOR_USE_HDF5
3015 target_tx.close();
3016 #endif
3017 }
3018
3019 #ifdef GREENPROPAGATOR_USE_HDF5
3020 lout << "ωq-file: " << label+"_"+xtINTqw_info()+".h5" << endl;
3021 HDF5Interface target_wq(label+"_"+xtINTqw_info()+".h5",WRITE);
3022 target_wq.create_group("G");
3023 if (NQ>0)
3024 {
3025 for (int iQ=0; iQ<NQ; ++iQ)
3026 {
3027 stringstream ss; ss << ".Q" << iQ;
3028 target_wq.create_group("G"); target_wq.create_group("G"+ss.str());
3029 }
3030 }
3031 target_wq.create_group("tinfo");
3032 target_wq.save_vector(VectorXd(tvals),"t","");
3033 #endif
3034
3035 if (Gwx.size() > 0)
3036 {
3037 #ifdef GREENPROPAGATOR_USE_HDF5
3038 if (PRINT) lout << label << " saving G[ωxRe], G[ωxIm]" << endl;
3039 target_wq.save_matrix(MatrixXd(Gwx.real()),"ωxRe","G");
3040 target_wq.save_matrix(MatrixXd(Gwx.imag()),"ωxIm","G");
3041 if (G0x.size() > 0)
3042 {
3043 if (PRINT) lout << label << " saving G[0xRe], G[0xIm]" << endl;
3044 target_wq.save_matrix(MatrixXd(G0x.real()),"0xRe","G");
3045 target_wq.save_matrix(MatrixXd(G0x.imag()),"0xIm","G");
3046 }
3047 #else
3048 saveMatrix(Gwx.real(), label+"_G=ωxRe_"+xtINTqw_info()+".dat", PRINT);
3049 saveMatrix(Gwx.imag(), label+"_G=ωxIm_"+xtINTqw_info()+".dat", PRINT);
3050 if (G0x.size() > 0)
3051 {
3052 saveMatrix(G0x.real(), make_string(label,"_G=0xRe_",xtINTqw_info(),".dat"), PRINT);
3053 saveMatrix(G0x.imag(), make_string(label,"_G=0xIm_",xtINTqw_info(),".dat"), PRINT);
3054 }
3055 #endif
3056 }
3057
3058 if (Gwq.size() > 0)
3059 {
3060 #ifdef GREENPROPAGATOR_USE_HDF5
3061 if (PRINT) lout << label << " saving G[ωqRe], G[ωqIm]" << endl;
3062 target_wq.save_matrix(MatrixXd(Gwq.real()),"ωqRe","G");
3063 target_wq.save_matrix(MatrixXd(Gwq.imag()),"ωqIm","G");
3064 if (G0q.size() > 0)
3065 {
3066 if (PRINT) lout << label << " saving G[0qRe], G[0qIm]" << endl;
3067 target_wq.save_matrix(MatrixXd(G0q.real()),"0qRe","G");
3068 target_wq.save_matrix(MatrixXd(G0q.imag()),"0qIm","G");
3069 }
3070 #else
3071 saveMatrix(Gwq.real(), label+"_G=ωqRe_"+xtINTqw_info()+".dat", PRINT);
3072 saveMatrix(Gwq.imag(), label+"_G=ωqIm_"+xtINTqw_info()+".dat", PRINT);
3073 if (G0q.size() > 0)
3074 {
3075 saveMatrix(G0q.real(), make_string(label,"_G=0qRe_",xtINTqw_info(),".dat"), PRINT);
3076 saveMatrix(G0q.imag(), make_string(label,"_G=0qIm_",xtINTqw_info(),".dat"), PRINT);
3077 }
3078 #endif
3079 }
3080//
3081// if (GtxQmulti.size() > 0 or GwqQmulti.size() > 0)
3082// {
3083// for (int iQ=0; iQ<NQ; ++iQ)
3084// {
3085// stringstream ss; ss << ".Q" << iQ;
3086//
3087// #ifdef GREENPROPAGATOR_USE_HDF5
3088// if (PRINT) lout << label << " saving G[txRe], G[txIm], G[ωqRe], G[ωqIm], iQ=" << iQ << endl;
3089// target_tx.save_matrix(MatrixXd(GtxQmulti[iQ].real()),"txRe","G"+ss.str());
3090// target_tx.save_matrix(MatrixXd(GtxQmulti[iQ].imag()),"txIm","G"+ss.str());
3091// target_wq.save_matrix(MatrixXd(GwqQmulti[iQ].real()),"ωqRe","G"+ss.str());
3092// target_wq.save_matrix(MatrixXd(GwqQmulti[iQ].imag()),"ωqIm","G"+ss.str());
3093// if (G0qQmulti[iQ].size() > 0)
3094// {
3095// if (PRINT) lout << label << " saving G[0qRe], G[0qIm], iQ=" << iQ << endl;
3096// target_wq.save_matrix(MatrixXd(G0qQmulti[iQ].real()),"0qRe","G"+ss.str());
3097// target_wq.save_matrix(MatrixXd(G0qQmulti[iQ].imag()),"0qIm","G"+ss.str());
3098// }
3099// #else
3100// saveMatrix(GtxQmulti[iQ].real(), label+"_G=txRe_"+xt_info()+ss.str()+".dat", PRINT);
3101// saveMatrix(GtxQmulti[iQ].imag(), label+"_G=txIm_"+xt_info()+ss.str()+".dat", PRINT);
3102// saveMatrix(GwqQmulti[iQ].real(), label+"_G=ωqRe_"+xtINTqw_info()+ss.str()+".dat", PRINT);
3103// saveMatrix(GwqQmulti[iQ].imag(), label+"_G=ωqIm_"+xtINTqw_info()+ss.str()+".dat", PRINT);
3104// if (G0qQmulti[iQ].size() > 0)
3105// {
3106// saveMatrix(G0qQmulti[iQ].real(), make_string(label,"_G=0qRe_",xtINTqw_info(),ss.str(),".dat"), PRINT);
3107// saveMatrix(G0qQmulti[iQ].imag(), make_string(label,"_G=0qIm_",xtINTqw_info(),ss.str(),".dat"), PRINT);
3108// }
3109// #endif
3110// }
3111// }
3112//
3113// if (Glocw.size() > 0 or Gloct.size() > 0)
3114// {
3115// #ifdef GREENPROPAGATOR_USE_HDF5
3116// if (PRINT) lout << label << " saving G[QDOS], G[t0Re], G[t0Im]" << endl;
3117// target_wq.save_matrix(MatrixXd(-M_1_PI*Glocw.imag()),"QDOS","G");
3118// target_tx.save_matrix(MatrixXd(Gloct.real()),"t0Re","G");
3119// target_tx.save_matrix(MatrixXd(Gloct.imag()),"t0Im","G");
3120// #else
3121// save_xy(wvals, -M_1_PI*Glocw.imag(), label+"_G=QDOS_"+xt_info()+".dat", PRINT);
3122// save_xy(tvals, Gloct.real(), Gloct.imag(), make_string(label,"_G=t0_",xt_info(),".dat"), PRINT);
3123// #endif
3124// }
3125//
3126// if (GlocwQmulti.size() > 0 or GloctQmulti.size() > 0)
3127// {
3128// for (int iQ=0; iQ<NQ; ++iQ)
3129// {
3130// stringstream ss; ss << ".Q" << iQ;
3131//
3132// #ifdef GREENPROPAGATOR_USE_HDF5
3133// if (PRINT) lout << label << " saving G[QDOS], G[t0Re], G[t0Im], iQ=" << iQ << endl;
3134// target_wq.save_matrix(MatrixXd(-M_1_PI*GlocwQmulti[iQ].imag()),"QDOS","G"+ss.str());
3135// target_tx.save_matrix(MatrixXd(GloctQmulti[iQ].real()),"t0Re","G"+ss.str());
3136// target_tx.save_matrix(MatrixXd(GloctQmulti[iQ].imag()),"t0Im","G"+ss.str());
3137// #else
3138// save_xy(wvals, -M_1_PI*GlocwQmulti[iQ].imag(), label+"_G=QDOS_"+xt_info()+ss.str()+".dat", PRINT);
3139// save_xy(tvals, GloctQmulti[iQ].real(), GloctQmulti[iQ].imag(), make_string(label,"_G=t0_",xt_info(),ss.str(),".dat"), PRINT);
3140// #endif
3141// }
3142// }
3143
3144 if (GwqCell.size() > 0)
3145 {
3146 for (int i=0; i<Lcell/Ns; ++i)
3147 for (int j=0; j<Lcell/Ns; ++j)
3148 {
3149 string Gstring = (i<10 and j<10)?make_string("G",i,j):make_string("G",i,"_",j);
3150 #ifdef GREENPROPAGATOR_USE_HDF5
3151 if (PRINT) lout << label << " saving " << Gstring << "[ωqRe], " << Gstring << "[ωqIm] " << endl;
3152 target_wq.create_group(Gstring);
3153 target_wq.save_matrix(MatrixXd(GwqCell[i][j].real()),"ωqRe",Gstring);
3154 target_wq.save_matrix(MatrixXd(GwqCell[i][j].imag()),"ωqIm",Gstring);
3155 if (G0qCell.size() > 0)
3156 {
3157 if (PRINT) lout << label << " saving " << Gstring << "[0qRe], " << Gstring << "[0qIm]" << endl;
3158 target_wq.save_vector(VectorXd(G0qCell[i][j].real()),"0qRe",Gstring);
3159 target_wq.save_vector(VectorXd(G0qCell[i][j].imag()),"0qIm",Gstring);
3160 }
3161 #else
3162 saveMatrix(GwqCell[i][j].real(), make_string(label,"_G=ωqRe_i=",i,"_j=",j,"_",xtINTqw_info(),".dat"), PRINT);
3163 saveMatrix(GwqCell[i][j].imag(), make_string(label,"_G=ωqIm_i=",i,"_j=",j,"_",xtINTqw_info(),".dat"), PRINT);
3164 if (G0qCell.size() > 0)
3165 {
3166 saveMatrix(G0qCell[i][j].real(), make_string(label,"_G=0qRe_i=",i,"_j=",j,"_",xtINTqw_info(),".dat"), PRINT);
3167 saveMatrix(G0qCell[i][j].imag(), make_string(label,"_G=0qIm_i=",i,"_j=",j,"_",xtINTqw_info(),".dat"), PRINT);
3168 }
3169 #endif
3170 }
3171 }
3172
3173 if (GlocwCell.size() > 0)
3174 {
3175 for (int i=0; i<Lcell/Ns; ++i)
3176 {
3177 string Gstring = make_string("G",i);
3178 #ifdef GREENPROPAGATOR_USE_HDF5
3179 if (PRINT) lout << label << " saving " << Gstring << "[QDOS], " << Gstring << "[t0Re], " << Gstring << "[t0Im]" << endl;
3180 if (PRINT) lout << label << " saving " << Gstring << "[QDOS], " << Gstring << "[t0Re], " << Gstring << "[t0Im]" << endl;
3181 target_wq.create_group(Gstring);
3182 target_wq.save_vector(VectorXd(-M_1_PI*GlocwCell[i].imag()),"QDOS",Gstring);
3183 #else
3184 save_xy(wvals, -M_1_PI*GlocwCell[i].imag(), make_string(label,"_G=QDOS_i=",i,"_",xtINTqw_info(),".dat"), PRINT);
3185 #endif
3186 }
3187 }
3188
3189 if (ncell.size() > 0)
3190 {
3191 if (PRINT) lout << label << " saving ncell" << endl;
3192 #ifdef GREENPROPAGATOR_USE_HDF5
3193 target_wq.save_vector(VectorXd(ncell),"ncell");
3194 #else
3195 saveMatrix(MatrixXd(ncell), "ncell", PRINT);
3196 #endif
3197 }
3198
3199 if (!std::isnan(mu))
3200 {
3201 if (PRINT) lout << label << " saving μ=" << mu << endl;
3202 #ifdef GREENPROPAGATOR_USE_HDF5
3203 target_wq.save_scalar(mu,"μ");
3204 #else
3205// saveMatrix(MatrixXd(mu), "μ", PRINT);
3206 #endif
3207 }
3208
3209 #ifdef GREENPROPAGATOR_USE_HDF5
3210 target_wq.close();
3211 #endif
3212
3213 if (Measure.size() != 0)
3214 {
3215 #ifdef GREENPROPAGATOR_USE_HDF5
3216 HDF5Interface target_measurment(make_string(measure_subfolder,"/",label+"_"+xt_info(),"_Op=",measure_name,".h5"),WRITE);
3217 for (int i=0; i<Lcell/Ns; ++i)
3218 {
3219 target_measurment.save_matrix(Measurement[i],make_string("i=",i));
3220 }
3221 target_measurment.create_group("tinfo");
3222 target_measurment.save_vector(VectorXd(tvals),"tvals","tinfo");
3223 target_measurment.save_vector(VectorXd(weights),"weights","tinfo");
3224 target_measurment.save_vector(VectorXd(tsteps),"tsteps","tinfo");
3225 target_measurment.close();
3226 #endif
3227 }
3228 }
3229}
3230
3231template<typename Hamiltonian, typename Symmetry, typename MpoScalar, typename TimeScalar>
3233save_GtqCell() const
3234{
3235 #pragma omp critical
3236 {
3237 bool PRINT = (CHOSEN_VERBOSITY >= DMRG::VERBOSITY::ON_EXIT)? true:false;
3238
3239 IntervalIterator w(wmin,wmax,Nw);
3240 ArrayXd wvals = w.get_abscissa();
3241
3242 lout << "tq-file: " << label+"_"+xtq_info()+".h5" << endl;
3243 HDF5Interface target_tq(label+"_"+xtq_info()+".h5",WRITE);
3244 target_tq.create_group("G");
3245
3246 if (GtqCell.size() > 0)
3247 {
3248 for (int i=0; i<Lcell; ++i)
3249 for (int j=0; j<Lcell; ++j)
3250 {
3251 string Gstring = (i<10 and j<10)?make_string("G",i,j):make_string("G",i,"_",j);
3252 #ifdef GREENPROPAGATOR_USE_HDF5
3253 if (PRINT) lout << label << " saving " << Gstring << "[tqRe], " << Gstring << "[tqIm] " << endl;
3254 target_tq.create_group(Gstring);
3255 target_tq.save_matrix(MatrixXd(GtqCell[i][j].real()),"tqRe",Gstring);
3256 target_tq.save_matrix(MatrixXd(GtqCell[i][j].imag()),"tqIm",Gstring);
3257 #else
3258 saveMatrix(GtqCell[i][j].real(), make_string(label,"_G=tqRe_i=",i,"_j=",j,"_",xtq_info(),".dat"), PRINT);
3259 saveMatrix(GtqCell[i][j].imag(), make_string(label,"_G=tqIm_i=",i,"_j=",j,"_",xtq_info(),".dat"), PRINT);
3260 #endif
3261 }
3262 }
3263 }
3264}
3265
3266#endif
Scalar dot(const Mps< Symmetry, Scalar > &Vbra, const Mps< Symmetry, Scalar > &Vket)
Array< Scalar, Dynamic, 1 > dot_green(const Mps< Symmetry, Scalar > &V1, const Mps< Symmetry, Scalar > &V2)
Scalar avg_hetero(const Mps< Symmetry, Scalar > &Vbra, const Mpo< Symmetry, MpoScalar > &O, const Mps< Symmetry, Scalar > &Vket, bool USE_BOUNDARY=false, size_t usePower=1ul, const qarray< Symmetry::Nq > &Qmid=Symmetry::qvacuum())
Scalar dot_hetero(const Mps< Symmetry, Scalar > &Vbra, const Mps< Symmetry, Scalar > &Vket, int Ncellshift=0)
Scalar avg(const Mps< Symmetry, Scalar > &Vbra, const Mpo< Symmetry, MpoScalar > &O, const Mps< Symmetry, Scalar > &Vket, size_t power_of_O=1ul, DMRG::DIRECTION::OPTION DIR=DMRG::DIRECTION::RIGHT, DMRG::VERBOSITY::OPTION CHOSEN_VERBOSITY=DMRG::VERBOSITY::SILENT)
Mpo< Symmetry, Scalar > diff(const Mpo< Symmetry, Scalar > &H1, const Mpo< Symmetry, Scalar > &H2, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
double norm(const PivotMatrix0< Symmetry, Scalar, MpoScalar > &H)
double isReal(double x)
Definition: DmrgTypedefs.h:21
Q_RANGE
@ ZERO_2PI
@ MPI_PPI
VectorXcd FT_interpol(const VectorXd &tvals, const VectorXcd &fvals, bool USE_QAWO, double wmin, double wmax, int wpoints)
std::ostream & operator<<(std::ostream &s, GREEN_INTEGRATION GI)
GREEN_INTEGRATION
@ DIRECT
@ OOURA
@ INTERP
double eps_truncWeight
Definition: DmrgJanitor.h:97
void entropy_skim()
Definition: DmrgJanitor.h:177
size_t max_Nsv
Definition: DmrgJanitor.h:98
vector< bool > TWO_SITE(int it, const MpsType &Psi, double r=1., vector< size_t > true_overrides={}, vector< size_t > false_overrides={})
vector< vector< MatrixXcd > > GwqCell
void calc_GreenCell(const int &tindex, const complex< double > &phase, const vector< Mps< Symmetry, complex< double > > > &OxPhi, const vector< Mps< Symmetry, complex< double > > > &Psi, int x0=0)
vector< VectorXcd > GlocwCell
void compute_one(int j0, const Hamiltonian &H, const vector< Mps< Symmetry, complex< double > > > &OxPhi, double Eg, bool TIME_FORWARDS=true)
vector< VectorXcd > GlocwQmulti
vector< MatrixXcd > GwqQmulti
vector< Mpo< Symmetry, MpoScalar > > Measure
vector< MatrixXcd > GtxQmulti
void set_measurement(const vector< Mpo< Symmetry, MpoScalar > > &Measure_input, int Lcell, int measure_interval_input=10, string measure_name_input="M", string measure_subfolder_input=".")
vector< VectorXcd > get_GlocwCell() const
void set_tol_DeltaS(double x)
GreenPropagator(string label_input, double tmax_input, int Nt_input, int Ns_input=1, double wmin_input=-10., double wmax_input=10., int Nw_input=501, Q_RANGE Q_RANGE_CHOICE_input=MPI_PPI, int Nq_input=501, GREEN_INTEGRATION GREENINT=OOURA)
void set_h_ooura(double x)
double integrate_Glocw_cell(double mu, int Nint=1000)
GreenPropagatorLog log
void set_tol_compr(double x)
GREEN_INTEGRATION GREENINT_CHOICE
void make_xarrays(int Lhetero_input, int Lcell_input, int Ncells_input, int Ns=1, bool PRINT=false)
string winfo() const
string xinfo() const
GreenPropagator(string label_input, int Lcell_input, int Ncells_input, int Ns_input, double tmax_input, const vector< vector< MatrixXcd > > &Gtx_input, Q_RANGE Q_RANGE_CHOICE_input=MPI_PPI, int Nq_input=501, GREEN_INTEGRATION GREENINT=OOURA)
void propagate_thermal_cell(const Hamiltonian &H, const vector< Mpo< Symmetry, MpoScalar > > &Ox, Mps< Symmetry, complex< double > > Phi, vector< Mps< Symmetry, complex< double > > > &OxPhi0, bool TIME_FORWARDS)
vector< int > dcellFT
string xtq_info() const
void set_OxPhiFull(const vector< Mps< Symmetry, complex< double > > > &OxPhiFull_input)
GreenPropagator(string label_input, int Lcell_input, double tmax_input, const MatrixXcd &Gtx_input, GREEN_INTEGRATION GREENINT=OOURA)
MatrixXcd get_Gtx() const
vector< MatrixXd > Measurement
vector< int > xinds
vector< vector< VectorXcd > > G0qCell
void save_log(int i, int tindex, double tval, const Mps< Symmetry, complex< double > > &Psi, const TDVPPropagator< Hamiltonian, Symmetry, MpoScalar, TimeScalar, Mps< Symmetry, complex< double > > > &TDVP, const EntropyObserver< Mps< Symmetry, complex< double > > > &Sobs, const vector< bool > &TWO_SITE)
string xt_info() const
vector< VectorXcd > GloctCell
vector< vector< VectorXcd > > G0xCell
vector< MatrixXcd > GtqQmulti
void set_Oshift(vector< MpoScalar > Oshift_input)
vector< VectorXcd > G0qQmulti
vector< int > dcell
void save_GtqCell() const
vector< VectorXcd > GloctQmulti
void set_log(string logfolder_input="./")
void FTcell_xq(bool TRANSPOSE=false)
vector< vector< MatrixXcd > > get_GwqCell() const
vector< double > xvals
void set_qlims(Q_RANGE CHOICE)
string tinfo() const
void print_starttext() const
void set_Lcell(int Lcell_input)
void calc_Green(const int &tindex, const complex< double > &phase, const vector< Mps< Symmetry, complex< double > > > &OxPhi, const Mps< Symmetry, complex< double > > &Psi)
void compute_cell(const Hamiltonian &H, const vector< Mps< Symmetry, complex< double > > > &OxPhiBra, const vector< Mps< Symmetry, complex< double > > > &OxPhiKet, double Eg, bool TIME_FORWARDS=true, bool COUNTERPROPAGATE=true, int x0=0)
void set_Qmulti(int NQ_input)
void FTxx_tw(const MatrixXcd &Gtx, MatrixXcd &Gwx, VectorXcd &G0x, VectorXcd &Glocw)
GreenPropagator(string label_input, int Lcell_input, int Ncells_input, int Ns_input, double tmax_input, const vector< string > &files, Q_RANGE Q_RANGE_CHOICE_input=MPI_PPI, int Nq_input=501, GREEN_INTEGRATION GREENINT=OOURA)
void propagate_cell(int x0, const Hamiltonian &H, const vector< Mps< Symmetry, complex< double > > > &OxPhi, double Eg, bool TIME_FORWARDS=true)
void FT_tw(const MatrixXcd &Gtq, MatrixXcd &Gwq, VectorXcd &G0q, VectorXcd &Glocw)
void recalc_FTw(double wmin_new, double wmax_new, int Nw_new=501)
string qinfo() const
void FTcellww_xq(bool TRANSPOSE=false)
void save(bool IGNORE_TX=false) const
void propagate_one(int j0, const Hamiltonian &H, const vector< Mps< Symmetry, complex< double > > > &OxPhi, double Eg, bool TIME_FORWARDS=true)
vector< vector< MatrixXcd > > GwxCell
ArrayXcd FTloc_tw(const VectorXcd &Gloct, const ArrayXd &wvals)
vector< Mps< Symmetry, complex< double > > > OxPhiFull
vector< vector< MatrixXcd > > GtqCell
void calc_GreenCell_thermal(const int &tindex, const vector< Mpo< Symmetry, MpoScalar > > &Ox, const vector< Mps< Symmetry, complex< double > > > &Psi)
void compute_thermal_cell(const Hamiltonian &H, const vector< Mpo< Symmetry, MpoScalar > > &Odag, const Mps< Symmetry, complex< double > > &Phi, vector< Mps< Symmetry, complex< double > > > &OxPhi0, bool TIME_FORWARDS)
void measure_wavepacket(const Mps< Symmetry, complex< double > > &Psi, double tval, int i=0)
void calc_Green_thermal(const int &tindex, const vector< Mpo< Symmetry, MpoScalar > > &Ox, const Mps< Symmetry, complex< double > > &Phi, const Mps< Symmetry, complex< double > > &Psi)
void set_verbosity(DMRG::VERBOSITY::OPTION VERBOSITY)
vector< vector< MatrixXcd > > get_GtxCell() const
vector< MpoScalar > Oshift
string xtINTqw_info() const
vector< vector< MatrixXcd > > GtxCell
DMRG::VERBOSITY::OPTION CHOSEN_VERBOSITY
vector< int > icell
void counterpropagate_cell(const Hamiltonian &H, const vector< Mps< Symmetry, complex< double > > > &OxPhiBra, const vector< Mps< Symmetry, complex< double > > > &OxPhiKet, double Eg, bool TIME_FORWARDS=true)
void set_lim_Nsv(size_t x)
void recalc_FTwCell(double wmin_new, double wmax_new, int Nw_new=501, bool TRANSPOSE=false)
string INTinfo() const
void set_dLphys(int x)
Definition: Mpo.h:40
Definition: Mps.h:39
string info() const
size_t calc_Mmax() const
ArrayXd get_truncWeight() const
Definition: Mps.h:465
string info() const
void t_step_adaptive(const Hamiltonian &H, VectorType &Vinout, TimeScalar dt, const vector< bool > &TWO_STEP_AT, int N_stages=1, double tol_Lanczos=1e-8)
static double damping(double tval)
static double gauss(double tval)
static double lorentz(double tval)
GreenPropagatorLog(int Nt, int L, string logfolder_input)
void save(string label) const