ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
meas_prepare.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  * 2011-2013 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 MAQUIS_DMRG_MODEL_MEAS_PREPARE_HPP
29 #define MAQUIS_DMRG_MODEL_MEAS_PREPARE_HPP
30 
31 #include "dmrg/models/lattice.h"
33 
34 namespace meas_prepare {
35 
36  template<class Matrix, class SymmGroup>
37  std::map<std::string, MPO<Matrix,SymmGroup> >
38  local(const Lattice & lat,
39  std::vector<block_matrix<Matrix, SymmGroup> > const & identities,
40  std::vector<block_matrix<Matrix, SymmGroup> > const & fillings,
41  std::vector<std::pair<std::vector<block_matrix<Matrix, SymmGroup> >, bool> > const & ops)
42  {
43  std::map<std::string, MPO<Matrix,SymmGroup> > mpos;
44 
45  for (std::size_t p = 0; p < lat.size(); ++p)
46  {
47  if (ops.size() == 1) {
48  int type = lat.get_prop<int>("type", p);
49  if (ops[0].first[type].n_blocks() > 0) {
50  generate_mpo::MPOMaker<Matrix, SymmGroup> mpom(lat, identities, fillings);
52  term.operators.push_back( std::make_pair(p, ops[0].first[type]) );
53  mpom.add_term(term);
54 
55  mpos[ lat.get_prop<std::string>("label", p) ] = mpom.create_mpo();
56  }
57  } else {
58  std::vector<Lattice::pos_t> neighs = lat.forward(p);
59  for (typename std::vector<Lattice::pos_t>::const_iterator hopto = neighs.begin();
60  hopto != neighs.end();
61  ++hopto)
62  {
63  int type1 = lat.get_prop<int>("type", p);
64  int type2 = lat.get_prop<int>("type", *hopto);
65  if (ops[0].first[type1].n_blocks() > 0 && ops[1].first[type2].n_blocks() > 0) {
66  generate_mpo::MPOMaker<Matrix, SymmGroup> mpom(lat, identities, fillings);
68  term.operators.push_back( std::make_pair(p, ops[0].first[type1]) );
69  term.operators.push_back( std::make_pair(*hopto, ops[1].first[type2]) );
70  term.with_sign = ops[0].second;
71  mpom.add_term(term);
72 
73  mpos[ lat.get_prop<std::string>("label", p, *hopto) ] = mpom.create_mpo();
74  }
75  }
76  }
77  }
78 
79  return mpos;
80  }
81 
82 
83  template<class Matrix, class SymmGroup>
85  average(const Lattice & lat,
86  std::vector<block_matrix<Matrix, SymmGroup> > const & identities,
87  std::vector<block_matrix<Matrix, SymmGroup> > const & fillings,
88  std::vector<std::pair<std::vector<block_matrix<Matrix, SymmGroup> >, bool> > const & ops)
89  {
90  generate_mpo::MPOMaker<Matrix, SymmGroup> mpom(lat, identities, fillings);
91 
92  for (std::size_t p = 0; p < lat.size(); ++p)
93  {
95  term.operators.push_back( std::make_pair(p, ops[0].first[lat.get_prop<int>("type", p)]) );
96  if (ops.size() == 1) {
97  mpom.add_term(term);
98  } else {
99  term.with_sign = ops[0].second;
100  std::vector<Lattice::pos_t> neighs = lat.forward(p);
101  for (typename std::vector<Lattice::pos_t>::const_iterator hopto = neighs.begin();
102  hopto != neighs.end();
103  ++hopto)
104  {
106  term2.operators.push_back( std::make_pair(*hopto, ops[1].first[lat.get_prop<int>("type", p)]) );
107  mpom.add_term(term2);
108  }
109 
110  }
111  }
112 
113  return mpom.create_mpo();
114  }
115 
116 }
117 
118 #endif
include all MPO generator
definition of Lattice base class
std::map< std::string, MPO< Matrix, SymmGroup > > local(const Lattice &lat, std::vector< block_matrix< Matrix, SymmGroup > > const &identities, std::vector< block_matrix< Matrix, SymmGroup > > const &fillings, std::vector< std::pair< std::vector< block_matrix< Matrix, SymmGroup > >, bool > > const &ops)
Definition: mpo.h:36
MPO< Matrix, SymmGroup > average(const Lattice &lat, std::vector< block_matrix< Matrix, SymmGroup > > const &identities, std::vector< block_matrix< Matrix, SymmGroup > > const &fillings, std::vector< std::pair< std::vector< block_matrix< Matrix, SymmGroup > >, bool > > const &ops)
T get_prop(std::string property, pos_t site) const
Definition: lattice.h:103
std::vector< op_pair_t > operators
Definition: utils.hpp:118
void add_term(Operator_Term< Matrix, SymmGroup > const &term)
Definition: mpo_maker.hpp:78
std::vector< pos_t > forward(pos_t site) const
Definition: lattice.h:100
MPO< Matrix, SymmGroup > create_mpo()
Definition: mpo_maker.hpp:121
pimpl resolved Lattice
Definition: lattice.h:84
pos_t size() const
Definition: lattice.h:115