ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
run_optim.cpp File Reference
#include <boost/filesystem/fstream.hpp>
#include <string>
#include "libpscan/run_sim.hpp"
#include "mps_eigenstate_sims/simulation.hpp"
#include "dmrg/sim/symmetry_factory.h"

Go to the source code of this file.

Functions

void run_sim (const boost::filesystem::path &infile, const boost::filesystem::path &outfile, bool write_xml, double time_limit)
 

Function Documentation

void run_sim ( const boost::filesystem::path &  infile,
const boost::filesystem::path &  outfile,
bool  write_xml,
double  time_limit 
)

Definition at line 36 of file run_optim.cpp.

38 {
39  maquis::cout.precision(10);
40 
41  /// Load parameters
42  DmrgParameters parms;
43  {
44  boost::filesystem::ifstream param_file(infile);
45  if (!param_file)
46  throw std::runtime_error(std::string("Could not open parameter file ") + infile.string() +".");
47  alps::Parameters p; p.extract_from_xml(param_file);
48  parms = DmrgParameters(p);
49  }
50 
51  /// Match parameters of ALPS DMRG
52  parms.set("chkpfile", (outfile.parent_path() / outfile.stem()).string() + ".chkp");
53  parms.set("resultfile", (outfile.parent_path() / outfile.stem()).string() + ".h5");
54  parms.set("run_seconds", time_limit);
55  if (parms.defined("SWEEPS")) parms.set("nsweeps", int(parms["SWEEPS"]));
56  if (parms.defined("TRUNCATION_ERROR")) parms.set("truncation_final", parms["TRUNCATION_ERROR"]);
57 
58  if (parms.defined("NUMSTATES")) {
59  parms.set("max_bond_dimension", int(parms["NUMSTATES"]));
60  } else if (parms.defined("MAXSTATES")) {
61  std::stringstream ss;
62 
63  int init_bond = 20;
64  double step = (int(parms["MAXSTATES"]) - init_bond) / (parms["nsweeps"]-1);
65 
66  ss << init_bond;
67  for (int sweep = 1; sweep < parms["nsweeps"]; ++sweep) {
68  ss << "," << int(init_bond + step*sweep);
69  }
70 
71  parms.set("sweep_bond_dimensions", ss.str());
72  } else if (parms.defined("STATES")) {
73  parms.set("sweep_bond_dimensions", parms["NUMSTATES"].str());
74  }
75  if (!parms.defined("max_bond_dimension") && !parms.defined("sweep_bond_dimensions"))
76  throw std::runtime_error("Number of renormalized states not set.");
77 
78  /// Start simulation
79  simulation_traits::shared_ptr sim = dmrg::symmetry_factory<simulation_traits>(parms);
80  sim->run(parms, write_xml, optim_and_measure);
81 }
virtual void run()=0
Definition: sim.h:69
void set(std::string const &key, T const &value)
boost::shared_ptr< simulation_base > shared_ptr
Definition: simulation.hpp:46