ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
coherent_init.h File Reference
#include "dmrg/mp_tensors/mps.h"
#include "dmrg/mp_tensors/basis_sector_iterators.h"
#include "dmrg/mp_tensors/state_mps.h"
#include <boost/tuple/tuple.hpp>

Go to the source code of this file.

Functions

template<class SymmGroup >
double coherent_weight (std::vector< double > const &coeff, std::vector< boost::tuple< typename SymmGroup::charge, size_t > > const &state)
 
template<class Matrix , class SymmGroup >
MPS< Matrix, SymmGroup > coherent_init_join (std::vector< double > const &coeff, Index< SymmGroup > const &phys, typename SymmGroup::charge initc=SymmGroup::IdentityCharge)
 
template<class Matrix , class SymmGroup >
MPS< Matrix, SymmGroup > coherent_init (std::vector< double > const &coeff, Index< SymmGroup > const &phys)
 
template<class Matrix , class SymmGroup >
MPS< Matrix, SymmGroup > coherent_init_dm_join (std::vector< double > const &coeff, Index< SymmGroup > const &phys_psi, Index< SymmGroup > const &phys_rho)
 
template<class Matrix , class SymmGroup >
MPS< Matrix, SymmGroup > coherent_init_dm (std::vector< double > const &coeff, Index< SymmGroup > const &phys_psi, Index< SymmGroup > const &phys_rho)
 

Function Documentation

template<class Matrix , class SymmGroup >
MPS<Matrix,SymmGroup> coherent_init ( std::vector< double > const &  coeff,
Index< SymmGroup > const &  phys 
)

Definition at line 84 of file coherent_init.h.

85 {
86  assert(phys.size() == 1); // only for TrivialGroup
87  // TODO: require mapping phys --> dens
88 
89  typedef typename SymmGroup::charge charge;
90 
91  using std::exp; using std::sqrt; using std::pow;
92  using boost::math::factorial;
93 
94  size_t L = coeff.size();
95 
96  Index<SymmGroup> trivial_i;
97  trivial_i.insert(std::make_pair(SymmGroup::IdentityCharge, 1));
98 
100  for (int p=0; p<L; ++p) {
101  int s=0;
102  Matrix m(phys[s].second, 1, 0.);
103  for (int ss=0; ss<phys[s].second; ++ss) {
104  m(ss, 0) = pow(coeff[p], ss) * sqrt(factorial<double>(ss)) / factorial<double>(ss);
105  }
107  block.insert_block(m, SymmGroup::IdentityCharge, SymmGroup::IdentityCharge);
108 
109  MPSTensor<Matrix, SymmGroup> t(phys, trivial_i, trivial_i);
110  t.data() = block;
111 
112  mps[p] = t;
113  }
114  return mps;
115 }
size_type insert_block(Matrix const &, charge, charge)
block_matrix< Matrix, SymmGroup > sqrt(block_matrix< Matrix, SymmGroup > m)
Definition: mps.h:40
std::size_t insert(std::pair< charge, std::size_t > const &x)
std::size_t size() const
template<class Matrix , class SymmGroup >
MPS<Matrix,SymmGroup> coherent_init_dm ( std::vector< double > const &  coeff,
Index< SymmGroup > const &  phys_psi,
Index< SymmGroup > const &  phys_rho 
)

Definition at line 160 of file coherent_init.h.

161 {
162  assert(phys_psi.size() == 1); // only for TrivialGroup
163  // TODO: require mapping phys --> dens
164 
165  typedef typename SymmGroup::charge charge;
166 
167  using std::exp; using std::sqrt; using std::pow;
168  using boost::math::factorial;
169 
170  size_t L = coeff.size();
171 
172  Index<SymmGroup> trivial_i;
173  trivial_i.insert(std::make_pair(SymmGroup::IdentityCharge, 1));
174 
175  MPS<Matrix, SymmGroup> mps(L);
176  for (int p=0; p<L; ++p) {
177  int s=0;
178  Matrix m(phys_rho[s].second, 1, 0.);
179  for (int ss1=0; ss1<phys_psi[s].second; ++ss1)
180  for (int ss2=0; ss2<phys_psi[s].second; ++ss2) {
181  m(ss1*phys_psi[s].second+ss2, 0) = pow(coeff[p], ss1) * sqrt(factorial<double>(ss1)) / factorial<double>(ss1);
182  m(ss1*phys_psi[s].second+ss2, 0) *= pow(coeff[p], ss2) * sqrt(factorial<double>(ss2)) / factorial<double>(ss2);
183  }
185  block.insert_block(m, SymmGroup::IdentityCharge, SymmGroup::IdentityCharge);
186 
187  MPSTensor<Matrix, SymmGroup> t(phys_rho, trivial_i, trivial_i);
188  t.data() = block;
189 
190  mps[p] = t;
191  }
192  return mps;
193 }
size_type insert_block(Matrix const &, charge, charge)
block_matrix< Matrix, SymmGroup > sqrt(block_matrix< Matrix, SymmGroup > m)
Definition: mps.h:40
std::size_t insert(std::pair< charge, std::size_t > const &x)
std::size_t size() const
template<class Matrix , class SymmGroup >
MPS<Matrix,SymmGroup> coherent_init_dm_join ( std::vector< double > const &  coeff,
Index< SymmGroup > const &  phys_psi,
Index< SymmGroup > const &  phys_rho 
)

