ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
model.h
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  * 2011-2011 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 #ifndef MAQUIS_DMRG_MODELS_MODELS_H
28 #define MAQUIS_DMRG_MODELS_MODELS_H
29 
33 
34 #include "dmrg/models/lattice.h"
35 #include "dmrg/models/op_handler.h"
38 
39 
40 #include <boost/shared_ptr.hpp>
41 
42 /// forward declaration
43 template<class Matrix, class SymmGroup> class Measurements;
44 
45 /// base type for all models
46 template <class Matrix, class SymmGroup>
47 class model_impl {
48 public:
49  typedef boost::shared_ptr<mps_initializer<Matrix, SymmGroup> > initializer_ptr;
50 
52  typedef boost::shared_ptr<table_type> table_ptr;
53  typedef typename table_type::tag_type tag_type;
54 
55  typedef ::term_descriptor<typename Matrix::value_type> term_descriptor;
56  typedef typename std::vector<term_descriptor> terms_type;
58  typedef boost::ptr_vector<measurement<Matrix, SymmGroup> > measurements_type;
59 
60  typedef std::size_t size_t;
61 
62  virtual ~model_impl() {}
63 
64  virtual void update(BaseParameters const& p) =0;
65 
66  virtual Index<SymmGroup> const& phys_dim(size_t type) const=0;
67  virtual op_t const& identity_matrix(size_t type) const { return operators_table()->get_op( identity_matrix_tag(type) ); }
68  virtual tag_type identity_matrix_tag(size_t type) const=0;
69  virtual op_t const& filling_matrix(size_t type) const { return operators_table()->get_op( filling_matrix_tag(type) ); }
70  virtual tag_type filling_matrix_tag(size_t type) const=0;
71 
72  virtual typename SymmGroup::charge total_quantum_numbers(BaseParameters & parms) const=0;
73 
74  virtual terms_type const& hamiltonian_terms() const { return terms_; }
75  virtual measurements_type measurements() const=0;
76 
77  virtual op_t const& get_operator(std::string const & name, size_t type) const { return operators_table()->get_op( get_operator_tag(name, type) ); }
78  virtual tag_type get_operator_tag(std::string const & name, size_t type) const=0;
79 
80  virtual table_ptr operators_table() const=0;
81 
82  virtual initializer_ptr initializer(Lattice const& lat, BaseParameters & parms) const;
83 
84 protected:
86 };
87 
88 /// model factory
89 template <class Matrix, class SymmGroup>
90 boost::shared_ptr<model_impl<Matrix, SymmGroup> >
91 model_factory(Lattice const& lattice, BaseParameters & parms);
92 
93 
94 /// pimpl for Model
95 template <class Matrix, class SymmGroup>
96 class Model {
98  typedef boost::shared_ptr<impl_type> impl_ptr;
99 public:
101 
103  typedef typename impl_type::table_ptr table_ptr;
104  typedef typename impl_type::tag_type tag_type;
105 
108  typedef typename impl_type::op_t op_t;
110 
111  typedef typename impl_type::size_t size_t;
112 
113  Model() { }
114 
115  Model(Lattice const& lattice, BaseParameters & parms)
116  : impl_(model_factory<Matrix, SymmGroup>(lattice, parms))
117  { }
118 
119  Model(impl_ptr impl) : impl_(impl) { }
120 
121  void update(BaseParameters const& p) { return impl_->update(p); }
122 
123  Index<SymmGroup> const& phys_dim(size_t type=0) const { return impl_->phys_dim(type); }
124  op_t const& identity_matrix(size_t type=0) const { return impl_->identity_matrix(type); }
125  tag_type identity_matrix_tag(size_t type=0) const { return impl_->identity_matrix_tag(type); }
126  op_t const& filling_matrix(size_t type=0) const { return impl_->filling_matrix(type); }
127  tag_type filling_matrix_tag(size_t type=0) const { return impl_->filling_matrix_tag(type); }
128 
129  typename SymmGroup::charge total_quantum_numbers(BaseParameters & parms) const { return impl_->total_quantum_numbers(parms); }
130 
131  terms_type const& hamiltonian_terms() const { return impl_->hamiltonian_terms(); }
132  measurements_type measurements() const { return impl_->measurements(); }
133 
134  op_t const& get_operator(std::string const & name, size_t type=0) const { return impl_->get_operator(name, type); }
135  tag_type get_operator_tag(std::string const & name, size_t type=0) const { return impl_->get_operator_tag(name, type); }
136 
137  table_ptr operators_table() const { return impl_->operators_table(); }
138 
139  initializer_ptr initializer(Lattice const& lat, BaseParameters & parms) const { return impl_->initializer(lat, parms); }
140 
141 private:
142  impl_ptr impl_;
143 };
144 
145 
146 #endif
virtual op_t const & get_operator(std::string const &name, size_t type) const
Definition: model.h:77
op_t const & filling_matrix(size_t type=0) const
Definition: model.h:126
definition of Lattice base class
virtual SymmGroup::charge total_quantum_numbers(BaseParameters &parms) const =0
std::size_t size_t
Definition: model.h:60
boost::ptr_vector< measurement< Matrix, SymmGroup > > measurements_type
Definition: model.h:58
tag_type get_operator_tag(std::string const &name, size_t type=0) const
Definition: model.h:135
block_matrix< Matrix, SymmGroup > op_t
Definition: model.h:57
terms_type const & hamiltonian_terms() const
Definition: model.h:131
impl_type::table_ptr table_ptr
Definition: model.h:103
pimpl for Model
Definition: model.h:96
forward declaration
Definition: model.h:43
terms_type terms_
Definition: model.h:85
Model(Lattice const &lattice, BaseParameters &parms)
Definition: model.h:115
measurements_type measurements() const
Definition: model.h:132
virtual tag_type get_operator_tag(std::string const &name, size_t type) const =0
impl_type::size_t size_t
Definition: model.h:111
op_t const & identity_matrix(size_t type=0) const
Definition: model.h:124
virtual table_ptr operators_table() const =0
declaration of block_matrix class
boost::shared_ptr< table_type > table_ptr
Definition: model.h:52
table_type::tag_type tag_type
Definition: model.h:53
base type for all models
Definition: model.h:47
std::vector< term_descriptor > terms_type
Definition: model.h:56
virtual op_t const & identity_matrix(size_t type) const
Definition: model.h:67
tag_type filling_matrix_tag(size_t type=0) const
Definition: model.h:127
initializer_ptr initializer(Lattice const &lat, BaseParameters &parms) const
Definition: model.h:139
Model(impl_ptr impl)
Definition: model.h:119
virtual tag_type filling_matrix_tag(size_t type) const =0
definition of Measurement base class
SymmGroup::charge total_quantum_numbers(BaseParameters &parms) const
Definition: model.h:129
impl_type::tag_type tag_type
Definition: model.h:104
virtual initializer_ptr initializer(Lattice const &lat, BaseParameters &parms) const
impl_type::initializer_ptr initializer_ptr
Definition: model.h:100
boost::shared_ptr< model_impl< Matrix, SymmGroup > > model_factory(Lattice const &lattice, BaseParameters &parms)
model factory
virtual void update(BaseParameters const &p)=0
::term_descriptor< typename Matrix::value_type > term_descriptor
Definition: model.h:55
impl_type::term_descriptor term_descriptor
Definition: model.h:106
virtual terms_type const & hamiltonian_terms() const
Definition: model.h:74
impl_type::measurements_type measurements_type
Definition: model.h:109
OPTable< Matrix, SymmGroup >::tag_type tag_type
Definition: op_handler.h:61
table_ptr operators_table() const
Definition: model.h:137
void update(BaseParameters const &p)
Definition: model.h:121
virtual Index< SymmGroup > const & phys_dim(size_t type) const =0
definition term_descriptor, the description of terms in the Hamiltonian
tag_type identity_matrix_tag(size_t type=0) const
Definition: model.h:125
Model()
Definition: model.h:113
Index< SymmGroup > const & phys_dim(size_t type=0) const
Definition: model.h:123
functions to initialize the MPS
virtual ~model_impl()
Definition: model.h:62
virtual measurements_type measurements() const =0
boost::shared_ptr< mps_initializer< Matrix, SymmGroup > > initializer_ptr
Definition: model.h:49
TagHandler< Matrix, SymmGroup > table_type
Definition: model.h:51
op_t const & get_operator(std::string const &name, size_t type=0) const
Definition: model.h:134
pimpl resolved Lattice
Definition: lattice.h:84
virtual tag_type identity_matrix_tag(size_t type) const =0
virtual op_t const & filling_matrix(size_t type) const
Definition: model.h:69
declaration of OPTable, TagHandler and KronHandler
impl_type::table_type table_type
Definition: model.h:102
impl_type::op_t op_t
Definition: model.h:108
impl_type::terms_type terms_type
Definition: model.h:107