adevs
Public Member Functions | Protected Member Functions | List of all members
adevs::dae_se1_system< X > Class Template Referenceabstract

#include <adevs_hybrid.h>

Inheritance diagram for adevs::dae_se1_system< X >:
adevs::ode_system< X >

Public Member Functions

 dae_se1_system (int N_vars, int M_event_funcs, int A_alg_vars, double err_tol=1E-10, int max_iters=30, double alpha=-1.0)
 
int numAlgVars () const
 Get the number of algebraic variables.
 
double getAlgVar (int i) const
 Get the algebraic variables.
 
virtual void init (double *q, double *a)=0
 
virtual void alg_func (const double *q, const double *a, double *af)=0
 
virtual void der_func (const double *q, const double *a, double *dq)=0
 
virtual void state_event_func (const double *q, const double *a, double *z)=0
 
virtual double time_event_func (const double *q, const double *a)=0
 Compute the time event function using state q and algebraic variables a.
 
virtual void postStep (double *q, double *a)=0
 
virtual void internal_event (double *q, double *a, const bool *state_event)=0
 The internal transition function.
 
virtual void external_event (double *q, double *a, double e, const Bag< X > &xb)=0
 The external transition function.
 
virtual void confluent_event (double *q, double *a, const bool *state_event, const Bag< X > &xb)=0
 The confluent transition function.
 
virtual void output_func (const double *q, const double *a, const bool *state_event, Bag< X > &yb)=0
 The output function.
 
virtual ~dae_se1_system ()
 Destructor.
 
int getIterFailCount () const
 
double getWorseError () const
 
void init (double *q)
 Do not override.
 
void der_func (const double *q, double *dq)
 Do not override.
 
void state_event_func (const double *q, double *z)
 Override only if you have no state event functions.
 
double time_event_func (const double *q)
 Override only if you have no time events.
 
void postStep (double *q)
 Do not override.
 
void internal_event (double *q, const bool *state_event)
 Do not override.
 
void external_event (double *q, double e, const Bag< X > &xb)
 Do not override.
 
void confluent_event (double *q, const bool *state_event, const Bag< X > &xb)
 Do not override.
 
void output_func (const double *q, const bool *state_event, Bag< X > &yb)
 Do not override.
 
- Public Member Functions inherited from adevs::ode_system< X >
 ode_system (int N_vars, int M_event_funcs)
 Make a system with N state variables and M state event functions.
 
int numVars () const
 Get the number of state variables.
 
int numEvents () const
 Get the number of state events.
 
virtual void gc_output (Bag< X > &gb)=0
 Garbage collection function. This works just like the Atomic gc_output method.
 
virtual ~ode_system ()
 Destructor.
 

Protected Member Functions

void solve (const double *q)
 

Detailed Description

template<typename X>
class adevs::dae_se1_system< X >

This extension of the ode_system provides for modeling some semi-explicit DAEs of index 1, specifically those in the form dx/dt = f(x,y), y = g(x,y). The solution to y=g(x,y) is found by iteration on y. See "The Numerical Solution of Differential-Algebraic Systems by Runge-Kutta Methods" by Ernst Hairer, Michel Roche and Christian Lubich, published by Springer as Lecture Notes in Mathematics, Volum 1409, c. 1989. The section on Half-explicit methods (starting pg. 20 of my copy) describes the procedure.

Only the methods that include the algebraic variables should be overriden. Any explicit, single step ODE solver can be used to generate trajectories for this object (e.g., the Runge-Kutta methods included with adevs will work).

Constructor & Destructor Documentation

template<typename X >
adevs::dae_se1_system< X >::dae_se1_system ( int  N_vars,
int  M_event_funcs,
int  A_alg_vars,
double  err_tol = 1E-10,
int  max_iters = 30,
double  alpha = -1.0 
)
inline

Make a system with N state variables, M state event functions and A algebraic variables. The error tolerance determines the acceptable accuracy for the algebraic solution to y=g(x,y). The max_iters argument determines how many iterations will be used to try and generate a solution.

Member Function Documentation

template<typename X >
virtual void adevs::dae_se1_system< X >::alg_func ( const double *  q,
const double *  a,
double *  af 
)
pure virtual

Calculate the algebraic function for the state vector q and algebraic variables a and store the result to af. A solution to alg_func(a,q) = a will be found by iteration on this function.

template<typename X >
virtual void adevs::dae_se1_system< X >::der_func ( const double *  q,
const double *  a,
double *  dq 
)
pure virtual

Calculate the derivative of the state variables and store the result in dq.

Referenced by adevs::dae_se1_system< X >::der_func().

template<typename X >
int adevs::dae_se1_system< X >::getIterFailCount ( ) const
inline

Get the number of times that the error tolerance was not satisfied before the iteration limit was reached.

template<typename X >
double adevs::dae_se1_system< X >::getWorseError ( ) const
inline

Get the worst error in a case where the algebraic solver did not satisfy the error tolerance. This will be zero if there were no failures of the algebraic solver.

template<typename X >
virtual void adevs::dae_se1_system< X >::init ( double *  q,
double *  a 
)
pure virtual

Write an intial solution for the state variables q and algebraic variables a.

Referenced by adevs::dae_se1_system< X >::init().

template<typename X >
virtual void adevs::dae_se1_system< X >::postStep ( double *  q,
double *  a 
)
pure virtual

Update any variables that need updating at then end of a simulation step. This is called both when postStep(q) would be called and also immediately after the execution a discrete state transition.

Referenced by adevs::dae_se1_system< X >::confluent_event(), adevs::dae_se1_system< X >::external_event(), adevs::dae_se1_system< X >::internal_event(), and adevs::dae_se1_system< X >::postStep().

template<typename X >
void adevs::dae_se1_system< X >::solve ( const double *  q)
protected

Solve the algebraic equations. This should not usually need to be called by the derived class. An exception might be where updated values for the algebraic variables are needed from within an event function due to some discrete change in q or the structure of the systems.

Solve y=g(x,y) by the conjugate gradient method. Method iterates on f(x,y)=g(x,y)-y to find f(x,y)=0.

Referenced by adevs::dae_se1_system< X >::confluent_event(), adevs::dae_se1_system< X >::der_func(), adevs::dae_se1_system< X >::external_event(), adevs::dae_se1_system< X >::internal_event(), adevs::dae_se1_system< X >::postStep(), adevs::dae_se1_system< X >::state_event_func(), and adevs::dae_se1_system< X >::time_event_func().

template<typename X >
virtual void adevs::dae_se1_system< X >::state_event_func ( const double *  q,
const double *  a,
double *  z 
)
pure virtual

Calculate the state event functions and store the result in z.

Referenced by adevs::dae_se1_system< X >::state_event_func().


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