34 #define BP_AVG_ITERS_START 500000
130 X.reset(
new SUP(*orig.
X));
131 Z.reset(
new SUP(*orig.
Z));
170 (*lineq) = *orig.
lineq;
215 std::function<double(int,int)> getT = [&hamin] (
int a,
int b) ->
double {
return hamin.
getTmat(a,b); };
216 std::function<double(int,int,int,int)> getV = [&hamin] (
int a,
int b,
int c,
int d) ->
double {
return hamin.
getVmat(a,b,c,d); };
218 ham->ham(getT, getV);
264 unsigned int iter_dual(0),iter_primal(0);
266 unsigned int tot_iter = 0;
268 unsigned int go_up = 0;
269 double P_conv_prev = 10;
271 std::ostream* fp = &std::cout;
275 fout.open(
outfile, std::ios::out | std::ios::app);
278 std::ostream &out = *fp;
280 out.setf(std::ios::scientific | std::ios::fixed, std::ios_base::floatfield);
283 auto start = std::chrono::high_resolution_clock::now();
361 out << std::setw(16) <<
P_conv <<
"\t" << std::setw(16) <<
D_conv <<
"\t" << std::setw(16) <<
sigma <<
"\t" << std::setw(16) << convergence <<
"\t" << std::setw(16) <<
energy +
nuclrep <<
"\t" << std::setw(16) <<
Z->getI().S_2() <<
"\t" << go_up << std::endl;
365 std::cout <<
"Bailing out: too many iterations! " << std::endl;
378 auto end = std::chrono::high_resolution_clock::now();
384 iters += iter_primal;
391 out <<
"Energy: " <<
ham->ddot(
Z->getI()) +
nuclrep << std::endl;
392 out <<
"Trace: " <<
Z->getI().trace() << std::endl;
393 out <<
"pd gap: " <<
Z->ddot(*
X) << std::endl;
394 out <<
"S^2: " <<
Z->getI().S_2() << std::endl;
395 out <<
"dual conv: " <<
D_conv << std::endl;
396 out <<
"primal conv: " <<
P_conv << std::endl;
397 out <<
"Runtime: " << std::fixed << std::chrono::duration_cast<std::chrono::duration<double,std::ratio<1>>>(end-start).count() <<
" s" << std::endl;
398 out <<
"Primal iters: " << iter_primal << std::endl;
399 out <<
"avg primal iters: " <<
avg_iters << std::endl;
402 out <<
"total nr of iterations = " << tot_iter << std::endl;
546 std::vector<double> results(symgroup.getNumberOfIrreps(), 0);
550 const auto& rdm =
getRDM();
551 const auto orbtoirrep = index.get_irrep_each_orbital();
554 results[0] =
ham->getMatrix(0).ddot(rdm.getMatrix(0));
558 for(
int b=a+1;b<
L;b++)
560 auto irrep_a = orbtoirrep[a];
561 auto irrep_b = orbtoirrep[b];
563 auto firrep = symgroup.directProd(irrep_a, irrep_b);
565 results[firrep] += 4 * (*ham)(a,b,a,b) * rdm(a,b,a,b);
571 std::cout <<
"Group: " << symgroup.getGroupName() << std::endl;
572 for(
int i=0;i<symgroup.getNumberOfIrreps();i++)
573 std::cout << symgroup.getIrrepName(i) <<
":\t" << results[i] << std::endl;
576 for(
auto &elem: results)
579 std::cout <<
"Check: " << rdm.ddot(*
ham)+hamin.
getEconst() <<
"\t" << check+hamin.
getEconst() << std::endl;
void daxpy(double, const SUP &)
double ddot(const SUP &) const
BoundaryPoint & operator=(const BoundaryPoint &)
double get_P_conv() const
#define BP_AVG_ITERS_START
std::vector< double > energyperirrep(const CheMPS2::Hamiltonian &, bool print=false)
void set_use_prev_result(bool)
double getVmat(const int index1, const int index2, const int index3, const int index4) const
Get a Vmat element.
double ddot(const Container &) const
double getFullEnergy() const
int InverseS(TPM &, const Lineq &)
double getTmat(const int index1, const int index2) const
Get a Tmat element.
double get_convergence() const
bool FullyConverged() const
void init_S(const Lineq &)
bool returnhigh
when true, return very high value for the energy if the calculation takes too many iterations ...
std::unique_ptr< Lineq > lineq
void sep_pm(SUP &, SUP &)
BoundaryPoint(const CheMPS2::Hamiltonian &)
Container & daxpy(double alpha, const Container &)
void Proj_E(const Lineq &, int option=0)
double evalEnergy() const
void ReturnHighWhenBailingOut(bool)
double get_D_conv() const
void set_max_iter(unsigned int)
std::unique_ptr< TPM > ham
BoundaryPoint * Clone() const
int getNGroup() const
Get the group number.
double getEconst() const
Get the constant energy.
double get_tol_PD() const
void BuildHam(const CheMPS2::Hamiltonian &)
void collaps(const SUP &, const Lineq &)
int getL() const
Get the number of orbitals.
double D_conv
the 3 convergence criteria