1#ifndef SPECTRAL_MANAGER
2#define SPECTRAL_MANAGER
9template<
typename Hamiltonian>
14 typedef typename Hamiltonian::Mpo::Scalar_
Scalar;
15 typedef typename Hamiltonian::Symmetry
Symmetry;
21 int Ncells_input,
const vector<Param> ¶ms_hetero,
22 string gs_label=
"gs",
bool LOAD_GS=
false,
bool SAVE_GS=
false,
24 double tol_OxV=2.,
int locyBra=0,
int locyKet=0);
28 string gs_label=
"gs",
bool LOAD_GS=
false,
bool SAVE_GS=
false,
30 double tol_OxV=2.,
int locy=0);
36 template<
typename HamiltonianThermal>
37 void beta_propagation (
const Hamiltonian &Hprop,
const HamiltonianThermal &Htherm,
int Lcell,
int dLphys,
38 double betamax_input,
double dbeta_input,
double tol_compr_beta_input,
size_t Mlim,
qarray<Symmetry::Nq> Q,
39 double s_betainit,
double betaswitch,
40 string wd,
string th_label,
bool LOAD_BETA=
false,
bool SAVE_BETA=
true,
42 vector<double> stateSavePoints={}, vector<string> stateSaveLabels={},
43 int Ntaylor=0,
bool CALC_C=
true,
bool CALC_CHI=
true,
bool USE_PHIT=
false);
48 string wd,
string th_label,
string LOAD_BETA,
bool SAVE_BETA,
50 vector<double> stateSavePoints, vector<string> stateSaveLabels,
51 bool CALC_C,
bool CALC_CHI);
55 void compute (
string wd,
string label,
int Ns,
double tmax,
double dt=0.2,
57 size_t Mlim=500ul,
double tol_DeltaS=1e-2,
double tol_compr=1e-4);
61 size_t Mlim=500ul,
double tol_DeltaS=1e-2,
double tol_compr=1e-4);
63 void compute_finite (
size_t j0,
string wd,
string label,
int Ns,
double tmax,
double dt=0.1,
65 size_t Mlim=500ul,
double tol_DeltaS=1e-2,
double tol_compr=1e-4);
69 size_t Mlim=500ul,
double tol_DeltaS=1e-2,
double tol_compr=1e-4);
71 void reload (
string wd,
const vector<string> &specs_input,
string label,
int L,
int Ncells,
int Ns,
double tmax,
75 const double &
energy()
const {
return g.energy;};
85 Mpo<Symmetry,Scalar> get_Op (
const Hamiltonian &H,
size_t loc, std::string spec,
double factor=1.,
size_t locy=0,
int dLphys=1);
87 void set_measurement (
int iz,
string spec,
double factor,
int dLphys,
qarray<Symmetry::Nq> Q,
int Lcell,
int measure_interval_input=10,
string measure_name_input=
"M",
string measure_subfolder_input=
".",
bool TRANSFORM=
false);
89 void resize_Green (
string wd,
string label,
int Ns,
double tmax,
double dt,
double wmin,
double wmax,
int wpoints,
Q_RANGE QR,
int qpoints,
GREEN_INTEGRATION INT);
97 return (spec==
"PES" or spec==
"PESUP" or spec==
"PESDN" or spec==
"AES" or spec==
"IPSZ" or spec==
"ICSF" or spec==
"SDAGSF" or spec==
"PDAGSF")?
false:
true;
100 static string DAG (std::string spec)
103 if (spec ==
"PES") res =
"IPE";
104 if (spec ==
"PESUP") res =
"IPEUP";
105 if (spec ==
"PESDN") res =
"IPEDN";
106 else if (spec ==
"SSF") res =
"SDAGSF";
107 else if (spec ==
"SPM") res =
"SMP";
108 else if (spec ==
"SMP") res =
"SPM";
109 else if (spec ==
"QSF") res =
"QDAGSF";
110 else if (spec ==
"SSZ") res =
"SSZ";
111 else if (spec ==
"IPE") res =
"PES";
112 else if (spec ==
"IPEUP") res =
"PESUP";
113 else if (spec ==
"IPEDN") res =
"PESDN";
114 else if (spec ==
"AES") res =
"APS";
115 else if (spec ==
"APS") res =
"AES";
116 else if (spec ==
"CSF") res =
"CSF";
117 else if (spec ==
"ICSF") res =
"ICSF";
118 else if (spec ==
"PSZ") res =
"PSZ";
119 else if (spec ==
"IPSZ") res =
"IPSZ";
120 else if (spec ==
"PSF") res =
"PDAGSF";
121 else if (spec ==
"PDAGSF")res =
"PSF";
122 else if (spec ==
"HSF") res =
"IHSF";
123 else if (spec ==
"IHSF") res =
"HSF";
124 else if (spec ==
"IHS") res =
"HSF";
125 else if (spec ==
"HTS") res =
"IHTS";
126 else if (spec ==
"IHTS") res =
"HTS";
132 std::array<string,26> possible_specs = {
"PES",
"PESUP",
"PESDN",
134 "IPE",
"IPEUP",
"IPEDN",
136 "CSF",
"ICSF",
"PSZ",
"IPSZ",
"PSF",
139 "JCJC",
"JEJE",
"JCJE",
"JEJC",
143 return find(possible_specs.begin(), possible_specs.end(), spec) != possible_specs.end();
168 Eigenstate<Umps<Symmetry,Scalar>>
g;
170 vector<GreenPropagator<Hamiltonian,typename Hamiltonian::Symmetry,Scalar,complex<double>>>
Green;
175 vector<vector<Mps<Symmetry,complex<double>>>>
OxPhiTt;
176 vector<vector<Mpo<typename Hamiltonian::Symmetry,Scalar>>>
Odag;
183template<
typename Hamiltonian>
186 int Ncells_input,
const vector<Param> ¶ms_hetero,
187 string gs_label,
bool LOAD_GS,
bool SAVE_GS,
189 double tol_OxV,
int locyBra,
int locyKet)
190:specs(specs_input), Ncells(Ncells_input), CHOSEN_VERB(VERB)
192 for (
const auto &spec:
specs)
194 assert(
CHECK_SPEC(spec) and
"Wrong spectral abbreviation!");
200 typename Hamiltonian::uSolver uDMRG(VERB);
204 g.state.load(gs_label,
g.energy);
205 lout <<
"loaded: " <<
g.state.info() << endl;
209 uDMRG.userSetGlobParam();
210 uDMRG.GlobParam = GlobSweepParams;
211 uDMRG.edgeState(H,
g,Q);
214 lout <<
"saving groundstate..." << endl;
215 g.state.save(gs_label,
"groundstate",
g.energy);
219 lout << setprecision(16) <<
"g.energy=" <<
g.energy << endl;
221 Hwork = Hamiltonian(
Lhetero,params_hetero,BC::INFINITE);
222 lout <<
"H_hetero: " <<
Hwork.info() << endl;
223 Hwork.transform_base(Q,
false,
L);
224 Hwork.precalc_TwoSiteData(
true);
230 vector<vector<Scalar>> OshiftKet(
Nspec);
231 for (
int z=0; z<
Nspec; ++z)
233 OshiftKet[z].resize(
L);
234 for (
int l=0; l<
L; ++l)
236 if (
specs[z] ==
"HSF")
239 OshiftKet[z][l] =
avg(
g.state,
get_Op(Haux,l,
specs[z],1.,locyKet),
g.state);
245 lout <<
"spec=" <<
specs[z] <<
", l=" << l <<
", shift=" << OshiftKet[z][l] << endl;
250 vector<vector<Mpo<Symmetry,Scalar>>> Oket(
Nspec);
251 for (
int z=0; z<
Nspec; ++z)
254 for (
int l=0; l<
L; ++l)
257 if (abs(OshiftKet[z][l]) > 1e-6)
259 Oket[z][l].scale(1.,-OshiftKet[z][l]);
261 Oket[z][l].transform_base(Q,
false,
L);
262 lout << Oket[z][l].info() << endl;
266 vector<vector<Mpo<Symmetry,Scalar>>> Obra(
Nspec);
267 if (locyBra == locyKet)
273 vector<vector<Scalar>> OshiftBra(
Nspec);
274 for (
int z=0; z<
Nspec; ++z)
276 OshiftBra[z].resize(
L);
277 for (
int l=0; l<
L; ++l)
279 if (
specs[z] ==
"HSF")
282 OshiftBra[z][l] =
avg(
g.state,
get_Op(Haux,l,
specs[z],1.,locyBra),
g.state);
288 lout <<
"spec=" <<
specs[z] <<
", l=" << l <<
", shift=" << OshiftBra[z][l] << endl;
292 for (
int z=0; z<
Nspec; ++z)
295 for (
int l=0; l<
L; ++l)
298 if (abs(OshiftBra[z][l]) > 1e-6)
300 Obra[z][l].scale(1.,-OshiftBra[z][l]);
302 Obra[z][l].transform_base(Q,
false,
L);
303 lout << Obra[z][l].info() << endl;
310 for (
int z=0; z<
Nspec; ++z)
315 auto tmpKet = uDMRG.create_Mps(
Ncells,
g, H, Oket[z][0], Oket[z], tol_OxV);
316 auto tmpBra = uDMRG.create_Mps(
Ncells,
g, H, Obra[z][0], Obra[z], tol_OxV);
318 for (
int l=0; l<
L; ++l)
320 OxPhiCellKet[z][l] = tmpKet[l].template cast<complex<double>>();
321 OxPhiCellBra[z][l] = tmpBra[l].template cast<complex<double>>();
326 lout << setprecision(16) <<
"Eg=" <<
Eg <<
", eg=" <<
g.energy << endl;
330template<
typename Hamiltonian>
334:specs(specs_input), CHOSEN_VERB(VERB)
336 for (
const auto &spec:
specs)
338 assert(
CHECK_SPEC(spec) and
"Wrong spectral abbreviation!");
345 typename Hamiltonian::Solver fDMRG(VERB);
350 lout <<
"loaded: " <<
gfinite.state.info() << endl;
354 fDMRG.userSetGlobParam();
355 fDMRG.GlobParam = GlobSweepParams;
359 lout <<
"saving groundstate..." << endl;
364 lout << setprecision(16) <<
"gfinite.energy=" <<
gfinite.energy << endl;
367 lout <<
"H: " <<
Hwork.info() << endl;
368 Hwork.precalc_TwoSiteData(
true);
375 for (
int z=0; z<
Nspec; ++z)
378 for (
int l=0; l<
L; ++l)
380 if (
specs[z] ==
"HSF")
389 lout <<
"spec=" <<
specs[z] <<
", l=" << l <<
", shift=" <<
Oshift[z][l] << endl;
394 vector<vector<Mpo<Symmetry,Scalar>>> O(
Nspec);
395 for (
int z=0; z<
Nspec; ++z)
398 for (
int l=0; l<
L; ++l)
401 if (O[z][l].Qtarget() == Symmetry::qvacuum())
403 O[z][l].scale(1.,-
Oshift[z][l]);
409 for (
int z=0; z<
Nspec; ++z)
412 for (
int l=0; l<
L; ++l)
417 OxPhiCellKet[z][l] = tmp.template cast<complex<double>>();
424template<
typename Hamiltonian>
425template<
typename HamiltonianThermal>
427beta_propagation (
const Hamiltonian &Hprop,
const HamiltonianThermal &Htherm,
int Lcell,
int dLphys,
429 double s_betainit,
double betaswitch,
430 string wd,
string th_label,
bool LOAD_BETA,
bool SAVE_BETA,
432 vector<double> stateSavePoints, vector<string> stateSaveLabels,
433 int Ntaylor,
bool CALC_C,
bool CALC_CHI,
bool USE_PHIT)
435 for (
const auto &spec:specs)
437 assert(CHECK_SPEC(spec) and
"Wrong spectral abbreviation!");
439 L = Hprop.length()/dLphys;
440 Nspec = specs.size();
444 lout <<
"loading beta result from: " << make_string(wd,
"/betaRes_",th_label) << endl;
445 PhiT.load(make_string(wd,
"/betaRes_",th_label));
446 lout <<
"loaded: " << PhiT.info() << endl;
452 lout <<
"Computing T=infinity state" << endl;
454 Eigenstate<Mps<Symmetry,typename HamiltonianThermal::Mpo::Scalar_> > th;
461 GlobParam.
Minit = 10ul;
462 GlobParam.
Qinit = 10ul;
465 size_t start_2site = 0ul;
466 size_t end_2site = 10ul;
469 DynParam.
max_alpha_rsvd = [] (
size_t i) {
return (i<20ul)? 1e8:0.;};
470 fDMRG.DynParam = DynParam;
471 fDMRG.userSetDynParam();
473 fDMRG.GlobParam = GlobParam;
474 fDMRG.userSetGlobParam();
475 th.state.eps_truncWeight = 0.;
476 fDMRG.edgeState(Htherm, th, Q, LANCZOS::EDGE::GROUND,
false);
479 th.state.entropy_skim();
480 lout << th.state.entropy().transpose() << endl;
486 vector<bool> ENTROPY_CHECK1;
487 for (
int l=0; l<dLphys*L-1; l+=dLphys) ENTROPY_CHECK1.push_back(abs(th.state.entropy()(l))>1e-10);
489 vector<bool> ENTROPY_CHECK2;
490 for (
int l=1; l<dLphys*L-1; l+=dLphys) ENTROPY_CHECK2.push_back(abs(th.state.entropy()(l))<1e-10);
492 ALL = all_of(ENTROPY_CHECK1.begin(), ENTROPY_CHECK1.end(), [](
const bool v){return v;}) and
493 all_of(ENTROPY_CHECK2.begin(), ENTROPY_CHECK2.end(), [](
const bool v){return v;});
509 lout << termcolor::yellow <<
"restarting..." << termcolor::reset << endl;
523 fDMRGnew.GlobParam = GlobParam;
525 fDMRGnew.GlobParam.min_halfsweeps = 30ul;
526 fDMRGnew.GlobParam.min_halfsweeps = 30ul;
531 GlobParam.
Minit = 10ul;
532 GlobParam.
Qinit = 10ul;
534 size_t start_2site = 0ul;
535 size_t end_2site = 10ul;
538 DynParam.
max_alpha_rsvd = [] (
size_t i) {
return (i<30ul)? 1e8:0.;};
539 fDMRGnew.DynParam = DynParam;
542 fDMRGnew.userSetGlobParam();
543 fDMRGnew.userSetDynParam();
545 fDMRGnew.edgeState(Htherm, th, Q, LANCZOS::EDGE::GROUND,
false);
546 th.state.entropy_skim();
550 lout << th.state.entropy().transpose() << endl;
551 vector<bool> ENTROPY_CHECK1, ENTROPY_CHECK2;
553 for (
int l=0; l<2*L-1; l+=2) ENTROPY_CHECK1.push_back(abs(th.state.entropy()(l))>1e-10);
554 for (
int l=1; l<2*L-1; l+=2) ENTROPY_CHECK2.push_back(abs(th.state.entropy()(l))<1e-10);
556 for (
int l=1; l<2*L-1; l+=2)
558 bool TEST = abs(th.state.entropy()(l))<1e-10;
560 ALL = all_of(ENTROPY_CHECK1.begin(), ENTROPY_CHECK1.end(), [](
const bool v){return v;}) and
561 all_of(ENTROPY_CHECK2.begin(), ENTROPY_CHECK2.end(), [](
const bool v){return v;});
572 for (
int l=0; l<L-dLphys; l+=dLphys)
577 val =
avg(th.state, Htherm.SdagS(l,l,0,1), th.state);
581 val =
avg(th.state, Htherm.SdagS(l,l+1,0,0), th.state);
583 cout << termcolor::yellow
586 <<
", avg_loc=" << val
591 PhiT = th.state.template cast<typename Hamiltonian::Mpo::Scalar_>();
595 PhiT.eps_truncWeight = tol_compr_beta;
599 typename Hamiltonian::Symmetry,
600 typename Hamiltonian::Mpo::Scalar_,
601 typename Hamiltonian::Mpo::Scalar_,
605 vector<double> lnZvec;
607 vector<double> betavals;
608 vector<double> betasteps;
609 betavals.push_back(0.01);
610 betasteps.push_back(0.01);
613 for (
int i=1; i<22; ++i)
615 double beta_last = betavals[betavals.size()-1];
616 if (beta_last > betamax)
break;
619 betasteps.push_back(0.05);
620 betavals.push_back(beta_last+0.05);
624 betasteps.push_back(0.01);
625 betavals.push_back(beta_last+0.01);
629 while (betavals[betavals.size()-1] < betamax)
631 betasteps.push_back(dbeta);
632 double beta_last = betavals[betavals.size()-1];
633 betavals.push_back(beta_last+dbeta);
636 if (betavals[betavals.size()-1] > betamax+0.005)
640 betasteps.pop_back();
648 ofstream BetaFiler(make_string(wd,
"/thermodyn_",th_label,
".dat"));
649 BetaFiler <<
"#T\tβ\tc\te\tchi\tchiz\tchic\ts";
650 if constexpr (Hamiltonian::FAMILY ==
HUBBARD or Hamiltonian::FAMILY ==
KONDO) BetaFiler <<
"\tnphys";
651 if constexpr (Hamiltonian::FAMILY ==
HEISENBERG) BetaFiler <<
"\tSpSm\tSzSz";
652 BetaFiler <<
"truncWeightGlob\ttruncWeightLoc\tMmax";
658 lout <<
"computing H^2..." << endl;
659 Hpropsq =
prod(Hprop,Hprop);
660 lout <<
"H^2 done!" << endl;
665 for (
int i=0; i<betasteps.size(); ++i)
667 Stopwatch<> betaStepper;
668 double beta = betavals[i];
672 if (i==0 or betasteps[i]!=betasteps[i-1])
677 Hmpo1.
scale(-0.5*betasteps[i]);
680 Hmpo2.
scale(0.125*betasteps[i]*betasteps[i]);
682 lout <<
"computing 1-1/2*dβ*H+1/8*(dβ*H)^2 for dβ=" << betasteps[i] << endl;
683 U =
sum(Id,
sum(Hmpo1,Hmpo2));
687 lout <<
"applying 1-1/2*dβ*H+1/8*(dβ*H)^2 and compressing for dβ=" << betasteps[i] << endl;
691 OxV(U,U,PhiT,
true,tol_compr_beta,50,Mlim,16,6,
false);
697 typename Hamiltonian::Symmetry,
698 typename Hamiltonian::Mpo::Scalar_,
699 typename Hamiltonian::Mpo::Scalar_,
708 TDVPT.t_step0(Hprop, PhiT, -0.5*betasteps[i], 1);
720 TDVPT.t_step(Hprop, PhiT, -0.5*betasteps[i], 1);
724 lnZvec.push_back(log(
norm));
726 lout << TDVPT.info() << endl;
727 size_t standard_precision = cout.precision();
728 lout << setprecision(16) << PhiT.info() << setprecision(standard_precision) << endl;
730 bool INTERMEDIATE_SAVEPOINT =
false;
731 string saveLabel =
"";
732 for (
int is=0; is<stateSavePoints.size(); ++is)
734 if (abs(beta-stateSavePoints[is]) < 1e-8)
736 INTERMEDIATE_SAVEPOINT =
true;
737 saveLabel = stateSaveLabels[is];
740 if (SAVE_BETA and INTERMEDIATE_SAVEPOINT)
742 lout << termcolor::green <<
"saving the intermediate beta result to: " << saveLabel <<
" in directory=" << wd << termcolor::reset << endl;
743 PhiT.save(make_string(wd,
"/betaRes_",saveLabel));
746 double avg_H =
isReal(
avg(PhiT,Hprop,PhiT));
750 double c = std::nan(
"0");
753 double avg_Hsq = (Hprop.maxPower()==1)?
isReal(
avg(PhiT,Hprop,Hprop,PhiT)):
isReal(
avg(PhiT,Hprop,PhiT,2));
754 double avgH_sq = pow(avg_H,2);
755 c =
isReal(beta*beta*(avg_Hsq-avgH_sq))/L;
758 double chi = std::nan(
"0");
759 double chiz = std::nan(
"0");
763 #if defined(USING_SU2xU1) or defined(USING_SU2xSU2) or defined(USING_SU2)
764 chi =
isReal(beta*
avg(PhiT, Hprop.Sdagtot(0,sqrt(3.),dLphys), Hprop.Stot(0,1.,dLphys), PhiT))/L;
766 for (
int l=0; l<dLphys*L; l+=dLphys)
768 chic +=
isReal(beta*
avg(PhiT, Hprop.SdagS(l,dLphys*L/2), PhiT))/3.;
771 chi = 0.5*
isReal(beta*
avg(PhiT, Hprop.Scomptot(
SP,0,1.,dLphys), Hprop.Scomptot(
SM,0,1.,dLphys), PhiT))/L;
772 chi += 0.5*
isReal(beta*
avg(PhiT, Hprop.Scomptot(
SM,0,1.,dLphys), Hprop.Scomptot(
SP,0,1.,dLphys), PhiT))/L;
773 chiz =
isReal(beta*
avg(PhiT, Hprop.Scomptot(
SZ,0,1.,dLphys), Hprop.Scomptot(
SZ,0,1.,dLphys), PhiT))/L;
775 for (
int l=0; l<dLphys*L; l+=dLphys)
777 chic +=
isReal(beta*
avg(PhiT, Hprop.SzSz(l,dLphys*L/2), PhiT));
784 VectorXd tmp = VectorXd::Map(lnZvec.data(), lnZvec.size());
785 double s = s_betainit + tmp.sum()/L + beta*e;
789 auto PhiTtmp = PhiT; PhiTtmp.entropy_skim();
790 cout <<
"aa" << endl;
791 lout <<
"S=" << PhiTtmp.entropy().transpose() << endl;
793 VectorXd nphys(Lcell); nphys.setZero();
797 #if not defined(USING_SU2xSU2)
798 if constexpr (Hamiltonian::FAMILY ==
HUBBARD or Hamiltonian::FAMILY ==
KONDO)
801 for (
int j=0, icell=0; j<dLphys*L; j+=dLphys, icell+=1)
803 nphys(icell%Lcell) +=
isReal(
avg(PhiT, Hprop.n(j,0), PhiT));
805 for (
int j=dLphys-1; j<dLphys*L; j+=dLphys)
807 nancl +=
isReal(
avg(PhiT, Hprop.n(j,dLphys%2), PhiT));
811 #if not defined(USING_SU2)
812 if constexpr (Hamiltonian::FAMILY ==
HEISENBERG)
815 for (
int j=0, icell=0; j<dLphys*L; j+=dLphys, icell+=1)
817 nphys(icell%Lcell) +=
isReal(
avg(PhiT, Hprop.Sz(j,0), PhiT));
819 for (
int j=dLphys-1; j<dLphys*L; j+=dLphys)
821 nancl +=
isReal(
avg(PhiT, Hprop.Sz(j,dLphys%2), PhiT));
840 double nphystot = nphys.sum();
843 lout << termcolor::bold <<
"β=" << beta <<
", T=" << 1./beta <<
", c=" << c <<
", e=" << e <<
", chi=" << chi;
845 lout <<
", chiz=" << chiz <<
"(3x=" << 3.*chiz <<
")";
847 lout <<
", chic=" << chic;
850 BetaFiler << setprecision(16) << 1./beta <<
"\t" << beta <<
"\t" << c <<
"\t" << e <<
"\t" << chi <<
"\t" << chiz <<
"\t" << chic <<
"\t" << s;
851 if constexpr (Hamiltonian::FAMILY ==
HUBBARD or Hamiltonian::FAMILY ==
KONDO)
853 lout <<
", nphys=" << nphys.transpose() <<
", sum=" << nphystot <<
", nancl=" << nancl;
854 BetaFiler <<
"\t" << nphystot;
856 else if constexpr (Hamiltonian::FAMILY ==
HEISENBERG)
858 lout <<
", Mphys=" << nphys.transpose() <<
", sum=" << nphystot <<
", Mancl=" << nancl;
859 BetaFiler <<
"\t" << nphystot;
863 BetaFiler <<
"\t" << PhiT.get_truncWeight().sum() <<
"\t" << PhiT.get_truncWeight().maxCoeff() <<
"\t" << PhiT.calc_Mmax();
871 lout << termcolor::reset << endl;
872 lout << betaStepper.info(
"βstep") << endl;
878 if (SAVE_BETA and !LOAD_BETA)
880 lout << termcolor::green <<
"saving the final beta result to: " << th_label <<
" in directory=" << wd << termcolor::reset << endl;
881 PhiT.save(make_string(wd,
"/betaRes_",th_label));
885template<
typename Hamiltonian>
888 double s_betainit_input,
double betainit,
double betamax,
double dbeta,
double tol_compr_beta,
size_t Mlim,
qarray<Hamiltonian::Symmetry::Nq> Q,
double betaswitch,
889 string wd,
string th_label,
string LOAD_BETA,
bool SAVE_BETA,
891 vector<double> stateSavePoints, vector<string> stateSaveLabels,
892 bool CALC_C,
bool CALC_CHI)
894 for (
const auto &spec:specs)
896 assert(CHECK_SPEC(spec) and
"Wrong spectral abbreviation!");
898 L = Hprop.length()/dLphys;
899 Nspec = specs.size();
901 lout <<
"loading beta result from: " << LOAD_BETA << endl;
902 PhiT.load(LOAD_BETA);
903 lout <<
"loaded: " << PhiT.info() << endl;
905 PhiT.eps_truncWeight = tol_compr_beta;
909 typename Hamiltonian::Symmetry,
910 typename Hamiltonian::Mpo::Scalar_,
911 typename Hamiltonian::Mpo::Scalar_,
915 vector<double> lnZvec;
916 vector<double> betavals;
917 vector<double> betasteps;
919 assert(betainit>=0.2);
920 betavals.push_back(betainit+dbeta);
921 betasteps.push_back(dbeta);
922 lout <<
"betaval=" << betavals[betavals.size()-1] <<
", betastep=" << betasteps[betasteps.size()-1] << endl;
924 double e =
isReal(
avg(PhiT,Hprop,PhiT)/
static_cast<double>(L));
925 double s_betainit = s_betainit_input;
926 s_betainit -= betainit*e;
928 while (betavals[betavals.size()-1] < betamax)
930 betasteps.push_back(dbeta);
931 double beta_last = betavals[betavals.size()-1];
932 betavals.push_back(beta_last+dbeta);
933 lout <<
"betaval=" << betavals[betavals.size()-1] <<
", betastep=" << betasteps[betasteps.size()-1] << endl;
935 if (betavals[betavals.size()-1] > betamax+0.005)
938 betasteps.pop_back();
942 ofstream BetaFiler(make_string(wd,
"/thermodyn_",th_label,
".dat"));
943 BetaFiler <<
"#T\tβ\tc\te\tchi\tchiz\tchic\ts";
944 if constexpr (Hamiltonian::FAMILY ==
HUBBARD or Hamiltonian::FAMILY ==
KONDO) BetaFiler <<
"\tnphys";
945 if constexpr (Hamiltonian::FAMILY ==
HEISENBERG) BetaFiler <<
"\tSpSm\tSzSz";
946 BetaFiler <<
"truncWeightGlob\ttruncWeightLoc\tMmax";
949 for (
int i=0; i<betasteps.size(); ++i)
951 Stopwatch<> betaStepper;
952 double beta = betavals[i];
956 PhiT.eps_truncWeight = 0.;
957 TDVPT.t_step0(Hprop, PhiT, -0.5*betasteps[i], 1);
961 PhiT.eps_truncWeight = tol_compr_beta;
962 TDVPT.t_step(Hprop, PhiT, -0.5*betasteps[i], 1);
965 lnZvec.push_back(log(
norm));
967 lout << TDVPT.info() << endl;
968 size_t standard_precision = cout.precision();
969 lout << setprecision(16) << PhiT.info() << setprecision(standard_precision) << endl;
971 bool INTERMEDIATE_SAVEPOINT =
false;
972 string saveLabel =
"";
973 for (
int is=0; is<stateSavePoints.size(); ++is)
975 if (abs(beta-stateSavePoints[is]) < 1e-8)
977 INTERMEDIATE_SAVEPOINT =
true;
978 saveLabel = stateSaveLabels[is];
981 if (SAVE_BETA and INTERMEDIATE_SAVEPOINT)
983 lout << termcolor::green <<
"saving the intermediate beta result to: " << saveLabel <<
" in directory=" << wd << termcolor::reset << endl;
984 PhiT.save(make_string(wd,
"/betaRes_",saveLabel));
987 double avg_H =
isReal(
avg(PhiT,Hprop,PhiT));
991 double c = std::nan(
"0");
994 double avg_Hsq = (Hprop.maxPower()==1)?
isReal(
avg(PhiT,Hprop,Hprop,PhiT)):
isReal(
avg(PhiT,Hprop,PhiT,2));
995 double avgH_sq = pow(avg_H,2);
996 c =
isReal(beta*beta*(avg_Hsq-avgH_sq))/L;
999 double chi = std::nan(
"0");
1000 double chiz = std::nan(
"0");
1005 chi =
isReal(beta*
avg(PhiT, Hprop.Sdagtot(0,sqrt(3.),dLphys), Hprop.Stot(0,1.,dLphys), PhiT))/L;
1007 for (
int l=0; l<dLphys*L; l+=dLphys)
1009 chic +=
isReal(beta*
avg(PhiT, Hprop.SdagS(l,dLphys*L/2), PhiT))/3.;
1012 chi = 0.5*
isReal(beta*
avg(PhiT, Hprop.Scomptot(
SP,0,1.,dLphys), Hprop.Scomptot(
SM,0,1.,dLphys), PhiT))/L;
1013 chi += 0.5*
isReal(beta*
avg(PhiT, Hprop.Scomptot(
SM,0,1.,dLphys), Hprop.Scomptot(
SP,0,1.,dLphys), PhiT))/L;
1014 chiz =
isReal(beta*
avg(PhiT, Hprop.Scomptot(
SZ,0,1.,dLphys), Hprop.Scomptot(
SZ,0,1.,dLphys), PhiT))/L;
1016 for (
int l=0; l<dLphys*L; l+=dLphys)
1018 chic +=
isReal(beta*
avg(PhiT, Hprop.SzSz(l,dLphys*L/2), PhiT));
1023 VectorXd tmp = VectorXd::Map(lnZvec.data(), lnZvec.size());
1024 double s = s_betainit + tmp.sum()/L + beta*e;
1026 auto PhiTtmp = PhiT; PhiTtmp.entropy_skim();
1027 lout <<
"S=" << PhiTtmp.entropy().transpose() << endl;
1029 VectorXd nphys(Lcell);
for (
int j=0; j<Lcell; ++j) nphys(j) = 0.;
1031 if constexpr (Hamiltonian::FAMILY ==
HUBBARD or Hamiltonian::FAMILY ==
KONDO)
1033 for (
int j=0, icell=0; j<dLphys*L; j+=dLphys, icell+=1)
1035 nphys(icell%Lcell) +=
isReal(
avg(PhiT, Hprop.n(j,0), PhiT));
1037 for (
int j=dLphys-1; j<dLphys*L; j+=dLphys)
1039 nancl +=
isReal(
avg(PhiT, Hprop.n(j,dLphys%2), PhiT));
1044 if constexpr (Hamiltonian::FAMILY ==
HEISENBERG)
1046 SpSm =
isReal(
avg(PhiT, Hprop.SpSm(L/4,3*L/4), PhiT));
1047 SzSz =
isReal(
avg(PhiT, Hprop.SzSz(L/4,3*L/4), PhiT));
1051 double nphystot = nphys.sum();
1054 lout << termcolor::bold <<
"β=" << beta <<
", T=" << 1./beta <<
", c=" << c <<
", e=" << e <<
", chi=" << chi;
1056 lout <<
", chiz=" << chiz <<
"(3x=" << 3.*chiz <<
")";
1058 lout <<
", chic=" << chic;
1060 lout <<
", s=" << s;
1061 BetaFiler << setprecision(16) << 1./beta <<
"\t" << beta <<
"\t" << c <<
"\t" << e <<
"\t" << chi <<
"\t" << chiz <<
"\t" << chic <<
"\t" << s;
1062 if constexpr (Hamiltonian::FAMILY ==
HUBBARD or Hamiltonian::FAMILY ==
KONDO)
1064 lout <<
", nphys=" << nphys.transpose() <<
", sum=" << nphystot <<
", nancl=" << nancl;
1065 BetaFiler <<
"\t" << nphystot;
1067 if constexpr (Hamiltonian::FAMILY ==
HEISENBERG)
1069 lout <<
", SpSm(" << L/4 <<
"," << 3*L/4 <<
")=" << SpSm <<
", SzSz(" << L/4 <<
"," << 3*L/4 <<
")=" << SzSz;
1070 BetaFiler <<
"\t" << SpSm <<
"\t" << SzSz;
1072 BetaFiler <<
"\t" << PhiT.get_truncWeight().sum() <<
"\t" << PhiT.get_truncWeight().maxCoeff() <<
"\t" << PhiT.calc_Mmax();
1074 lout << termcolor::reset << endl;
1075 lout << betaStepper.info(
"βstep") << endl;
1083 lout << termcolor::green <<
"saving the final beta result to: " << th_label <<
" in directory=" << wd << termcolor::reset << endl;
1084 PhiT.save(make_string(wd,
"/betaRes_",th_label));
1088template<
typename Hamiltonian>
1092 PhiTt = PhiT.template cast<complex<double>>();
1098 vector<vector<Mpo<typename Hamiltonian::Symmetry,Scalar>>> O(Nspec);
1100 for (
int z=0; z<Nspec; ++z) O[z].resize(L);
1101 for (
int z=0; z<Nspec; ++z) Odag[z].resize(L);
1103 for (
int z=0; z<Nspec; ++z)
1104 for (
int l=0; l<L; ++l)
1106 O[z][l] = get_Op(Hwork, dLphys*l, specs[z], 1., 0, dLphys);
1108 if (specs[z] ==
"SSF")
1110 dagfactor = sqrt(3);
1112 else if (specs[z] ==
"PES")
1114 dagfactor = -sqrt(2);
1116 else if (specs[z] ==
"IPE")
1118 dagfactor = +sqrt(2);
1124 Odag[z][l] = get_Op(Hwork, dLphys*l, DAG(specs[z]), dagfactor, 0, dLphys);
1128 vector<vector<Scalar>> Oshift(Nspec);
1129 vector<vector<Scalar>> Odagshift(Nspec);
1130 for (
int z=0; z<Nspec; ++z)
1132 Oshift[z].resize(L);
1133 Odagshift[z].resize(L);
1134 for (
int l=0; l<L; ++l)
1136 Oshift[z][l] =
avg(PhiT, O[z][l], PhiT);
1137 Odagshift[z][l] =
avg(PhiT, Odag[z][l], PhiT);
1142 for (
int z=0; z<Nspec; ++z)
1143 for (
int l=0; l<L; ++l)
1145 O[z][l].scale (1.,-Oshift[z][l]);
1146 Odag[z][l].scale(1.,-Odagshift[z][l]);
1153 for (
int z=0; z<Nspec; ++z)
1155 lout <<
"check z=" << z
1156 <<
", spec=" << specs[z] <<
", dag=" << DAG(specs[z])
1157 <<
", <O†[z][l]*O[z][l]>=" <<
avg(PhiTt, Odag[z][L/2], O[z][L/2], PhiTt)
1158 <<
", <O†[z][l]>=" <<
avg(PhiTt, Odag[z][L/2], PhiTt)
1159 <<
", <O[z][l]>=" <<
avg(PhiTt, O[z][L/2], PhiTt)
1165 OxPhiTt.resize(Nspec);
1166 for (
int z=0; z<Nspec; ++z)
1168 OxPhiTt[z].resize(Lcell);
1169 for (
int i=0; i<Lcell; ++i)
1176template<
typename Hamiltonian>
1178set_measurement (
int iz,
string spec,
double factor,
int dLphys,
qarray<Symmetry::Nq> Q,
int Lcell,
int measure_interval,
string measure_name,
string measure_subfolder,
bool TRANSFORM)
1180 assert(Green.size()>0);
1182 vector<Mpo<Symmetry,Scalar>> Measure(Hwork.length()/dLphys);
1183 for (
int l=0, iphys=0; l<Hwork.length(); l+=dLphys, iphys+=1)
1185 Measure[iphys] = get_Op(Hwork, l, spec, factor, 0, dLphys);
1186 if (TRANSFORM) Measure[l].transform_base(Q,
false,L);
1188 Green[iz].set_measurement(Measure, Lcell, measure_interval, measure_name, measure_subfolder);
1191template<
typename Hamiltonian>
1193resize_Green (
string wd,
string label,
int Ns,
double tmax,
double dt,
double wmin,
double wmax,
int wpoints,
Q_RANGE QR,
int qpoints,
GREEN_INTEGRATION INT)
1195 int Nt =
static_cast<int>(tmax/dt);
1198 Green.resize(Nspec);
1199 for (
int z=0; z<Nspec; ++z)
1201 string spec = specs[z];
1203 (wd+spec+
"_"+label,tmax,Nt,Ns,wmin,wmax,wpoints,QR,qpoints,INT);
1206 Green[0].set_verbosity(CHOSEN_VERB);
1209template<
typename Hamiltonian>
1211compute (
string wd,
string label,
int Ns,
double tmax,
double dt,
double wmin,
double wmax,
int wpoints,
Q_RANGE QR,
int qpoints,
GREEN_INTEGRATION INT,
size_t Mlim,
double tol_DeltaS,
double tol_compr)
1213 if (Green.size()==0)
1215 resize_Green(wd,label,Ns,tmax,dt,wmin,wmax,wpoints,QR,qpoints,INT);
1219 #pragma omp parallel for
1220 for (
int z=0; z<Nspec; ++z)
1222 string spec = specs[z];
1223 Green[z].set_tol_DeltaS(tol_DeltaS);
1224 Green[z].set_lim_Nsv(Mlim);
1225 Green[z].set_tol_compr(tol_compr);
1227 Green[z].compute_cell(Hwork, OxPhiCellBra[z], OxPhiCellKet[z], Eg, TIME_DIR(spec),
true);
1228 Green[z].save(
false);
1232template<
typename Hamiltonian>
1234compute_finite (
size_t j0,
string wd,
string label,
int Ns,
double tmax,
double dt,
double wmin,
double wmax,
int wpoints,
GREEN_INTEGRATION INT,
size_t Mlim,
double tol_DeltaS,
double tol_compr)
1236 if (Green.size()==0)
1238 resize_Green(wd,label,Ns,tmax,dt,wmin,wmax,wpoints,
ZERO_2PI,501,INT);
1242 #pragma omp parallel for
1243 for (
int z=0; z<Nspec; ++z)
1245 string spec = specs[z];
1246 Green[z].set_tol_DeltaS(tol_DeltaS);
1247 Green[z].set_lim_Nsv(Mlim);
1248 Green[z].set_tol_compr(tol_compr);
1250 Green[z].set_OxPhiFull(OxPhiCellKet[z]);
1251 Green[z].compute_one(j0, Hwork, OxPhiCellKet[z], Eg, TIME_DIR(spec),
false);
1252 Green[z].save(
false);
1256template<
typename Hamiltonian>
1258compute_finiteCell (
int Lcell,
int x0,
string wd,
string label,
double tmax,
double dt,
double wmin,
double wmax,
int wpoints,
Q_RANGE QR,
int qpoints,
GREEN_INTEGRATION INT,
size_t Mlim,
double tol_DeltaS,
double tol_compr)
1260 if (Green.size()==0)
1262 resize_Green(wd,label,1,tmax,dt,wmin,wmax,wpoints,QR,qpoints,INT);
1265 for (
int z=0; z<Nspec; ++z)
1267 Green[z].set_Lcell(Lcell);
1271 #pragma omp parallel for
1272 for (
int z=0; z<Nspec; ++z)
1274 string spec = specs[z];
1275 Green[z].set_tol_DeltaS(tol_DeltaS);
1276 Green[z].set_lim_Nsv(Mlim);
1277 Green[z].set_tol_compr(tol_compr);
1279 Green[z].set_OxPhiFull(OxPhiCellKet[z]);
1280 if (Oshift.size() != 0)
1282 if (Oshift[z][0] != 0.)
1284 Green[z].set_Oshift(Oshift[z]);
1287 Green[z].compute_cell(Hwork, OxPhiCellKet[z], Eg, TIME_DIR(spec),
false, x0);
1288 Green[z].save(
false);
1292template<
typename Hamiltonian>
1294compute_thermal (
string wd,
string label,
int dLphys,
double tmax,
double dt,
double wmin,
double wmax,
int wpoints,
Q_RANGE QR,
int qpoints,
GREEN_INTEGRATION INT,
size_t Mlim,
double tol_DeltaS,
double tol_compr)
1296 if (Green.size()==0)
1298 resize_Green(wd,label,1,tmax,dt,wmin,wmax,wpoints,QR,qpoints,INT);
1301 #pragma omp parallel for
1302 for (
int z=0; z<Nspec; ++z)
1304 string spec = specs[z];
1305 Green[z].set_tol_DeltaS(tol_DeltaS);
1306 Green[z].set_lim_Nsv(Mlim);
1307 Green[z].set_tol_compr(tol_compr);
1309 Green[z].compute_thermal_cell(Hwork, Odag[z], PhiTt, OxPhiTt[z], TIME_DIR(spec));
1311 Green[z].save(
false);
1315template<
typename Hamiltonian>
1319 assert(Green.size() == Nspec);
1320 for (
int z=0; z<Nspec; ++z)
1322 Green[z].FTcell_xq();
1323 Green[z].save_GtqCell();
1327template<
typename Hamiltonian>
1329make_A1P (
GreenPropagator<Hamiltonian,
Symmetry,
Scalar,complex<double> > &Gfull,
string wd,
string label,
int Ns,
double tmax,
double wmin,
double wmax,
int wpoints,
Q_RANGE QR,
int qpoints,
GREEN_INTEGRATION INT,
bool SAVE_N_MU)
1331 auto itPES = find(specs.begin(), specs.end(),
"PES");
1332 auto itIPE = find(specs.begin(), specs.end(),
"IPE");
1334 if (itPES != specs.end() and itIPE != specs.end())
1336 int iPES = distance(specs.begin(), itPES);
1337 int iIPE = distance(specs.begin(), itIPE);
1340 vector<vector<MatrixXcd>> GinA1P(L);
for (
int i=0; i<L; ++i) {GinA1P[i].resize(L);}
1341 for (
int i=0; i<L; ++i)
1342 for (
int j=0; j<L; ++j)
1344 GinA1P[i][j].resize(Green[iPES].get_GtxCell()[0][0].rows(),
1345 Green[iPES].get_GtxCell()[0][0].cols());
1346 GinA1P[i][j].setZero();
1349 for (
int i=0; i<L; ++i)
1350 for (
int j=0; j<L; ++j)
1352 GinA1P[i][j] += Green[iPES].get_GtxCell()[i][j] + Green[iIPE].get_GtxCell()[i][j];
1354 Gfull =
GreenPropagator<Hamiltonian,Symmetry,Scalar,complex<double> >(wd+
"A1P"+
"_"+label,L,Ncells,Ns,tmax,GinA1P,QR,qpoints,INT);
1359 IntervalIterator mu(wmin,wmax,501);
1360 for (mu=mu.begin(); mu!=mu.end(); ++mu)
1362 mu << Gfull.integrate_Glocw_cell(*mu);
1363 mu.save(make_string(wd,
"n(μ)_tmax=",tmax,
"_",label,
".dat"));
1369template<
typename Hamiltonian>
1371make_A1P_finite (
GreenPropagator<Hamiltonian,
Symmetry,
Scalar,complex<double> > &Gfull,
string wd,
string label,
double tmax,
double wmin,
double wmax,
int wpoints,
GREEN_INTEGRATION INT)
1373 auto itPES = find(specs.begin(), specs.end(),
"PES");
1374 auto itIPE = find(specs.begin(), specs.end(),
"IPE");
1376 if (itPES != specs.end() and itIPE != specs.end())
1378 int iPES = distance(specs.begin(), itPES);
1379 int iIPE = distance(specs.begin(), itIPE);
1383 GinA1P.resize(Green[iPES].get_Gtx().rows(), Green[iPES].get_Gtx().cols());
1385 GinA1P += Green[iPES].get_Gtx() + Green[iIPE].get_Gtx();
1392template<
typename Hamiltonian>
1394reload (
string wd,
const vector<string> &specs_input,
string label,
int L_input,
int Ncells_input,
int Ns,
double tmax,
double wmin,
double wmax,
int wpoints,
Q_RANGE QR,
int qpoints,
GREEN_INTEGRATION INT)
1397 Ncells = Ncells_input;
1400 specs = specs_input;
1401 Nspec = specs.size();
1403 for (
const auto &spec:specs)
1405 assert(CHECK_SPEC(spec) and
"Wrong spectral abbreviation!");
1408 Green.resize(Nspec);
1410 for (
int z=0; z<Nspec; ++z)
1412 string spec = specs[z];
1414 (wd+spec+
"_"+label,L,Ncells,Ns,tmax,{wd+spec+
"_"+label+make_string(
"_L=",L,
"x",Ncells,
"_tmax=",tmax)},QR,qpoints,INT);
1416 Green[z].save(
true);
1420template<
typename Hamiltonian>
1422get_Op (
const Hamiltonian &H,
size_t loc, std::string spec,
double factor,
size_t locy,
int dLphys)
1425 bool OPERATOR_IS_SET =
false;
1430 if constexpr (Symmetry::IS_SPIN_SU2())
1432 Res = H.S(loc,locy,factor);
1433 OPERATOR_IS_SET =
true;
1437 Res = H.Scomp(
SP,loc,locy);
1438 OPERATOR_IS_SET =
true;
1441 else if (spec ==
"SDAGSF")
1443 if constexpr (Symmetry::IS_SPIN_SU2())
1445 Res = H.Sdag(loc,locy,factor);
1446 OPERATOR_IS_SET =
true;
1450 Res = H.Scomp(
SM,loc,locy);
1451 OPERATOR_IS_SET =
true;
1454 else if (spec ==
"SSZ")
1456 if constexpr (!Symmetry::IS_SPIN_SU2())
1458 Res = H.Scomp(
SZ,loc,locy);
1459 OPERATOR_IS_SET =
true;
1466 else if (spec ==
"SPM")
1468 if constexpr (!Symmetry::IS_SPIN_SU2())
1470 Res = H.Scomp(
SM,loc,locy);
1471 OPERATOR_IS_SET =
true;
1478 else if (spec ==
"SMP")
1480 if constexpr (!Symmetry::IS_SPIN_SU2())
1482 Res = H.Scomp(
SP,loc,locy);
1483 OPERATOR_IS_SET =
true;
1490 if constexpr (Hamiltonian::FAMILY ==
HEISENBERG)
1494 if constexpr (Symmetry::IS_SPIN_SU2())
1496 Res = H.Q(loc,locy,factor);
1497 OPERATOR_IS_SET =
true;
1501 Res = H.Scomp(
SP,loc,locy);
1502 OPERATOR_IS_SET =
true;
1505 else if (spec ==
"QDAGSF")
1507 if constexpr (Symmetry::IS_SPIN_SU2())
1509 Res = H.Qdag(loc,locy,factor);
1510 OPERATOR_IS_SET =
true;
1514 Res = H.Scomp(
SM,loc,locy);
1515 OPERATOR_IS_SET =
true;
1519 if constexpr (Hamiltonian::FAMILY ==
HUBBARD or Hamiltonian::FAMILY ==
KONDO)
1522 if (spec ==
"PES" or spec ==
"PESUP")
1524 if constexpr (Symmetry::IS_SPIN_SU2())
1526 Res = H.c(loc,locy,factor);
1527 OPERATOR_IS_SET =
true;
1531 Res = H.template c<UP>(loc,locy);
1532 OPERATOR_IS_SET =
true;
1535 else if (spec ==
"PESDN")
1537 if constexpr (Symmetry::IS_SPIN_SU2())
1539 Res = H.c(loc,locy,factor);
1540 OPERATOR_IS_SET =
true;
1544 Res = H.template c<DN>(loc,locy);
1545 OPERATOR_IS_SET =
true;
1549 else if (spec ==
"IPE" or spec ==
"IPEUP")
1551 if constexpr (Symmetry::IS_SPIN_SU2())
1553 Res = H.cdag(loc,locy,factor);
1554 OPERATOR_IS_SET =
true;
1558 Res = H.template cdag<UP>(loc,locy,factor);
1559 OPERATOR_IS_SET =
true;
1562 else if (spec ==
"IPEDN")
1564 if constexpr (Symmetry::IS_SPIN_SU2())
1566 Res = H.cdag(loc,locy,factor);
1567 OPERATOR_IS_SET =
true;
1571 Res = H.template cdag<DN>(loc,locy,factor);
1572 OPERATOR_IS_SET =
true;
1576 else if (spec ==
"CSF" or spec ==
"ICSF")
1578 if constexpr (!Symmetry::IS_CHARGE_SU2())
1580 Res = H.n(loc,locy);
1581 OPERATOR_IS_SET =
true;
1589 else if (spec ==
"AES")
1591 if constexpr (!Symmetry::IS_CHARGE_SU2())
1593 Res = H.cc(loc,locy);
1594 OPERATOR_IS_SET =
true;
1602 else if (spec ==
"APS")
1604 if constexpr (!Symmetry::IS_CHARGE_SU2())
1606 Res = H.cdagcdag(loc,locy);
1607 OPERATOR_IS_SET =
true;
1615 else if (spec ==
"PSF")
1617 if constexpr (Symmetry::IS_CHARGE_SU2())
1619 Res = H.T(loc,locy);
1620 OPERATOR_IS_SET =
true;
1624 Res = H.Tp(loc,locy);
1625 OPERATOR_IS_SET =
true;
1629 else if (spec ==
"PDAGSF")
1631 if constexpr (Symmetry::IS_CHARGE_SU2())
1633 Res = H.Tdag(loc,locy);
1634 OPERATOR_IS_SET =
true;
1638 Res = H.Tm(loc,locy);
1639 OPERATOR_IS_SET =
true;
1643 else if (spec ==
"PSZ" or spec ==
"IPSZ")
1645 if constexpr (!Symmetry::IS_CHARGE_SU2())
1647 Res = H.Tz(loc,locy);
1648 OPERATOR_IS_SET =
true;
1656 else if (spec ==
"HSF")
1658 if constexpr (Symmetry::IS_SPIN_SU2())
1660 if (loc<H.length()-dLphys)
1662 Res = H.cdagc(loc,loc+dLphys,0,0);
1663 OPERATOR_IS_SET =
true;
1667 lout << termcolor::yellow <<
"HSF operator hit right edge! Returning zero." << termcolor::reset << endl;
1668 Res = Hamiltonian::Zero(H.qPhys);
1669 OPERATOR_IS_SET =
true;
1674 if (loc<H.length()-dLphys)
1676 Res = H.template cdagc<UP,UP>(loc,loc+dLphys,0,0);
1677 OPERATOR_IS_SET =
true;
1681 lout << termcolor::yellow <<
"HSF operator hit right edge! Returning zero." << termcolor::reset << endl;
1682 Res = Hamiltonian::Zero(H.qPhys);
1683 OPERATOR_IS_SET =
true;
1688 else if (spec ==
"IHSF")
1690 if constexpr (Symmetry::IS_SPIN_SU2())
1692 if (loc<H.length()-dLphys)
1694 Res = H.cdagc(loc+dLphys,loc,0,0);
1695 OPERATOR_IS_SET =
true;
1699 lout << termcolor::yellow <<
"IHSF operator hit right edge! Returning zero." << termcolor::reset << endl;
1700 Res = Hamiltonian::Zero(H.qPhys);
1701 OPERATOR_IS_SET =
true;
1706 if (loc<H.length()-dLphys)
1708 Res = H.template cdagc<UP,UP>(loc+dLphys,loc,0,0);
1709 OPERATOR_IS_SET =
true;
1713 lout << termcolor::yellow <<
"IHSF operator hit right edge! Returning zero." << termcolor::reset << endl;
1714 Res = Hamiltonian::Zero(H.qPhys);
1715 OPERATOR_IS_SET =
true;
1720 else if (spec ==
"HTS")
1722 if constexpr (Symmetry::IS_SPIN_SU2())
1724 if (loc<H.length()-dLphys)
1726 Res = H.cdagc3(loc,loc+dLphys,0,0);
1727 OPERATOR_IS_SET =
true;
1731 lout << termcolor::yellow <<
"HTS operator hit right edge! Returning zero." << termcolor::reset << endl;
1732 Res = Hamiltonian::Zero(H.qPhys);
1733 OPERATOR_IS_SET =
true;
1738 if (loc<H.length()-dLphys)
1740 Res = H.template cdagc<UP,DN>(loc,loc+dLphys,0,0);
1741 OPERATOR_IS_SET =
true;
1745 lout << termcolor::yellow <<
"HTS operator hit right edge! Returning zero." << termcolor::reset << endl;
1746 Res = Hamiltonian::Zero(H.qPhys);
1747 OPERATOR_IS_SET =
true;
1752 else if (spec ==
"IHTS")
1754 if constexpr (Symmetry::IS_SPIN_SU2())
1756 if (loc<H.length()-dLphys)
1758 Res = H.cdagc3(loc+dLphys,loc,0,0);
1759 OPERATOR_IS_SET =
true;
1763 lout << termcolor::yellow <<
"IHTS operator hit right edge! Returning zero." << termcolor::reset << endl;
1764 Res = Hamiltonian::Zero(H.qPhys);
1765 OPERATOR_IS_SET =
true;
1770 if (loc<H.length()-dLphys)
1772 Res = H.template cdagc<DN,UP>(loc+dLphys,loc,0,0);
1773 OPERATOR_IS_SET =
true;
1777 lout << termcolor::yellow <<
"IHTS operator hit right edge! Returning zero." << termcolor::reset << endl;
1778 Res = Hamiltonian::Zero(H.qPhys);
1779 OPERATOR_IS_SET =
true;
1786 assert(OPERATOR_IS_SET);
External functions to manipulate Mps and Mpo objects.
Scalar dot(const Mps< Symmetry, Scalar > &Vbra, const Mps< Symmetry, Scalar > &Vket)
Hamiltonian sum(const Hamiltonian &H1, const Hamiltonian &H2, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
void OxV(const Mpo< Symmetry, MpoScalar > &H, const Mpo< Symmetry, MpoScalar > &Hdag, const Mps< Symmetry, Scalar > &Vin, Mps< Symmetry, Scalar > &Vout, bool VERBOSE=true, double tol_compr=1e-4, int Mincr=100, int Mlimit=10000, int max_halfsweeps=100, int min_halfsweeps=1, bool MEASURE_DISTANCE=true)
Hamiltonian prod(const Hamiltonian &H1, const Hamiltonian &H2, const qarray< Hamiltonian::Symmetry::Nq > &Qtot=Hamiltonian::Symmetry::qvacuum(), DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
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 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)
void OxV_exact(const Mpo< Symmetry, MpoScalar > &O, const Mps< Symmetry, Scalar > &Vin, Mps< Symmetry, Scalar > &Vout, double tol_compr=1e-7, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::HALFSWEEPWISE, int max_halfsweeps=200, int min_halfsweeps=1, int Minit=-1, DMRG::BROOM::OPTION BROOMOPTION=DMRG::BROOM::QR)
double norm(const PivotMatrix0< Symmetry, Scalar, MpoScalar > &H)
void recalc_FTw(double wmin_new, double wmax_new, int Nw_new=501)
void set_verbosity(DMRG::VERBOSITY::OPTION VERBOSITY)
void recalc_FTwCell(double wmin_new, double wmax_new, int Nw_new=501, bool TRANSPOSE=false)
void scale(const Scalar factor, const Scalar offset=0., const std::size_t power=0ul, const double tolerance=1.e-14)
static Mpo< Symmetry, Scalar > Identity(const std::vector< std::vector< qType > > &qPhys, const qType &Q=Symmetry::qvacuum())
void set_locality(std::size_t LocalSite_input)
void compute_finiteCell(int Lcell, int x0, string wd, string label, double tmax, double dt=0.1, double wmin=-10., double wmax=10., int wpoints=501, Q_RANGE QR=ZERO_2PI, int qpoints=501, GREEN_INTEGRATION INT=OOURA, size_t Mlim=500ul, double tol_DeltaS=1e-2, double tol_compr=1e-4)
Mps< Symmetry, Scalar > PhiT
Hamiltonian::Symmetry Symmetry
vector< vector< Mps< Symmetry, complex< double > > > > OxPhiCellKet
const double & energy() const
static string DAG(std::string spec)
vector< vector< Scalar > > Oshift
static bool TIME_DIR(std::string spec)
static bool CHECK_SPEC(string spec)
vector< vector< Mps< Symmetry, complex< double > > > > OxPhiCellBra
void make_A1P_finite(GreenPropagator< Hamiltonian, Symmetry, Scalar, complex< double > > &Gfull, string wd, string label, double tmax, double wmin=-10., double wmax=10., int wpoints=501, GREEN_INTEGRATION INT=OOURA)
const Mps< Symmetry, Scalar > & get_PhiT() const
void continue_beta_propagation(const Hamiltonian &Hprop, int Lcell, int dLphys, double s_betainit, double betainit, double betamax, double dbeta, double tol_compr_beta, size_t Mlim, qarray< Hamiltonian::Symmetry::Nq > Q, double betaswitch, string wd, string th_label, string LOAD_BETA, bool SAVE_BETA, DMRG::VERBOSITY::OPTION VERB, vector< double > stateSavePoints, vector< string > stateSaveLabels, bool CALC_C, bool CALC_CHI)
Eigenstate< Umps< Symmetry, Scalar > > g
Mps< Symmetry, complex< double > > PhiTt
void resize_Green(string wd, string label, int Ns, double tmax, double dt, double wmin, double wmax, int wpoints, Q_RANGE QR, int qpoints, GREEN_INTEGRATION INT)
vector< GreenPropagator< Hamiltonian, typename Hamiltonian::Symmetry, Scalar, complex< double > > > Green
void compute_thermal(string wd, string label, int dLphys, double tmax, double dt=0.1, double wmin=-10., double wmax=10., int wpoints=501, Q_RANGE QR=ZERO_2PI, int qpoints=501, GREEN_INTEGRATION INT=OOURA, size_t Mlim=500ul, double tol_DeltaS=1e-2, double tol_compr=1e-4)
Mpo< Symmetry, Scalar > get_Op(const Hamiltonian &H, size_t loc, std::string spec, double factor=1., size_t locy=0, int dLphys=1)
Eigenstate< Mps< Symmetry, Scalar > > gfinite
vector< vector< MatrixXcd > > get_GwqCell(int z) const
void compute(string wd, string label, int Ns, double tmax, double dt=0.2, double wmin=-10., double wmax=10., int wpoints=501, Q_RANGE QR=ZERO_2PI, int qpoints=501, GREEN_INTEGRATION INT=OOURA, size_t Mlim=500ul, double tol_DeltaS=1e-2, double tol_compr=1e-4)
vector< vector< Mps< Symmetry, complex< double > > > > OxPhiTt
void apply_operators_on_thermal_state(int Lcell, int dLphys, bool CHECK=true)
void make_A1P(GreenPropagator< Hamiltonian, Symmetry, Scalar, complex< double > > &Gfull, string wd, string label, int Ns, double tmax, double wmin=-10., double wmax=10., int wpoints=501, Q_RANGE QR=ZERO_2PI, int qpoints=501, GREEN_INTEGRATION INT=OOURA, bool SAVE_N_MU=true)
void set_Ncells(int Ncells_input)
Mps< Symmetry, Scalar > Phi
vector< vector< Mpo< typename Hamiltonian::Symmetry, Scalar > > > Odag
SpectralManager(const vector< string > &specs_input, const Hamiltonian &H, DMRG::VERBOSITY::OPTION VERB=DMRG::VERBOSITY::HALFSWEEPWISE)
void set_measurement(int iz, string spec, double factor, int dLphys, qarray< Symmetry::Nq > Q, int Lcell, int measure_interval_input=10, string measure_name_input="M", string measure_subfolder_input=".", bool TRANSFORM=false)
void beta_propagation(const Hamiltonian &Hprop, const HamiltonianThermal &Htherm, int Lcell, int dLphys, double betamax_input, double dbeta_input, double tol_compr_beta_input, size_t Mlim, qarray< Symmetry::Nq > Q, double s_betainit, double betaswitch, string wd, string th_label, bool LOAD_BETA=false, bool SAVE_BETA=true, DMRG::VERBOSITY::OPTION VERB=DMRG::VERBOSITY::HALFSWEEPWISE, vector< double > stateSavePoints={}, vector< string > stateSaveLabels={}, int Ntaylor=0, bool CALC_C=true, bool CALC_CHI=true, bool USE_PHIT=false)
void compute_finite(size_t j0, string wd, string label, int Ns, double tmax, double dt=0.1, double wmin=-10., double wmax=10., int wpoints=501, GREEN_INTEGRATION INT=OOURA, size_t Mlim=500ul, double tol_DeltaS=1e-2, double tol_compr=1e-4)
void reload(string wd, const vector< string > &specs_input, string label, int L, int Ncells, int Ns, double tmax, double wmin=-10., double wmax=10., int wpoints=501, Q_RANGE QR=ZERO_2PI, int qpoints=501, GREEN_INTEGRATION INT=OOURA)
DMRG::VERBOSITY::OPTION CHOSEN_VERB
Hamiltonian::Mpo::Scalar_ Scalar
const Umps< Symmetry, Scalar > & ground() const
void set_PhiT(const Mps< Symmetry, Scalar > &PhiT_input)
function< double(size_t)> max_alpha_rsvd
function< DMRG::ITERATION::OPTION(size_t)> iteration
DMRG::DIRECTION::OPTION INITDIR