C++QEDElements  v2 Milestone 10
a framework for simulating open quantum dynamics – generic elements
Particle_.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 CPPQEDELEMENTS_FREES_PARTICLE__H_INCLUDED
5 #define CPPQEDELEMENTS_FREES_PARTICLE__H_INCLUDED
6 
7 #include "Particle_Fwd.h"
8 
9 #include "ParsParticle.h"
10 
11 #include "QM_PictureFwd.h"
12 #include "StateVectorFwd.h"
13 
14 #include "ModeFunction.h"
15 #include "ElementAveraged.h"
16 #include "Free.h"
17 #include "FreeExact.h"
18 #include "TridiagonalHamiltonian.h"
19 
20 #include <boost/shared_ptr.hpp>
21 
22 namespace particle {
23 
24 using namespace structure::freesystem; using structure::NoTime;
25 
26 
27 typedef boost::shared_ptr<const ParticleBase> Ptr;
28 
29 typedef boost::shared_ptr<const PumpedParticleBase> PtrPumped;
30 
31 
32 const Tridiagonal expINKX(particle::Ptr, ptrdiff_t);
33 
34 inline const Tridiagonal sinNKX(particle::Ptr particle, ptrdiff_t nK) {return (expINKX(particle,nK)-expINKX(particle,-nK))/(2.*DCOMP_I);}
35 inline const Tridiagonal cosNKX(particle::Ptr particle, ptrdiff_t nK) {return (expINKX(particle,nK)+expINKX(particle,-nK))/ 2. ;}
36 
37 const Tridiagonal mfNKX (particle::Ptr, const ModeFunction&);
38 const Tridiagonal mfNKX_AbsSqr(particle::Ptr, const ModeFunction&);
39 
40 
41 const StateVector wavePacket(const InitialCondition&, const Spatial&, bool kFlag=true);
42 const StateVector wavePacket(const Pars &, bool kFlag=true);
43 const StateVector wavePacket(const ParsPumped&, bool kFlag=true);
44 
45 const StateVector hoState(int n, const InitialCondition&, const Spatial&, bool kFlag=true/*, bool exactRenorm=true*/);
46 const StateVector hoState(const Pars &, bool Kflag=true);
47 const StateVector hoState(const ParsPumped&, bool Kflag=true);
48 
49 const StateVector init(const Pars&);
50 
51 Ptr make(const Pars&, QM_Picture);
52 
53 PtrPumped makePumped(const ParsPumped&, QM_Picture);
54 
55 
56 namespace details {
57 
58 typedef boost::tuple<const Spatial&, double> Storage;
59 
60 } // details
61 
62 
63 class Exact : public structure::FreeExact<false>, private details::Storage
64 {
65 public:
66  Exact(const Spatial&, double omrec);
67 
68  using details::Storage::get;
69 
70 private:
71  void updateU(structure::OneTime) const;
72 
73  bool applicableInMaster_v() const {return true;}
74 
75  const Diagonal factorExponents_;
76 
77 };
78 
79 
80 namespace details { struct EmptyBase {}; }
81 
82 
83 template<bool IS_TIME_DEPENDENT>
85  : public quantumoperator::TridiagonalHamiltonian<1,IS_TIME_DEPENDENT>,
86  public mpl::if_c<IS_TIME_DEPENDENT,Exact,details::EmptyBase>::type
87 {
88 public:
90 
91  Hamiltonian(const Spatial&, double omrec, double vClass, const ModeFunction&);
92  Hamiltonian(const Spatial&, double omrec, mpl::bool_<IS_TIME_DEPENDENT> =mpl::false_());
93 
94 };
95 
96 template<>
97 Hamiltonian<true >::Hamiltonian(const Spatial& space, double omrec, double vClass, const ModeFunction& mf);
98 
99 template<>
100 Hamiltonian<false>::Hamiltonian(const Spatial& space, double omrec, double vClass, const ModeFunction& mf);
101 
102 template<>
103 Hamiltonian<false>::Hamiltonian(const Spatial& space, double omrec, boost::mpl::bool_<false>);
104 
105 // Spatial is a tool to facilitate state vector representations in both X and K space, where the two are canonically conjugate operators, so that [X,K]=i, and hence the two representations are linked with ffTransform.
106 
107 class Spatial
108 {
109 public:
110  typedef DArray<1> Array;
111 
112  explicit Spatial(size_t, double deltaK=1);
113 
114  size_t getFinesse () const {return fin_;}
115  size_t getDimension() const {return x_.size();}
116 
117  // x and k space coordinates, respectively
118  double x(size_t i) const {return x_(i);}
119  double k(size_t i) const {return k_(i);}
120 
121  const Array& getX() const {return x_;}
122  const Array& getK() const {return k_;}
123 
124  void header(std::ostream&) const;
125 
126 private:
127  const size_t fin_; // = log2 (number of dimensions)
128 
129  const double xMax_, deltaX_, kMax_, deltaK_;
130 
131  const Array x_, k_;
132 
133 };
134 
135 
136 class Averaged
137  : public structure::ElementAveraged<1>
138 {
139 public:
141 
142  Averaged(const Spatial&);
143 
144  const Spatial& getSpace() const {return space_;}
145 
146 private:
147  const Averages average_v(NoTime, const LazyDensityOperator&) const;
148  void process_v( Averages&) const;
149 
150  const Spatial space_;
151 
152 };
153 
154 
155 
156 } // particle
157 
158 
159 
161 //
162 // Highest level
163 //
165 
166 
168  : public structure::Free, public particle::Averaged
169 {
170 protected:
171  explicit ParticleBase(size_t fin, const RealFreqs& =emptyRF, const ComplexFreqs& =emptyCF);
172 
173 };
174 
175 
177  : public ParticleBase
178 {
179 public:
180  double getV_Class() const {return vClass_;}
181 
182  const ModeFunction& getMF() const {return mf_;}
183 
184 protected:
185  PumpedParticleBase(size_t fin, double vClass, const ModeFunction&,
186  const RealFreqs& =emptyRF, const ComplexFreqs& =emptyCF);
187 
188 private:
189  const double vClass_;
190  const ModeFunction mf_ ;
191 
192 };
193 
194 
195 class Particle
196  : public ParticleBase, public particle::Exact
197 {
198 public:
199  explicit Particle(const particle::Pars&);
200 
201 };
202 
203 
205  : public ParticleBase, public particle::Hamiltonian<false>
206 {
207 public:
208  explicit ParticleSch(const particle::Pars&);
209 
210 };
211 
212 
214  : public PumpedParticleBase, public particle::Hamiltonian<true>
215 {
216 public:
217  explicit PumpedParticle(const particle::ParsPumped&);
218 };
219 
220 
222  : public PumpedParticleBase, public particle::Hamiltonian<false>
223 {
224 public:
225  explicit PumpedParticleSch(const particle::ParsPumped&);
226 };
227 
228 
229 #endif // CPPQEDELEMENTS_FREES_PARTICLE__H_INCLUDED
boost::shared_ptr< const Base > Ptr
const dcomp DCOMP_I(0, 1)
std::list< CF > ComplexFreqs
blitz::Array< double, RANK > DArray
const StateVector init(const Pars &)
Dispatcher for initial condition.
Definition: Qbit_.h:84
std::list< RF > RealFreqs
const Ptr make(const IA &ia)