ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
models_none.hpp
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 Bela Bauer <bauerb@phys.ethz.ch>
7  * Michele Dolfi <dolfim@phys.ethz.ch>
8  *
9  * This software is part of the ALPS Applications, published under the ALPS
10  * Application License; you can use, redistribute it and/or modify it under
11  * the terms of the license, either version 1 or (at your option) any later
12  * version.
13  *
14  * You should have received a copy of the ALPS Application License along with
15  * the ALPS Applications; see the file LICENSE.txt. If not, the license is also
16  * available from http://alps.comp-phys.org/.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
21  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
22  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  *
26  *****************************************************************************/
27 
28 #ifndef MODELS_CODED_NONE_H
29 #define MODELS_CODED_NONE_H
30 
31 #include <sstream>
32 
33 #include "dmrg/models/model.h"
35 
36 /* ****************** BOSE-HUBBARD */
37 template<class Matrix>
38 class BoseHubbardNone : public model_impl<Matrix, TrivialGroup>
39 {
41 
42  typedef typename base::table_type table_type;
43  typedef typename base::table_ptr table_ptr;
44  typedef typename base::tag_type tag_type;
45 
46  typedef typename base::term_descriptor term_descriptor;
47  typedef typename base::terms_type terms_type;
48  typedef typename base::op_t op_t;
49  typedef typename base::measurements_type measurements_type;
50 
51  typedef typename base::size_t size_t;
52  typedef typename Matrix::value_type value_type;
53 
54 public:
55  BoseHubbardNone (const Lattice& lat, BaseParameters & model_)
56  : model(model_)
57  , lattice(lat)
58  , tag_handler(new table_type())
59  {
60  int Nmax = model["Nmax"];
61  double U = model["U"];
62  double t = model["t"];
63  double V = model["V"];
64 
65  op_t ident_op;
66  op_t create_op, destroy_op, count_op, interaction_op;
67 
69  size_t N = Nmax+1;
70 
71  phys.insert(std::make_pair(C, N));
72  ident_op.insert_block(Matrix::identity_matrix(N), C, C);
73 
74  Matrix mcount(N,N), minteraction(N,N), mcreate(N,N), mdestroy(N,N);
75  for (int n=1; n<=Nmax; ++n)
76  {
77  mcount(n,n) = n;
78  if ((n*n-n) != 0)
79  minteraction(n,n) = n*n-n;
80 
81  mcreate(n-1,n) = std::sqrt(value_type(n)); // input n-1, output n
82  mdestroy(n,n-1) = std::sqrt(value_type(n)); // input n, output n-1
83  }
84  count_op.insert_block(mcount, C,C);
85  interaction_op.insert_block(minteraction, C,C);
86  create_op.insert_block(mcreate, C,C);
87  destroy_op.insert_block(mdestroy, C,C);
88 
89  /**********************************************************************/
90  /*** Create operator tag table ****************************************/
91  /**********************************************************************/
92 
93 #define REGISTER(op, kind) op = tag_handler->register_op(op ## _op, kind);
94 
99  REGISTER(interaction, tag_detail::bosonic)
100 
101 #undef REGISTER
102  /**********************************************************************/
103 
104 
105  for (int p=0; p<lat.size(); ++p) {
106  /* interaction */
107  if (U != 0.) {
108  term_descriptor term;
109  term.is_fermionic = false;
110  term.coeff = U/2.;
111  term.push_back( boost::make_tuple(p, interaction) );
112  this->terms_.push_back(term);
113  }
114 
115  std::vector<int> neighs = lat.forward(p);
116  for (int n=0; n<neighs.size(); ++n) {
117  /* hopping */
118  {
119  term_descriptor term;
120  term.coeff = -t;
121  term.push_back( boost::make_tuple(p, create) );
122  term.push_back( boost::make_tuple(neighs[n], destroy) );
123  this->terms_.push_back(term);
124  }
125  {
126  term_descriptor term;
127  term.coeff = -t;
128  term.push_back( boost::make_tuple(p, destroy) );
129  term.push_back( boost::make_tuple(neighs[n], create) );
130  this->terms_.push_back(term);
131  }
132  /* nearest-neighborn interaction */
133  if (V != 0.){
134  term_descriptor term;
135  term.coeff = V;
136  term.push_back( boost::make_tuple(p, count) );
137  term.push_back( boost::make_tuple(neighs[n], count) );
138  this->terms_.push_back(term);
139  }
140  }
141  }
142 
143  }
144 
145  void update(BaseParameters const& p)
146  {
147  // TODO: update this->terms_ with the new parameters
148  throw std::runtime_error("update() not yet implemented for this model.");
149  return;
150  }
151 
152  Index<TrivialGroup> const& phys_dim(size_t type) const
153  {
154  return phys;
155  }
156  tag_type identity_matrix_tag(size_t type) const
157  {
158  return ident;
159  }
160  tag_type filling_matrix_tag(size_t type) const
161  {
162  return identity_matrix_tag(type);
163  }
165  {
167  }
168 
169 
170  measurements_type measurements() const
171  {
172  typedef std::vector<block_matrix<Matrix, TrivialGroup> > op_vec;
173  typedef std::vector<std::pair<op_vec, bool> > bond_element;
174 
175  measurements_type meas;
176 
177  if (model["MEASURE[Density]"]) {
178  meas.push_back( new measurements::average<Matrix, TrivialGroup>("Density", lattice,
179  op_vec(1,this->identity_matrix(0)),
180  op_vec(1,this->filling_matrix(0)),
181  op_vec(1,tag_handler->get_op(count))) );
182  }
183 
184  if (model["MEASURE[Local density]"]) {
185  meas.push_back( new measurements::local<Matrix, TrivialGroup>("Local density", lattice,
186  op_vec(1,this->identity_matrix(0)),
187  op_vec(1,this->filling_matrix(0)),
188  op_vec(1,tag_handler->get_op(count))) );
189  }
190 
191  if (model["MEASURE[Onebody density matrix]"]) {
192  bond_element ops;
193  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(create)), false) );
194  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(destroy)), false) );
195  meas.push_back( new measurements::correlations<Matrix, TrivialGroup>("Onebody density matrix", lattice,
196  op_vec(1,this->identity_matrix(0)),
197  op_vec(1,this->filling_matrix(0)),
198  ops, true, false) );
199  }
200 
201  return meas;
202  }
203 
204  tag_type get_operator_tag(std::string const & name, size_t type) const
205  {
206  if (name == "n")
207  return count;
208  else if (name == "bdag")
209  return create;
210  else if (name == "b")
211  return destroy;
212  else
213  throw std::runtime_error("Operator not valid for this model.");
214  return 0;
215  }
216 
217  table_ptr operators_table() const
218  {
219  return tag_handler;
220  }
221 
222 
223 private:
224  BaseParameters & model;
225  Lattice lattice;
226  Index<TrivialGroup> phys;
227 
228  table_ptr tag_handler;
229  tag_type ident, create, destroy, count, interaction;
230 };
231 
232 
233 
234 #endif
table_ptr operators_table() const
boost::ptr_vector< measurement< Matrix, TrivialGroup > > measurements_type
Definition: model.h:58
measurements_type measurements() const
BoseHubbardNone(const Lattice &lat, BaseParameters &model_)
Definition: models_none.hpp:55
definition of Model base class
Index< TrivialGroup > const & phys_dim(size_t type) const
tag_type get_operator_tag(std::string const &name, size_t type) const
tag_type filling_matrix_tag(size_t type) const
block_matrix< Matrix, SymmGroup > identity_matrix(Index< SymmGroup > const &size)
size_type insert_block(Matrix const &, charge, charge)
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
block_matrix< Matrix, SymmGroup > sqrt(block_matrix< Matrix, SymmGroup > m)
TrivialGroup::charge total_quantum_numbers(BaseParameters &parms) const
::term_descriptor< typename Matrix::value_type > term_descriptor
Definition: model.h:55
#define REGISTER(op, kind)
tag_type identity_matrix_tag(size_t type) const
static const charge IdentityCharge
Definition: none.h:44
void update(BaseParameters const &p)
std::vector< pos_t > forward(pos_t site) const
Definition: lattice.h:100
std::size_t insert(std::pair< charge, std::size_t > const &x)
pimpl resolved Lattice
Definition: lattice.h:84
virtual op_t const & filling_matrix(size_t type) const
Definition: model.h:69
pos_t size() const
Definition: lattice.h:115