Class FirstOrderNonLinearDS¶
Defined in Program listing for file kernel/src/modelingTools/FirstOrderNonLinearDS.hpp
-
class FirstOrderNonLinearDS : public DynamicalSystem¶
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 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
-
inline SP::SiconosMatrix invM() const¶
get the inverse of LU fact.
of M operator (pointer link)
- Returns
pointer to a SiconosMatrix
-
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
-
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
-
virtual void display(bool brief = true) const override¶
print the data of the dynamical system on the standard output