4 #ifndef CPPQEDCORE_STRUCTURE_ELEMENTLIOUVILLEAN_H_INCLUDED
5 #define CPPQEDCORE_STRUCTURE_ELEMENTLIOUVILLEAN_H_INCLUDED
7 #include "ElementLiouvilleanFwd.h"
12 #include <boost/function.hpp>
14 #include <boost/mpl/for_each.hpp>
26 template<
int NLINDBLADS>
31 template<int LINDBLAD_ORDINAL, typename OTHER=typename boost::enable_if_c< (LINDBLAD_ORDINAL<NLINDBLADS) >::type>
49 template<
int RANK,
int LINDBLAD_ORDINAL,
bool IS_TIME_DEPENDENT,
int NLINDBLADS=LINDBLAD_ORDINAL+1>
50 class _ :
public mpl::if_c<LINDBLAD_ORDINAL,_<RANK,LINDBLAD_ORDINAL-1,IS_TIME_DEPENDENT,NLINDBLADS>,Base<NLINDBLADS> >::type
62 virtual void doActWithJ(Time,
typename quantumdata::Types<RANK>::StateVectorLow&,
typename Base<NLINDBLADS>::template LindbladNo<LINDBLAD_ORDINAL>)
const = 0;
93 template<
int RANK,
int NLINDBLADS,
bool IS_TIME_DEPENDENT>
101 typedef typename Base::StateVectorLow StateVectorLow;
103 typedef typename Base::LazyDensityOperator LazyDensityOperator;
107 typedef typename Base::Time Time;
110 template<
typename... KeyLabelsPack>
111 ElementLiouvillean(
const std::string& keyTitle, KeyLabelsPack&&... keyLabelsPack) : Base(keyTitle,keyLabelsPack...) {}
113 ElementLiouvillean(
const std::string& keyTitle,
typename Base::KeyLabelsInitializer il) : Base(keyTitle,il) {}
119 Average(
const ElementLiouvillean* ptr, Rates&
rates, Time t,
const LazyDensityOperator& matrix) : ptr_(ptr), rates_(rates), t_(t), matrix_(matrix) {}
124 const ElementLiouvillean*
const ptr_;
127 const LazyDensityOperator& matrix_;
130 virtual const Rates rates_v(Time t,
const LazyDensityOperator& matrix)
const final {Rates
rates(NLINDBLADS); mpl::for_each<tmptools::Ordinals<NLINDBLADS> >(Average(
this,rates,t,matrix));
return rates;}
135 ActWithJ(
const ElementLiouvillean* ptr, Time t, StateVectorLow& psi,
size_t lindbladNo) : ptr_(ptr), t_(t), psi_(psi), lindbladNo_(lindbladNo) {}
141 const ElementLiouvillean*
const ptr_;
143 StateVectorLow& psi_;
144 const size_t lindbladNo_;
147 virtual void actWithJ_v(Time t, StateVectorLow& psi,
size_t lindbladNo)
const final {
if (lindbladNo>=NLINDBLADS)
throw ElementLiouvilleanException(
Base::getTitle()); mpl::for_each<tmptools::Ordinals<NLINDBLADS> >(ActWithJ(
this,t,psi,lindbladNo));}
161 template<
int RANK,
bool IS_TIME_DEPENDENT>
168 typedef typename Base::StateVectorLow StateVectorLow;
170 typedef typename Base::LazyDensityOperator LazyDensityOperator;
174 typedef typename Base::Time Time;
177 ElementLiouvillean(
const std::string& keyTitle,
const std::string& keyLabel) : Base(keyTitle,1,keyLabel) {}
180 virtual const Rates rates_v(Time t,
const LazyDensityOperator& matrix)
const final {Rates
rates(1);
rates(0)=rate(t,matrix);
return rates;}
184 virtual void doActWithJ(Time, StateVectorLow&)
const = 0;
186 virtual double rate(Time,
const LazyDensityOperator&)
const = 0;
199 template<
int RANK,
int NLINDBLADS,
bool IS_TIME_DEPENDENT>
206 typedef typename Base::StateVectorLow StateVectorLow;
208 typedef typename Base::LazyDensityOperator LazyDensityOperator;
212 typedef typename Base::Time Time;
216 typedef typename mpl::if_c<IS_TIME_DEPENDENT,boost::function<void (double, StateVectorLow& )>,boost::function<void ( StateVectorLow& )> >::type
JumpStrategy;
218 typedef typename mpl::if_c<IS_TIME_DEPENDENT,boost::function<double(double, const LazyDensityOperator&)>,boost::function<double(const LazyDensityOperator&)> >::type
JumpRateStrategy;
226 template<
typename... KeyLabelsPack>
227 ElementLiouvilleanStrategies(
const JumpStrategies& jumps,
const JumpRateStrategies& jumpRates,
const std::string& keyTitle, KeyLabelsPack&&... keyLabelsPack)
228 : Base(keyTitle,keyLabelsPack...), jumps_(jumps), jumpRates_(jumpRates) {}
230 ElementLiouvilleanStrategies(
const JumpStrategies& jumps,
const JumpRateStrategies& jumpRates,
const std::string& keyTitle,
typename Base::KeyLabelsInitializer il)
231 : Base(keyTitle,il), jumps_(jumps), jumpRates_(jumpRates) {}
234 virtual const Rates rates_v(Time t,
const LazyDensityOperator& matrix)
const final;
236 virtual void actWithJ_v(Time t, StateVectorLow& psi,
size_t lindbladNo)
const final;
238 const JumpStrategies jumps_ ;
239 const JumpRateStrategies jumpRates_;
247 #endif // CPPQEDCORE_STRUCTURE_ELEMENTLIOUVILLEAN_H_INCLUDED
Metafunction dispatching two OneTime & NoTime according to the template parameter IS_TIME_DEPENDENT ...
A tagging class for Lindblad.
const Rates rates(double t, const StateVector &psi) const
Returns the set of jump rates where the Lindblads are in general time-dependent. ...
mpl::if_c< IS_TIME_DEPENDENT, boost::function< void(double, StateVectorLow &)>, boost::function< void(StateVectorLow &)> >::type JumpStrategy
Strategy functional for acting with a given Lindblad operator (= performing a given jump) on a state...
Thrown if the Lindblad index is not smaller than the total number of Lindblads.
void typeErasedActWithJ(Time t, typename quantumdata::Types< RANK >::StateVectorLow &psi) const
calls the virtual doActWithJ for the given LINDBLAD_ORDINAL
Class reporting also the “what-ness” of the exception.
blitz::TinyVector< JumpStrategy,NLINDBLADS > JumpStrategies
Tiny vector of length NLINDBLADS containing the JumpStrategy instances.
blitz::TinyVector< JumpRateStrategy, NLINDBLADS > JumpRateStrategies
Tiny vector of length NLINDBLADS containing the JumpRateStrategy instances.
Comprises modules for describing quantum systems.
double typeErasedRate(Time t, const quantumdata::LazyDensityOperator< RANK > &matrix) const
calls the virtual rate for the given LINDBLAD_ORDINAL
const std::string & getTitle() const
redirect to cpputils::KeyPrinter
A class to encapsulate Base::LindbladNo, so that the latter has information about the number of Lindb...
Implements LiouvilleanAveragedCommon::displayKey and LiouvilleanAveragedCommon::nAvr with the help of...
Class defining the virtual functions corresponding to a single Lindblad…
Defines class of the same name.
mpl::if_c< IS_TIME_DEPENDENT, boost::function< double(double, const LazyDensityOperator &)>, boost::function< double(const LazyDensityOperator &)> >::type JumpRateStrategy
Strategy functional for calculating from a state the jump rate corresponding to a given Lindblad...
Common interface for calculating quantum averages.
Besides ElementLiouvillean, this is another solution based on the strategy idiom to control the numbe...
An implementation of Liouvillean for the case when the number of Lindblads is known @ compile time (w...
Defines class of the same name.
Base::DArray1D Rates
The 1D real array for storing the jump rates.