C++QEDCore  v2 Milestone 10
a framework for simulating open quantum dynamics – core
Master.h
Go to the documentation of this file.
1 // Copyright András Vukics 2006–2014. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)
3 // -*- C++ -*-
4 #ifndef CPPQEDCORE_QUANTUMTRAJECTORY_MASTER_H_INCLUDED
5 #define CPPQEDCORE_QUANTUMTRAJECTORY_MASTER_H_INCLUDED
6 
7 #include "MasterFwd.h"
8 
9 #include "Structure.h"
10 
11 #include "DO_Display.h"
12 #include "QuantumTrajectory.h"
13 #include "Types.h"
14 
15 #include "Exception.h"
16 #include "SmartPtr.h"
18 
19 #include <boost/function.hpp>
20 
21 
22 
23 namespace quantumtrajectory {
24 
25 
27 namespace master {
28 
29 
31 
32 
34 
38 
39 
41 template<int RANK>
42 class Base : public QuantumTrajectory<RANK, trajectory::Adaptive<typename quantumdata::Types<RANK>::DensityOperatorLow> >
43 {
44 public:
46  typedef structure::Exact <RANK> Exact ;
49  typedef structure::Averaged <RANK> Averaged ;
50 
51  typedef typename quantumdata::Types<RANK>::DensityOperatorLow DensityOperatorLow;
52  typedef typename quantumdata::Types<RANK>:: StateVectorLow StateVectorLow;
53 
55 
57 
59 
61  void derivs(double, const DensityOperatorLow&, DensityOperatorLow&) const;
62 
63 protected:
64  using QuantumTrajectory::getQSW;
65 
66  Base(DensityOperator&, typename QuantumSystem::Ptr, const Pars&, const DensityOperatorLow& =DensityOperatorLow());
67 
68  typedef boost::function<void( StateVectorLow&)> UnaryFunction;
69  typedef boost::function<void(const StateVectorLow&, StateVectorLow&)> BinaryFunction;
70 
71  DensityOperator& rho_;
72 
73  const typename Averaged::Ptr getAv() const {return getQSW().getAv();}
74 
75 private:
76  virtual void step_v(double) final;
77 
78  std::ostream& displayParameters_v(std::ostream&) const override;
79 
80  virtual void unaryIter( DensityOperatorLow&, UnaryFunction) const;
81  virtual void binaryIter(const DensityOperatorLow&, DensityOperatorLow&, BinaryFunction) const;
82 
83  virtual const std::string addToParameterDisplay() const {return "";}
84 
85 };
86 
87 
88 
90 template<int RANK>
91 class BaseFast : public Base<RANK>
92 {
93 public:
95 
97 
98  typedef typename Base<RANK>::DensityOperatorLow DensityOperatorLow;
99 
100  BaseFast(DensityOperator& rho, typename QuantumSystem::Ptr sys, const Pars& p, const DensityOperatorLow& scaleAbs=DensityOperatorLow())
101  : Base<RANK>(rho,sys,p,scaleAbs), slicesData_(rho.getArray()) {}
102 
103 private:
104  typedef typename Base<RANK>:: UnaryFunction UnaryFunction;
105  typedef typename Base<RANK>::BinaryFunction BinaryFunction;
106 
107  virtual void unaryIter( DensityOperatorLow&, UnaryFunction) const final;
108  virtual void binaryIter(const DensityOperatorLow&, DensityOperatorLow&, BinaryFunction) const final;
109 
110  virtual const std::string addToParameterDisplay() const final {return " Fast Iteration.";}
111 
113 
114 };
115 
116 
117 
118 } // master
119 
120 
121 
122 #define BASE_class boost::mpl::if_c<IS_FAST,master::BaseFast<RANK>,master::Base<RANK> >::type
123 
125 
135 template<int RANK, typename V, bool IS_FAST>
136 class Master : public BASE_class
137 {
138 public:
139  typedef typename BASE_class Base;
140 
141 #undef BASE_class
142 
143  typedef typename Base::QuantumSystem QuantumSystem;
144 
145  typedef typename Base::DensityOperatorLow DensityOperatorLow;
146 
147  typedef typename Base::DensityOperator DensityOperator;
148 
150 
151  template<typename SYS>
152  Master(DensityOperator& rho,
153  const SYS& sys,
154  const master::Pars& pt,
155  bool negativity,
156  const DensityOperatorLow& scaleAbs=DensityOperatorLow()
157  )
158  : Base(rho,cpputils::sharedPointerize(sys),pt,scaleAbs), doDisplay_(this->getAv(),negativity)
159  {}
160 
161  const DensityOperator& getRho() const {return this->rho_;}
162 
163 private:
164  std::ostream& display_v (std::ostream& os, int precision) const override {return doDisplay_.display (this->getTime(),this->rho_,os,precision);}
165  std::ostream& displayKey_v(std::ostream& os, size_t& i ) const override {return doDisplay_.displayKey(os,i);}
166 
167  const std::string trajectoryID_v() const override {return "Master";}
168 
169  const display_densityoperator::_<RANK,V> doDisplay_;
170 
171 };
172 
173 
174 
175 } // quantumtrajectory
176 
177 
178 #endif // CPPQEDCORE_QUANTUMTRAJECTORY_MASTER_H_INCLUDED
An Adaptive trajectory class representing Master equation evolution from a density-operator initial c...
Definition: Master.h:136
The class that is (meant to be, at least) the base of all exceptions in the framework.
Definition: Exception.h:18
The interface every system that needs transformation between two quantum mechanical pictures must pre...
Definition: Exact.h:57
Defines display_densityoperator::_.
Defines class of the same name.
Class hosting common code of MCWF_Trajectory and Master.
Master(DensityOperator &rho, const SYS &sys, const master::Pars &pt, bool negativity, const DensityOperatorLow &scaleAbs=DensityOperatorLow())
Templated constructor.
Definition: Master.h:152
Namespace comprising otherwise hard-to-classify generic utilities.
Definition: Algorithm.h:10
The actual working base of Master in the case when blitzplusplus::basi::Iterator is used for implemen...
Definition: Master.h:42
Density operator of arbitrary arity.
boost::shared_ptr< const QuantumSystem > Ptr
Many of the basic template classes in the framework act as template metafunctions returning a shared ...
Definition: QuantumSystem.h:30
Defines class of the same name.
const boost::shared_ptr< T > sharedPointerize(boost::shared_ptr< T > t)
Part of a bundle of functions providing a unified interface to wrap objects into the shared-pointer i...
Definition: SmartPtr.h:52
void derivs(double, const DensityOperatorLow &, DensityOperatorLow &) const
The actual function calculating the time derivative for ODE evolution.
Defines structur::QuantumSystemWrapper.
quantumdata::Types< 1 >::DensityOperatorLow DensityOperatorLow
unary DensityOperatorFwd
Definition: Free.h:35
Comprises modules representing trajectory drivers for simulating quantum systems. ...
Definition: DO_Display.h:12
Aggregate condensing parameters concerning adaptive ODE evolution (cf. Adaptive::Adaptive()) in the s...
The interface every system having (possibly non-Hermitian) Hamiltonian time-evolution must present to...
Definition: Hamiltonian.h:27
The interface every system that calculates and displays quantum averages must present towards the tra...
Definition: Averaged.h:84
Adaptive is basically an evolved::Evolved wrapped into the Trajectory interface.
Definition: Trajectory.h:288
Tools for adapting blitzplusplus::basi::Iterators to iteration over rows or columns of (multi)matrice...
Tools for creating non-owning shared pointers.
The abstract interface every system has to present towards the quantum trajectory drivers quantumtraj...
Definition: QuantumSystem.h:25
quantumdata::DensityOperator< 1 > DensityOperator
unary DensityOperator
Definition: Free.h:40
Thrown if the system is not applicable in Master-equation evolution.
Definition: Master.h:37
The interface every system having Liouvillean time-evolution must present towards the trajectory driv...
Definition: Liouvillean.h:37
The actual working base of Master in the case when blitzplusplus::basi_fast::Iterator is used for imp...
Definition: Master.h:91
Contains data for pre-calculated slices for basi_fast::Iterator.
Defines tentative base classes for the exception classes of the framework.