siconos.kernel.OneStepNSProblem (Python class)

class siconos.kernel.OneStepNSProblem(*args)[source]

Bases: object

Non Smooth Problem Formalization and Simulation.

This is an abstract class, that provides an interface to define a non smooth problem:

  • a formulation (ie the way the problem is written)
  • a solver (algorithm and solving formulation, that can be different from problem formulation)
  • routines to compute the problem solution.

Two types of problem formulation are available :

  • Quadratic Problem
  • Linear Problem

See derived classes (QP and LinearOSNS) for details.

For Linear problems, the following formulations exists:

  • Linear Complementarity (LCP)
  • Mixed Linear Complementarity (MLCP)
  • Affine Variational Inequalities (AVI)
  • FrictionContact
  • Relay
  • Equality
  • GenericMechanical
  • OSNSMultipleImpact
  • GlobalFrictionContact (unstable)

The usual way to build and initialize a one-step nonsmooth problem is :

  • call constructor with the id of the required Numerics solver. (see Solver class or Numerics documentation for details on algorithm name and parameters).
  • initialize(simulation) Initialize process is usually done through model->initialize(simulation). See Examples for practical details.

Options for Numerics and the driver for solvers When the Numerics driver is called a set of solver options (name, tolerance, max. number of iterations …) is required –> SolverOptions.

Default values are always set in solver options the OneStepNSProblem is built but if you need to set them yourself, please check Users’guide, Numerics solvers part.

Generated class (swig), based on C++ header Program listing for file kernel/src/simulationTools/OneStepNSProblem.hpp.

Constructors

OneStepNSProblem(int numericsSolverId)

constructor with a solver from Numerics

Parameters:numericsSolverId – id of numerics solver, see Numerics for the meaning
compute(time: double) → int[source]

compute(double time)=0 -> int

To run the solver for ns problem.

Parameters:time – current time
Returns:int information about the solver convergence.
computeDiagonalInteractionBlock(vd: InteractionsGraph::VDescriptor const &) → void[source]

computeDiagonalInteractionBlock( InteractionsGraph::VDescriptor vd)=0 -> None

compute diagonal Interaction block

Parameters:vd – a vertex descriptor
computeInteractionBlock(ed: InteractionsGraph::EDescriptor const &) → void[source]

computeInteractionBlock( InteractionsGraph::EDescriptor ed)=0 -> None

compute extra-diagonal interactionBlock-matrix

Parameters:ed – an edge descriptor
display() → None[source]
displayBlocks(InteractionsGraph indexSet) → None[source]

Display the set of blocks for a given indexSet.

Parameters:indexSet – the concerned index set
getOSIMatrix(OneStepIntegrator osi, DynamicalSystem ds) -> array_like (np.float64, 2D)[source]

get the OSI-related matrices used to compute the current InteractionBlock (Ex: for MoreauJeanOSI, W)

Parameters:
  • osi – the OSI of the concerned dynamical system
  • ds – the concerned dynamical system
Returns:

the required matrix.

getSizeOutput() → int[source]

returns the dimension of the nonsmooth problem

hasBeenUpdated() → bool[source]
Returns:bool _hasBeenUpdated
hasInteractions() → bool[source]

Check if the OSNSPb has interactions.

Returns:
  • bool = true if the osnsp has interactions, i.e. indexSet(_indexSetLevel)->size
  • >0
indexSetLevel() → int[source]

get indexSetLevel

Returns:an unsigned int
initialize(Simulation sim) → None[source]

initialize the problem(compute topology …)

Parameters:sim – the simulation, owner of this OSNSPB
inputOutputLevel() → int[source]

get the Input/Output level

Returns:an unsigned int
maxSize() → int[source]

get maximum value allowed for the dimension of the problem

Returns:an unsigned int
numericsSolverOptions() → SolverOptions[source]

To get the SolverOptions structure.

Returns:, the numerics structure used to save solver parameters
postCompute() → void[source]

postCompute()=0 -> None

post treatment for output of the solver

preCompute(time: double) → bool[source]

preCompute(double time)=0 -> bool

prepare data of the osns for solving

Parameters:time – the current time
Returns:true if the computation of the OSNS has to be carry on, false otherwise
setHasBeenUpdated(bool v) → None[source]
Parameters:v – to set _hasBeenUpdated.
setIndexSetLevel(int newVal) → None[source]

set the value of level min

Parameters:newVal – an unsigned int
setInputOutputLevel(int newVal) → None[source]

set the value of Input/Output level

Parameters:newVal – an unsigned int
setMaxSize(int newVal) → None[source]

set the value of maxSize

Parameters:newVal – an unsigned int
setNumericsVerboseMode(bool vMode) → None[source]

Turn on/off verbose mode in numerics solver.

setSimulationPtr(Simulation newS) → None[source]

set the Simulation of the OneStepNSProblem

Parameters:newS – a pointer to Simulation
setSolverId(int solverId) → None[source]

change the solver type.

This requires a reset of the Solveroption struct

Parameters:solverId – the new solver
simulation() → Simulation[source]

get the simulation which owns this nonsmooth problem

Returns:a pointer on Simulation
updateInteractionBlocks() → None[source]

compute interactionBlocks if necessary (this depends on the type of OSNS, on the indexSets …)