File kernel/src/modelingTools/DynamicalSystem.hpp#

Go to the source code of this file

Abstract class - General interface for all Dynamical Systems.

class DynamicalSystem
#include <DynamicalSystem.hpp>

Abstract interface to Dynamical Systems.

This class is used to describe dynamical systems of the form :

\( g(\dot x, x, t, z) = 0 \)

where

  • \( x \in R^{n} \) is the state.

  • \( z \in R^{zSize} \) is a vector of arbitrary algebraic variables, some sort of discret state. For example, z may be used to set some perturbation parameters, to control the system (z set by actuators) and so on.

  • \( g : R^{n} \times R \to R^{n} \) .

By default, the DynamicalSystem is considered to be an Initial Value Problem (IVP) and the initial conditions are given by

\( x(t_0)=x_0 \)

Under some specific conditions, the system can be written as:

\( \dot x = rhs(x, t, z) \)

In that case, \( \nabla_{\dot x} g \) must be invertible.

Subclassed by FirstOrderNonLinearDS, SecondOrderDS

Public Types

enum DSWorkVectorId

List of indices used to save tmp work vectors The last value is the size of the present list, so you HAVE to leave it at the end position.

Values:

enumerator local_buffer
enumerator freeresidu
enumerator free
enumerator acce_memory
enumerator acce_like
enumerator sizeWorkV

Public Functions

inline virtual ~DynamicalSystem()

destructor

virtual void initRhs(double time) = 0

allocate (if needed) and compute rhs and its jacobian.

Parameters:

time – of initialization

virtual void initializeNonSmoothInput(unsigned int level) = 0

set nonsmooth input to zero

Parameters:

level – input-level to be initialized.

void update(double time)

compute all component of the dynamical system, for the current state.

Parameters:

time – current time (the one used to update ds component)

virtual void computeRhs(double time) = 0

update right-hand side for the current state

Parameters:

time – of interest

virtual void computeJacobianRhsx(double time) = 0

update \( \nabla_x rhs \) for the current state

Parameters:

time – of interest

virtual void resetAllNonSmoothParts() = 0

reset nonsmooth part of the rhs, for all ‘levels’

virtual void resetNonSmoothPart(unsigned int level) = 0

set nonsmooth part of the rhs to zero for a given level

Parameters:

level

inline size_t number() const

returns the id of the dynamical system

inline size_t setNumber(size_t new_number)

set the id of the DynamicalSystem

Returns:

the previous value of number

inline unsigned int n() const

returns the size of the vector state x

inline virtual unsigned int dimension() const

returns the dimension of the system (depends on system type, e.g.

n for first order, ndof for Lagrangian).

inline SP::SiconosVector x0() const

returns a pointer to the initial state vector

inline const SiconosVector getX0() const

get a copy of the initial state vector

void setX0(const SiconosVector &newValue)

set initial state (copy)

Parameters:

newValue – input vector to copy

void setX0Ptr(SP::SiconosVector newPtr)

set initial state (pointer link)

Parameters:

newPtr – vector (pointer) to set x0

inline SP::SiconosVector x() const

returns a pointer to the state vector \( x \)

Returns:

SP::SiconosVector

inline const SiconosVector &getx() const

get a copy of the current state vector \( x \)

Returns:

SiconosVector

void setX(const SiconosVector &newValue)

set content of current state vector \( x \)

Parameters:

newValueSiconosVector

void setXPtr(SP::SiconosVector newPtr)

set state vector \( x \) (pointer link)

Parameters:

newPtr – SP::SiconosVector

inline SP::SiconosVector r() const

returns a pointer to r vector (input due to nonsmooth behavior)

Returns:

SP::SiconosVector

inline const SiconosVector getR() const

get a copy of r vector (input due to nonsmooth behavior)

Returns:

a SiconosVector

void setR(const SiconosVector &newValue)

set r vector (input due to nonsmooth behavior) content (copy)

Parameters:

newValueSiconosVector

void setRPtr(SP::SiconosVector newPtr)

set r vector (input due to nonsmooth behavior) (pointer link)

Parameters:

newPtr – SP::SiconosVector newPtr

inline SP::SiconosVector rhs() const

returns a pointer to the right-hand side vector, (i.e.

\( \dot x \))

Returns:

SP::SiconosVector

inline SiconosVector &getRhs() const

get a copy of the right-hand side vector, (i.e.

\( \dot x \))

Returns:

SiconosVector

