C++QEDElements  v2 Milestone 10
a framework for simulating open quantum dynamics – generic elements
Spin.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_SPIN_H_INCLUDED
5 #define CPPQEDELEMENTS_FREES_SPIN_H_INCLUDED
6 
7 #include "SpinFwd.h"
8 
9 #include "ElementLiouvillean.h"
10 #include "ElementAveraged.h"
11 #include "Free.h"
12 #include "FreeExact.h"
13 #include "TridiagonalHamiltonian.h"
14 
15 #include "ParsFwd.h"
16 #include "SmartPtr.h"
17 
18 
19 // A general Spin yet incomplete
20 
21 namespace spin {
22 
23 using namespace structure::freesystem;
24 
25 
26 typedef boost::shared_ptr<const SpinBase> Ptr;
27 
28 
29 const Tridiagonal splus(Ptr);
30 
31 inline const Tridiagonal sminus(Ptr spin) {return splus(spin).dagger();}
32 
33 inline const Tridiagonal sx(Ptr spin) {return (splus(spin)+sminus(spin))/2;}
34 inline const Tridiagonal sy(Ptr spin) {return (splus(spin)-sminus(spin))/(2.*DCOMP_I);}
35 
36 const Tridiagonal sn(Ptr);
37 
38 
39 const Tridiagonal sz(Ptr);
40 
41 
42 struct Pars
43 {
44  size_t &twoS, &dim;
45  double &theta, &phi;
46  double &omega, &gamma;
47 
48  Pars(parameters::ParameterTable&, const std::string& ="");
49 
50 };
51 
52 
53 } // spin
54 
55 
57 class SpinBase
58  : public structure::Free,
60 {
61 public:
62  typedef structure::ElementAveraged<1>::LazyDensityOperator LazyDensityOperator;
63 
64  SpinBase(size_t twoS, double theta, double phi, double omega, double gamma, size_t dim=0);
65 
66  size_t getTwoS() const {return twoS_;}
67 
68  double getTheta() const {return theta_;}
69  double getPhi () const {return phi_;}
70 
71  double getOmega() const {return omega_;}
72  double getGamma() const {return gamma_;}
73 
74  const dcomp get_z() const {return dcomp(gamma_,omega_);}
75 
76 private:
77  void process_v(Averages&) const;
78 
79  const Averages average_v(structure::NoTime, const LazyDensityOperator&) const;
80 
81  const size_t twoS_;
82 
83  const double theta_, phi_, omega_, gamma_, s_;
84 
85 };
86 
87 // NOTE if p.gamma is nonzero, Spin & SpinSch will contain the “Hamiltonian” part of the loss!
88 
89 class Spin
90  : public SpinBase,
91  public structure::FreeExact<false>
92 {
93 public:
94 
95  Spin(const spin::Pars& p)
96  : SpinBase(p.twoS,0.,0.,p.omega,p.gamma,p.dim), FreeExact(getTotalDimension())
97  // here, we need to assume that the Hamiltonian is diagonal in the given basis, that is why we set theta=phi=0.
98  {}
99 
100 private:
101  void updateU(structure::OneTime) const;
102 
103  bool applicableInMaster_v() const {return !getGamma();}
104 
105 };
106 
107 
108 class SpinSch
109  : public SpinBase,
111 {
112 public:
113 
114  SpinSch(const spin::Pars& p)
115  : SpinBase(p.twoS,p.theta,p.phi,p.omega,p.gamma,p.dim),
117  {
118  getParsStream()<<"# Schrodinger picture."<<std::endl;
119  }
120 
121 };
122 
123 
125  : public Spin,
126  public structure::ElementLiouvillean<1,1,false>
127 {
128 public:
129 
130  LossySpin(const spin::Pars& p) : Spin(p), structure::ElementLiouvillean<1,1,false>("Spin","S-") {}
131 
132 private:
133 
135  double rate (structure::NoTime, const structure::freesystem::LazyDensityOperator&) const {return -1.;}
136 
137 };
138 
139 
140 #endif // CPPQEDELEMENTS_FREES_SPIN_H_INCLUDED
const boost::shared_ptr< const T > nonOwningConstSharedPtr(T *t)
boost::shared_ptr< const Base > Ptr
quantumdata::Types< 1 >::StateVectorLow StateVectorLow
const dcomp get_z() const
This plays analogous role to in Mode.
Definition: Spin.h:74
const dcomp DCOMP_I(0, 1)
Definition: Spin.h:89
Definition: Spin.h:108
Definition: Spin.h:57
Definition: Spin.h:21
const Tridiagonal dagger() const
std::complex< double > dcomp