ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
sim< Matrix, SymmGroup > Class Template Referenceabstract

#include <sim.h>

Inheritance diagram for sim< Matrix, SymmGroup >:
abstract_sim dmrg_sim< Matrix, SymmGroup > tevol_sim< Matrix, SymmGroup, TimeEvolver >

Public Member Functions

 sim (DmrgParameters const &)
 
virtual ~sim ()
 
virtual void run ()=0
 

Protected Types

typedef Model< Matrix,
SymmGroup >::measurements_type 
measurements_type
 
typedef std::map< std::string,
int > 
status_type
 

Protected Member Functions

virtual std::string results_archive_path (status_type const &) const
 
measurements_type iteration_measurements (int sweep)
 
virtual void measure (std::string archive_path, measurements_type &meas)
 
virtual void checkpoint_simulation (MPS< Matrix, SymmGroup > const &state, status_type const &)
 

Protected Attributes

DmrgParameters parms
 
int init_sweep
 
int init_site
 
bool restore
 
bool dns
 
std::string chkpfile
 
std::string rfile
 
time_stopper stop_callback
 
Lattice lat
 
Model< Matrix, SymmGroup > model
 
MPS< Matrix, SymmGroup > mps
 
MPO< Matrix, SymmGroup > mpo
 
MPO< Matrix, SymmGroup > mpoc
 
measurements_type all_measurements
 
measurements_type sweep_measurements
 

Detailed Description

template<class Matrix, class SymmGroup>
class sim< Matrix, SymmGroup >

Definition at line 69 of file sim.h.

Member Typedef Documentation

template<class Matrix, class SymmGroup>
typedef Model<Matrix, SymmGroup>::measurements_type sim< Matrix, SymmGroup >::measurements_type
protected

Definition at line 77 of file sim.h.

template<class Matrix, class SymmGroup>
typedef std::map<std::string, int> sim< Matrix, SymmGroup >::status_type
protected

Definition at line 78 of file sim.h.

Constructor & Destructor Documentation

template<class Matrix , class SymmGroup >
sim< Matrix, SymmGroup >::sim ( DmrgParameters const &  parms_)

Definition at line 31 of file sim.hpp.

32 : parms(parms_)
33 , init_sweep(0)
34 , init_site(-1)
35 , restore(false)
36 , dns( (parms["donotsave"] != 0) )
37 , chkpfile(boost::trim_right_copy_if(parms["chkpfile"].str(), boost::is_any_of("/ ")))
38 , rfile(parms["resultfile"].str())
39 , stop_callback(static_cast<double>(parms["run_seconds"]))
40 {
41  maquis::cout << DMRG_VERSION_STRING << std::endl;
42  storage::setup(parms);
43  dmrg_random::engine.seed(parms["seed"]);
44 
45  {
46  boost::filesystem::path p(chkpfile);
47  if (boost::filesystem::exists(p) && boost::filesystem::exists(p / "mps0.h5"))
48  {
49  storage::archive ar_in(chkpfile+"/props.h5");
50  if (ar_in.is_scalar("/status/sweep"))
51  {
52  ar_in["/status/sweep"] >> init_sweep;
53 
54  if (ar_in.is_data("/status/site") && ar_in.is_scalar("/status/site"))
55  ar_in["/status/site"] >> init_site;
56 
57  if (init_site == -1)
58  ++init_sweep;
59 
60  maquis::cout << "Restoring state." << std::endl;
61  maquis::cout << "Will start again at site " << init_site << " in sweep " << init_sweep << std::endl;
62  restore = true;
63  } else {
64  maquis::cout << "A fresh simulation will start." << std::endl;
65  }
66  }
67  }
68 
69 
70  {
71  storage::archive ar(rfile, "w");
72 
73  ar["/parameters"] << parms;
74  ar["/version"] << DMRG_VERSION_STRING;
75  }
76  if (!dns)
77  {
78  if (!boost::filesystem::exists(chkpfile))
79  boost::filesystem::create_directory(chkpfile);
80  storage::archive ar(chkpfile+"/props.h5", "w");
81 
82  ar["/parameters"] << parms;
83  ar["/version"] << DMRG_VERSION_STRING;
84  }
85 
86 
87  /// Model initialization
88  lat = Lattice(parms);
90  mpo = make_mpo(lat, model, parms);
91  all_measurements = model.measurements();
92  all_measurements << overlap_measurements<Matrix, SymmGroup>(parms);
93 
94 
95  /// MPS initialization
96  if (restore) {
97  load(chkpfile, mps);
98  } else if (!parms["initfile"].empty()) {
99  maquis::cout << "Loading init state from " << parms["initfile"] << std::endl;
100  load(parms["initfile"].str(), mps);
101  } else {
102  mps = MPS<Matrix, SymmGroup>(lat.size(), *(model.initializer(lat, parms)));
103  }
104 
105  assert(mps.length() == lat.size());
106  maquis::cout << "MPS initialization has finished...\n"; // MPS restored now
107 
108 }
void load(alps::hdf5::archive &ar, std::string const &path, TrivialGroup::charge &value, std::vector< std::size_t > chunk=std::vector< std::size_t >(), std::vector< std::size_t > offset=std::vector< std::size_t >())
Definition: none.h:81
MPO< Matrix, SymmGroup > make_mpo(Lattice const &lat, Model< Matrix, SymmGroup > const &model, BaseParameters &parms)
DmrgParameters parms
Definition: sim.h:89
pimpl for Model
Definition: model.h:96
static engine_t engine
Definition: random.hpp:39
std::string chkpfile
Definition: sim.h:94
MPS< Matrix, SymmGroup > mps
Definition: sim.h:101
Model< Matrix, SymmGroup > model
Definition: sim.h:100
time_stopper stop_callback
Definition: sim.h:97
bool restore
Definition: sim.h:92
Definition: mps.h:40
bool dns
Definition: sim.h:93
std::string rfile
Definition: sim.h:95
#define DMRG_VERSION_STRING
Definition: version.h:35
int init_sweep
Definition: sim.h:91
int init_site
Definition: sim.h:91
Lattice lat
Definition: sim.h:99
measurements_type all_measurements
Definition: sim.h:103
MPO< Matrix, SymmGroup > mpo
Definition: sim.h:102
pimpl resolved Lattice
Definition: lattice.h:84
template<class Matrix , class SymmGroup >
sim< Matrix, SymmGroup >::~sim ( )
virtual

