File kernel/src/modelingTools/FirstOrderNonLinearDS.hpp

Contents

File kernel/src/modelingTools/FirstOrderNonLinearDS.hpp#

Go to the source code of this file

First Order Non Linear Dynamical Systems.

class FirstOrderNonLinearDS : public DynamicalSystem
#include <FirstOrderNonLinearDS.hpp>

General First Order Non Linear Dynamical Systems.

This class defines and computes a generic n-dimensional dynamical system of the form :

\[ M \dot x = f(x,t,z) + r, \quad x(t_0) = x_0 \]
where

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

  • \( M \in R^{n\times n} \) a “mass matrix”

  • \( r \in R^{n} \) the input due to the Non Smooth Interaction.

  • \( 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.

  • \( f : R^{n} \times R \mapsto R^{n} \) the vector field.

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 \]

To define a Boundary Value Problem, a pointer on a BoundaryCondition must be set.

The right-hand side and its jacobian (from base class) are defined as

\[\begin{split} rhs &=& \dot x = M^{-1}(f(x,t,z)+ r) \\ jacobianRhsx &=& \nabla_x rhs(x,t,z) = M^{-1}\nabla_x f(x,t,z) \end{split}\]

The following operators can be plugged, in the usual way (see User Guide)

  • \( f(x,t,z) \)

  • \( \nabla_x f(x,t,z) \)

  • \( M(t) \)

Subclassed by FirstOrderLinearDS

Public Functions

FirstOrderNonLinearDS(SP::SiconosVector newX0)

constructor from initial state, leads to \( \dot x = r \)

Warning

you need to set explicitely the plugin for f and its jacobian if needed (e.g. if used with an EventDriven scheme)

Parameters:

newX0 – initial state

FirstOrderNonLinearDS(SP::SiconosVector newX0, const std::string &fPlugin, const std::string &jacobianfxPlugin)

constructor from initial state and f (plugins), \( \dot x = f(x, t, z) + r \)

Parameters:
  • newX0 – initial state

  • fPlugin – name of the plugin function to be used for f(x,t,z)

  • jacobianfxPlugin – name of the plugin to be used for the jacobian of f(x,t,z)

FirstOrderNonLinearDS(const FirstOrderNonLinearDS &FONLDS)

Copy constructor.

Parameters:

FONLDS – the FirstOrderNonLinearDS to copy

inline virtual ~FirstOrderNonLinearDS()

destructor

virtual void initRhs(double time) override

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

Parameters:

time – of initialization

virtual void initializeNonSmoothInput(unsigned int level) override

set nonsmooth input to zero

Parameters:

level – input-level to be initialized.

virtual void resetToInitialState() override

reset the state to the initial state

virtual void computeRhs(double time) override

update right-hand side for the current state

Parameters:

time – of interest

virtual void computeJacobianRhsx(double time) override

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

Parameters:

time – of interest

virtual void resetAllNonSmoothParts() override

reset non-smooth part of the rhs (i.e.

r), for all ‘levels’

virtual void resetNonSmoothPart(unsigned int level) override

set nonsmooth part of the rhs (i.e.

r) to zero for a given level

Parameters:

level

inline SP::SiconosMatrix M() const

returns a pointer to M, matrix coeff.

on left-hand side

inline void setMPtr(SP::SiconosMatrix newM)

set M, matrix coeff of left-hand side (pointer link)

Parameters:

newM – the new M matrix

inline const SimpleMatrix getInvM() const

get a copy of the LU factorisation of M operator

Returns:

SimpleMatrix

inline SP::SiconosMatrix invM() const

get the inverse of LU fact.

of M operator (pointer link)

Returns:

pointer to a SiconosMatrix

inline SP::SiconosVector f() const

returns f(x,t,z) (pointer link)

inline void setFPtr(SP::SiconosVector newPtr)

set f(x,t,z) (pointer link)

Parameters:

newPtr – a SP::SiconosVector

inline virtual SP::SiconosMatrix jacobianfx() const

get jacobian of f(x,t,z) with respect to x (pointer link)

Returns:

SP::SiconosMatrix

inline void setJacobianfxPtr(SP::SiconosMatrix newPtr)

set jacobian of f(x,t,z) with respect to x (pointer link)

Parameters:

newPtr – the new value

inline const SiconosMemory &rMemory() const

get all the values of the state vector r stored in memory

Returns:

