ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tevol_mpo_sim.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  * 2011-2011 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 APP_DMRG_TEVOL_MPO_SIM_H
28 #define APP_DMRG_TEVOL_MPO_SIM_H
29 
30 #include <cmath>
31 
32 #include "dmrg/utils/storage.h"
33 #include "dmrg/evolve/te_utils.hpp"
36 
37 // ****** SIMULATION CLASS ******
38 template <class Matrix, class SymmGroup>
39 class mpo_evolver {
41 public:
43  Lattice const& lattice_, Model<Matrix, SymmGroup> const& model_,
44  int init_sweep=0)
45  : parms(parms_)
46  , mps(mps_)
47  , lattice(lattice_) // shallow copy
48  , model(model_) // shallow copy
49  , hamils(separate_hamil_terms(model.hamiltonian_terms()))
50  {
51  maquis::cout << "Using MPO time evolution." << std::endl;
52 
53  maquis::cout << "Found " << hamils.size() << " non overlapping Hamiltonians." << std::endl;
54 
55  /// compute the time evolution gates
56  prepare_te_terms(init_sweep);
57  }
58 
59  void prepare_te_terms(unsigned sweep)
60  {
61  double dt = (*parms)["dt"];
62  typename Matrix::value_type I;
63  if (sweep < (*parms)["nsweeps_img"])
65  else
67  typename Matrix::value_type alpha = -I*dt;
68 
69  Uterms.resize(hamils.size());
70  for (int i=0; i<hamils.size(); ++i)
71  Uterms[i] = make_exp_mpo(lattice, model, hamils[i], alpha);
72  }
73 
74  void operator()(unsigned sweep, unsigned nsteps)
75  {
76  iteration_results_.clear();
77  for (unsigned i=0; i < nsteps; ++i) evolve_time_step(sweep+i);
78  }
79 
81  {
82  return iteration_results_;
83  }
84 
85 private:
86  void evolve_time_step(unsigned sweep)
87  {
88  for (int which = 0; which < Uterms.size(); ++which)
89  {
90  int maxiter = 6; double tol = 1e-6;
91  mpo_contractor_ss<Matrix, SymmGroup, storage::nop> evolution(*mps, Uterms[which], (*parms));
92  for (int k = 0; k < maxiter; ++k) {
93  std::pair<double,double> eps = evolution.sweep(sweep);
94  double rel_error = std::abs( (eps.first-eps.second) / eps.second );
95  if (rel_error < tol)
96  break;
97  }
98  evolution.finalize();
99  *mps = evolution.get_current_mps();
100  }
101  }
102 
103 
104 private:
105  DmrgParameters * parms;
107  Lattice lattice;
109 
110  results_collector iteration_results_;
111 
112  std::vector<std::vector<term_t> > hamils;
113  std::vector<MPO<Matrix, SymmGroup> > Uterms;
114 };
115 
116 #endif
std::vector< std::vector< term_descriptor< T > > > separate_hamil_terms(std::vector< term_descriptor< T > > const &hamil_terms)
Definition: te_utils.hpp:49
pimpl for Model
Definition: model.h:96
iterative contraction of MPS * MPO tensor network
utilities for the preparation of time evolution operators
results_collector const & iteration_results() const
Definition: tevol_mpo_sim.h:80
Definition: mps.h:40
void prepare_te_terms(unsigned sweep)
Definition: tevol_mpo_sim.h:59
mpo_evolver(DmrgParameters *parms_, MPS< Matrix, SymmGroup > *mps_, Lattice const &lattice_, Model< Matrix, SymmGroup > const &model_, int init_sweep=0)
Definition: tevol_mpo_sim.h:42
void operator()(unsigned sweep, unsigned nsteps)
Definition: tevol_mpo_sim.h:74
MPO< Matrix, SymmGroup > make_exp_mpo(Lattice const &lat, Model< Matrix, SymmGroup > const &model, std::vector< term_descriptor< typename Matrix::value_type > > const &hamil_terms, typename Matrix::value_type const &alpha=1)
Definition: te_utils.hpp:331
pimpl resolved Lattice
Definition: lattice.h:84