Class FirstOrderNonLinearDS

Defined in Program listing for file kernel/src/modelingTools/FirstOrderNonLinearDS.hpp

class FirstOrderNonLinearDS : public DynamicalSystem

General First Order Non Linear Dynamical Systems - \( M(t) \dot{x} = f(x,t,z) + r, \quad x(t_0) = x_0 \).

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

Right-hand side computation

void initRhs(double time)

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

Parameters
  • time: of initialization

void initializeNonSmoothInput(unsigned int level)

set nonsmooth input to zero

Parameters
  • level: input-level to be initialized.

void computeRhs(double time)

update right-hand side for the current state

Parameters
  • time: of interest

void computeJacobianRhsx(double time)

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

Parameters
  • time: of interest

virtual void resetAllNonSmoothParts()

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

r), for all ‘levels’

virtual void resetNonSmoothPart(unsigned int level)

set nonsmooth part of the rhs (i.e.

r) to zero for a given level

Parameters
  • level:

Attributes access

SP::SiconosMatrix M() const

returns a pointer to M, matrix coeff.

on left-hand side

void setMPtr(SP::SiconosMatrix newM)

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

Parameters
  • newM: the new M matrix

const SimpleMatrix getInvM() const

get a copy of the LU factorisation of M operator

Return
SimpleMatrix

SP::SiconosMatrix invM() const

get the inverse of LU fact.

of M operator (pointer link)

Return
pointer to a SiconosMatrix

SP::SiconosVector f() const

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

void setFPtr(SP::SiconosVector newPtr)

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

Parameters
  • newPtr: a SP::SiconosVector

virtual SP::SiconosMatrix jacobianfx() const

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

Return
SP::SiconosMatrix

void setJacobianfxPtr(SP::SiconosMatrix newPtr)

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

Parameters
  • newPtr: the new value

Memory vectors management

const SiconosMemory &rMemory() const

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

Return
a memory vector

SP::SiconosVector fold() const

returns previous value of rhs >OSI Related!!

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)

void swapInMemory()

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)

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
Exceptions

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
Exceptions

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
Exceptions

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

SP::PluggedObject getPluginF() const

Get _pluginf.

Return
a SP::PluggedObject

SP::PluggedObject getPluginJacxf() const

Get _pluginJacxf.

Return
a SP::PluggedObject

SP::PluggedObject getPluginM() const

Get _pluginM.

Return
a SP::PluggedObject

Miscellaneous public methods

void display() const

print the data of the dynamical system on the standard output

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

virtual ~FirstOrderNonLinearDS()

destructor