File kernel/src/modelingTools/SecondOrderDS.hpp

Go to the source code of this file

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

Second Order non linear dynamical systems - \(M(q,z) \dot v = F(v, q, t, z) + p \).

This class defines and computes a generic ndof-dimensional second order Non Linear Dynamical System of the form :

\[\begin{split}M(q,z) \dot v = F(v, q, t, z) + p \\ \dot q = G(q,v)\end{split}\]

where

  • \(q \in R^{ndof} \) is the set of the coordinates,

  • \( \dot q =v \in R^{ndof} \) the velocity,

  • \( \ddot q =\dot v \in R^{ndof} \) the acceleration, i. e. the second time derivative of the generalized coordinates.

  • \( p \in R^{ndof} \) the reaction forces due to the Non Smooth Interaction.

  • \( M(q) \in R^{ndof \times ndof} \) is the inertia term (access : mass() method).

  • \( F(\dot q , q , t) \in R^{ndof} \) are the forces (access forces() method).

  • \( z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discrete state.

q[i] is the derivative number i of q. Thus: q[0]= \( q \), global coordinates, q[1]= \( \dot q\), velocity, q[2]= \( \ddot q \), acceleration.

The following operators (and their jacobians) can be plugged, in the usual way (see User Guide, ‘User-defined plugins’)

  • \(M(q)\) (computeMass())

  • \(F(v , q , t, z)\) (computeF()) 3 If required (e.g. for Event-Driven like simulation), formulation as a first-order system is also available, and writes:

  • \( n= 2 ndof \)

  • \( x = \left[\begin{array}{c}q \\ \dot q\end{array}\right]\)

  • rhs given by:

\[\begin{split}\dot x = \left[\begin{array}{c} \dot q\\ \ddot q = M^{-1}(q)\left[F(v, q , t, z) + p \right]\\ \end{array}\right]\end{split}\]

  • jacobian of the rhs, with respect to x

\[\begin{split}\nabla_{x}rhs(x,t) = \left[\begin{array}{cc} 0 & I \\ \nabla_{q}(M^{-1}(q)F(v, q , t, z)) & \nabla_{\dot q}(M^{-1}(q)F(v, q , t, z)) \\ \end{array}\right]\end{split}\]

with the input due to the non smooth law:

\[\begin{split}\left[\begin{array}{c} 0 \\ p \end{array}\right]\end{split}\]

In that case, use the following methods:

Subclassed by LagrangianDS

Right-hand side computation

virtual void resetToInitialState() = 0

reset the state to the initial state

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.

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 non-smooth part of the rhs (i.e.

p), for all ‘levels’

virtual void resetNonSmoothPart(unsigned int level) = 0

set nonsmooth part of the rhs (i.e.

p) to zero for a given level

Parameters
  • level:

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

virtual void computeForces(double time, SP::SiconosVector q, SP::SiconosVector velocity) = 0

function to compute \(F(v,q,t,z)\) for the current state

Parameters
  • time: the current timeCompute \(F(v,q,t,z)\)

  • time: the current time

  • q: SP::SiconosVector: pointers on q

  • velocity: SP::SiconosVector: pointers on velocity

virtual void computeJacobianqForces(double time) = 0

Compute \(\nabla_qF(v,q,t,z)\) for current \(q,v\) Default function to compute forces.

Parameters
  • time: the current time

virtual void computeJacobianvForces(double time) = 0

Compute \(\nabla_{\dot q}F(v,q,t,z)\) for current \(q,v\).

Parameters
  • time: the current time

Attributes access

unsigned int dimension() const

return the number of degrees of freedom of the system

Return

an unsigned int.

virtual SP::SiconosVector q() const = 0

generalized coordinates of the system (vector of size dimension())

Return

pointer on a SiconosVector

virtual void setQ(const SiconosVector &newValue) = 0

set value of generalized coordinates vector (copy)

Parameters
  • newValue:

virtual void setQPtr(SP::SiconosVector newPtr) = 0

set value of generalized coordinates vector (pointer link)

Parameters
  • newPtr:

SP::SiconosVector q0() const

get initial state (pointer link)

Return

pointer on a SiconosVector

virtual void setQ0(const SiconosVector &newValue) = 0

set initial state (copy)

Parameters
  • newValue:

virtual void setQ0Ptr(SP::SiconosVector newPtr) = 0

set initial state (pointer link)

Parameters
  • newPtr:

virtual SP::SiconosVector velocity() const = 0

get velocity vector (pointer link)

Return

pointer on a SiconosVector

virtual void setVelocity(const SiconosVector &newValue) = 0

set velocity vector (copy)

Parameters
  • newValue:

virtual void setVelocityPtr(SP::SiconosVector newPtr) = 0

set velocity vector (pointer link)

Parameters
  • newPtr:

virtual SP::SiconosVector velocity0() const = 0

get initial velocity (pointer)

Return

pointer on a SiconosVector

virtual void setVelocity0(const SiconosVector &newValue) = 0

set initial velocity (copy)

Parameters
  • newValue:

virtual void setVelocity0Ptr(SP::SiconosVector newPtr) = 0

set initial velocity (pointer link)

Parameters
  • newPtr:

virtual SP::SiconosVector acceleration() const = 0

get acceleration (pointer link)

Return

pointer on a SiconosVector

virtual SP::SiconosVector forces() const = 0

get \( F(v,q,t,z)\) (pointer link)

Return

pointer on a SiconosVector

virtual SP::SiconosMatrix jacobianqForces() const = 0

get \( \nabla_qF(v,q,t,z)\) (pointer link)

Return

pointer on a SiconosMatrix

virtual SP::SiconosMatrix jacobianvForces() const = 0

get \( \nabla_{\dot q}F(v,q,t,z)\) (pointer link)

Return

pointer on a SiconosMatrix

Memory vectors management

virtual const SiconosMemory &qMemory() = 0

get all the values of the state vector q stored in memory.

note: not const due to SchatzmanPaoliOSI::initializeWorkVectorsForDS

Return

a memory

virtual const SiconosMemory &velocityMemory() = 0

get all the values of the state vector velocity stored in memory.

note: not const due to SchatzmanPaoliOSI::initializeWorkVectorsForDS

Return

a memory

virtual const SiconosMemory &forcesMemory() = 0

get forces in memory buff

Return

pointer on a SiconosMemory

virtual void initMemory(unsigned int size) = 0

initialize the SiconosMemory objects with a positive size.

Parameters
  • size: the size of the SiconosMemory. must be >= 0

virtual void swapInMemory() = 0

push the current values of x, q and r in the stored previous values xMemory, qMemory, rMemory,

Public Functions

virtual ~SecondOrderDS()

destructor

ACCEPT_STD_VISITORS()
SP::BoundaryCondition boundaryConditions()

get Boundary Conditions

Return

SP::BoundaryCondition pointer on a BoundaryConditions

virtual void computeMass() = 0

default function to compute the mass

virtual void computeMass(SP::SiconosVector position) = 0

function to compute the mass

Parameters
  • position: value used to evaluate the mass matrix

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

print the data of the dynamical system on the standard output

virtual void init_forces() = 0

Allocate memory for forces and its jacobian.

virtual void init_inverse_mass() = 0

Allocate memory for the lu factorization of the mass of the system.

Useful for some integrators with system inversion involving the mass

SP::SimpleMatrix inverseMass() const

get (pointer) inverse or LU-factorization of the mass, used for LU-forward-backward computation

Return

pointer SP::SimpleMatrix

SP::SiconosMatrix mass() const

get mass matrix (pointer link)

Return

SP::SiconosMatrix

SP::SiconosVector p(unsigned int level = 2) const

get p

Return

pointer on a SiconosVector

Parameters
  • level: unsigned int, required level for p, default = 2

SP::SiconosVector reactionToBoundaryConditions()

get Reaction to Boundary Conditions

Return

pointer on a BoundaryConditions

virtual void setBoundaryConditions(SP::BoundaryCondition newbd)

set Boundary Conditions

Parameters
  • newbd: BoundaryConditions

void setMassPtr(SP::SimpleMatrix newPtr)

set mass to pointer newPtr

Parameters
  • newPtr: a plugged matrix SP

void setReactionToBoundaryConditions(SP::SiconosVector newrbd)

set Reaction to Boundary Conditions

Parameters
  • newrbd: BoundaryConditions pointer

virtual void update_inverse_mass() = 0

Update the content of the lu factorization of the mass of the system, if required.

virtual void updatePlugins(double time) = 0

default function to update the plugins functions using a new time:

Parameters
  • time: the current time

Protected Functions

SecondOrderDS()

Default constructor.

SecondOrderDS(unsigned int dimension, unsigned int ndof)

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

Parameters
  • dimension: size of the system (n)

ACCEPT_SERIALIZATION(SecondOrderDS)

Protected Attributes

SP::BoundaryCondition _boundaryConditions

Boundary condition applied to a dynamical system.

bool _hasConstantMass

true if the mass matrix is constant

SP::SimpleMatrix _inverseMass

inverse or factorization of the mass of the system

SP::SiconosMatrix _mass

mass of the system

unsigned int _ndof

number of degrees of freedom of the system

std::vector<SP::SiconosVector> _p

“Reaction”, generalized forces or imuplses due to the non smooth law The index corresponds to the kinematic level of the corresponding constraints.

It mainly depends on what the simulation part want to store, but some rules have to be followed. For instance :

  • for the constraints at the acceleration level, _p[2] stores the reaction forces,

  • for the constraints at the veocity level, _p[1] stores the (discrete) reaction impulse

  • for the constraints at the position level, _p[0] stores the multiplier for a constraint in position

VectorOfMemories _pMemory

memory of previous generalized forces due to constraints

SP::SiconosVector _q0

Initial position.

SP::SiconosVector _reactionToBoundaryConditions

Reaction to an applied boundary condition.