C++QEDCore  v2 Milestone 10
a framework for simulating open quantum dynamics – core
BinarySystem.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 #ifndef CPPQEDCORE_COMPOSITES_BINARYSYSTEM_H_INCLUDED
4 #define CPPQEDCORE_COMPOSITES_BINARYSYSTEM_H_INCLUDED
5 
6 #include "BinarySystemFwd.h"
7 
8 #include "QuantumSystem.h"
9 #include "SubSystem.h"
10 
11 #include "SmartPtr.h"
12 
13 
15 namespace binary {
16 
17 typedef boost::shared_ptr<const Base> Ptr;
18 
20 
22 
27 const Ptr doMake(Interaction::Ptr);
28 
30 template<typename IA>
31 const Ptr make(const IA& ia)
32 {
34 }
35 
36 
39 
40 
42 template<structure::LiouvilleanAveragedTag>
43 std::ostream& displayKey(std::ostream&, size_t&, const SSF& free0, const SSF& free1, const SSI& ia);
44 
46 template<structure::LiouvilleanAveragedTag>
47 size_t nAvr(const SSF& free0, const SSF& free1, const SSI& ia);
48 
50 template<structure::LiouvilleanAveragedTag>
52 average(double t, const quantumdata::LazyDensityOperator<2>& ldo, const SSF& free0, const SSF& free1, const SSI& ia, size_t numberAvr);
53 
54 
56 
70 class Base
71  : public structure::QuantumSystem<2>,
72  public structure::Averaged <2>
73 {
74 protected:
77 
79  explicit Base(Interaction::Ptr);
80 
82 
83  const SSF& getFree0() const {return free0_;}
84  const SSF& getFree1() const {return free1_;}
85  const SSI& getIA () const {return ia_;}
87 
88 private:
89  double highestFrequency_v( ) const;
90  std::ostream& displayParameters_v(std::ostream&) const;
91 
92  size_t nAvr_v() const {return binary::nAvr <structure::LA_Av>( free0_,free1_,ia_ );}
93  const Averages average_v(double t, const LazyDensityOperator& ldo) const {return binary::average <structure::LA_Av>(t,ldo,free0_,free1_,ia_,nAvr());}
94  void process_v(Averages&) const;
95  std::ostream& display_v(const Averages&, std::ostream&, int) const;
96  std::ostream& displayKey_v(std::ostream& os, size_t& i) const {return binary::displayKey<structure::LA_Av>(os,i, free0_,free1_,ia_ );}
97 
98  const SSF free0_, free1_;
99 
100  const SSI ia_;
101 
102 };
103 
104 
105 #define CLASS_HEADER(Class) class Class : public structure::Class<2>
106 
107 #define CLASS_BODY_PART(Class,Aux) public: \
108  typedef structure::Class<1> Aux##1; \
109  typedef structure::Class<2> Aux##2; \
110  \
111  Class(const SSF& free0, const SSF& free1, const SSI& ia) : free0_(free0), free1_(free1), ia_(ia) {} \
112  \
113 private: \
114  const SSF &free0_, &free1_; \
115  const SSI &ia_; \
116 
117 
119 CLASS_HEADER(Exact)
120 {
121  CLASS_BODY_PART(Exact,Ex)
122 
123  bool applicableInMaster_v() const;
124 
125  void actWithU_v(double, StateVectorLow&, double) const;
126 
127 };
128 
129 
131 CLASS_HEADER(Hamiltonian)
132 {
133  CLASS_BODY_PART(Hamiltonian,Ha)
134 
135  void addContribution_v(double, const StateVectorLow&, StateVectorLow&, double) const;
136 
137 };
138 
139 
141 CLASS_HEADER(Liouvillean)
142 {
143  CLASS_BODY_PART(Liouvillean,Li)
144 
145  void actWithJ_v(double, StateVectorLow&, size_t) const;
146 
147  std::ostream& displayKey_v(std::ostream& os, size_t& i ) const {return binary::displayKey<structure::LA_Li>(os,i, free0_,free1_,ia_);}
148  size_t nAvr_v( ) const {return binary::nAvr <structure::LA_Li>( free0_,free1_,ia_);}
149  const Rates average_v(double t, const LazyDensityOperator& ldo) const {return binary::average <structure::LA_Li>(t,ldo,free0_,free1_,ia_,nAvr());}
150 
151 };
152 
153 
154 #undef CLASS_BODY_PART
155 #undef CLASS_HEADER
156 
158 template<typename>
160 {
161 public:
162  EmptyBase(const SSF&, const SSF&, const SSI&) {}
163 };
164 
165 
166 } // binary
167 
168 
169 #define BASE_class(Aux,Class) mpl::if_c<IS_##Aux,binary::Class,binary::EmptyBase<binary::Class> >::type
170 
171 
173 
186 template<bool IS_EX, bool IS_HA, bool IS_LI>
188  : public binary::Base,
189  public BASE_class(EX,Exact),
190  public BASE_class(HA,Hamiltonian),
191  public BASE_class(LI,Liouvillean)
192 {
193 public:
194  typedef typename BASE_class(EX,Exact) ExactBase;
195  typedef typename BASE_class(HA,Hamiltonian) HamiltonianBase;
196  typedef typename BASE_class(LI,Liouvillean) LiouvilleanBase;
197 
199 
200  explicit BinarySystem(Interaction::Ptr);
201 
202 };
203 
204 
205 #undef BASE_class
206 
207 
208 #endif // CPPQEDCORE_COMPOSITES_BINARYSYSTEM_H_INCLUDED
Defines class of the same name.
boost::shared_ptr< const Base > Ptr
Convenience typedef.
Definition: BinarySystem.h:17
quantumdata::LazyDensityOperator< 1 > LazyDensityOperator
unary LazyDensityOperator
Definition: Free.h:37
Describes interaction of Free elements.
Definition: Interaction.h:38
DArray< 1 > DArray1D
A 1D real array storing the quantum averages – even if they are complex, their real & imaginary part...
Implements the structure::Liouvillean interface for a BinarySystem.
Definition: BinarySystem.h:141
Helper for class composition of BinarySystem.
Definition: BinarySystem.h:159
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
const Ptr doMake(Interaction::Ptr)
Maker function for BinarySystem.
Implements the simplest composite system: a binary where a single binary::Interaction couples two fre...
Definition: BinarySystem.h:187
const structure::LiouvilleanAveragedCommon::DArray1D average(double t, const quantumdata::LazyDensityOperator< 2 > &ldo, const SSF &free0, const SSF &free1, const SSI &ia, size_t numberAvr)
Outfactored common functionality of Liouvillean and Averaged.
std::ostream & displayKey(std::ostream &, size_t &, const SSF &free0, const SSF &free1, const SSI &ia)
Outfactored common functionality of Liouvillean and Averaged.
Implements the structure::Exact interface for a BinarySystem along the same lines as Base implements ...
Definition: BinarySystem.h:119
size_t nAvr(const SSF &free0, const SSF &free1, const SSI &ia)
Outfactored common functionality of Liouvillean and Averaged.
Auxiliary tools for BinarySystem.
Definition: BinarySystem.h:15
The interface every system that calculates and displays quantum averages must present towards the tra...
Definition: Averaged.h:84
composite::SubSystemFree SSF
Convenience typedef.
Definition: BinarySystem.h:37
composite::SubSystemsInteraction< 2 > SSI
Convenience typedef.
Definition: BinarySystem.h:38
structure::Interaction< 2 > Interaction
Binary interaction.
Definition: BinarySystem.h:19
Common interface for calculating quantum averages.
Implements the structure::Hamiltonian interface for a BinarySystem.
Definition: BinarySystem.h:131
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
Base(Interaction::Ptr)
Constructor from an Interaction instant.
Defines composite::SubSystemFree and composite::SubSystemsInteraction.
Common base for all class-composed BinarySystems.
Definition: BinarySystem.h:70
const Ptr make(const IA &ia)
Templatized maker function relying on cpputils::sharedPointerize to delegate to make() ...
Definition: BinarySystem.h:31
Base::DArray1D Rates
The 1D real array for storing the jump rates.
Definition: Liouvillean.h:55