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, LagrangianDS

Right-hand side computation

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:

Attributes access

For each ‘Member’ :

  • Member() returns a pointer to the object
  • getMember() a copy of the object
  • setMember() set the content of Member with a copy
  • setMemberPtr() set a pointer link to Member

int number() const

returns the id of the dynamical system

int setNumber(int new_number)

set the id of the DynamicalSystem

Return
the previous value of number

unsigned int n() const

returns the size of the vector state x

virtual unsigned int dimension() const

returns the dimension of the system (n for first order, ndof for Lagrangian).

Useful to avoid if(typeOfDS) when size is required.

SP::SiconosVector x0() const

returns a pointer to the initial state vector

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

SP::SiconosVector x() const

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

Return
SP::SiconosVector

const SiconosVector &getx() const

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

Return
SiconosVector

void setX(const SiconosVector &newValue)

set content of current state vector \( x \)

Parameters

void setXPtr(SP::SiconosVector newPtr)

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

Parameters
  • newPtr: SP::SiconosVector

SP::SiconosVector r() const

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

Return
SP::SiconosVector

const SiconosVector getR() const

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

Return
a SiconosVector

void setR(const SiconosVector &newValue)

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

Parameters

void setRPtr(SP::SiconosVector newPtr)

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

Parameters
  • newPtr: SP::SiconosVector newPtr

SP::SiconosVector rhs() const

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

\( \dot x \))

Return
SP::SiconosVector

SiconosVector &getRhs() const

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

\( \dot x \))

Return
SiconosVector

virtual void setRhs(const SiconosVector &newValue)

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

Parameters

virtual void setRhsPtr(SP::SiconosVector newPtr)

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

Parameters
  • newPtr: SP::SiconosVector

SP::SiconosMatrix jacobianRhsx() const

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

Return
SP::SiconosMatrix

void setJacobianRhsx(const SiconosMatrix &newValue)

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

Parameters
  • newValue: SiconosMatrix

void setJacobianRhsxPtr(SP::SiconosMatrix newPtr)

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

Parameters
  • newPtr: SP::SiconosMatrix

SP::SiconosVector z() const

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

Return
SP::SiconosVector

const SiconosVector &getz() const

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

Return
a SiconosVector

void setz(const SiconosVector &newValue)

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

Parameters

void setzPtr(SP::SiconosVector newPtr)

set \( z \) (pointer link)

Parameters
  • newPtr: SP::SiconosVector

Memory vectors management

SiconosMemory &xMemory()

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

Return
a reference to the SiconosMemory object

const SiconosMemory &xMemory() const

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

Return
a const reference to the SiconosMemory object

int stepsInMemory() const

returns the number of step saved in memory for state vector

Return
int

void setStepsInMemory(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,

Plugins management

virtual void updatePlugins(double time) = 0

call all plugged functions for the current state

Parameters
  • time: the current time

Miscellaneous public methods

virtual void resetToInitialState()

reset the state x() to the initial state x0

virtual bool isLinear()

True if the system is linear.

Return
a boolean

virtual void display() const = 0

print the data of the dynamical system on the standard output

static int resetCount(int new_count = 0)

reset the global DynamicSystem counter (for ids)

Return
the previous value of count

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:

local_buffer
freeresidu
free
acce_memory
acce_like
sizeWorkV

Public Functions

virtual ~DynamicalSystem()

destructor

VIRTUAL_ACCEPT_VISITORS(DynamicalSystem)

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

void _init()

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

virtual void _zeroPlugin() = 0

Initialize all PluggedObject whether they are used or not.

Protected Attributes

SP::SiconosMatrix _jacxRhs

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

unsigned int _n

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

unsigned int _number

An id number for the DynamicalSystem.

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

unsigned int _stepsInMemory

number of previous states stored in memory

VectorOfVectors _x

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

SP::SiconosVector _x0

initial state of the system

SiconosMemory _xMemory

the previous state vectors stored in memory

SP::SiconosVector _z

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

Private Functions

ACCEPT_SERIALIZATION(DynamicalSystem)

Private Static Attributes

unsigned int __count

used to set ds number