1#ifndef ENTROPY_OBSERVER
2#define ENTROPY_OBSERVER
6template<
typename MpsType>
19 vector<bool>
TWO_SITE (
int it,
const MpsType &Psi,
double r=1., vector<size_t> true_overrides={}, vector<size_t> false_overrides={});
21 void elongate (
size_t Lleft=0,
size_t Lright=0);
23 void save (
string filename)
const;
24 void save (
int it,
string filename)
const;
38template<
typename MpsType>
40TWO_SITE (
int it,
const MpsType &Psi,
double r, vector<size_t> true_overrides, vector<size_t> false_overrides)
42 vector<bool> res(L-1);
44 for (
int b=0; b<L-1; ++b)
46 data(it,b) = Psi.entropy()(b);
48 DeltaSb(it,b) = std::nan(
"0");
53 DeltaSb(it,b) = (data(it,b)-data(it-1,b))/data(it-1,b);
60 DeltaSb(it,b) = 0.5*(3.*data(it,b)-4.*data(it-1,b)+data(it-2,b)) * 0.5*(1.+r) /data(it-2,b);
69 res[b] = (abs(DeltaSb(it,b)) > DeltaS)?
true:
false;
72 #ifndef TIME_PROP_USE_TERMPLOT
75 std::streamsize ss = std::cout.precision();
76 lout << setprecision(4) <<
"b=" << b <<
", δS(b)/S=" << DeltaSb(it,b) <<
", S=" << data(it,b) << setprecision(ss) << endl;
81 #ifdef TIME_PROP_USE_TERMPLOT
86 ArrayXd plotrow = DeltaSb.row(it);
87 if (!isnan(plotrow(0))) TerminalPlot::plot(plotrow,p);
100 for (
int ib=0; ib<true_overrides.size(); ++ib)
102 res[true_overrides[ib]] =
true;
104 for (
int ib=0; ib<false_overrides.size(); ++ib)
106 res[false_overrides[ib]] =
false;
111 lout <<
"EntropyObserver: ";
112 for (
int b=0; b<L-1; ++b)
116 cout << termcolor::red;
121 cout << termcolor::blue;
125 cout << termcolor::reset;
126 int trues = std::count(res.begin(), res.end(),
true);
127 lout <<
" N_steps(2-site)=" << trues <<
" (" << round(trues*100./(L-1),1) <<
"%)" << endl;
133template<
typename MpsType>
135elongate (
size_t Lleft,
size_t Lright)
137 if (Lleft>0 or Lright>0)
141 MatrixXd data_new(tpoints,L-1+Lleft+Lright);
143 data_new.block(Lleft,0,data.rows(),data.cols()) = data;
148template<
typename MpsType>
150save (
string filename)
const
152 saveMatrix<double>(data, filename);
155template<
typename MpsType>
157save (
int it,
string filename)
const
159 saveMatrix<double>(data.topRows(it+1), filename);
vector< bool > TWO_SITE(int it, const MpsType &Psi, double r=1., vector< size_t > true_overrides={}, vector< size_t > false_overrides={})
void save(string filename) const
MatrixXd get_DeltaSb() const
void elongate(size_t Lleft=0, size_t Lright=0)
DMRG::VERBOSITY::OPTION CHOSEN_VERBOSITY
EntropyObserver(size_t L_input, size_t tpoints_input, DMRG::VERBOSITY::OPTION VERBOSITY=DMRG::VERBOSITY::SILENT, double DeltaS_input=1e-2)