virtual void setRhs(const SiconosVector &newValue)

set the value of the right-hand side, \( \dot x \)

Parameters:

newValueSiconosVector

virtual void setRhsPtr(SP::SiconosVector newPtr)

set right-hand side, \( \dot x \) (pointer link)

Parameters:

newPtr – SP::SiconosVector

inline SP::SiconosMatrix jacobianRhsx() const

returns a pointer to \( \nabla_x rhs()\)

Returns:

SP::SiconosMatrix

void setJacobianRhsx(const SiconosMatrix &newValue)

set the value of \( \nabla_x rhs() \)

Parameters:

newValueSiconosMatrix

void setJacobianRhsxPtr(SP::SiconosMatrix newPtr)

set \( \nabla_x rhs() \), pointer link

Parameters:

newPtr – SP::SiconosMatrix

inline SP::SiconosVector z() const

returns a pointer to \( z \), the vector of algebraic parameters.

Returns:

SP::SiconosVector

inline const SiconosVector &getz() const

get a copy of \( z \), the vector of algebraic parameters.

Returns:

a SiconosVector

void setz(const SiconosVector &newValue)

set the value of \( z \) (copy)

Parameters:

newValueSiconosVector

void setzPtr(SP::SiconosVector newPtr)

set \( z \) (pointer link)

Parameters:

newPtr – SP::SiconosVector

inline SiconosMemory &xMemory()

get all the values of the state vector x stored in a SiconosMemory object (not const due to LinearSMC::actuate)

Returns:

a reference to the SiconosMemory object

inline const SiconosMemory &xMemory() const

get all the values of the state vector x stored in a SiconosMemory object

Returns:

a const reference to the SiconosMemory object

inline unsigned int stepsInMemory() const

returns the number of step saved in memory for state vector

Returns:

int

inline void setStepsInMemory(unsigned int steps)

set number of steps to be saved

Parameters:

steps

virtual void initMemory(unsigned int steps)

initialize the SiconosMemory objects: reserve memory for i vectors in memory and reset all to zero.

Parameters:

steps – the size of the SiconosMemory (i)

virtual void swapInMemory() = 0

push the current values of x and r in memory (index 0 of memory is the last inserted vector) xMemory and rMemory,

virtual void updatePlugins(double time) = 0

call all plugged functions for the current state

Parameters:

time – the current time

virtual void resetToInitialState() = 0

reset the state x() to the initial state x0

inline virtual bool isLinear()
Returns:

true if the system is linear

virtual void display(bool brief = true) const = 0

print the data of the dynamical system on the standard output

VIRTUAL_ACCEPT_VISITORS(DynamicalSystem)#

Public Static Functions

static inline size_t resetCount(size_t new_count = 0)

reset the global DynamicSystem counter (for ids)

Returns:

the previous value of count

Protected Functions

DynamicalSystem()#

default constructor

DynamicalSystem(unsigned int dimension)#

minimal constructor, from state dimension result in \( \dot x = r \)

Parameters:

dimension – size of the system (n)

DynamicalSystem(const DynamicalSystem &ds)#

Copy constructor.

Parameters:

ds – the DynamicalSystem to copy

virtual void _zeroPlugin() = 0#

Initialize all PluggedObject whether they are used or not.

void _init()#

Common code for constructors should be replaced in C++11 by delegating constructors.

Protected Attributes

size_t _number#

An id number for the DynamicalSystem.

unsigned int _n#

the dimension of the system (ie size of the state vector x)

SP::SiconosVector _x0#

initial state of the system

SP::SiconosVector _r#

the input vector due to the non-smooth law \( r \in R^{n} \) (multiplier, force, …)

Remark

V.A. 17/09/2011 : This should be a VectorOfVectors as for _x when higher relative degree systems will be simulated

VectorOfVectors _x#

state of the system, \( x \in R^{n} \) - With _x[0]= \( x \) , _x[1]= \( \dot{x} \) .

SP::SiconosMatrix _jacxRhs#

jacobian according to x of the right-hand side ( \( rhs = \dot x = f(x,t) + r \))

SP::SiconosVector _z#

Arbitrary algebraic values vector, z, discrete state of the system.

SiconosMemory _xMemory#

the previous state vectors stored in memory

unsigned int _stepsInMemory#

number of previous states stored in memory

Private Functions

ACCEPT_SERIALIZATION(DynamicalSystem)#

Private Static Attributes

static size_t __count#

used to set ds number