Definition at line 119 of file coherent_init.h.

120 {
121  typedef typename SymmGroup::charge charge;
122  typedef boost::tuple<charge, size_t> local_state;
123 
124  size_t L = coeff.size();
125 
127  double prev_weight;
128  bool first = true;
129  basis_sector_iterator_<SymmGroup> it1,it2,end1,end2;
130  for (boost::tie(it1,end1)=basis_sector_iterators(L, phys_psi, SymmGroup::IdentityCharge); it1!=end1; ++it1)
131  for (boost::tie(it2,end2)=basis_sector_iterators(L, phys_psi, SymmGroup::IdentityCharge); it2!=end2; ++it2)
132  {
133  std::vector<local_state> const& state1 = *it1;
134  std::vector<local_state> const& state2 = *it2;
135  std::vector<local_state> state_rho(L);
136 
137  for (int p=0; p<L; ++p) {
138  boost::get<0>(state_rho[p]) = SymmGroup::IdentityCharge;
139  boost::get<1>(state_rho[p]) = boost::get<1>(state1[p])*phys_psi.size_of_block(boost::get<0>(state2[p])) + boost::get<1>(state2[p]);
140  }
141 
142  double weight = coherent_weight<SymmGroup>(coeff, state1)*coherent_weight<SymmGroup>(coeff, state2);
143  if (mps.length() == 0) {
144  mps = state_mps<Matrix>(state_rho, phys_rho);
145  } else {
146  if (first)
147  mps = join(mps, state_mps<Matrix>(state_rho, phys_rho), prev_weight, weight);
148  else
149  mps = join(mps, state_mps<Matrix>(state_rho, phys_rho), 1., weight);
150 
151  first = false;
152  }
153  prev_weight = weight;
154  }
155 
156  return mps;
157 }
std::pair< basis_sector_iterator_< SymmGroup >, basis_sector_iterator_< SymmGroup > > basis_sector_iterators(size_t L, Index< SymmGroup > const &phys, typename SymmGroup::charge initc=SymmGroup::IdentityCharge)
std::size_t size_of_block(charge c) const
Definition: mps.h:40
size_t length() const
Definition: mps.h:58
MPSTensor< Matrix, SymmGroup > join(MPSTensor< Matrix, SymmGroup > const &m1, MPSTensor< Matrix, SymmGroup > const &m2, boundary_flag_t boundary_f=no_boundary_f)
Definition: joins.hpp:33
template<class Matrix , class SymmGroup >
MPS<Matrix,SymmGroup> coherent_init_join ( std::vector< double > const &  coeff,
Index< SymmGroup > const &  phys,
typename SymmGroup::charge  initc = SymmGroup::IdentityCharge 
)

Definition at line 51 of file coherent_init.h.

53 {
54  typedef typename SymmGroup::charge charge;
55  typedef boost::tuple<charge, size_t> local_state;
56 
57  size_t L = coeff.size();
58 
60  double prev_weight;
61  bool first = true;
63  for (boost::tie(it,end)=basis_sector_iterators(L, phys, initc); it!=end; ++it)
64  {
65  std::vector<local_state> const& state = *it;
66  double weight = coherent_weight<SymmGroup>(coeff, state);
67  if (mps.length() == 0) {
68  mps = state_mps<Matrix>(state, phys);
69  } else {
70  if (first)
71  mps = join(mps, state_mps<Matrix>(state, phys), prev_weight, weight);
72  else
73  mps = join(mps, state_mps<Matrix>(state, phys), 1., weight);
74 
75  first = false;
76  }
77  prev_weight = weight;
78  }
79 
80  return mps;
81 }
std::pair< basis_sector_iterator_< SymmGroup >, basis_sector_iterator_< SymmGroup > > basis_sector_iterators(size_t L, Index< SymmGroup > const &phys, typename SymmGroup::charge initc=SymmGroup::IdentityCharge)
Definition: mps.h:40
size_t length() const
Definition: mps.h:58
MPSTensor< Matrix, SymmGroup > join(MPSTensor< Matrix, SymmGroup > const &m1, MPSTensor< Matrix, SymmGroup > const &m2, boundary_flag_t boundary_f=no_boundary_f)
Definition: joins.hpp:33
template<class SymmGroup >
double coherent_weight ( std::vector< double > const &  coeff,
std::vector< boost::tuple< typename SymmGroup::charge, size_t > > const &  state 
)

Definition at line 37 of file coherent_init.h.

38 {
39  using std::exp; using std::sqrt; using std::pow;
40  using boost::math::factorial;
41 
42  double w = 1.;
43  for (int p=0; p<state.size(); ++p) {
44  int n = boost::get<1>(state[p]);
45  w *= pow(coeff[p], n) * sqrt(factorial<double>(n)) / factorial<double>(n);
46  }
47  return w;
48 }
block_matrix< Matrix, SymmGroup > sqrt(block_matrix< Matrix, SymmGroup > m)