Definition at line 126 of file sim.hpp.

127 {
128 }

Member Function Documentation

template<class Matrix, class SymmGroup>
void sim< Matrix, SymmGroup >::checkpoint_simulation ( MPS< Matrix, SymmGroup > const &  state,
status_type const &  status 
)
protectedvirtual

Definition at line 131 of file sim.hpp.

132 {
133  if (!dns) {
134  /// create chkp dir
135  if (!boost::filesystem::exists(chkpfile))
136  boost::filesystem::create_directory(chkpfile);
137  /// save state to chkp dir
138  save(chkpfile, state);
139 
140  /// save status
141  storage::archive ar(chkpfile+"/props.h5", "w");
142  ar["/status"] << status;
143  }
144 }
std::string chkpfile
Definition: sim.h:94
bool dns
Definition: sim.h:93
void save(alps::hdf5::archive &ar, std::string const &path, TrivialGroup::charge const &value, std::vector< std::size_t > size=std::vector< std::size_t >(), std::vector< std::size_t > chunk=std::vector< std::size_t >(), std::vector< std::size_t > offset=std::vector< std::size_t >())
Definition: none.h:70
template<class Matrix , class SymmGroup >
sim< Matrix, SymmGroup >::measurements_type sim< Matrix, SymmGroup >::iteration_measurements ( int  sweep)
protected

Definition at line 112 of file sim.hpp.

113 {
115  mymeas << overlap_measurements<Matrix, SymmGroup>(parms, sweep);
116 
118  if (!parms["ALWAYS_MEASURE"].empty())
119  sweep_measurements = meas_sublist(mymeas, parms["ALWAYS_MEASURE"]);
120 
121  return sweep_measurements;
122 }
Model< Matrix, SymmGroup >::measurements_type measurements_type
Definition: sim.h:77
DmrgParameters parms
Definition: sim.h:89
measurements_type sweep_measurements
Definition: sim.h:103
boost::ptr_vector< measurement< Matrix, SymmGroup > > meas_sublist(boost::ptr_vector< measurement< Matrix, SymmGroup > > const &m, std::vector< std::string > const &meas_list)
Definition: measurements.h:97
measurements_type all_measurements
Definition: sim.h:103
template<class Matrix , class SymmGroup >
void sim< Matrix, SymmGroup >::measure ( std::string  archive_path,
measurements_type meas 
)
protectedvirtual

Definition at line 161 of file sim.hpp.