a memory vector

inline SP::SiconosVector fold() const

returns previous value of rhs –>OSI Related!!

virtual void initMemory(unsigned int steps) override

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() override

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) override

Call all plugged-function to initialize plugged-object values.

Parameters:

time – value

void setComputeMFunction(const std::string &pluginPath, const std::string &functionName)

to set a specified function to compute M

Parameters:
  • pluginPath – the complete path to the plugin

  • functionName – function name to use in this library

void setComputeMFunction(FPtr1 fct)

set a specified function to compute M

Parameters:

fct – a pointer on the plugin function

void setComputeFFunction(const std::string &pluginPath, const std::string &functionName)

to set a specified function to compute f(x,t)

Parameters:
  • pluginPath – the complete path to the plugin

  • functionName – the function name to use in this library

void setComputeFFunction(FPtr1 fct)

set a specified function to compute the vector f

Parameters:

fct – a pointer on the plugin function

void setComputeJacobianfxFunction(const std::string &pluginPath, const std::string &functionName)

to set a specified function to compute jacobianfx

Parameters:
  • pluginPath – the complete path to the plugin

  • functionName – function name to use in this library

void setComputeJacobianfxFunction(FPtr1 fct)

set a specified function to compute jacobianfx

Parameters:

fct – a pointer on the plugin function

void computeM(double time)

Default function to compute \( M: (x,t) \).

Parameters:

time – time instant used in the computations

virtual void computef(double time, SP::SiconosVector state)

Default function to compute \( f: (x,t) \).

Parameters:
  • time – time instant used in the computations function to compute \( f: (x,t) \)

  • time – time instant used in the computations

  • state – x value

virtual void computeJacobianfx(double time, SP::SiconosVector state)

Default function to compute \( \nabla_x f: (x,t) \in R^{n} \times R \mapsto R^{n \times n} \) with x different from current saved state.

Parameters:
  • time – instant used in the computations

  • state – a SiconosVector to store the resuting value

inline SP::PluggedObject getPluginF() const

Get _pluginf.

Returns:

a SP::PluggedObject

inline SP::PluggedObject getPluginJacxf() const

Get _pluginJacxf.

Returns:

a SP::PluggedObject

inline SP::PluggedObject getPluginM() const

Get _pluginM.

Returns:

a SP::PluggedObject

virtual void display(bool brief = true) const override

print the data of the dynamical system on the standard output

ACCEPT_STD_VISITORS()#

Protected Functions

ACCEPT_SERIALIZATION(FirstOrderNonLinearDS)#
void _init(SP::SiconosVector initial_state)#

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

Parameters:

initial_state – vector of initial values for state

inline FirstOrderNonLinearDS()#

default constructor

virtual void _zeroPlugin() override#

Reset the PluggedObjects.

Protected Attributes

SP::SiconosMatrix _M#

Matrix coefficient of \( \dot x \).

SP::SiconosVector _f#

value of f(x,t,z)

SP::SiconosVector _fold#

to store f(x_k,t_k,z_k)

SP::SiconosMatrix _jacobianfx#

Gradient of \( f(x,t,z) \) with respect to \( x \).

SP::PluggedObject _pluginf#

DynamicalSystem plug-in to compute f(x,t,z)

Param current:

time

Param size:

of the vector _x

Param pointer:

[inout] to the first element of the vector _x

Param the:

[inout] pointer to the first element of the vector _f

Param the:

size of the vector _z

Param a:

vector of parameters _z

SP::PluggedObject _pluginJacxf#

DynamicalSystem plug-in to compute the gradient of f(x,t,z) with respect to the state: \( \nabla_x f: (x,t,z) \in R^{n} \times R \mapsto R^{n \times n} \).

Param time:

current time

Param sizeOfX:

size of vector x

Param x:

pointer to the first element of x

Param jacob:

[inout] pointer to the first element of jacobianfx matrix

Param the:

size of the vector z

Param a:

[inout] vector of parameters, z

SP::PluggedObject _pluginM#
SiconosMemory _rMemory#

the previous r vectors

SP::SiconosMatrix _invM#

Copy of M Matrix, LU-factorized, used to solve systems like Mx = b with LU-factorization.

(Warning: may not exist, used if we need to avoid factorization in place of M)

Private Types

typedef void (*FNLDSPtrfct)(double, unsigned int, const double*, double*, unsigned int, double*)#

plugin signature