4#include <boost/algorithm/string.hpp>
6#include <Eigen/SparseCore>
7#include <boost/rational.hpp>
10#include "HDF5Interface.h"
11#include "ParamHandler.h"
14template<
typename VectorType>
32 return (
l==b.
l and
s==b.
s)?
true:
false;
46 std::array<int,4>
lev;
47 std::array<int,4>
jx2;
51double cgc (
int j1x2,
int j2x2,
int Jx2,
int m1x2,
int m2x2,
int Mx2)
53 double Wigner3j = gsl_sf_coupling_3j(j1x2,j2x2,Jx2,m1x2,m2x2,-Mx2);
55 return pow(-1,+j1x2/2-j2x2/2+Mx2/2) * sqrt(Jx2+1.) * Wigner3j;
79void load_nuclearData (
string el,
string set,
string rootfolder,
NuclearInfo &info,
double &V0, MatrixXd &Vij, vector<MatrixXd> &Vijnocgc, VectorXi °, VectorXd &eps0,
bool &REF)
83 ifstream DataLoader(rootfolder+
"data_nuclear/sets.sav");
85 while (getline(DataLoader, line))
87 if (line[0] ==
'#')
continue;
90 boost::split(split, line, boost::is_any_of(
"\t"));
91 if (split[0] == el and split[1] == set)
96 info.
Nmax = stoi(split[3]);
99 info.
P =
static_cast<Nuclear::PARTICLE
>(stoi(split[9]));
100 info.
PARAM = split[10];
101 lout << info.
info() << endl;
111 if (el ==
"Sn" and set ==
"benchmark")
119 deg.resize(info.
Nlev); deg << 4, 3, 2, 1, 6;
121 eps0.resize(info.
Nlev); eps0 << -6.121, -5.508, -3.749, -3.891, -3.778;
141 for (
int i=0; i<info.
Nlev; ++i)
142 for (
int j=0; j<i; ++j)
148 Vijnocgc.resize(Jmax/2+1);
149 for (
int J=0; J<=Jmax; J+=2)
154 for (
int i=0; i<info.
Nlev; ++i)
155 for (
int j=0; j<info.
Nlev; ++j)
157 Vij(i,j) /= sqrt(deg(i)*deg(j));
162 else if (el ==
"h11shell" and set ==
"benchmark")
169 deg.resize(info.
Nlev); deg << 6;
171 eps0.resize(info.
Nlev); eps0 << 0.;
174 Vij.setConstant(0.25);
177 Vijnocgc.resize(Jmax/2+1);
178 for (
int J=0; J<=Jmax; J+=2)
180 Vijnocgc[J/2] = Vij*6.;
183 else if (el ==
"Richardson50" and set ==
"benchmark")
190 deg.resize(info.
Nlev); deg.setConstant(1);
192 eps0.resize(info.
Nlev);
193 for (
int j=0; j<info.
Nlev; ++j)
202 Vijnocgc.resize(Jmax/2+1);
203 for (
int J=0; J<=Jmax; J+=2)
209 else if (el ==
"f7shell" and set ==
"benchmark")
212 std::array<double,4> V_J = {1., 0.981/V0, -0.140/V0, -0.664/V0};
217 deg.resize(info.
Nlev); deg << 4;
219 eps0.resize(info.
Nlev); eps0 << -9.626;
225 Vijnocgc.resize(Jmax/2+1);
226 for (
int J=0; J<=Jmax; J+=2)
228 Vijnocgc[J/2] = Vij * V_J[J/2];
231 else if (el ==
"testshell" and set ==
"benchmark")
234 std::array<double,3> V_J = {1., 0.5, 0.25};
239 deg.resize(info.
Nlev); deg << 1, 2, 3;
241 eps0.resize(info.
Nlev); eps0 << 0., 0., 0.;
243 double lower_bound = 0.;
244 double upper_bound = 1.;
245 std::uniform_real_distribution<double> unif(lower_bound,upper_bound);
246 std::default_random_engine re;
250 for (
int i=0; i<info.
Nlev; ++i)
251 for (
int j=0; j<=i; ++j)
258 Vijnocgc.resize(Jmax/2+1);
259 for (
int J=0; J<=Jmax; J+=2)
261 Vijnocgc[J/2] = Vij * V_J[J/2];
265 if (set !=
"benchmark")
267 HDF5Interface target(make_string(rootfolder+
"NuclearLevels",info.
PARAM,
"/hdf5/NuclearData_Z=",info.
Zsingle,
"_N=",info.
Nsingle,
"_P=",info.
P,
"_j=",info.
levelstring,
".h5"), READ);
268 target.load_matrix(Vij,
"Vij",
"");
269 target.load_vector(eps0,
"eps0",
"");
270 target.load_vector(deg,
"deg",
"");
273 target.load_scalar(Jmax,
"Jmax",
"");
274 Vijnocgc.resize(Jmax/2+1);
275 for (
int J=0; J<=Jmax; J+=2)
277 target.load_matrix(Vijnocgc[J/2],
"Vijnocgc",make_string(
"J=",J));
296template<
typename MODEL>
303 NuclearManager (
int Nclosed_input,
int Nsingle_input,
int Z_input,
const ArrayXi °_input,
const vector<string> &labels_input,
304 const ArrayXd &eps0_input,
const ArrayXXd &Vij_input,
double V0_input=1.,
305 bool REF_input=
false,
string PARAM_input=
"Seminole")
310 lout <<
"Nlev=" <<
Nlev <<
", L=" <<
L << endl;
311 Vij.triangularView<Lower>() =
Vij.transpose();
317 NuclearManager (
int Nclosed_input,
int Nsingle_input,
int Z_input,
const string &filename,
double V0_input,
bool REF_input=
false)
320 HDF5Interface source(filename+
".h5", READ);
322 source.load_vector<
int>(
deg,
"deg",
"");
323 source.load_vector<
double>(
eps0,
"eps0",
"");
324 source.load_matrix<
double>(
Vij,
"Vij",
"");
328 lout <<
"Nlev=" <<
Nlev <<
", L=" <<
L << endl;
329 Vij.triangularView<Lower>() =
Vij.transpose();
332 for (
int i=0; i<
Nlev; ++i)
334 source.load_char(
labels[i], make_string(
"lev",i));
346 tuple<Eigenstate<typename MODEL::StateXd>,string,
int>
349 Eigenstate<typename MODEL::StateXd>
352 void compute (
bool LOAD_MPO=
false,
bool SAVE_MPO=
false,
string wd=
"./",
int minNshell=0,
int maxNshell=-1,
bool SAVE=
true);
353 void compute_parallel (
bool LOADv=
false,
bool SAVE_MPO=
false,
string wd=
"./",
int minNshell=0,
int maxNshell=-1,
bool SAVE=
true);
367 ArrayXd
Sn_nref (
int Nshell)
const;
368 ArrayXd
Sn_Nref (
int Nshell)
const;
369 ArrayXd
Sn_Pref (
int Nshell)
const;
372 const Eigenstate<typename MODEL::StateXd> &
get_g (
int Nshell)
const {
return g[Nshell];}
384 void save (
string wd,
int Nfrst=0,
int Nlast=-1,
int dNshell=1)
const;
412 vector<Eigenstate<typename MODEL::StateXd>>
g;
425 vector<Mpo<typename MODEL::Symmetry>>
make_cdagj (
const MODEL &H_input)
const;
427 vector<Mpo<typename MODEL::Symmetry>>
cdagj;
430template<
typename MODEL>
437 for (
int i=1; i<Nlev; ++i)
439 offset(i) = deg.head(i).sum();
441 lout <<
"offset=" << offset.transpose() << endl;
444 Ghop.resize(L,L); Ghop.setZero();
445 for (
int i=0; i<Nlev; ++i)
446 for (
int j=0; j<Nlev; ++j)
448 Ghop.block(offset(i),offset(j),deg(i),deg(j)).setConstant(-V0*Vij(i,j));
451 if constexpr (MODEL::FAMILY ==
HUBBARD)
453 for (
int i=0; i<L; ++i)
454 for (
int j=0; j<L; ++j)
456 Ghop(i,j) *= pow(-1,i+j);
464 for (
int j1=0; j1<Nlev; ++j1)
465 for (
int j2=0; j2<Nlev; ++j2)
467 boost::rational<int> J1 = deg(j1)-boost::rational<int>(1,2);
468 boost::rational<int> J2 = deg(j2)-boost::rational<int>(1,2);
470 ArrayXXd signblock(deg(j1),deg(j2));
472 for (
int m1=0; m1<deg(j1); ++m1)
473 for (
int m2=0; m2<deg(j2); ++m2)
475 boost::rational<int> M1 = J1-m1;
476 boost::rational<int> M2 = J2-m2;
477 assert((J1+J2+M1+M2).denominator() == 1);
478 signblock(m1,m2) = pow(-1,(J1+J2-M1-M2).numerator());
481 sign2d.block(offset(j1),offset(j2),deg(j1),deg(j2)) = signblock;
485 sign_per_level.resize(Nlev);
487 for (
int j=0; j<Nlev; ++j)
489 boost::rational<int> J = deg(j)-boost::rational<int>(1,2);
491 ArrayXd signblock(deg(j));
493 for (
int m=0; m<deg(j); ++m)
495 boost::rational<int> M = J-m;
496 signblock(m) = pow(-1,(J-M).numerator());
499 sign_per_level[j] = signblock;
500 lout << signblock.transpose() << endl;
502 sign.segment(offset(j),deg(j)) = signblock;
506 Ghop = (Ghop.array()*sign2d).matrix();
511 Gloc = Ghop.diagonal();
512 Ghop.diagonal().setZero();
515 onsite.resize(L); onsite.setZero();
516 for (
int i=0; i<Nlev; ++i)
518 onsite.segment(offset(i),deg(i)).setConstant(eps0(i));
521 onsite_free.resize(2*L);
522 for (
int i=0; i<L; ++i)
524 onsite_free(2*i) = onsite(i);
525 onsite_free(2*i+1) = onsite(i);
528 outfile = make_string(
"PairingResult_Z=",Z,
"_Nclosed=",Nclosed,
"_Nsingle=",Nsingle,
"_V0=",V0);
529 outfile += make_string(
"_j=",levelstring);
530 if (PARAM!=
"Seminole") outfile += make_string(
"_PARAM=",PARAM);
532 lout <<
"outfile=" << outfile << endl;
543 mfactor.resize(L); mfactor.setZero();
545 for (
int j=0; j<Nlev; ++j)
547 boost::rational<int> jval = deg(j)-boost::rational<int>(1,2);
552 for (boost::rational<int> mval=jval; mval>0; --mval)
554 mfactor(l) = (boost::rational<int>(2,1)*mval).numerator();
555 mlist.push_back(+mval);
556 mlist.push_back(-mval);
557 jlist.push_back(jval);
558 jlist.push_back(jval);
559 orblist.push_back(j);
560 orblist.push_back(j);
570 FlipChart[
UP].resize(2*L,2*L); FlipChart[
UP].setZero();
571 FlipChart[
DN].resize(2*L,2*L); FlipChart[
DN].setZero();
572 for (
int i=0; i<mlist.size(); ++i)
573 for (
int j=0; j<mlist.size(); ++j)
575 double jval = boost::rational_cast<double>(jlist[i]);
576 double m1 = boost::rational_cast<double>(mlist[i]);
577 double m2 = boost::rational_cast<double>(mlist[j]);
579 if (mlist[j] == mlist[i]+boost::rational<int>(1,1) and jlist[i]==jlist[j])
581 FlipChart[
DN](i,j) = sqrt(jval*(jval+1.)-m1*m2);
583 if (mlist[j] == mlist[i]-boost::rational<int>(1,1) and jlist[i]==jlist[j])
585 FlipChart[
UP](i,j) = sqrt(jval*(jval+1.)-m1*m2);
592template<
typename MODEL>
597 for (
int i=0; i<deg.rows(); ++i)
604template<
typename MODEL>
608 double res = std::nan(
"0");
621 vector<double> EDenergies =
657 return EDenergies[Nshell];
660template<
typename MODEL>
664 ArrayXd res = Sn_Nref(Nshell);
665 for (
int i=0; i<5; ++i) res(i) /= deg(i)*2;
674template<
typename MODEL>
687 else if (Nshell == 14)
695 else if (Nshell == 16)
703 else if (Nshell == 18)
714template<
typename MODEL>
727 else if (Nshell == 14)
735 else if (Nshell == 16)
743 else if (Nshell == 18)
751 for (
int i=0; i<5; ++i) res(i) /= sqrt(deg(i));
760template<
typename MODEL>
773template<
typename MODEL>
777 string filename = make_string(wd,
"H_Z=",Z,
"_Nclosed=",Nclosed,
"_Nsingle=",Nsingle,
"_V0=",V0);
778 filename += make_string(
"_j=",levelstring);
779 if (PARAM!=
"Seminole") filename += make_string(
"_PARAM=",PARAM);
783 MODEL Hres(L,{{
"maxPower",1ul}});
786 lout << H.info() << endl;
790 ArrayXXd Ghopx2 = 2.*Ghop;
792 vector<Param> params_loc;
793 params_loc.push_back({
"t",0.});
794 params_loc.push_back({
"J",0.});
795 params_loc.push_back({
"maxPower",1ul});
796 if constexpr (MODEL::FAMILY ==
HUBBARD) params_loc.push_back({
"REMOVE_SINGLE",
true});
798 for (
size_t l=0; l<L; ++l)
800 if constexpr (MODEL::FAMILY ==
HUBBARD)
802 params_loc.push_back({
"t0",onsite(l),l});
803 params_loc.push_back({
"U",Gloc(l),l});
804 params_loc.push_back({
"mfactor",mfactor(l),l});
806 else if constexpr (MODEL::FAMILY ==
HEISENBERG)
808 params_loc.push_back({
"nu",2.*onsite(l)+Gloc(l),l});
815 Stopwatch<> CompressionTimer;
816 for (
int i=0; i<Ghopx2.rows(); ++i)
819 vector<Param> params_tmp;
820 params_tmp.push_back({
"t",0.});
821 params_tmp.push_back({
"J",0.});
822 params_tmp.push_back({
"maxPower",1ul});
823 if constexpr (MODEL::FAMILY ==
HUBBARD) params_tmp.push_back({
"REMOVE_SINGLE",
true});
825 ArrayXXd Ghopx2row(Ghop.rows(),Ghop.cols());
827 Ghopx2row.matrix().row(i) = Ghopx2.matrix().row(i);
828 if constexpr (MODEL::FAMILY ==
HUBBARD)
830 params_tmp.push_back({
"Vxyfull",Ghopx2row});
831 for (
size_t l=0; l<L; ++l) params_tmp.push_back({
"mfactor",mfactor(l),l});
833 else if constexpr (MODEL::FAMILY ==
HEISENBERG)
835 params_tmp.push_back({
"Jxyfull",Ghopx2row});
841 Terms = MODEL::sum(Terms,Hterm);
844 vector<Param> params_full = params_loc;
845 if constexpr (MODEL::FAMILY ==
HUBBARD)
847 params_full.push_back({
"Vxyfull",Ghopx2});
849 else if constexpr (MODEL::FAMILY ==
HEISENBERG)
851 params_full.push_back({
"Jxyfull",Ghopx2});
858 H = MODEL(Hmpo,params_full);
860 lout << H.info() << endl;
861 lout << CompressionTimer.info(
"MPO compression even") << endl;
863 if (SAVE) H.save(filename);
866 if constexpr (MODEL::FAMILY ==
HUBBARD)
872 Stopwatch<> CompressionTimerOdd;
873 #pragma omp parallel for
874 for (
int j=0; j<Nlev; ++j)
876 vector<Param> params_loc_odd;
877 params_loc_odd.push_back({
"t",0.});
878 params_loc_odd.push_back({
"J",0.});
879 params_loc_odd.push_back({
"maxPower",1ul});
880 for (
size_t l=0; l<L; ++l)
882 if (l<offset(j) or l>=offset(j)+deg(j)) params_loc_odd.push_back({
"REMOVE_SINGLE",
true,l});
883 else params_loc_odd.push_back({
"REMOVE_SINGLE",
false,l});
885 params_loc_odd.push_back({
"t0",onsite(l),l});
886 params_loc_odd.push_back({
"U",Gloc(l),l});
887 params_loc_odd.push_back({
"mfactor",mfactor(l),l});
893 for (
int i=0; i<Ghopx2.rows(); ++i)
895 vector<Param> params_tmp_odd;
896 params_tmp_odd.push_back({
"t",0.});
897 params_tmp_odd.push_back({
"J",0.});
898 params_tmp_odd.push_back({
"maxPower",1ul});
899 for (
size_t l=0; l<L; ++l)
901 if (l<offset(j) or l>=offset(j)+deg(j)) params_tmp_odd.push_back({
"REMOVE_SINGLE",
true,l});
902 else params_tmp_odd.push_back({
"REMOVE_SINGLE",
false,l});
904 params_tmp_odd.push_back({
"mfactor",mfactor(l),l});
907 ArrayXXd Ghopx2row(Ghop.rows(),Ghop.cols());
909 Ghopx2row.matrix().row(i) = Ghopx2.row(i);
910 params_tmp_odd.push_back({
"Vxyfull",Ghopx2row});
915 Terms_odd = MODEL::sum(Terms_odd,Hterm);
918 vector<Param> params_full_odd = params_loc_odd;
919 params_loc_odd.push_back({
"Vxyfull",Ghopx2});
922 Hodd[j] = MODEL(Hmpo,params_full_odd);
924 lout << CompressionTimerOdd.info(
"MPO compression odd") << endl;
949template<
typename MODEL>
953 string filename = make_string(wd,
"H_Z=",Z,
"_Nclosed=",Nclosed,
"_Nsingle=",Nsingle,
"_V0=",V0);
954 filename += make_string(
"_j=",levelstring);
955 if (PARAM!=
"Seminole") filename += make_string(
"_PARAM=",PARAM);
959 MODEL Hres(L,{{
"maxPower",1ul}});
962 lout << H.info() << endl;
966 ArrayXXd Ghopx2 = 2.*Ghop;
968 vector<Param> params_loc;
969 params_loc.push_back({
"t",0.});
970 params_loc.push_back({
"J",0.});
971 params_loc.push_back({
"maxPower",1ul});
973 for (
size_t l=0; l<L; ++l)
975 if constexpr (MODEL::FAMILY ==
HUBBARD)
977 params_loc.push_back({
"t0",onsite(l),l});
978 params_loc.push_back({
"U",Gloc(l),l});
979 params_loc.push_back({
"mfactor",mfactor(l),l});
981 else if constexpr (MODEL::FAMILY ==
HEISENBERG)
983 params_loc.push_back({
"nu",2.*onsite(l)+Gloc(l),l});
990 Stopwatch<> CompressionTimer;
991 for (
int i=0; i<Ghopx2.rows(); ++i)
994 vector<Param> params_tmp;
995 params_tmp.push_back({
"t",0.});
996 params_tmp.push_back({
"J",0.});
997 params_tmp.push_back({
"maxPower",1ul});
999 ArrayXXd Ghopx2row(Ghop.rows(),Ghop.cols());
1000 Ghopx2row.setZero();
1001 Ghopx2row.matrix().row(i) = Ghopx2.matrix().row(i);
1002 if constexpr (MODEL::FAMILY ==
HUBBARD)
1004 params_tmp.push_back({
"Vxyfull",Ghopx2row});
1005 for (
size_t l=0; l<L; ++l) params_tmp.push_back({
"mfactor",mfactor(l),l});
1007 else if constexpr (MODEL::FAMILY ==
HEISENBERG)
1009 params_tmp.push_back({
"Jxyfull",Ghopx2row});
1015 Terms = MODEL::sum(Terms,Hterm);
1018 vector<Param> params_full = params_loc;
1019 if constexpr (MODEL::FAMILY ==
HUBBARD)
1021 params_full.push_back({
"Vxyfull",Ghopx2});
1023 else if constexpr (MODEL::FAMILY ==
HEISENBERG)
1025 params_full.push_back({
"Jxyfull",Ghopx2});
1029 Hfull = MODEL(Hmpo,params_full);
1030 lout << CompressionTimer.info(
"MPO compression full") << endl;
1032 if (SAVE) H.save(filename);
1040 vector<Mpo<typename VMPS::HubbardU1::Symmetry>> res;
1042 for (
int j=0; j<Nlev; ++j)
1044 for (
int i=0; i<deg[j]; ++i)
1046 auto cdagj1 = H_input.template cdag<UP>(offset(j)+i);
1047 auto cdagj2 = H_input.template cdag<DN>(offset(j)+i);
1050 res[j] =
sum(cdagj1,cdagj2);
1054 res[j] =
sum(res[j],cdagj1);
1055 res[j] =
sum(res[j],cdagj2);
1067 for (
int i=0; i<deg[j]; ++i)
1069 auto cdagj1 = H_input.template cdag<UP>(offset(j)+i);
1070 auto cdagj2 = H_input.template cdag<DN>(offset(j)+i);
1073 res =
sum(cdagj1,cdagj2);
1077 res =
sum(res,cdagj1);
1078 res =
sum(res,cdagj2);
1088 vector<Mpo<typename VMPS::HubbardU1xU1::Symmetry>> res;
1090 for (
int j=0; j<Nlev; ++j)
1092 for (
int i=0; i<deg[j]; ++i)
1094 auto cdagj1 = H_input.template cdag<UP>(offset(j)+i);
1102 res[j] =
sum(res[j],cdagj1);
1115 for (
int i=0; i<deg[j]; ++i)
1117 auto cdagj1 = H_input.template cdag<UP>(offset(j)+i);
1125 res =
sum(res,cdagj1);
1136 vector<Mpo<typename VMPS::HeisenbergU1::Symmetry>> res;
1148template<
typename MODEL>
1152 vector<tuple<orbital,orbital,orbital,orbital,double,orbinfo>> res;
1154 for (
int r1=0; r1<2*L; ++r1)
1155 for (
int r2=0; r2<2*L; ++r2)
1156 for (
int r3=0; r3<2*L; ++r3)
1157 for (
int r4=0; r4<2*L; ++r4)
1164 int j1x2 = (2*jlist[r1]).numerator();
1165 int j2x2 = (2*jlist[r2]).numerator();
1166 int j3x2 = (2*jlist[r3]).numerator();
1167 int j4x2 = (2*jlist[r4]).numerator();
1169 int m1x2 = (2*mlist[r1]).numerator();
1170 int m2x2 = (2*mlist[r2]).numerator();
1171 int m3x2 = (2*mlist[r3]).numerator();
1172 int m4x2 = (2*mlist[r4]).numerator();
1174 int lev1 = orblist[r1];
1175 int lev2 = orblist[r2];
1176 int lev3 = orblist[r3];
1177 int lev4 = orblist[r4];
1180 oinfo.
jx2[0] = j1x2;
1181 oinfo.
jx2[1] = j2x2;
1182 oinfo.
jx2[2] = j3x2;
1183 oinfo.
jx2[3] = j4x2;
1184 oinfo.
lev[0] = lev1;
1185 oinfo.
lev[1] = lev2;
1186 oinfo.
lev[2] = lev3;
1187 oinfo.
lev[3] = lev4;
1188 oinfo.
label[0] = labels[lev1];
1189 oinfo.
label[1] = labels[lev2];
1190 oinfo.
label[2] = labels[lev3];
1191 oinfo.
label[3] = labels[lev4];
1194 if (lev1==lev2 and lev3==lev4)
1197 for (
int M=-J; M<=J; ++M)
1199 factor +=
cgc(j1x2,j2x2,2*J, m1x2,m2x2,2*M) *
cgc(j3x2,j4x2,2*J, m3x2,m4x2,2*M);
1206 for (
int i=0; i<res.size(); ++i)
1209 (get<0>(res[i])==o2 and get<1>(res[i])==o1 and
1210 get<2>(res[i])==o4 and get<3>(res[i])==o3 and
1211 get<5>(res[i])==oinfo)
1213 (get<0>(res[i])==o1 and get<1>(res[i])==o2 and
1214 get<2>(res[i])==o3 and get<3>(res[i])==o4 and
1215 get<5>(res[i])==oinfo)
1218 get<4>(res[i]) -= factor;
1221 else if (get<0>(res[i])==o2 and get<1>(res[i])==o1 and
1222 get<2>(res[i])==o3 and get<3>(res[i])==o4 and
1223 get<5>(res[i])==oinfo)
1225 get<4>(res[i]) += factor;
1230 if (!ADDED and abs(factor)>1e-8)
1235 res.push_back(make_tuple(o1,o2,o3,o4, -factor, oinfo));
1251 GlobParam.
Minit = 100ul;
1252 GlobParam.
Qinit = 100ul;
1255 GlobParam.
Mlimit = 500ul;
1261 size_t lim2site = 24ul;
1263 DynParam.
max_alpha_rsvd = [lim2site] (
size_t i) {
return (i<=lim2site+4ul)? 1e4:0.;};
1264 size_t Mincr_per = 2ul;
1265 DynParam.
Mincr_per = [Mincr_per] (
size_t i) {
return Mincr_per;};
1271 string Jlabel_res =
"0";
1272 int Jindex_res = -1;
1273 Eigenstate<typename VMPS::HubbardU1::StateXd> gres;
1275 vector<jEigenstate<typename VMPS::HubbardU1::StateXd>> godd;
1276 vector<jEigenstate<typename VMPS::HubbardU1::StateXd>> ginit;
1278 typename VMPS::HubbardU1::Solver DMRGs;
1279 DMRGs.userSetGlobParam();
1280 DMRGs.userSetDynParam();
1281 DMRGs.GlobParam = GlobParam;
1282 DMRGs.DynParam = DynParam;
1286 DMRGs.edgeState(H, gres, Q, EDGE);
1291 for (
int j=0; j<Nlev; ++j)
1295 Eigenstate<typename VMPS::HubbardU1::StateXd> gprev;
1296 while (Ediff > 1e-6)
1299 DMRGt.GlobParam.min_halfsweeps = 1ul;
1302 DMRGt.edgeState(Hodd[j], gprev, {Nshell-1}, EDGE);
1303 Ediff = abs(gprev.energy-g[Nshell-1].energy);
1306 if (Niter == 4)
break;
1309 bool INCLUDE =
true;
1314 if (2.*deg(j)-avgN[Nshell-1](j) > 0.01 and INCLUDE)
1316 double compr_tol = (Nshell<=10 or Nshell>=max(2*
static_cast<int>(L)-10,0))? 2.:1e-8;
1320 gtmp.
label = labels[j];
1324 ginit.push_back(gtmp);
1329 #pragma omp critical
1331 lout <<
"guess: j=" << j
1332 <<
", label=" << labels[j]
1334 <<
", Niter=" << Niter << endl;
1339 assert(ginit.size()>0);
1341 sort(ginit.begin(), ginit.end(), [] (
const auto& lhs,
const auto& rhs) {return lhs.eigenstate.energy < rhs.eigenstate.energy;});
1345 for (
int i=0; i<min(Nguess,ginit.size()); ++i)
1347 int j = ginit[i].index;
1348 godd.push_back(ginit[i]);
1356 #pragma omp critical
1358 lout << termcolor::yellow <<
"Nshell=" << Nshell
1359 <<
": must restart j=" << j <<
" with var=" << var << termcolor::reset << endl;
1364 DMRGr.GlobParam.min_halfsweeps = 2ul;
1366 DMRGr.edgeState(Hodd[j], godd[i].eigenstate, Q, EDGE, (Niter==0)?
true:
false);
1367 var = abs(
avg(godd[i].eigenstate.state,Hodd[j],Hodd[j],godd[i].eigenstate.state)-pow(godd[i].eigenstate.energy,2))/L;
1368 if (Niter>0 and var<1e-5)
1370 #pragma omp critical
1372 lout <<
"Nshell=" << Nshell <<
", j=" << j <<
", new try brought: var=" << var << endl;
1376 if (Niter == 21)
break;
1380 sort(godd.begin(), godd.end(), [] (
const auto& lhs,
const auto& rhs) {return lhs.eigenstate.energy < rhs.eigenstate.energy;});
1382 gres = godd[0].eigenstate;
1383 Jlabel_res = godd[0].label;
1384 Jindex_res = godd[0].index;
1388 for (
int i=0; i<min(Nguess,ginit.size()); ++i)
1390 lout <<
"j=" << godd[i].index <<
", label=" << godd[i].label <<
", energy=" << godd[i].eigenstate.energy << endl;
1398 lout << termcolor::blue << setprecision(16) << gres.energy << setprecision(6) << termcolor::reset << endl;
1406 var = abs(
avg(gres.state,H,H,gres.state)-pow(gres.energy,2))/L;
1410 var = abs(
avg(gres.state,Hodd[Jindex_res],Hodd[Jindex_res],gres.state)-pow(gres.energy,2))/L;
1417 return {gres, Jlabel_res, Jindex_res};
1427 GlobParam.
Minit = 100ul;
1428 GlobParam.
Qinit = 100ul;
1431 GlobParam.
Mlimit = 500ul;
1437 size_t lim2site = 24ul;
1439 DynParam.
max_alpha_rsvd = [lim2site] (
size_t i) {
return (i<=lim2site+4ul)? 1e4:0.;};
1440 size_t Mincr_per = 2ul;
1441 DynParam.
Mincr_per = [Mincr_per] (
size_t i) {
return Mincr_per;};
1447 string Jlabel_res =
"0";
1448 int Jindex_res = -1;
1449 Eigenstate<typename VMPS::HubbardU1xU1::StateXd> gres;
1450 vector<jEigenstate<typename VMPS::HubbardU1xU1::StateXd>> godd;
1452 typename VMPS::HubbardU1xU1::Solver DMRGs;
1453 DMRGs.userSetGlobParam();
1454 DMRGs.userSetDynParam();
1455 DMRGs.GlobParam = GlobParam;
1456 DMRGs.DynParam = DynParam;
1461 DMRGs.edgeState(H, gres, Q, EDGE);
1466 for (
int j=0; j<Nlev; ++j)
1470 typename VMPS::HubbardU1xU1::Solver DMRGr;
1471 DMRGr.userSetGlobParam();
1472 DMRGr.userSetDynParam();
1473 DMRGr.GlobParam = GlobParam;
1474 DMRGr.DynParam = DynParam;
1476 gtry.
label = labels[j];
1478 DMRGr.edgeState(Hfull, gtry.
eigenstate, Q, EDGE);
1479 godd.push_back(gtry);
1480 cout <<
"j=" << j <<
", label=" << labels[j] <<
", energy=" << setprecision(16) << gtry.
eigenstate.energy << setprecision(6) <<
", Q=" << Q << endl;
1482 gres = godd[0].eigenstate;
1483 Jlabel_res = godd[0].label;
1484 Jindex_res = godd[0].index;
1485 for (
int j=1; j<Nlev; ++j)
1487 if (godd[j].eigenstate.energy < gres.energy)
1489 gres = godd[j].eigenstate;
1490 Jlabel_res = godd[j].label;
1491 Jindex_res = godd[j].index;
1498 lout << termcolor::blue << setprecision(16) << gres.energy << setprecision(6) << termcolor::reset << endl;
1506 var = abs(
avg(gres.state,H,H,gres.state)-pow(gres.energy,2))/L;
1511 var = abs(
avg(gres.state,Hfull,Hfull,gres.state)-pow(gres.energy,2))/L;
1518 return {gres, Jlabel_res, Jindex_res};
1521template<
typename MODEL>
1525 assert(Nshell%2 == 0);
1526 assert(Hfull.length() != 0 and
"Calculate full Hamiltonian first!");
1531 GlobParam.
Minit = 100ul;
1532 GlobParam.
Qinit = 100ul;
1535 GlobParam.
Mlimit = 500ul;
1541 size_t lim2site = 24ul;
1543 DynParam.
max_alpha_rsvd = [lim2site] (
size_t i) {
return (i<=lim2site+4ul)? 1e4:0.;};
1544 size_t Mincr_per = 2ul;
1545 DynParam.
Mincr_per = [Mincr_per] (
size_t i) {
return Mincr_per;};
1549 Eigenstate<typename MODEL::StateXd> gres;
1551 typename MODEL::Solver DMRGs;
1552 DMRGs.userSetGlobParam();
1553 DMRGs.userSetDynParam();
1554 DMRGs.GlobParam = GlobParam;
1555 DMRGs.DynParam = DynParam;
1560 DMRGs.edgeState(Hfull, gres, Q, EDGE);
1565 lout << termcolor::blue << setprecision(16) << gres.energy << setprecision(6) << termcolor::reset << endl;
1838 GlobParam.
Minit = 100ul;
1839 GlobParam.
Qinit = 100ul;
1842 GlobParam.
Mlimit = 500ul;
1848 size_t lim2site = 24ul;
1850 DynParam.
max_alpha_rsvd = [lim2site] (
size_t i) {
return (i<=lim2site+4ul)? 1e4:0.;};
1851 size_t Mincr_per = 2ul;
1852 DynParam.
Mincr_per = [Mincr_per] (
size_t i) {
return Mincr_per;};
1858 Eigenstate<typename VMPS::HeisenbergU1::StateXd> gres;
1860 typename VMPS::HeisenbergU1::Solver DMRGs;
1861 DMRGs.userSetGlobParam();
1862 DMRGs.userSetDynParam();
1863 DMRGs.GlobParam = GlobParam;
1864 DMRGs.DynParam = DynParam;
1866 DMRGs.edgeState(H, gres, Q, EDGE);
1870 lout << termcolor::blue << setprecision(16) << gres.energy << setprecision(6) << termcolor::reset << endl;
1875 double var = abs(
avg(gres.state,H,H,gres.state)-pow(gres.energy,2))/L;
1881 return {gres,
"0",-1};
1886compute (
bool LOAD_MPO,
bool SAVE_MPO,
string wd,
int minNshell,
int maxNshell,
bool SAVE)
1888 make_Hamiltonian(LOAD_MPO,SAVE_MPO,wd,
false);
1889 make_fullHamiltonian(LOAD_MPO,SAVE_MPO,wd);
1896 Jlabel.resize(2*L+1);
1897 Jindex.resize(2*L+1);
1898 energies.resize(2*L+1);
1899 energies_free.resize(2*L+1);
1901 int Nshelllast = (maxNshell==-1)? 2*L : maxNshell;
1903 for (
int Nshell=minNshell; Nshell<=Nshelllast; Nshell+=1)
1905 int A = Z+Nclosed+Nshell;
1906 lout << termcolor::bold <<
"A=" <<
A <<
", Z=" << Z <<
", N=" << Nclosed+Nshell <<
", Nshell=" << Nshell <<
"/" << 2*L <<
", progress=" << round(Nshell*1./(2*L)*100,1) <<
"%" << termcolor::reset << endl;
1908 auto [gres, Jlabel_res, Jindex_res] = calc_gs(Nshell, LANCZOS::EDGE::GROUND,
false);
1910 Jlabel[Nshell] = Jlabel_res;
1911 Jindex[Nshell] = Jindex_res;
1913 lout << g[Nshell].state.info() << endl;
1915 lout <<
"J of ground state: " << Jlabel[Nshell] <<
", index=" << Jindex[Nshell] << endl;
1917 if (Nshell != 0 and Nshell != 2*L)
1921 var[Nshell] = abs(
avg(g[Nshell].state,H,H,g[Nshell].state)-pow(g[Nshell].energy,2))/L;
1926 var[Nshell] = abs(
avg(g[Nshell].state,Hfull,Hfull,g[Nshell].state)-pow(g[Nshell].energy,2))/L;
1933 lout << termcolor::blue <<
"var=" << var[Nshell] << termcolor::reset << endl;
1935 Mmax[Nshell] = g[Nshell].state.calc_Mmax();
1937 energies(Nshell) = g[Nshell].energy;
1938 energies_free(Nshell) = onsite_free.head(Nshell).sum();
1939 lout <<
"noninteracting energy=" << energies_free(Nshell) <<
", interacting energy=" << energies(Nshell) << endl;
1940 if (Nshell > 1 and Nshell<2*L-1) assert(g[Nshell].energy < energies_free(Nshell));
1942 if (Z==50 and Nclosed==50 and REF)
1944 double diff = abs(g[Nshell].energy-Sn_Eref(Nshell));
1945 if (
diff<1e-2) lout << termcolor::green;
1946 else lout << termcolor::red;
1947 lout <<
"ref=" << Sn_Eref(Nshell) <<
", diff=" <<
diff << endl;
1948 lout << termcolor::reset;
1950 lout <<
"E_B/A=" << abs(g[Nshell].energy)/Nshell <<
" MeV" << endl;
1952 n[Nshell].resize(Nlev);
1953 avgN[Nshell].resize(Nlev);
1955 for (
int j=0; j<Nlev; ++j)
1957 avgN[Nshell](j) = 0.;
1958 for (
int i=0; i<deg(j); ++i)
1962 avgN[Nshell](j) +=
avg(g[Nshell].state, H.n(offset(j)+i), g[Nshell].state);
1967 avgN[Nshell](j) +=
avg(g[Nshell].state, Hfull.n(offset(j)+i), g[Nshell].state);
1970 n[Nshell](j) = avgN[Nshell](j)/(2.*deg(j));
1972 double Nplot = (avgN[Nshell](j)<1e-14)? 0 : avgN[Nshell](j);
1973 double nplot = (n[Nshell](j) <1e-14)? 0 : n[Nshell](j);
1974 lout <<
"N(" << labels[j] <<
")=" << Nplot <<
"/" << 2*deg(j) <<
", " <<
"n=" << nplot;
1977 if (Z==50 and Nclosed==50 and REF and (Nshell==12 or Nshell==14 or Nshell==16 or Nshell==18))
1979 auto Sn_nref_ = Sn_nref(Nshell);
1980 auto Sn_Nref_ = Sn_Nref(Nshell);
1981 auto Sn_Pref_ = Sn_Pref(Nshell);
1983 lout <<
", ref(N)=";
1984 if (abs(Sn_Nref_(j)-avgN[Nshell](j))<1e-3)
1986 lout << termcolor::green;
1990 lout << termcolor::red;
1992 lout << Sn_Nref_(j) << termcolor::reset;
1994 lout <<
", ref(n)=";
1995 if (abs(Sn_nref_(j)-n[Nshell](j))<1e-3)
1997 lout << termcolor::green;
2001 lout << termcolor::red;
2003 lout << Sn_nref_(j) << termcolor::reset;
2010 if (SAVE) save(wd, minNshell, Nshelllast);
2015compute (
bool LOAD_MPO,
bool SAVE_MPO,
string wd,
int minNshell,
int maxNshell,
bool SAVE)
2017 make_Hamiltonian(LOAD_MPO,SAVE_MPO,wd);
2024 Jlabel.resize(2*L+1);
2025 Jindex.resize(2*L+1);
2026 energies.resize(2*L+1);
2027 energies_free.resize(2*L+1);
2029 int Nshelllast = (maxNshell==-1)? 2*L : maxNshell;
2031 for (
int Nshell=minNshell; Nshell<=Nshelllast; ++Nshell)
2033 int A = Z+Nclosed+Nshell;
2034 lout << termcolor::bold <<
"A=" <<
A <<
", Z=" << Z <<
", N=" << Nclosed+Nshell <<
", Nshell=" << Nshell <<
"/" << 2*L <<
", progress=" << round(Nshell*1./(2*L)*100,1) <<
"%" << termcolor::reset << endl;
2036 auto [gres, Jlabel_res, Jindex_res] = calc_gs(Nshell, LANCZOS::EDGE::GROUND,
false);
2038 Jlabel[Nshell] = Jlabel_res;
2039 Jindex[Nshell] = Jindex_res;
2041 lout << g[Nshell].state.info() << endl;
2043 lout <<
"J of ground state: " << Jlabel[Nshell] <<
", index=" << Jindex[Nshell] << endl;
2045 if (Nshell != 0 and Nshell != 2*L)
2049 var[Nshell] = abs(
avg(g[Nshell].state,H,H,g[Nshell].state)-pow(g[Nshell].energy,2))/L;
2053 var[Nshell] = abs(
avg(g[Nshell].state,Hodd[Jindex[Nshell]],Hodd[Jindex[Nshell]],g[Nshell].state)-pow(g[Nshell].energy,2))/L;
2060 lout << termcolor::blue <<
"var=" << var[Nshell] << termcolor::reset << endl;
2062 Mmax[Nshell] = g[Nshell].state.calc_Mmax();
2064 energies(Nshell) = g[Nshell].energy;
2065 energies_free(Nshell) = onsite_free.head(Nshell).sum();
2066 lout <<
"noninteracting energy=" << energies_free(Nshell) <<
", interacting energy=" << energies(Nshell) << endl;
2067 if (Nshell > 1 and Nshell<2*L-1) assert(g[Nshell].energy < energies_free(Nshell));
2069 if (Z==50 and Nclosed==50 and REF)
2071 double diff = abs(g[Nshell].energy-Sn_Eref(Nshell));
2072 if (
diff<1e-2) lout << termcolor::green;
2073 else lout << termcolor::red;
2074 lout <<
"ref=" << Sn_Eref(Nshell) <<
", diff=" <<
diff << endl;
2075 lout << termcolor::reset;
2077 lout <<
"E_B/A=" << abs(g[Nshell].energy)/Nshell <<
" MeV" << endl;
2079 n[Nshell].resize(Nlev);
2080 avgN[Nshell].resize(Nlev);
2082 for (
int j=0; j<Nlev; ++j)
2084 avgN[Nshell](j) = 0.;
2085 for (
int i=0; i<deg(j); ++i)
2089 avgN[Nshell](j) +=
avg(g[Nshell].state, H.n(offset(j)+i), g[Nshell].state);
2093 avgN[Nshell](j) +=
avg(g[Nshell].state, Hodd[Jindex[Nshell]].n(offset(j)+i), g[Nshell].state);
2096 n[Nshell](j) = avgN[Nshell](j)/(2.*deg(j));
2098 double Nplot = (avgN[Nshell](j)<1e-14)? 0 : avgN[Nshell](j);
2099 double nplot = (n[Nshell](j) <1e-14)? 0 : n[Nshell](j);
2100 lout <<
"N(" << labels[j] <<
")=" << Nplot <<
"/" << 2*deg(j) <<
", " <<
"n=" << nplot;
2103 if (Z==50 and Nclosed==50 and REF and (Nshell==12 or Nshell==14 or Nshell==16 or Nshell==18))
2105 auto Sn_nref_ = Sn_nref(Nshell);
2106 auto Sn_Nref_ = Sn_Nref(Nshell);
2107 auto Sn_Pref_ = Sn_Pref(Nshell);
2109 lout <<
", ref(N)=";
2110 if (abs(Sn_Nref_(j)-avgN[Nshell](j))<1e-3)
2112 lout << termcolor::green;
2116 lout << termcolor::red;
2118 lout << Sn_Nref_(j) << termcolor::reset;
2120 lout <<
", ref(n)=";
2121 if (abs(Sn_nref_(j)-n[Nshell](j))<1e-3)
2123 lout << termcolor::green;
2127 lout << termcolor::red;
2129 lout << Sn_nref_(j) << termcolor::reset;
2162 if (SAVE) save(wd, minNshell, Nshelllast);
2167compute (
bool LOAD_MPO,
bool SAVE_MPO,
string wd,
int minNshell,
int maxNshell,
bool SAVE)
2169 make_Hamiltonian(LOAD_MPO,SAVE_MPO,wd);
2176 Jlabel.resize(2*L+1);
2177 Jindex.resize(2*L+1);
2178 energies.resize(2*L+1);
2179 energies_free.resize(2*L+1);
2181 int Nshelllast = (maxNshell==-1)? 2*L : maxNshell;
2183 for (
int Nshell=minNshell; Nshell<=Nshelllast; Nshell+=2)
2185 int A = Z+Nclosed+Nshell;
2186 lout << termcolor::bold <<
"A=" <<
A <<
", Z=" << Z <<
", N=" << Nclosed+Nshell <<
", Nshell=" << Nshell <<
"/" << 2*L <<
", progress=" << round(Nshell*1./(2*L)*100,1) <<
"%" << termcolor::reset << endl;
2188 auto [gres, Jlabel_res, Jindex_res] = calc_gs(Nshell, LANCZOS::EDGE::GROUND,
false);
2190 Jlabel[Nshell] = Jlabel_res;
2191 Jindex[Nshell] = Jindex_res;
2193 lout << g[Nshell].state.info() << endl;
2195 if (Nshell != 0 and Nshell != 2*L)
2197 var[Nshell] = abs(
avg(g[Nshell].state,H,H,g[Nshell].state)-pow(g[Nshell].energy,2))/L;
2203 lout << termcolor::blue <<
"var=" << var[Nshell] << termcolor::reset << endl;
2205 Mmax[Nshell] = g[Nshell].state.calc_Mmax();
2207 energies(Nshell) = g[Nshell].energy;
2208 energies_free(Nshell) = onsite_free.head(Nshell).sum();
2209 lout <<
"noninteracting energy=" << energies_free(Nshell) <<
", interacting energy=" << energies(Nshell) << endl;
2210 if (Nshell > 1 and Nshell<2*L-1) assert(g[Nshell].energy < energies_free(Nshell));
2212 if (Z==50 and Nclosed==50 and REF and (Nshell==12 or Nshell==14 or Nshell==16))
2214 double diff = abs(g[Nshell].energy-Sn_Eref(Nshell));
2217 lout << termcolor::green;
2221 lout << termcolor::red;
2223 lout <<
"ref=" << Sn_Eref(Nshell) << endl;
2224 lout << termcolor::reset;
2226 lout <<
"E_B/A=" << abs(g[Nshell].energy)/Nshell <<
" MeV" << endl;
2228 n[Nshell].resize(Nlev);
2229 avgN[Nshell].resize(Nlev);
2231 for (
int j=0; j<Nlev; ++j)
2233 avgN[Nshell](j) = 0.;
2234 for (
int i=0; i<deg(j); ++i)
2236 avgN[Nshell](j) += 2.*
avg(g[Nshell].state, H.Sz(offset(j)+i), g[Nshell].state)+1.;
2238 n[Nshell](j) = avgN[Nshell](j)/(2.*deg(j));
2240 double Nplot = (avgN[Nshell](j)<1e-14)? 0 : avgN[Nshell](j);
2241 double nplot = (n[Nshell](j)<1e-14)? 0 : n[Nshell](j);
2242 lout <<
"N(" << labels[j] <<
")=" << Nplot <<
"/" << 2*deg(j) <<
", " <<
"n=" << nplot;
2245 if (Z==50 and Nclosed==50 and REF and (Nshell==12 or Nshell==14 or Nshell==16 or Nshell==18))
2247 auto Sn_nref_ = Sn_nref(Nshell);
2248 auto Sn_Nref_ = Sn_Nref(Nshell);
2249 auto Sn_Pref_ = Sn_Pref(Nshell);
2251 lout <<
", ref(N)=";
2252 if (abs(Sn_Nref_(j)-avgN[Nshell](j))<1e-3)
2254 lout << termcolor::green;
2258 lout << termcolor::red;
2260 lout << Sn_Nref_(j) << termcolor::reset;
2262 lout <<
", ref(n)=";
2263 if (abs(Sn_nref_(j)-n[Nshell](j))<1e-3)
2265 lout << termcolor::green;
2269 lout << termcolor::red;
2271 lout << Sn_nref_(j) << termcolor::reset;
2278 if (SAVE) save(wd, minNshell, Nshelllast, 2);
2283compute_parallel (
bool LOAD_MPO,
bool SAVE_MPO,
string wd,
int minNshell,
int maxNshell,
bool SAVE)
2285 make_Hamiltonian(LOAD_MPO,SAVE_MPO,wd);
2292 Jlabel.resize(2*L+1);
2293 Jindex.resize(2*L+1);
2294 energies.resize(2*L+1);
2295 energies_free.resize(2*L+1);
2297 int Nshelllast = (maxNshell==-1)? 2*L : maxNshell;
2299 #pragma omp parallel for schedule(dynamic)
2300 for (
int iNshell=minNshell; iNshell<=Nshelllast; iNshell+=2)
2302 int jmaxNshell = (iNshell==Nshelllast)? 0:1;
2303 for (
int jNshell=0; jNshell<=jmaxNshell; ++jNshell)
2305 int Nshell = iNshell+jNshell;
2306 int A = Z+Nclosed+Nshell;
2308 #pragma omp critical
2310 lout << termcolor::bold <<
"A=" <<
A <<
", Z=" << Z <<
", N=" << Nclosed+Nshell <<
", Nshell=" << Nshell <<
"/" << 2*L << termcolor::reset << endl;
2315 Jlabel[Nshell] = Jlabel_res;
2316 Jindex[Nshell] = Jindex_res;
2318 #pragma omp critical
2320 lout <<
"Nshell=" << Nshell <<
" done!, E0=" << g[Nshell].energy << endl;
2323 if (Nshell != 0 and Nshell != 2*L)
2327 var[Nshell] = abs(
avg(g[Nshell].state,H,H,g[Nshell].state)-pow(g[Nshell].energy,2))/L;
2331 var[Nshell] = abs(
avg(g[Nshell].state,Hodd[Jindex[Nshell]],Hodd[Jindex[Nshell]],g[Nshell].state)-pow(g[Nshell].energy,2))/L;
2339 Mmax[Nshell] = g[Nshell].state.calc_Mmax();
2341 energies(Nshell) = g[Nshell].energy;
2342 energies_free(Nshell) = onsite_free.head(Nshell).sum();
2343 if (Nshell > 1 and Nshell<2*L-1) assert(g[Nshell].energy < energies_free(Nshell));
2345 n[Nshell].resize(Nlev);
2346 avgN[Nshell].resize(Nlev);
2348 for (
int j=0; j<Nlev; ++j)
2350 avgN[Nshell](j) = 0.;
2351 for (
int i=0; i<deg(j); ++i)
2355 avgN[Nshell](j) +=
avg(g[Nshell].state, H.n(offset(j)+i), g[Nshell].state);
2359 avgN[Nshell](j) +=
avg(g[Nshell].state, Hodd[Jindex[Nshell]].n(offset(j)+i), g[Nshell].state);
2362 n[Nshell](j) = avgN[Nshell](j)/(2.*deg(j));
2367 if (SAVE) save(wd, minNshell, Nshelllast);
2372compute_parallel (
bool LOAD_MPO,
bool SAVE_MPO,
string wd,
int minNshell,
int maxNshell,
bool SAVE)
2374 make_Hamiltonian(LOAD_MPO,SAVE_MPO,wd);
2381 Jlabel.resize(2*L+1);
2382 Jindex.resize(2*L+1);
2383 energies.resize(2*L+1);
2384 energies_free.resize(2*L+1);
2386 int Nshelllast = (maxNshell==-1)? 2*L : maxNshell;
2388 #pragma omp parallel for schedule(dynamic)
2389 for (
int iNshell=minNshell; iNshell<=Nshelllast; iNshell+=2)
2391 int jmaxNshell = (iNshell==Nshelllast)? 0:1;
2392 for (
int jNshell=0; jNshell<=jmaxNshell; ++jNshell)
2394 int Nshell = iNshell+jNshell;
2395 int A = Z+Nclosed+Nshell;
2397 #pragma omp critical
2399 lout << termcolor::bold <<
"A=" <<
A <<
", Z=" << Z <<
", N=" << Nclosed+Nshell <<
", Nshell=" << Nshell <<
"/" << 2*L << termcolor::reset << endl;
2404 Jlabel[Nshell] = Jlabel_res;
2405 Jindex[Nshell] = Jindex_res;
2407 #pragma omp critical
2409 lout <<
"Nshell=" << Nshell <<
" done!, E0=" << g[Nshell].energy << endl;
2412 if (Nshell != 0 and Nshell != 2*L)
2416 var[Nshell] = abs(
avg(g[Nshell].state,H,H,g[Nshell].state)-pow(g[Nshell].energy,2))/L;
2420 var[Nshell] = abs(
avg(g[Nshell].state,Hodd[Jindex[Nshell]],Hodd[Jindex[Nshell]],g[Nshell].state)-pow(g[Nshell].energy,2))/L;
2428 Mmax[Nshell] = g[Nshell].state.calc_Mmax();
2430 energies(Nshell) = g[Nshell].energy;
2431 energies_free(Nshell) = onsite_free.head(Nshell).sum();
2432 if (Nshell > 1 and Nshell<2*L-1) assert(g[Nshell].energy < energies_free(Nshell));
2434 n[Nshell].resize(Nlev);
2435 avgN[Nshell].resize(Nlev);
2437 for (
int j=0; j<Nlev; ++j)
2439 avgN[Nshell](j) = 0.;
2440 for (
int i=0; i<deg(j); ++i)
2444 avgN[Nshell](j) +=
avg(g[Nshell].state, H.n(offset(j)+i), g[Nshell].state);
2448 avgN[Nshell](j) +=
avg(g[Nshell].state, Hodd[Jindex[Nshell]].n(offset(j)+i), g[Nshell].state);
2451 n[Nshell](j) = avgN[Nshell](j)/(2.*deg(j));
2456 if (SAVE) save(wd, minNshell, Nshelllast);
2461compute_parallel (
bool LOAD_MPO,
bool SAVE_MPO,
string wd,
int minNshell,
int maxNshell,
bool SAVE)
2463 make_Hamiltonian(LOAD_MPO,SAVE_MPO,wd);
2470 Jlabel.resize(2*L+1);
2471 Jindex.resize(2*L+1);
2472 energies.resize(2*L+1);
2473 energies_free.resize(2*L+1);
2475 int Nshelllast = (maxNshell==-1)? 2*L : maxNshell;
2477 #pragma omp parallel for schedule(dynamic)
2478 for (
int Nshell=minNshell; Nshell<=Nshelllast; Nshell+=2)
2480 int A = Z+Nclosed+Nshell;
2482 #pragma omp critical
2484 lout << termcolor::bold <<
"A=" <<
A <<
", Z=" << Z <<
", N=" << Nclosed+Nshell <<
", Nshell=" << Nshell <<
"/" << 2*L << termcolor::reset << endl;
2489 Jlabel[Nshell] = Jlabel_res;
2490 Jindex[Nshell] = Jindex_res;
2492 if (Nshell != 0 and Nshell != 2*L)
2494 var[Nshell] = abs(
avg(g[Nshell].state,H,H,g[Nshell].state)-pow(g[Nshell].energy,2))/L;
2501 Mmax[Nshell] = g[Nshell].state.calc_Mmax();
2503 energies(Nshell) = g[Nshell].energy;
2504 energies_free(Nshell) = onsite_free.head(Nshell).sum();
2505 if (Nshell > 1 and Nshell<2*L-1) assert(g[Nshell].energy < energies_free(Nshell));
2507 n[Nshell].resize(Nlev);
2508 avgN[Nshell].resize(Nlev);
2510 for (
int j=0; j<Nlev; ++j)
2512 avgN[Nshell](j) = 0.;
2513 for (
int i=0; i<deg(j); ++i)
2515 avgN[Nshell](j) += 2.*
avg(g[Nshell].state, H.Sz(offset(j)+i), g[Nshell].state)+1.;
2517 n[Nshell](j) = avgN[Nshell](j)/(2.*deg(j));
2521 if (SAVE) save(wd, minNshell, Nshelllast, 2);
2524template<
typename MODEL>
2526save (
string wd,
int Nfrst,
int Nlast,
int dNshell)
const
2528 HDF5Interface target(wd+outfile, WRITE);
2529 target.save_vector(eps0,
"eps0",
"");
2530 target.save_vector(deg,
"deg",
"");
2532 for (
int Nshell=Nfrst; Nshell<=Nlast; Nshell+=dNshell)
2534 target.create_group(make_string(Nshell));
2535 target.save_scalar(g[Nshell].energy,
"E0",make_string(Nshell));
2536 target.save_scalar(energies_free(Nshell),
"E0free",make_string(Nshell));
2537 target.save_vector(avgN[Nshell],
"avgN",make_string(Nshell));
2538 target.save_vector(n[Nshell],
"n",make_string(Nshell));
2539 target.save_scalar(var[Nshell],
"var",make_string(Nshell));
2540 target.save_scalar(Mmax[Nshell],
"Mmax",make_string(Nshell));
2541 target.save_scalar(Jlabel[Nshell],
"Jlabel",make_string(Nshell));
2542 target.save_scalar(Jindex[Nshell],
"Jindex",make_string(Nshell));
2545 MatrixXd Delta3(0,2);
2546 for (
int Nshell=1, i=0; Nshell<=2*L-1; ++Nshell, ++i)
2548 double DeltaVal = 0.5*(2.*energies(Nshell)-energies(Nshell-1)-energies(Nshell+1));
2551 Delta3.conservativeResize(Delta3.rows()+1,Delta3.cols());
2552 Delta3(i,0) = Nshell;
2553 Delta3(i,1) = DeltaVal;
2555 target.save_matrix(Delta3,
"Delta3");
2557 MatrixXd Delta3free(0,2);
2558 for (
int Nshell=1, i=0; Nshell<=2*L-1; ++Nshell, ++i)
2560 double DeltaVal = 0.5*(2.*energies_free(Nshell)-energies_free(Nshell-1)-energies_free(Nshell+1));
2562 Delta3free.conservativeResize(Delta3free.rows()+1,Delta3free.cols());
2563 Delta3free(i,0) = Nshell;
2564 Delta3free(i,1) = DeltaVal;
2566 target.save_matrix(Delta3free,
"Delta3free");
2568 MatrixXd Delta3b(0,2);
2569 for (
int Nshell=2, i=0; Nshell<=2*L; ++Nshell, ++i)
2571 double DeltaVal = 0.5*(energies(Nshell)-2.*energies(Nshell-1)+energies(Nshell-2));
2574 Delta3b.conservativeResize(Delta3b.rows()+1,Delta3b.cols());
2575 Delta3b(i,0) = Nshell;
2576 Delta3b(i,1) = DeltaVal;
2578 target.save_matrix(Delta3b,
"Delta3b");
2580 MatrixXd Delta4(0,2);
2581 for (
int Nshell=2, i=0; Nshell<=2*L-1; ++Nshell, ++i)
2583 double DeltaVal = 0.25*(energies(Nshell-2)-3.*energies(Nshell-1)+3.*energies(Nshell)-energies(Nshell+1));
2586 Delta4.conservativeResize(Delta4.rows()+1,Delta4.cols());
2587 Delta4(i,0) = Nshell;
2588 Delta4(i,1) = DeltaVal;
2590 target.save_matrix(Delta4,
"Delta4");
2592 MatrixXd Delta5(0,2);
2593 for (
int Nshell=2, i=0; Nshell<=2*L-2; ++Nshell, ++i)
2595 double DeltaVal = -0.125*(6.*energies(Nshell-2)-4.*energies(Nshell+1)-4.*energies(Nshell-1)+energies(Nshell+2)+energies(Nshell-2));
2598 Delta5.conservativeResize(Delta5.rows()+1,Delta5.cols());
2599 Delta5(i,0) = Nshell;
2600 Delta5(i,1) = DeltaVal;
2602 target.save_matrix(Delta5,
"Delta5");
2604 lout << termcolor::green <<
"saved: " << wd+outfile << termcolor::reset << endl;
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)
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)
Mpo< Symmetry, Scalar > diff(const Mpo< Symmetry, Scalar > &H1, const Mpo< Symmetry, Scalar > &H2, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT)
void load_nuclearData(string el, string set, string rootfolder, NuclearInfo &info, double &V0, MatrixXd &Vij, vector< MatrixXd > &Vijnocgc, VectorXi °, VectorXd &eps0, bool &REF)
double cgc(int j1x2, int j2x2, int Jx2, int m1x2, int m2x2, int Mx2)
void set_verbosity(const DMRG::VERBOSITY::OPTION VERB_in)
VectorXd get_Gloc() const
Mpo< typename MODEL::Symmetry > make_cdagj(int j, const MODEL &H_input) const
vector< Eigenstate< typename MODEL::StateXd > > g
std::array< MatrixXd, 2 > FlipChart
void make_fullHamiltonian(bool LOAD=false, bool SAVE=false, string wd="./")
NuclearManager(int Nclosed_input, int Nsingle_input, int Z_input, const string &filename, double V0_input, bool REF_input=false)
ArrayXd get_levelsign(int level)
vector< ArrayXd > sign_per_level
ArrayXi get_offset() const
ArrayXXd get_sign2d() const
VectorXd get_onsite_free() const
std::array< MatrixXd, 2 > get_FlipChart() const
vector< tuple< orbital, orbital, orbital, orbital, double, orbinfo > > generate_couplingList(int J) const
MatrixXd get_Ghop() const
vector< boost::rational< int > > jlist
void make_Hamiltonian(bool LOAD=false, bool SAVE=false, string wd="./", bool ODD=true)
vector< boost::rational< int > > mlist
vector< Mpo< typename MODEL::Symmetry > > cdagj
ArrayXd Sn_nref(int Nshell) const
NuclearManager(int Nclosed_input, int Nsingle_input, int Z_input, const ArrayXi °_input, const vector< string > &labels_input, const ArrayXd &eps0_input, const ArrayXXd &Vij_input, double V0_input=1., bool REF_input=false, string PARAM_input="Seminole")
ArrayXd Sn_Nref(int Nshell) const
void save(string wd, int Nfrst=0, int Nlast=-1, int dNshell=1) const
ArrayXd Sn_Sref14() const
VectorXd get_onsite() const
const Eigenstate< typename MODEL::StateXd > & get_g(int Nshell) const
void compute_parallel(bool LOADv=false, bool SAVE_MPO=false, string wd="./", int minNshell=0, int maxNshell=-1, bool SAVE=true)
ArrayXd Sn_Pref(int Nshell) const
VectorXi get_mfactor() const
double Sn_Eref(int N) const
Eigenstate< typename MODEL::StateXd > calc_gs_full(int Nshell, LANCZOS::EDGE::OPTION EDGE=LANCZOS::EDGE::GROUND, bool CALC_VAR=true, DMRG::VERBOSITY::OPTION VERB=DMRG::VERBOSITY::ON_EXIT) const
tuple< Eigenstate< typename MODEL::StateXd >, string, int > calc_gs(int Nshell, LANCZOS::EDGE::OPTION EDGE=LANCZOS::EDGE::GROUND, bool CALC_VAR=true, DMRG::VERBOSITY::OPTION VERB=DMRG::VERBOSITY::ON_EXIT) const
void compute(bool LOAD_MPO=false, bool SAVE_MPO=false, string wd="./", int minNshell=0, int maxNshell=-1, bool SAVE=true)
vector< double > perturb_sweeps
vector< Mpo< typename MODEL::Symmetry > > make_cdagj(const MODEL &H_input) const
static qarray< 1 > singlet(int N)
Hubbard model with U(1) symmetries. MPO representation of the Hubbard model.
static qarray< 2 > singlet(int N=0, int L=0)
function< size_t(size_t)> Mincr_per
function< double(size_t)> max_alpha_rsvd
function< DMRG::ITERATION::OPTION(size_t)> iteration
DMRG::CONVTEST::OPTION CONVTEST
Eigenstate< VectorType > eigenstate
bool operator==(const orbinfo &b) const
std::array< string, 4 > label
bool operator==(const orbital &b) const