ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
run_sim.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * ALPS MPS DMRG Project
4  *
5  * Copyright (C) 2013 Institute for Theoretical Physics, ETH Zurich
6  * 2013-2013 by Michele Dolfi <dolfim@phys.ethz.ch>
7  *
8  * This software is part of the ALPS Applications, published under the ALPS
9  * Application License; you can use, redistribute it and/or modify it under
10  * the terms of the license, either version 1 or (at your option) any later
11  * version.
12  *
13  * You should have received a copy of the ALPS Application License along with
14  * the ALPS Applications; see the file LICENSE.txt. If not, the license is also
15  * available from http://alps.comp-phys.org/.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  *
25  *****************************************************************************/
26 
27 #include <boost/filesystem/fstream.hpp>
28 #include <string>
29 
32 #include "libpscan/run_sim.hpp"
33 
34 void run_sim(const boost::filesystem::path& infile, const boost::filesystem::path& outfile,
35  bool write_xml, double time_limit)
36 {
37  maquis::cout.precision(10);
38 
39  /// Load parameters
40  DmrgParameters parms;
41  {
42  boost::filesystem::ifstream param_file(infile);
43  if (!param_file)
44  throw std::runtime_error(std::string("Could not open parameter file ") + infile.string() +".");
45  alps::Parameters p; p.extract_from_xml(param_file);
46  parms = DmrgParameters(p);
47  }
48 
49  /// Match parameters of ALPS DMRG
50  if (parms.defined("MAXSTATES")) parms.set("max_bond_dimension", int(parms["MAXSTATES"]));
51  if (parms.defined("TRUNCATION_ERROR")) parms.set("truncation_final", double(parms["TRUNCATION_ERROR"]));
52 
53  if (parms.defined("DT")) parms.set("dt", double(parms["DT"]));
54  if (parms.defined("SWEEPS")) parms.set("nsweeps", int(parms["SWEEPS"]));
55  if (parms.defined("timesteps")) parms.set("nsweeps", int(parms["timesteps"]));
56  if (parms.defined("TIMESTEPS")) parms.set("nsweeps", int(parms["TIMESTEPS"]));
57  if (parms.defined("img_timesteps")) parms.set("nsweeps_img", int(parms["img_timesteps"]));
58  if (parms.defined("IMG_TIMESTEPS")) parms.set("nsweeps_img", int(parms["IMG_TIMESTEPS"]));
59 
60  parms.set("chkpfile", (outfile.parent_path() / outfile.stem()).string() + ".chkp");
61  parms.set("resultfile", (outfile.parent_path() / outfile.stem()).string() + ".h5");
62  parms.set("run_seconds", time_limit);
63 
64 
65  /// Start simulation
66  simulation_traits::shared_ptr sim = dmrg::symmetry_factory<simulation_traits>(parms);
67  sim->run(parms, write_xml);
68 }
virtual void run()=0
Definition: sim.h:69
void set(std::string const &key, T const &value)
void run_sim(const boost::filesystem::path &infile, const boost::filesystem::path &outfile, bool write_xml, double time_limit)
Definition: run_sim.cpp:34
run one parameter set
wrapper of tevol_sim for symmetry factory
boost::shared_ptr< simulation_base > shared_ptr
Definition: simulation.hpp:46
symmetry factory: runtime dispatch for SymmGroup template argument