ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
models_u1.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_U1_H
29 #define MODELS_CODED_U1_H
30 
31 #include <sstream>
32 
33 #include "dmrg/models/model.h"
36 
37 /* ****************** HEISENBERG */
38 template<class Matrix>
39 class Heisenberg : public model_impl<Matrix, U1>
40 {
42 
43  typedef typename base::table_type table_type;
44  typedef typename base::table_ptr table_ptr;
45  typedef typename base::tag_type tag_type;
46 
47  typedef typename base::term_descriptor term_descriptor;
48  typedef typename base::terms_type terms_type;
49  typedef typename base::op_t op_t;
50  typedef typename base::measurements_type measurements_type;
51 
52 public:
53  Heisenberg (const Lattice& lat, double Jxy, double Jz)
54  : tag_handler(new table_type())
55  {
56  phys.insert(std::make_pair(1, 1));
57  phys.insert(std::make_pair(-1, 1));
58 
59  op_t ident_op, splus_op, sminus_op, sz_op;
60 
61  ident_op.insert_block(Matrix(1, 1, 1), -1, -1);
62  ident_op.insert_block(Matrix(1, 1, 1), 1, 1);
63 
64  splus_op.insert_block(Matrix(1, 1, 1), -1, 1);
65 
66  sminus_op.insert_block(Matrix(1, 1, 1), 1, -1);
67 
68  sz_op.insert_block(Matrix(1, 1, 0.5), 1, 1);
69  sz_op.insert_block(Matrix(1, 1, -0.5), -1, -1);
70 
71  /**********************************************************************/
72  /*** Create operator tag table ****************************************/
73  /**********************************************************************/
74 
75 #define REGISTER(op, kind) op = tag_handler->register_op(op ## _op, kind);
76 
81 
82 #undef REGISTER
83  /**********************************************************************/
84 
85 
86  for (int p=0; p<lat.size(); ++p) {
87  std::vector<int> neighs = lat.forward(p);
88  for (int n=0; n<neighs.size(); ++n) {
89  {
90  term_descriptor term;
91  term.coeff = Jz;
92  term.push_back( boost::make_tuple(p, sz) );
93  term.push_back( boost::make_tuple(neighs[n], sz) );
94  this->terms_.push_back(term);
95  }
96  {
97  term_descriptor term;
98  term.coeff = Jxy/2;
99  term.push_back( boost::make_tuple(p, splus) );
100  term.push_back( boost::make_tuple(neighs[n], sminus) );
101  this->terms_.push_back(term);
102  }
103  {
104  term_descriptor term;
105  term.coeff = Jxy/2;
106  term.push_back( boost::make_tuple(p, sminus) );
107  term.push_back( boost::make_tuple(neighs[n], splus) );
108  this->terms_.push_back(term);
109  }
110  }
111  }
112 
113  }
114 
115  void update(BaseParameters const& p)
116  {
117  // TODO: update this->terms_ with the new parameters
118  return;
119  }
120 
121  Index<U1> const& phys_dim(size_t type) const
122  {
123  return phys;
124  }
125  tag_type identity_matrix_tag(size_t type) const
126  {
127  return ident;
128  }
129  tag_type filling_matrix_tag(size_t type) const
130  {
131  return identity_matrix_tag(type);
132  }
134  {
135  return static_cast<int>(parms["u1_total_charge"]);
136  }
137 
138  measurements_type measurements () const
139  {
140  return measurements_type();
141  }
142 
143  tag_type get_operator_tag(std::string const & name, size_t type) const
144  {
145  if (name == "splus")
146  return splus;
147  else if (name == "sminus")
148  return sminus;
149  else if (name == "sz")
150  return sz;
151  else
152  throw std::runtime_error("Operator not valid for this model.");
153  return 0;
154  }
155 
156  table_ptr operators_table() const
157  {
158  return tag_handler;
159  }
160 
161 private:
162  Index<U1> phys;
163 
164  boost::shared_ptr<TagHandler<Matrix, U1> > tag_handler;
165  tag_type ident, splus, sminus, sz;
166 };
167 
168 /* ****************** HARD CORE BOSONS */
169 template<class Matrix>
170 class HCB : public model_impl<Matrix, U1>
171 {
173 
174  typedef typename base::table_type table_type;
175  typedef typename base::table_ptr table_ptr;
176  typedef typename base::tag_type tag_type;
177 
178  typedef typename base::term_descriptor term_descriptor;
179  typedef typename base::terms_type terms_type;
180  typedef typename base::op_t op_t;
181  typedef typename base::measurements_type measurements_type;
182 
183 public:
184  HCB (const Lattice& lat, double t=1)
185  : tag_handler(new table_type())
186  {
187  phys.insert(std::make_pair(0, 1));
188  phys.insert(std::make_pair(1, 1));
189 
190  op_t ident_op;
191  op_t create_op, destroy_op, count_op;
192 
193  ident_op.insert_block(Matrix(1, 1, 1), 0, 0);
194  ident_op.insert_block(Matrix(1, 1, 1), 1, 1);
195 
196  create_op.insert_block(Matrix(1, 1, 1), 0, 1);
197  destroy_op.insert_block(Matrix(1, 1, 1), 1, 0);
198 
199  count_op.insert_block(Matrix(1, 1, 1), 1, 1);
200 
201  /**********************************************************************/
202  /*** Create operator tag table ****************************************/
203  /**********************************************************************/
204 
205 #define REGISTER(op, kind) op = tag_handler->register_op(op ## _op, kind);
206 
209  REGISTER(destroy, tag_detail::bosonic)
211 
212 #undef REGISTER
213  /**********************************************************************/
214 
215 
216  for (int p=0; p<lat.size(); ++p) {
217  std::vector<int> neighs = lat.forward(p);
218  for (int n=0; n<neighs.size(); ++n) {
219  {
220  term_descriptor term;
221  term.coeff = -t;
222  term.push_back( boost::make_tuple(p, create) );
223  term.push_back( boost::make_tuple(neighs[n], destroy) );
224  this->terms_.push_back(term);
225  }
226  {
227  term_descriptor term;
228  term.coeff = -t;
229  term.push_back( boost::make_tuple(p, destroy) );
230  term.push_back( boost::make_tuple(neighs[n], create) );
231  this->terms_.push_back(term);
232  }
233  }
234  }
235 
236  }
237 
238 
239  void update(BaseParameters const& p)
240  {
241  // TODO: update this->terms_ with the new parameters
242  throw std::runtime_error("update() not yet implemented for this model.");
243  return;
244  }
245 
246  Index<U1> const& phys_dim(size_t type) const
247  {
248  return phys;
249  }
250  tag_type identity_matrix_tag(size_t type) const
251  {
252  return ident;
253  }
254  tag_type filling_matrix_tag(size_t type) const
255  {
256  return identity_matrix_tag(type);
257  }
259  {
260  return static_cast<int>(parms["u1_total_charge"]);
261  }
262 
263  measurements_type measurements () const
264  {
265  return measurements_type();
266  }
267 
268  tag_type get_operator_tag(std::string const & name, size_t type) const
269  {
270  if (name == "n")
271  return count;
272  else if (name == "bdag")
273  return create;
274  else if (name == "b")
275  return destroy;
276  else
277  throw std::runtime_error("Operator not valid for this model.");
278  return 0;
279  }
280 
281  table_ptr operators_table() const
282  {
283  return tag_handler;
284  }
285 
286 
287 private:
288  Index<U1> phys;
289 
290  boost::shared_ptr<TagHandler<Matrix, U1> > tag_handler;
291  tag_type ident, create, destroy, count;
292 };
293 
294 /* ****************** BOSE-HUBBARD */
295 template<class Matrix>
296 class BoseHubbard : public model_impl<Matrix, U1>
297 {
299 
300  typedef typename base::table_type table_type;
301  typedef typename base::table_ptr table_ptr;
302  typedef typename base::tag_type tag_type;
303 
304  typedef typename base::term_descriptor term_descriptor;
305  typedef typename base::terms_type terms_type;
306  typedef typename base::op_t op_t;
307  typedef typename base::measurements_type measurements_type;
308 
309  typedef typename Matrix::value_type value_type;
310 public:
311  BoseHubbard (const Lattice& lat_, BaseParameters & model_)
312  : lat(lat_)
313  , model(model_)
314  , tag_handler(new table_type())
315  {
316  int Nmax = model["Nmax"];
317  double t = model["t"];
318  double U = model["U"];
319  double V = model["V"];
320 
321  op_t ident_op;
322  op_t create_op, destroy_op, count_op, interaction_op;
323 
324  phys.insert(std::make_pair(0, 1));
325  ident_op.insert_block(Matrix(1, 1, 1), 0, 0);
326 
327  for (int n=1; n<=Nmax; ++n)
328  {
329  phys.insert(std::make_pair(n, 1));
330 
331  ident_op.insert_block(Matrix(1, 1, 1), n, n);
332 
333  count_op.insert_block(Matrix(1, 1, n), n, n);
334  if ((n*n-n) != 0)
335  interaction_op.insert_block(Matrix(1, 1, n*n-n), n, n);
336 
337 
338  create_op.insert_block(Matrix(1, 1, std::sqrt(value_type(n))), n-1, n);
339  destroy_op.insert_block(Matrix(1, 1, std::sqrt(value_type(n))), n, n-1);
340  }
341 
342 
343  /**********************************************************************/
344  /*** Create operator tag table ****************************************/
345  /**********************************************************************/
346 
347 #define REGISTER(op, kind) op = tag_handler->register_op(op ## _op, kind);
348 
351  REGISTER(destroy, tag_detail::bosonic)
353  REGISTER(interaction, tag_detail::bosonic)
354 
355 #undef REGISTER
356  /**********************************************************************/
357 
358 
359  for (int p=0; p<lat.size(); ++p) {
360  /* interaction */
361  {
362  term_descriptor term;
363  term.coeff = U/2.;
364  term.push_back( boost::make_tuple(p, interaction) );
365  this->terms_.push_back(term);
366  }
367 
368  std::vector<int> neighs = lat.forward(p);
369  for (int n=0; n<neighs.size(); ++n) {
370  /* hopping */
371  {
372  term_descriptor term;
373  term.coeff = -t;
374  term.push_back( boost::make_tuple(p, create) );
375  term.push_back( boost::make_tuple(neighs[n], destroy) );
376  this->terms_.push_back(term);
377  }
378  {
379  term_descriptor term;
380  term.coeff = -t;
381  term.push_back( boost::make_tuple(p, destroy) );
382  term.push_back( boost::make_tuple(neighs[n], create) );
383  this->terms_.push_back(term);
384  }
385  /* nearest-neighborn interaction */
386  {
387  term_descriptor term;
388  term.coeff = V;
389  term.push_back( boost::make_tuple(p, count) );
390  term.push_back( boost::make_tuple(neighs[n], count) );
391  this->terms_.push_back(term);
392  }
393  }
394  }
395 
396  }
397 
398  void update(BaseParameters const& p)
399  {
400  // TODO: update this->terms_ with the new parameters
401  throw std::runtime_error("update() not yet implemented for this model.");
402  return;
403  }
404 
405  Index<U1> const& phys_dim(size_t type) const
406  {
407  return phys;
408  }
409  tag_type identity_matrix_tag(size_t type) const
410  {
411  return ident;
412  }
413  tag_type filling_matrix_tag(size_t type) const
414  {
415  return identity_matrix_tag(type);
416  }
418  {
419  return static_cast<int>(parms["u1_total_charge"]);
420  }
421 
422  tag_type get_operator_tag(std::string const & name, size_t type) const
423  {
424  if (name == "n")
425  return count;
426  else if (name == "bdag")
427  return create;
428  else if (name == "b")
429  return destroy;
430  else if (name == "id")
431  return ident;
432  else if (name == "fill")
433  return ident;
434  else
435  throw std::runtime_error("Operator not valid for this model.");
436  return 0;
437  }
438 
439  table_ptr operators_table() const
440  {
441  return tag_handler;
442  }
443 
444  measurements_type measurements () const
445  {
446  typedef std::vector<block_matrix<Matrix, U1> > op_vec;
447  typedef std::vector<std::pair<op_vec, bool> > bond_element;
448 
449  measurements_type meas;
450 
451  if (model["MEASURE[Density]"]) {
452  std::string name = "Density";
453  meas.push_back( new measurements::average<Matrix, U1>(name, lat,
454  op_vec(1,this->identity_matrix(0)),
455  op_vec(1,this->filling_matrix(0)),
456  op_vec(1,tag_handler->get_op(count))) );
457  }
458 
459  if (model["MEASURE[Local density]"]) {
460  std::string name = "Local density";
461  meas.push_back( new measurements::local<Matrix, U1>(name, lat,
462  op_vec(1,this->identity_matrix(0)),
463  op_vec(1,this->filling_matrix(0)),
464  op_vec(1,tag_handler->get_op(count))) );
465  }
466 
467  if (model["MEASURE[Onebody density matrix]"]) {
468  std::string name = "Onebody density matrix";
469  bond_element ops;
470  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(create)), false) );
471  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(destroy)), false) );
472  meas.push_back( new measurements::correlations<Matrix, U1>(name, lat,
473  op_vec(1,this->identity_matrix(0)),
474  op_vec(1,this->filling_matrix(0)),
475  ops, true, false) );
476  }
477 
478  return meas;
479  }
480 
481 private:
482  const Lattice & lat;
483  BaseParameters & model;
484  Index<U1> phys;
485 
486  boost::shared_ptr<TagHandler<Matrix, U1> > tag_handler;
487  tag_type ident, create, destroy, count, interaction;
488 };
489 
490 /* ****************** FREE FERMIONS */
491 template<class Matrix>
492 class FreeFermions : public model_impl<Matrix, U1>
493 {
495 
496  typedef typename base::table_type table_type;
497  typedef typename base::table_ptr table_ptr;
498  typedef typename base::tag_type tag_type;
499 
500  typedef typename base::term_descriptor term_descriptor;
501  typedef typename base::terms_type terms_type;
502  typedef typename base::op_t op_t;
503  typedef typename base::measurements_type measurements_type;
504 
505 public:
506  FreeFermions (const Lattice& lat, double t=1)
507  : lattice(lat)
508  , tag_handler(new table_type())
509  {
510  op_t ident_op;
511  op_t create_op, destroy_op, sign_op, dens_op;
512 
513  create_op.insert_block(Matrix(1, 1, 1), 0, 1);
514  destroy_op.insert_block(Matrix(1, 1, 1), 1, 0);
515 
516  dens_op.insert_block(Matrix(1, 1, 1), 1, 1);
517 
518  ident_op.insert_block(Matrix(1, 1, 1), 0, 0);
519  ident_op.insert_block(Matrix(1, 1, 1), 1, 1);
520  sign_op.insert_block(Matrix(1, 1, 1), 0, 0);
521  sign_op.insert_block(Matrix(1, 1, -1), 1, 1);
522 
523  phys.insert(std::make_pair(0, 1));
524  phys.insert(std::make_pair(1, 1));
525 
526 #define REGISTER(op, kind) op = tag_handler->register_op(op ## _op, kind);
527 
533 
534 #undef REGISTER
535 
536 
537  for (int p=0; p<lat.size(); ++p) {
538  std::vector<int> neighs = lat.forward(p);
539  for (int n=0; n<neighs.size(); ++n) {
540  {
541  term_descriptor term;
542  term.is_fermionic = true;
543  term.coeff = -t;
544  term.push_back( boost::make_tuple(p, create) );
545  term.push_back( boost::make_tuple(neighs[n], destroy) );
546  this->terms_.push_back(term);
547  }
548  {
549  term_descriptor term;
550  term.is_fermionic = true;
551  term.coeff = -t;
552  term.push_back( boost::make_tuple(p, destroy) );
553  term.push_back( boost::make_tuple(neighs[n], create) );
554  this->terms_.push_back(term);
555  }
556  }
557  }
558 
559  }
560 
561  void update(BaseParameters const& p)
562  {
563  // TODO: update this->terms_ with the new parameters
564  throw std::runtime_error("update() not yet implemented for this model.");
565  return;
566  }
567 
568  Index<U1> const& phys_dim(size_t type) const
569  {
570  return phys;
571  }
572  tag_type identity_matrix_tag(size_t type) const
573  {
574  return ident;
575  }
576  tag_type filling_matrix_tag(size_t type) const
577  {
578  return sign;
579  }
581  {
582  return static_cast<int>(parms["u1_total_charge"]);
583  }
584 
585  tag_type get_operator_tag(std::string const & name, size_t type) const
586  {
587  if (name == "n")
588  return dens;
589  else if (name == "cdag")
590  return create;
591  else if (name == "c")
592  return destroy;
593  else
594  throw std::runtime_error("Operator not valid for this model.");
595  return 0;
596  }
597 
598  table_ptr operators_table() const
599  {
600  return tag_handler;
601  }
602 
603  measurements_type measurements () const
604  {
605  typedef std::vector<block_matrix<Matrix, U1> > op_vec;
606  typedef std::vector<std::pair<op_vec, bool> > bond_element;
607 
608  measurements_type meas;
609  {
610  meas.push_back( new measurements::local<Matrix, U1>("Density", lattice,
611  op_vec(1,this->identity_matrix(0)),
612  op_vec(1,this->filling_matrix(0)),
613  op_vec(1,tag_handler->get_op(dens))) );
614  }
615  {
616  bond_element ops;
617  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(dens)), false) );
618  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(dens)), false) );
619  meas.push_back( new measurements::correlations<Matrix, U1>("DensityCorrelation", lattice,
620  op_vec(1,this->identity_matrix(0)),
621  op_vec(1,this->filling_matrix(0)),
622  ops, true, false) );
623  }
624  {
625  bond_element ops;
626  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(create)), true) );
627  ops.push_back( std::make_pair(op_vec(1,tag_handler->get_op(destroy)), true) );
628  meas.push_back( new measurements::correlations<Matrix, U1>("OneBodyDM", lattice,
629  op_vec(1,this->identity_matrix(0)),
630  op_vec(1,this->filling_matrix(0)),
631  ops, true, false) );
632  }
633  return meas;
634  }
635 
636 private:
637  Lattice lattice;
638  Index<U1> phys;
639 
640  boost::shared_ptr<TagHandler<Matrix, U1> > tag_handler;
641  tag_type ident;
642  tag_type create, destroy, sign, dens;
643 };
644 
645 /* ****************** FERMI HUBBARD */
646 // MD: this model is disabled, because the new Model interface only works for
647 // Hamiltonians with a single filling_matrix between bond terms.
648 // For moment the user should jsut use the ALPS Model, which provides the same.
649 // TODO: Two possibilities
650 // 1) rewrite the Hamiltonian to have different Jordan-Wiger trasform with only
651 // one filling matrix
652 // 2) unroll the filling matrices explicitly in the bond terms
653 /*
654 template<class Matrix>
655 class FermiHubbardU1 : public model_impl<Matrix, U1> base
656 {
657 public:
658  typedef model_impl<Matrix, U1> base;
659 
660  typedef typename base::table_type table_type;
661  typedef typename base::table_ptr table_ptr;
662  typedef typename base::tag_type tag_type;
663 
664  typedef typename base::term_descriptor term_descriptor;
665  typedef typename base::terms_type terms_type;
666  typedef typename base::op_t op_t;
667  typedef typename base::measurements_type measurements_type;
668 
669  FermiHubbardU1(const Lattice& lat, BaseParameters & parms)
670  : tag_handler(new table_type())
671  {
672  phys.insert(std::make_pair(0, 1));
673  phys.insert(std::make_pair(1, 2));
674  phys.insert(std::make_pair(2, 1));
675  op_t create_up_op, create_down_op, destroy_up_op, destroy_down_op,
676  count_up_op, count_down_op, doubly_occ_op,
677  sign_up_op, sign_down_op, fill_op, ident_op;
678 
679  ident_op.insert_block(Matrix(1, 1, 1), 0, 0);
680  ident_op.insert_block(Matrix::identity_matrix(2), 1, 1);
681  ident_op.insert_block(Matrix(1, 1, 1), 2, 2);
682 
683  {Matrix tmp(1,2,0); tmp(0,0)=1; create_up_op.insert_block(tmp, 0, 1);}
684  {Matrix tmp(2,1,0); tmp(1,0)=1; create_up_op.insert_block(tmp, 1, 2);}
685  {Matrix tmp(1,2,0); tmp(0,1)=1; create_down_op.insert_block(tmp, 0, 1);}
686  {Matrix tmp(2,1,0); tmp(0,0)=1; create_down_op.insert_block(tmp, 1, 2);}
687 
688  {Matrix tmp(2,1,0); tmp(0,0)=1; destroy_up_op.insert_block(tmp, 1, 0);}
689  {Matrix tmp(1,2,0); tmp(0,1)=1; destroy_up_op.insert_block(tmp, 2, 1);}
690  {Matrix tmp(2,1,0); tmp(1,0)=1; destroy_down_op.insert_block(tmp, 1, 0);}
691  {Matrix tmp(1,2,0); tmp(0,0)=1; destroy_down_op.insert_block(tmp, 2, 1);}
692 
693  {Matrix tmp(2,2,0); tmp(0,0)=1; count_up_op.insert_block(tmp, 1, 1);}
694  count_up_op.insert_block(Matrix(1, 1, 1), 2, 2);
695  {Matrix tmp(2,2,0); tmp(1,1)=1; count_down_op.insert_block(tmp, 1, 1);}
696  count_down_op.insert_block(Matrix(1, 1, 1), 2, 2);
697 
698  doubly_occ_op.insert_block(Matrix(1, 1, 1), 2, 2);
699 
700  sign_up_op.insert_block(Matrix(1, 1, 1), 0, 0);
701  {Matrix tmp=Matrix::identity_matrix(2); tmp(0,0)=-1; sign_up_op.insert_block(tmp, 1, 1);}
702  sign_up_op.insert_block(Matrix(1, 1, -1), 2, 2);
703 
704  sign_down_op.insert_block(Matrix(1, 1, 1), 0, 0);
705  {Matrix tmp=Matrix::identity_matrix(2); tmp(1,1)=-1; sign_down_op.insert_block(tmp, 1, 1);}
706  sign_down_op.insert_block(Matrix(1, 1, -1), 2, 2);
707 
708  gemm(sign_up_op, sign_down_op, fill_op);
709 
710 #define REGISTER(op, kind) op = tag_handler->register_op(op ## _op, kind);
711 
712  REGISTER(ident, tag_detail::bosonic)
713  REGISTER(fill, tag_detail::bosonic)
714  REGISTER(create_up, tag_detail::fermionic)
715  REGISTER(create_down, tag_detail::fermionic)
716  REGISTER(destroy_up, tag_detail::fermionic)
717  REGISTER(destroy_down, tag_detail::fermionic)
718  REGISTER(count_up, tag_detail::bosonic)
719  REGISTER(count_down, tag_detail::bosonic)
720  REGISTER(doubly_occ, tag_detail::bosonic)
721  REGISTER(sign_up, tag_detail::bosonic)
722  REGISTER(sign_down, tag_detail::bosonic)
723 
724 #undef REGISTER
725 
726  double U = parms["U"];
727  op_t tmp;
728  for (int p=0; p<lat.size(); ++p) {
729  { // U term
730  term_descriptor term;
731  term.is_fermionic = false;
732  term.coeff = U;
733  term.push_back( boost::make_tuple(p, doubly_occ) );
734  this->terms_.push_back(term);
735  }
736 
737  std::vector<int> neighs = lat.forward(p);
738  for (std::vector<int>::iterator hopto = neighs.begin();
739  hopto != neighs.end(); ++hopto)
740  {
741  double ti = get_t(parms,
742  lat.get_prop<int>("type", p, *hopto));
743  { // t*cdag_up*c_up
744  term_descriptor term;
745  term.is_fermionic = true;
746  term.fill_operator = sign_up;
747 
748  // Note inverse notation because of notation in operator.
749  std::pair<tag_type, value_type> prod = tag_handler->get_product_tag(sign_up, create_up);
750  term.coeff = -ti * prod.second;
751  term.push_back( boost::make_tuple(p, prod.first) );
752  term.push_back( boost::make_tuple(*hopto, destroy_up) );
753  this->terms_.push_back(term);
754  }
755  { // t*c_up*cdag_up
756  term_descriptor term;
757  term.is_fermionic = true;
758  term.fill_operator = sign_up;
759 
760  // Note inverse notation because of notation in operator.
761  std::pair<tag_type, value_type> prod = tag_handler->get_product_tag(destroy_up, sign_up);
762  term.coeff = -ti * prod.second;
763  term.push_back( boost::make_tuple(p, prod.first) );
764  term.push_back( boost::make_tuple(*hopto, create_up) );
765  this->terms_.push_back(term);
766  }
767  { // t*cdag_down*c_down
768  term_descriptor term;
769  term.is_fermionic = true;
770  term.fill_operator = sign_down;
771 
772  // Note inverse notation because of notation in operator.
773  std::pair<tag_type, value_type> prod = tag_handler->get_product_tag(sign_down, create_down);
774  term.coeff = -ti * prod.second;
775  term.push_back( boost::make_tuple(p, prod.first) );
776  term.push_back( boost::make_tuple(*hopto, destroy_down) );
777  this->terms_.push_back(term);
778  }
779  { // t*c_down*cdag_down
780  term_descriptor term;
781  term.is_fermionic = true;
782  term.fill_operator = sign_down;
783 
784  // Note inverse notation because of notation in operator.
785  std::pair<tag_type, value_type> prod = tag_handler->get_product_tag(destroy_down, sign_down);
786  term.coeff = -ti * prod.second;
787  term.push_back( boost::make_tuple(p, prod.first) );
788  term.push_back( boost::make_tuple(*hopto, create_down) );
789  this->terms_.push_back(term);
790  }
791  }
792  }
793  }
794 
795  Index<U1> const& phys_dim(size_t type) const
796  {
797  return phys;
798  }
799  tag_type identity_matrix_tag(size_t type) const
800  {
801  return ident;
802  }
803  tag_type filling_matrix_tag(size_t type) const
804  {
805  return fill;
806  }
807  typename U1::charge total_quantum_numbers(BaseParameters & parms) const
808  {
809  return static_cast<int>(parms["u1_total_charge"]);
810  }
811 
812  tag_type get_operator_tag(std::string const & name, size_t type) const
813  {
814  if (name == "n_up")
815  return count_up;
816  else if (name == "n_down")
817  return count_down;
818  else if (name == "cdag_up")
819  return create_up;
820  else if (name == "cdag_down")
821  return create_down;
822  else if (name == "c_up")
823  return destroy_up;
824  else if (name == "c_down")
825  return destroy_down;
826  else if (name == "id")
827  return ident;
828  else if (name == "fill")
829  return fill;
830  else
831  throw std::runtime_error("Operator not valid for this model.");
832  return 0;
833  }
834 
835  table_ptr operators_table() const
836  {
837  return tag_handler;
838  }
839 
840  Measurements<Matrix, U1> measurements () const
841  {
842  return Measurements<Matrix, U1>();
843  }
844 
845 private:
846  Index<U1> phys;
847  tag_type create_up, create_down, destroy_up, destroy_down, count_up, count_down, doubly_occ,
848  sign_up, sign_down, fill, ident;
849 
850  boost::shared_ptr<TagHandler<Matrix, U1> > tag_handler;
851 
852  double get_t (BaseParameters & parms, int i)
853  {
854  std::ostringstream key;
855  key << "t" << (i+1);
856  return (parms.is_set(key.str())) ? parms[key.str()] : parms["t"];
857  }
858 };
859 */
860 
861 #endif
tag_type filling_matrix_tag(size_t type) const
Definition: models_u1.hpp:576
table_ptr operators_table() const
Definition: models_u1.hpp:598
tag_type filling_matrix_tag(size_t type) const
Definition: models_u1.hpp:129
boost::ptr_vector< measurement< Matrix, U1 > > measurements_type
Definition: model.h:58
U1::charge total_quantum_numbers(BaseParameters &parms) const
Definition: models_u1.hpp:580
Index< U1 > const & phys_dim(size_t type) const
Definition: models_u1.hpp:568
terms_type terms_
Definition: model.h:85
FreeFermions(const Lattice &lat, double t=1)
Definition: models_u1.hpp:506
void update(BaseParameters const &p)
Definition: models_u1.hpp:398
measurements_type measurements() const
Definition: models_u1.hpp:603
tag_type filling_matrix_tag(size_t type) const
Definition: models_u1.hpp:413
tag_type get_operator_tag(std::string const &name, size_t type) const
Definition: models_u1.hpp:143
table_ptr operators_table() const
Definition: models_u1.hpp:439
tag_type identity_matrix_tag(size_t type) const
Definition: models_u1.hpp:572
definition of Model base class
Heisenberg(const Lattice &lat, double Jxy, double Jz)
Definition: models_u1.hpp:53
#define REGISTER(op, kind)
size_type insert_block(Matrix const &, charge, charge)
boost::shared_ptr< table_type > table_ptr
Definition: model.h:52
void update(BaseParameters const &p)
Definition: models_u1.hpp:239
table_type::tag_type tag_type
Definition: model.h:53
base type for all models
Definition: model.h:47
Index< U1 > const & phys_dim(size_t type) const
Definition: models_u1.hpp:246
std::vector< term_descriptor > terms_type
Definition: model.h:56
virtual op_t const & identity_matrix(size_t type) const
Definition: model.h:67
table_ptr operators_table() const
Definition: models_u1.hpp:156
int charge
Definition: u1.h:42
block_matrix< Matrix, SymmGroup > sqrt(block_matrix< Matrix, SymmGroup > m)
tag_type get_operator_tag(std::string const &name, size_t type) const
Definition: models_u1.hpp:422
BoseHubbard(const Lattice &lat_, BaseParameters &model_)
Definition: models_u1.hpp:311
tag_type filling_matrix_tag(size_t type) const
Definition: models_u1.hpp:254
HCB(const Lattice &lat, double t=1)
Definition: models_u1.hpp:184
::term_descriptor< typename Matrix::value_type > term_descriptor
Definition: model.h:55
tag_type identity_matrix_tag(size_t type) const
Definition: models_u1.hpp:409
tag_type get_operator_tag(std::string const &name, size_t type) const
Definition: models_u1.hpp:268
U1::charge total_quantum_numbers(BaseParameters &parms) const
Definition: models_u1.hpp:417
void update(BaseParameters const &p)
Definition: models_u1.hpp:115
table_ptr operators_table() const
Definition: models_u1.hpp:281
measurements_type measurements() const
Definition: models_u1.hpp:444
measurements_type measurements() const
Definition: models_u1.hpp:138
std::vector< pos_t > forward(pos_t site) const
Definition: lattice.h:100
Index< U1 > const & phys_dim(size_t type) const
Definition: models_u1.hpp:405
std::size_t insert(std::pair< charge, std::size_t > const &x)
measurements_type measurements() const
Definition: models_u1.hpp:263
U1::charge total_quantum_numbers(BaseParameters &parms) const
Definition: models_u1.hpp:133
Index< U1 > const & phys_dim(size_t type) const
Definition: models_u1.hpp:121
tag_type identity_matrix_tag(size_t type) const
Definition: models_u1.hpp:125
tag_type identity_matrix_tag(size_t type) const
Definition: models_u1.hpp:250
void update(BaseParameters const &p)
Definition: models_u1.hpp:561
pimpl resolved Lattice
Definition: lattice.h:84
virtual op_t const & filling_matrix(size_t type) const
Definition: model.h:69
U1::charge total_quantum_numbers(BaseParameters &parms) const
Definition: models_u1.hpp:258
pos_t size() const
Definition: lattice.h:115
include all Measurements
tag_type get_operator_tag(std::string const &name, size_t type) const
Definition: models_u1.hpp:585