ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
initializer_factory.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  * 2013-2013 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_INITIALIZER_FACTORY_H
28 #define MAQUIS_DMRG_MODELS_INITIALIZER_FACTORY_H
29 
30 #include "dmrg/models/model.h"
32 
33 
34 template <class Matrix, class SymmGroup>
37 {
38  typename SymmGroup::charge initc = this->total_quantum_numbers(parms);
39 
40  int max_site_type = 0;
41  std::vector<int> site_types(lat.size(), 0);
42  for (int p = 0; p < lat.size(); ++p) {
43  site_types[p] = lat.get_prop<int>("type", p);
44  max_site_type = std::max(site_types[p], max_site_type);
45  }
46 
47  std::cout << "site_types: ";
48  std::copy(site_types.begin(), site_types.end(), std::ostream_iterator<int>(std::cout, " "));
49  std::cout << std::endl;
50 
51  std::vector<Index<SymmGroup> > site_bases(max_site_type+1);
52  for (int type = 0; type < site_bases.size(); ++type) {
53  site_bases[type] = this->phys_dim(type);
54  std::cout << "phys["<<type <<"]: " << site_bases[type] << std::endl;
55  }
56 
57  if (parms["init_state"] == "default")
58  return initializer_ptr(new default_mps_init<Matrix, SymmGroup>(parms, site_bases, initc, site_types));
59 
60  else if (parms["init_state"] == "const")
61  return initializer_ptr(new const_mps_init<Matrix, SymmGroup>(parms, site_bases, initc, site_types));
62 
63  else if (parms["init_state"] == "thin")
64  return initializer_ptr(new thin_mps_init<Matrix, SymmGroup>(parms, site_bases, initc, site_types));
65 
66  else if (parms["init_state"] == "thin_const")
67  return initializer_ptr(new thin_const_mps_init<Matrix, SymmGroup>(parms, site_bases, initc, site_types));
68 
69  else if (parms["init_state"] == "basis_state")
70  return initializer_ptr(new basis_mps_init<Matrix, SymmGroup>(parms, site_bases, site_types));
71 
72  else if (parms["init_state"] == "basis_state_generic")
73  return initializer_ptr(new basis_mps_init_generic<Matrix, SymmGroup>(parms, site_bases, initc, site_types));
74 
75  else if (parms["init_state"] == "coherent")
76  return initializer_ptr(new coherent_mps_init<Matrix, SymmGroup>(parms, site_bases, site_types));
77 
78  else if (parms["init_state"] == "basis_state_dm")
79  return initializer_ptr(new basis_dm_mps_init<Matrix, SymmGroup>(parms, site_bases, site_types));
80 
81  else if (parms["init_state"] == "coherent_dm")
82  return initializer_ptr(new coherent_dm_mps_init<Matrix, SymmGroup>(parms, site_bases, site_types));
83 
84  else {
85  throw std::runtime_error("Don't know this initial state.");
86  return initializer_ptr();
87  }
88 
89 }
90 
91 #endif
definition of Model base class
virtual initializer_ptr initializer(Lattice const &lat, BaseParameters &parms) const
T get_prop(std::string property, pos_t site) const
Definition: lattice.h:103
functions to initialize the MPS
boost::shared_ptr< mps_initializer< Matrix, SymmGroup > > initializer_ptr
Definition: model.h:49
pimpl resolved Lattice
Definition: lattice.h:84
pos_t size() const
Definition: lattice.h:115