ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
models_2u1.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_2U1_H
29 #define MODELS_CODED_2U1_H
30 
31 #include <sstream>
32 
33 #include "dmrg/models/model.h"
36 
37 /* ****************** FERMI HUBBARD */
38 template<class Matrix>
39 class FermiHubbardTwoU1 : public model_impl<Matrix, TwoU1>
40 {
41 public:
43 
44  typedef typename base::table_type table_type;
45  typedef typename base::table_ptr table_ptr;
46  typedef typename base::tag_type tag_type;
47 
49  typedef typename base::terms_type terms_type;
50  typedef typename base::op_t op_t;
52 
53  typedef typename Matrix::value_type value_type;
54 
55  FermiHubbardTwoU1(const Lattice& lat_, BaseParameters & parms_)
56  : lat(lat_)
57  , parms(parms_)
58  , tag_handler(new TagHandler<Matrix, TwoU1>())
59  {
60  TwoU1::charge A(0), B(0), C(0), D(1);
61  B[0]=1; C[1]=1;
62  phys.insert(std::make_pair(A, 1));
63  phys.insert(std::make_pair(B, 1));
64  phys.insert(std::make_pair(C, 1));
65  phys.insert(std::make_pair(D, 1));
66 
67  op_t create_up_op, create_down_op, destroy_up_op, destroy_down_op,
68  count_up_op, count_down_op, doubly_occ_op,
69  fill_op, ident_op;
70 
71  ident_op.insert_block(Matrix(1, 1, 1), A, A);
72  ident_op.insert_block(Matrix(1, 1, 1), B, B);
73  ident_op.insert_block(Matrix(1, 1, 1), C, C);
74  ident_op.insert_block(Matrix(1, 1, 1), D, D);
75 
76  create_up_op.insert_block(Matrix(1, 1, 1), A, B);
77  create_up_op.insert_block(Matrix(1, 1, 1), C, D);
78  create_down_op.insert_block(Matrix(1, 1, 1), A, C);
79  create_down_op.insert_block(Matrix(1, 1, 1), B, D);
80 
81  destroy_up_op.insert_block(Matrix(1, 1, 1), B, A);
82  destroy_up_op.insert_block(Matrix(1, 1, 1), D, C);
83  destroy_down_op.insert_block(Matrix(1, 1, 1), C, A);
84  destroy_down_op.insert_block(Matrix(1, 1, 1), D, B);
85 
86  count_up_op.insert_block(Matrix(1, 1, 1), B, B);
87  count_up_op.insert_block(Matrix(1, 1, 1), D, D);
88  count_down_op.insert_block(Matrix(1, 1, 1), C, C);
89  count_down_op.insert_block(Matrix(1, 1, 1), D, D);
90 
91  doubly_occ_op.insert_block(Matrix(1, 1, 1), D, D);
92 
93  // TODO: use one sign operator only
94  fill_op.insert_block(Matrix(1, 1, 1), A, A);
95  fill_op.insert_block(Matrix(1, 1, -1), B, B);
96  fill_op.insert_block(Matrix(1, 1, -1), C, C);
97  fill_op.insert_block(Matrix(1, 1, 1), D, D);
98 
99  op_t tmp;
100 
101  gemm(fill_op, create_down_op, tmp);
102  create_down_op = tmp;
103  gemm(destroy_down_op, fill_op, tmp);
104  destroy_down_op = tmp;
105 
106  /**********************************************************************/
107  /*** Create operator tag table ****************************************/
108  /**********************************************************************/
109 
110 #define REGISTER(op, kind) op = tag_handler->register_op(op ## _op, kind);
111 
114  REGISTER(create_up, tag_detail::fermionic)
115  REGISTER(create_down, tag_detail::fermionic)
116  REGISTER(destroy_up, tag_detail::fermionic)
117  REGISTER(destroy_down, tag_detail::fermionic)
118  REGISTER(count_up, tag_detail::bosonic)
119  REGISTER(count_down, tag_detail::bosonic)
120  REGISTER(doubly_occ, tag_detail::bosonic)
121 
122 #undef REGISTER
123  /**********************************************************************/
124 
125  value_type U = parms["U"];
126  std::pair<tag_type, value_type> ptag;
127  for (int p=0; p<lat.size(); ++p) {
128  { // U term
129  term_descriptor term;
130  term.coeff = U;
131  term.push_back( boost::make_tuple(p, doubly_occ) );
132  this->terms_.push_back(term);
133  }
134 
135  std::vector<int> neighs = lat.forward(p);
136  for (std::vector<int>::iterator hopto = neighs.begin();
137  hopto != neighs.end(); ++hopto)
138  {
139  value_type ti = get_t(parms,
140  lat.get_prop<int>("type", p, *hopto));
141  { // t*cdag_up*c_up
142  term_descriptor term;
143  term.is_fermionic = true;
144  term.coeff = -ti;
145 
146  ptag = tag_handler->get_product_tag(fill, create_up); // Note inverse notation because of notation in operator.
147  term.coeff *= ptag.second;
148 
149  term.push_back( boost::make_tuple(p, ptag.first) );
150  term.push_back( boost::make_tuple(*hopto, destroy_up) );
151  this->terms_.push_back(term);
152  }
153  { // t*c_up*cdag_up
154  term_descriptor term;
155  term.is_fermionic = true;
156  term.coeff = -ti;
157 
158  ptag = tag_handler->get_product_tag(fill, destroy_up); // Note inverse notation because of notation in operator.
159  term.coeff *= -ptag.second; // Note minus because of anti-commutation
160 
161  term.push_back( boost::make_tuple(p, ptag.first) );
162  term.push_back( boost::make_tuple(*hopto, create_up) );
163  this->terms_.push_back(term);
164  }
165  { // t*cdag_down*c_down
166  term_descriptor term;
167  term.is_fermionic = true;
168  term.coeff = -ti;
169 
170  ptag = tag_handler->get_product_tag(fill, create_down); // Note inverse notation because of notation in operator.
171  term.coeff *= ptag.second;
172 
173  term.push_back( boost::make_tuple(p, ptag.first) );
174  term.push_back( boost::make_tuple(*hopto, destroy_down) );
175  this->terms_.push_back(term);
176  }
177  { // t*c_down*cdag_down
178  term_descriptor term;
179  term.is_fermionic = true;
180  term.coeff = -ti;
181 
182  ptag = tag_handler->get_product_tag(fill, destroy_down); // Note inverse notation because of notation in operator.
183  term.coeff *= -ptag.second; // Note minus because of anti-commutation
184 
185  term.push_back( boost::make_tuple(p, ptag.first) );
186  term.push_back( boost::make_tuple(*hopto, create_down) );
187  this->terms_.push_back(term);
188  }
189  }
190  }
191  }
192 
193  void update(BaseParameters const& p)
194  {
195  // TODO: update this->terms_ with the new parameters
196  throw std::runtime_error("update() not yet implemented for this model.");
197  return;
198  }
199 
200  Index<TwoU1> const & phys_dim(size_t type) const
201  {
202  return phys;
203  }
204 
206  {
207  typedef std::vector<block_matrix<Matrix, TwoU1> > op_vec;
208  typedef std::vector<std::pair<op_vec, bool> > bond_element;
209 
210  measurements_type meas;
211 
212  if (parms["MEASURE[Density]"]) {
213  meas.push_back( new measurements::average<Matrix, TwoU1>("Density up", lat,
214  op_vec(1,this->identity_matrix(0)),
215  op_vec(1,this->filling_matrix(0)),
216  op_vec(1,tag_handler->get_op(count_up))) );
217  }
218  if (parms["MEASURE[Density]"]) {
219  meas.push_back( new measurements::average<Matrix, TwoU1>("Density down", lat,
220  op_vec(1,this->identity_matrix(0)),
221  op_vec(1,this->filling_matrix(0)),
222  op_vec(1,tag_handler->get_op(count_down))) );
223  }
224 
225  if (parms["MEASURE[Local density]"]) {
226  meas.push_back( new measurements::local<Matrix, TwoU1>("Local density up", lat,
227  op_vec(1,this->identity_matrix(0)),
228  op_vec(1,this->filling_matrix(0)),
229  op_vec(1,tag_handler->get_op(count_up))) );
230  }
231  if (parms["MEASURE[Local density]"]) {
232  meas.push_back( new measurements::local<Matrix, TwoU1>("Local density down", lat,
233  op_vec(1,this->identity_matrix(0)),
234  op_vec(1,this->filling_matrix(0)),
235  op_vec(1,tag_handler->get_op(count_down))) );
236  }
237 
238  if (parms["MEASURE[Onebody density matrix]"]) {
239  bond_element ops;
240  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(create_up)), true) );
241  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(destroy_up)), true) );
242  meas.push_back( new measurements::correlations<Matrix, TwoU1>("Onebody density matrix up", lat,
243  op_vec(1,this->identity_matrix(0)),
244  op_vec(1,this->filling_matrix(0)),
245  ops, false, false) );
246  }
247  if (parms["MEASURE[Onebody density matrix]"]) {
248  bond_element ops;
249  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(create_down)), true) );
250  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(destroy_down)), true) );
251  meas.push_back( new measurements::correlations<Matrix, TwoU1>("Onebody density matrix down", lat,
252  op_vec(1,this->identity_matrix(0)),
253  op_vec(1,this->filling_matrix(0)),
254  ops, false, false) );
255  }
256 
257  return meas;
258  }
259 
260  tag_type identity_matrix_tag(size_t type) const
261  {
262  return ident;
263  }
264  tag_type filling_matrix_tag(size_t type) const
265  {
266  return fill;
267  }
269  {
270  typename TwoU1::charge ret(0);
271  ret[0] = static_cast<int>(parms["u1_total_charge1"]);
272  ret[1] = static_cast<int>(parms["u1_total_charge2"]);
273  return ret;
274  }
275 
276  tag_type get_operator_tag(std::string const & name, size_t type) const
277  {
278  if (name == "create_up")
279  return create_up;
280  else if (name == "create_down")
281  return create_down;
282  else if (name == "destroy_up")
283  return destroy_up;
284  else if (name == "destroy_down")
285  return destroy_down;
286  else if (name == "count_up")
287  return count_up;
288  else if (name == "count_down")
289  return count_down;
290  else if (name == "doubly_occ")
291  return doubly_occ;
292  else
293  throw std::runtime_error("Operator not valid for this model.");
294  return 0;
295  }
296 
298  {
299  return tag_handler;
300  }
301 
302 private:
303  Index<TwoU1> phys;
304 
305  Lattice const & lat;
306  BaseParameters & parms;
307 
308  boost::shared_ptr<TagHandler<Matrix, TwoU1> > tag_handler;
309  tag_type create_up, create_down, destroy_up, destroy_down,
310  count_up, count_down, doubly_occ,
311  ident, fill;
312 
313 
314  double get_t (BaseParameters & parms, int i) const
315  {
316  std::ostringstream key;
317  key << "t" << (i+1);
318  return (parms.is_set(key.str())) ? parms[key.str()] : parms["t"];
319  }
320 };
321 
322 #endif
boost::ptr_vector< measurement< Matrix, TwoU1 > > measurements_type
Definition: model.h:58
table_ptr operators_table() const
Definition: models_2u1.hpp:297
tag_type get_operator_tag(std::string const &name, size_t type) const
Definition: models_2u1.hpp:276
tag_type filling_matrix_tag(size_t type) const
Definition: models_2u1.hpp:264
Matrix::value_type value_type
Definition: models_2u1.hpp:53
measurements_type measurements() const
Definition: models_2u1.hpp:205
bool is_set(std::string const &key) const
definition of Model base class
base::term_descriptor term_descriptor
Definition: models_2u1.hpp:48
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
TwoU1::charge total_quantum_numbers(BaseParameters &parms) const
Definition: models_2u1.hpp:268
std::vector< term_descriptor > terms_type
Definition: model.h:56
Index< TwoU1 > const & phys_dim(size_t type) const
Definition: models_2u1.hpp:200
virtual op_t const & identity_matrix(size_t type) const
Definition: model.h:67
model_impl< Matrix, TwoU1 > base
Definition: models_2u1.hpp:42
tag_type identity_matrix_tag(size_t type) const
Definition: models_2u1.hpp:260
T get_prop(std::string property, pos_t site) const
Definition: lattice.h:103
::term_descriptor< typename Matrix::value_type > term_descriptor
Definition: model.h:55
base::tag_type tag_type
Definition: models_2u1.hpp:46
FermiHubbardTwoU1(const Lattice &lat_, BaseParameters &parms_)
Definition: models_2u1.hpp:55
base::table_type table_type
Definition: models_2u1.hpp:44
void update(BaseParameters const &p)
Definition: models_2u1.hpp:193
std::vector< pos_t > forward(pos_t site) const
Definition: lattice.h:100
base::op_t op_t
Definition: models_2u1.hpp:50
base::table_ptr table_ptr
Definition: models_2u1.hpp:45
base::terms_type terms_type
Definition: models_2u1.hpp:49
void gemm(block_matrix< Matrix1, SymmGroup > const &A, block_matrix< Matrix2, SymmGroup > const &B, block_matrix< Matrix3, SymmGroup > &C)
base::measurements_type measurements_type
Definition: models_2u1.hpp:51
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
#define REGISTER(op, kind)
include all Measurements