C++QEDCore  2.100.2 (v2 Milestone 10 Development branch)
a framework for simulating open quantum dynamics – core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
trajectory::Simulated< A > Class Template Reference

Class fully implementing the Adaptive interface by displaying (and serializing) the whole content of the evolved array. More...

#include <Simulated_.h>

+ Inheritance diagram for trajectory::Simulated< A >:
+ Collaboration diagram for trajectory::Simulated< A >:

Public Types

typedef Adaptive< A > Base
 
typedef evolved::Evolved< A > Evolved
 
- Public Types inherited from trajectory::Adaptive< A >
typedef evolved::Evolved< A > Evolved
 

Public Member Functions

 Simulated (A &, typename Evolved::Derivs, double dtInit, double, double, const A &scaleAbs=A(), const evolved::Maker< A > &=evolved::MakerGSL< A >())
 
 Simulated (A &array, typename Evolved::Derivs derivs, double dtInit, const ParsEvolved &pe, const A &scaleAbs=A(), const evolved::Maker< A > &maker=evolved::MakerGSL< A >())
 
- Public Member Functions inherited from trajectory::Adaptive< A >
void step (double deltaT)
 corresponding to Evolved::step, it takes a single adaptive step More...
 
- Public Member Functions inherited from trajectory::AdaptiveIO< A >
 AdaptiveIO (Ptr)
 
cpputils::iarchivereadState (cpputils::iarchive &iar)
 Read in the EvolvedIO from a cpputils::iarchive. More...
 
cpputils::oarchivewriteState (cpputils::oarchive &oar) const
 Write the EvolvedIO to a cpputils::oarchive.
 
double getTime () const
 Returns the time of the underlying EvolvedIO.
 
- Public Member Functions inherited from trajectory::Trajectory
void evolve (double deltaT)
 Propagation for a time interval of exactly deltaT.
 
std::ostream & display (std::ostream &, int precision) const
 Displays a limited set of relevant physical and numerical information about the actual state of Trajectory at the actual time instant. More...
 
std::ostream & displayParameters (std::ostream &os) const
 print header
 
std::ostream & logOnEnd (std::ostream &os) const
 print a log at the end summarizing overall (e.g. time-averaged) physical and numerical data during the run
 
double getTime () const
 actual time instant
 
double getDtDid () const
 last perfomed timestep
 
cpputils::iarchivereadState (cpputils::iarchive &iar)
 read from an archive
 
cpputils::oarchivewriteState (cpputils::oarchive &oar) const
 write to an archive
 

Additional Inherited Members

- Protected Types inherited from trajectory::Adaptive< A >
typedef Evolved::ConstPtr ConstPtr
 
typedef Evolved::Ptr Ptr
 
- Protected Member Functions inherited from trajectory::Adaptive< A >
 Adaptive (A &, typename Evolved::Derivs, double, double, double, const A &, const evolved::Maker< A > &)
 Constructor taking the same parameters as needed to operate evolved::Maker.
 
 Adaptive (A &, typename Evolved::Derivs, double, const ParsEvolved &, const A &, const evolved::Maker< A > &)
 
const std::string trajectoryID () const
 redirected to a pure virtual, this is needed for serialization of trajectory metadata
 
std::ostream & displayParameters_v (std::ostream &) const override
 
virtual cpputils::iarchivereadStateMore_v (cpputils::iarchive &iar)
 hook into Trajectory::readState
 
virtual cpputils::oarchivewriteStateMore_v (cpputils::oarchive &oar) const
 hook into Trajectory::writeState
 
const ConstPtr getEvolved () const
 
const Ptr getEvolved ()
 
double getDtTry () const
 
- Protected Member Functions inherited from trajectory::AdaptiveIO< A >
const Ptr getEvolvedIO () const
 note: not the same const-correctness as in Adaptive
 
- Protected Attributes inherited from trajectory::AdaptiveIO< A >
SerializationMetadata meta_
 

Detailed Description

template<typename A>
class trajectory::Simulated< A >

Class fully implementing the Adaptive interface by displaying (and serializing) the whole content of the evolved array.

Meant for all cases when simple ODE evolution is desired with intermittent displays

Example usage: simulation of a complex driven damped harmonic oscillator mode described by the ODE

\[\ddot{y}+2\gamma\,\dot{y}+y=e^{i\,\omega t},\]

where $\gamma$ is the damping rate and $\omega$ the driving frequency, and the timescale has been chosen such that the eigenfrequency is 1.

// Copyright András Vukics 2006–2014. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)
#include "Simulated.h"
#include <boost/bind.hpp>
using std::max;
typedef blitz::Array<dcomp,1> Array;
/*
y(0) y
y(1) dy/dt
*/
void derivs(double tau, const Array& y, Array& dydt, double omega, double gamma)
{
dydt(0)=y(1);
dydt(1)=exp(DCOMP_I*omega*tau)-2*gamma*y(1)-y(0);
}
int main(int argc, char* argv[])
{
ParameterTable pt;
Pars p(pt);
double & omega=pt.add("O","Driving frequency",1.),
& gamma=pt.add("G","Damping rate" ,1.);
dcomp & yinit=pt.add( "yinit"," y initial condition",dcomp( 3.45263,-2.0746 )),
& dydtinit=pt.add("dydtinit","dydt initial condition",dcomp(-4.83065, 1.16527));
// Parameter finalization
update(pt,argc,argv,"--");
// Initial condition
Array y(2); y=yinit,dydtinit;
Simulated<Array> S(y,
bind(derivs,_1,_2,_3,omega,gamma),
.1/max(1.,max(omega,gamma)),
p);
run(S,p);
}
Todo:
Provide optional key printing

Definition at line 27 of file Simulated_.h.


The documentation for this class was generated from the following file: