27 #ifndef APP_DMRG_TEVOL_SIM_H
28 #define APP_DMRG_TEVOL_SIM_H
38 template <
class Matrix,
class SymmGroup,
class TimeEvolver>
58 , write_xml(write_xml_)
60 alps::oxstream out(boost::replace_last_copy(
rfile,
".h5",
".xml"));
61 out << alps::header(
"UTF-8") << alps::stylesheet(alps::xslt_path(
"ALPS.xsl"));
62 out << alps::start_tag(
"SIMULATION") << alps::xml_namespace(
"xsi",
"http://www.w3.org/2001/XMLSchema-instance")
63 << alps::attribute(
"xsi:noNamespaceSchemaLocation",
"http://xml.comp-phys.org/2003/10/ALPS.xsd");
65 out << alps::end_tag(
"SIMULATION");
70 int meas_each =
parms[
"measure_each"];
71 int chkp_each =
parms[
"chkp_each"];
72 int update_each =
parms[
"update_each"];
73 int nsweeps =
parms[
"nsweeps"];
74 int nsweeps_img =
parms[
"nsweeps_img"];
79 int nsteps =
parms[
"nsweeps"];
81 nsteps = std::min(nsteps, meas_each);
83 nsteps = std::min(nsteps, chkp_each);
85 nsteps = std::min(nsteps, update_each);
87 #define CHECK_MULTIPLICITY(var) \
88 if (var > 0 && var % nsteps != 0) \
89 throw std::runtime_error("var must be a multiple of 'nsteps'.");
95 #undef CHECK_MULTIPLICITY
99 int n = nsweeps / nsteps;
103 int sweep = i*nsteps;
105 if (update_each > -1 && (sweep % update_each) == 0)
107 if (iteration_params.size() > 1) {
108 parms << iteration_params;
109 meas_each =
parms[
"measure_each"];
110 chkp_each =
parms[
"chkp_each"];
111 update_each =
parms[
"update_each"];
116 }
else if (sweep == nsweeps_img) {
119 evolver.prepare_te_terms(sweep);
123 evolver(sweep, nsteps);
124 sweep = (i+1)*nsteps - 1;
125 iteration_params.
set(
"Time", sweep);
128 if ((sweep+1) % meas_each == 0 || (sweep+1) ==
parms[
"nsweeps"])
132 maquis::cout <<
"Energy " << energy << std::endl;
136 if (!
parms[
"ALWAYS_MEASURE"].empty())
137 this->
measure(this->results_archive_path(sweep) +
"/results/", always_measure);
142 ar[this->results_archive_path(sweep) +
"/parameters"] << iteration_params;
143 ar[this->results_archive_path(sweep) +
"/results"] << evolver.iteration_results();
144 ar[this->results_archive_path(sweep) +
"/results/Energy/mean/value"] << std::vector<double>(1, energy);
151 if (stopped || (sweep+1) % chkp_each == 0 || (sweep+1) ==
parms[
"nsweeps"])
152 checkpoint_simulation(
mps, sweep);
160 std::string results_archive_path(
int sweep)
const
163 status[
"sweep"] = sweep;
171 status[
"sweep"] = sweep;
Model< Matrix, SymmGroup >::measurements_type measurements_type
virtual void measure(std::string archive_path, measurements_type &meas)
MPO< Matrix, SymmGroup > make_mpo(Lattice const &lat, Model< Matrix, SymmGroup > const &model, BaseParameters &parms)
double expval(MPS< Matrix, SymmGroup > const &mps, MPO< Matrix, SymmGroup > const &mpo, int d)
MPS< Matrix, SymmGroup > mps
measurements_type iteration_measurements(int sweep)
utilities for the preparation of time evolution operators
void set(std::string const &key, T const &value)
Model< Matrix, SymmGroup > model
time_stopper stop_callback
std::map< std::string, int > status_type
virtual void checkpoint_simulation(MPS< Matrix, SymmGroup > const &state, status_type const &)
BaseParameters iteration_params(std::string const &var, std::size_t val)
tevol_sim(DmrgParameters const &parms_, bool write_xml_)
virtual std::string results_archive_path(status_type const &) const
#define CHECK_MULTIPLICITY(var)
measurements_type all_measurements
MPO< Matrix, SymmGroup > mpo
alps::numeric::real_type< T >::type real(T f)
declaration of simulation class