162 {
163  maquis::cout << "Measurements." << std::endl;
164  std::for_each(meas.begin(), meas.end(), measure_and_save<Matrix, SymmGroup>(rfile, archive_path, mps));
165 
166  // TODO: move into special measurement
167  std::vector<int> * measure_es_where = NULL;
168  entanglement_spectrum_type * spectra = NULL;
169  if (!parms["entanglement_spectra"].empty()) {
170  spectra = new entanglement_spectrum_type();
171  measure_es_where = new std::vector<int>();
172  *measure_es_where = parms.template get<std::vector<int> >("entanglement_spectra");
173  }
174  std::vector<double> entropies, renyi2;
175  if (parms["MEASURE[Entropy]"]) {
176  maquis::cout << "Calculating vN entropy." << std::endl;
177  entropies = calculate_bond_entropies(mps);
178  }
179  if (parms["MEASURE[Renyi2]"]) {
180  maquis::cout << "Calculating n=2 Renyi entropy." << std::endl;
181  renyi2 = calculate_bond_renyi_entropies(mps, 2, measure_es_where, spectra);
182  }
183 
184  {
185  storage::archive ar(rfile, "w");
186  if (entropies.size() > 0)
187  ar[archive_path + "/Entropy/mean/value"] << entropies;
188  if (renyi2.size() > 0)
189  ar[archive_path + "/Renyi2/mean/value"] << renyi2;
190  if (spectra != NULL)
191  ar[archive_path + "/Entanglement Spectra/mean/value"] << *spectra;
192  }
193 }
DmrgParameters parms
Definition: sim.h:89
std::vector< double > calculate_bond_entropies(MPS< Matrix, SymmGroup > &mps)
Definition: mps_mpo_ops.h:252
MPS< Matrix, SymmGroup > mps
Definition: sim.h:101
std::vector< std::pair< std::vector< std::string >, std::vector< double > > > entanglement_spectrum_type
Definition: mps_mpo_ops.h:183
std::string rfile
Definition: sim.h:95
std::vector< double > calculate_bond_renyi_entropies(MPS< Matrix, SymmGroup > &mps, double n, std::vector< int > *measure_es_where=NULL, entanglement_spectrum_type *spectra=NULL)
Definition: mps_mpo_ops.h:186
template<class Matrix , class SymmGroup >
std::string sim< Matrix, SymmGroup >::results_archive_path ( status_type const &  status) const
protectedvirtual

Definition at line 147 of file sim.hpp.

148 {
149  std::ostringstream oss;
150  oss.str("");
151 #if defined(__xlC__) || defined(__FCC_VERSION)
152  typename status_type::const_iterator match = status.find("sweep");
153  oss << "/spectrum/iteration/" << match->second;
154 #else
155  oss << "/spectrum/iteration/" << status.at("sweep");
156 #endif
157  return oss.str();
158 }
template<class Matrix, class SymmGroup>
virtual void sim< Matrix, SymmGroup >::run ( )
pure virtual

Member Data Documentation

template<class Matrix, class SymmGroup>
measurements_type sim< Matrix, SymmGroup >::all_measurements
protected

Definition at line 103 of file sim.h.

template<class Matrix, class SymmGroup>
std::string sim< Matrix, SymmGroup >::chkpfile
protected

Definition at line 94 of file sim.h.

template<class Matrix, class SymmGroup>
bool sim< Matrix, SymmGroup >::dns
protected

Definition at line 93 of file sim.h.

template<class Matrix, class SymmGroup>
int sim< Matrix, SymmGroup >::init_site
protected

Definition at line 91 of file sim.h.

template<class Matrix, class SymmGroup>
int sim< Matrix, SymmGroup >::init_sweep
protected

Definition at line 91 of file sim.h.

template<class Matrix, class SymmGroup>
Lattice sim< Matrix, SymmGroup >::lat
protected

Definition at line 99 of file sim.h.

template<class Matrix, class SymmGroup>
Model<Matrix, SymmGroup> sim< Matrix, SymmGroup >::model
protected

Definition at line 100 of file sim.h.

template<class Matrix, class SymmGroup>
MPO<Matrix, SymmGroup> sim< Matrix, SymmGroup >::mpo
protected

Definition at line 102 of file sim.h.

template<class Matrix, class SymmGroup>
MPO<Matrix, SymmGroup> sim< Matrix, SymmGroup >::mpoc
protected

Definition at line 102 of file sim.h.

template<class Matrix, class SymmGroup>
MPS<Matrix, SymmGroup> sim< Matrix, SymmGroup >::mps
protected

Definition at line 101 of file sim.h.

template<class Matrix, class SymmGroup>
DmrgParameters sim< Matrix, SymmGroup >::parms
protected

Definition at line 89 of file sim.h.

template<class Matrix, class SymmGroup>
bool sim< Matrix, SymmGroup >::restore
protected

Definition at line 92 of file sim.h.

template<class Matrix, class SymmGroup>
std::string sim< Matrix, SymmGroup >::rfile
protected

Definition at line 95 of file sim.h.

template<class Matrix, class SymmGroup>
time_stopper sim< Matrix, SymmGroup >::stop_callback
protected

Definition at line 97 of file sim.h.

template<class Matrix, class SymmGroup>
measurements_type sim< Matrix, SymmGroup >::sweep_measurements
protected

Definition at line 103 of file sim.h.


The documentation for this class was generated from the following files: