siconos.kernel.Interaction (Python class)

class siconos.kernel.Interaction(NSL: SP::NonSmoothLaw, rel: SP::Relation)[source]

Bases: object

Non-smooth interaction involving 1 or 2 Dynamical Systems.

An interaction represents the “link” between a set of Dynamical Systems. The state variables and inputs of the DynamicalSystem (x,R) are related to the interaction variables (y,lambda) thanks to the interaction with the help of the relation The interaction completed by a non-smooth law that describes the type of law between y and lambda.

Thus, the interaction main members are:

  • relation: a pointer to a Relation object that determines the type of relation and so the way it is computed. Warning: there is only one Relation object (ie only one type of relation for an interaction) but there can be several “relations”, in the sense of constraints equations between (y,lambda) and (x,r).

  • nslaw: the nonsmooth law

  • the local variable y (its size is interactionSize). STL vectors are used and y[i] usually represents the i-eme derivative of variable y.

  • the local variable lambda (its size is interactionSize). STL vectors are used and lambda[i] represents various level of multiplier involved in the nonsmooth law with y[i]

    y (resp, lambda) is a container of SiconosVector.

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

Constructors

Interaction(NonSmoothLaw NSL, Relation rel)

constructor with NonSmoothLaw and Relation (i.e.

inter size == nslaw size)

Parameters:
  • NSL – pointer to the NonSmoothLaw, the interaction size is infered from the size of the NonSmoothLaw
  • rel – a pointer to the Relation
computeInput(double time, int level=0) → None[source]

Compute input r of all Dynamical Systems involved in the present Interaction.

Parameters:
  • time – current time
  • level – order of _lambda used to compute input.
computeOutput(double time, int derivativeNumber=0) → None[source]

Computes output y; depends on the relation type.

Parameters:
  • time – current time
  • derivativeNumber – number of the derivative to compute, optional, default = 0.
dimension() → int[source]

returns dimension (i.e.

nslaw size == y and lambda size)

display(bool brief=True) → None[source]

print the data to the screen

getCopyOfy(int i) -> array_like (np.float64, 1D)[source]

Get y[i], derivative number i of output.

Parameters:i – : the derivative number.
Returns:BlockVector
getCopyOfyOld(int i) -> array_like (np.float64, 1D)[source]

get y[i], derivative number i of output

Parameters:i – derivative number i of output
Returns:BlockVector
getExtraInteractionBlock(array_like (np.float64, 2D) InteractionBlock) → None[source]

gets extra interactionBlock corresponding to the present Interaction (see the top of this files for extra interactionBlock meaning)

Parameters:InteractionBlock – SP::SiconosMatrix
getLambda(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

getLambda() → VectorOfVectors[source]

get vector of input derivatives

Returns:a VectorOfVectors
getLambda(int i) -> array_like (np.float64, 1D)[source]

get _lambda[i], derivative number i of input

Parameters:i – derivative number i of output
Returns:SiconosVector
getLambdaOld(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

getLambdaOld() → VectorOfVectors[source]

get vector of input derivatives

Returns:a VectorOfVectors
getLambdaOld(int i) -> array_like (np.float64, 1D)[source]

get _lambdaOld[i], derivative number i of input

Parameters:i – derivative number i of output
Returns:SiconosVector
getLeftInteractionBlockForDS(int pos, array_like (np.float64, 2D) InteractionBlock) → None[source]

gets the matrix used in interactionBlock computation, (left * W * right), depends on the relation type (ex, LinearTIR, left = C, right = B).

We get only the part corresponding to one ds.

Parameters:
  • pos – int, relative position of the beginning of the required block in relation matrix.
  • InteractionBlock – a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
getLeftInteractionBlockForDSProjectOnConstraints(int pos, array_like (np.float64, 2D) InteractionBlock) → None[source]

gets the matrix used in interactionBlock computation.

Used only for the formulation projecting on the constraints. We get only the part corresponding to ds.

Parameters:
  • pos – int, relative position of the beginning of the required block in relation matrix.
  • InteractionBlock – a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
getRightInteractionBlockForDS(int pos, array_like (np.float64, 2D) InteractionBlock) → None[source]

gets the matrix used in interactionBlock computation, (left * W * rigth), depends on the relation type (ex, LinearTIR, left = C, right = B).

We get only the part corresponding to ds.

Parameters:
  • pos – int, relative position of the beginning of the required block in relation matrix.
  • InteractionBlock – a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
getSizeOfDS() → int[source]

Get the sum of DS sizes, for DS involved in interaction.

Returns:an unsigned int
getYOld(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

getYOld() → VectorOfVectors[source]

get vector of output derivatives

Returns:a VectorOfVectors
getYOld(int i) -> array_like (np.float64, 1D)[source]

get yOld[i], derivative number i of output

Parameters:i – derivative number i of output
Returns:BlockVector
has2Bodies() → bool[source]

Check the number of dynamical systems concerned by this interaction.

Returns:bool (true if two ds, else false)
initializeLinkToDsVariables(DynamicalSystem ds1, DynamicalSystem ds2) → None[source]

set the links between the interaction and the DynamicalSystem(s) members.

Parameters:
  • ds1 – first ds linked to this Interaction (i.e IG->vertex.source)
  • ds2 – second ds linked to this Interaction (i.e IG->vertex.target) ds1 == ds2 is allowed.
initializeMemory(int steps) → None[source]

build memories vectors for y and \(\lambda\)

Parameters:
  • computeResiduY – true if interaction should compute extra residu value
  • steps – number of required memories (depends on the OSI)
lambdaMemory(int level) → SiconosMemory[source]

get all the values of the multiplier lambda stored in memory

Parameters:level
Returns:a memory
lambdaOld(int i) -> array_like (np.float64, 1D)[source]

get _lambdaOld[i], derivative number i of input

Parameters:i – derivative number i of output
Returns:pointer on a SiconosVector
lambda_(i: unsigned int const) → SP::SiconosVector[source]

lambda( int i) -> array_like (np.float64, 1D)

get _lambda[i], derivative number i of input

Parameters:i – derivative number i of output
Returns:pointer on a SiconosVector
linkToDSVariables() → VectorOfBlockVectors[source]
lowerLevelForInput() → int[source]

Get the lower level for input Lambda.

Returns:an unsigned int.
lowerLevelForOutput() → int[source]

Get the lower level for output y.

Returns:an unsigned int.
nonSmoothLaw() → NonSmoothLaw[source]

get the NonSmoothLaw of this Interaction

Returns:a pointer on this NonSmoothLaw
number() → int[source]

get the value of number

Returns:the value of number
relation() → Relation[source]

get the Relation of this Interaction

Returns:a pointer on this Relation
relationMatrices() → VectorOfSMatrices[source]
relationVectors() → VectorOfVectors[source]
reset() → None[source]

Update interactions attributes.

Must be called when levels have been modified.

resetAllLambda() → None[source]

set all lambda to zero

static resetCount(int new_count=0) → int[source]

reset the global Interaction counter (for ids)

Returns:the previous value of count
resetLambda(int level) → None[source]

set lambda to zero for a given level

Parameters:level
setDSSizes(int s1) → None[source]

set interaction ‘ds-dimension’, i.e.

sum of all sizes of the dynamical systems linked by the current interaction. This must be done by topology during call to link(inter, ds, …).

Parameters:s1 – int sum of ds sizes
setHas2Bodies(bool val) → None[source]

Set the number of dynamical systems concerned by this interaction.

Warning FP: this function is supposed to be called only during topology->link(inter, ds1, ds2) call.

Parameters:val – : true if two ds, else false
setLambda(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

setLambda(VectorOfVectors v) → None[source]

set the input vector _lambda to newVector

Parameters:v – VectorOfVectors
setLambda(int i, array_like (np.float64, 1D) newValue) → None[source]

set _lambda[i] to newValue

Parameters:
  • i – derivative number i of output
  • newValue – a SiconosVector
setLambdaOld(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

setLambdaOld(VectorOfVectors v) → None[source]

set the input vector _lambdaOld to newVector

Parameters:v – VectorOfVectors
setLambdaOld(int i, array_like (np.float64, 1D) v) → None[source]

set _lambdaOld[i] to newValue

Parameters:
  • i – derivative number i of output
  • v – a SiconosVector
setLambdaOldPtr(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

setLambdaOldPtr(VectorOfVectors v) → None[source]

set vector _lambdaOld to newVector with direct pointer equality for the _lambdaOld

Parameters:v – VectorOfVectors
setLambdaOldPtr(int i, array_like (np.float64, 1D) newPtr) → None[source]

set _lambdaOld[i] to pointer newPtr

Parameters:
  • i – derivative number i of output
  • newPtr – a SP::SiconosVector
setLambdaPtr(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

setLambdaPtr(VectorOfVectors v) → None[source]

set vector _lambda to newVector with direct pointer equality for the _lambda[i]

Parameters:v – VectorOfVectors
setLambdaPtr(int i, array_like (np.float64, 1D) newPtr) → None[source]

set _lambda[i] to pointer newPtr

Parameters:
  • i – derivative number i of output
  • newPtr – a SP::SiconosVector
setLowerLevelForInput(int newVal) → None[source]

Set the lower level for input Lambda.

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

Set the lower level for output y.

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

Set the upper level for input Lambda.

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

Set the upper level for output y.

Parameters:newVal – : an unsigned int
setY(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

setY(VectorOfVectors v) → None[source]

set the output vector y to newVector with copy of the y[i] (ie memory allocation)

Parameters:v – VectorOfVectors
setY(int i, array_like (np.float64, 1D) v) → None[source]

set y[i] to newValue

Parameters:
  • i – derivative number i of output
  • v – a SiconosVector and an unsigned int
setYOld(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

setYOld(VectorOfVectors v) → None[source]

set the output vector yOld to newVector

Parameters:v – VectorOfVectors
setYOld(int i, array_like (np.float64, 1D) v) → None[source]

set yOld[i] to newValue

Parameters:
  • i – derivative number i of output
  • v – a SiconosVector and an unsigned int
setYOldPtr(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

setYOldPtr(VectorOfVectors v) → None[source]

set vector yOld to newVector with direct pointer equality for the yOld[i]

Parameters:v – VectorOfVectors
setYOldPtr(int i, array_like (np.float64, 1D) v) → None[source]

set yOld[i] to pointer newPtr

Parameters:
  • i – derivative number i of output
  • v – a SP::SiconosVector and an unsigned int
setYPtr(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

setYPtr(VectorOfVectors v) → None[source]

set the output vector y to newVector with direct pointer equality for the y[i]

Parameters:v – VectorOfVectors
setYPtr(int i, array_like (np.float64, 1D) v) → None[source]

set y[i] to pointer newPtr

Parameters:
  • i – derivative number i of output
  • v – a SP::SiconosVector and an unsigned int
swapInMemory() → None[source]

Must be call to fill _y_k.

(after convergence of the Newton iterations)

swapInOldVariables() → None[source]

put values of y into yOld, the same for _lambda

upperLevelForInput() → int[source]

Get the upper level for input Lambda.

Returns:an unsigned int.
upperLevelForOutput() → int[source]

Get the upper level for output y.

Returns:an unsigned int.
y(*args)[source]

Warning - Overloaded function : multiple signatures available, check prototypes below.

y() → VectorOfVectors[source]

get vector of output derivatives

Returns:a VectorOfVectors
y(int i) -> array_like (np.float64, 1D)[source]

get y[i], derivative number i of output

Parameters:i – derivative number i of output
Returns:pointer on a SiconosVector
yMemory(int level) → SiconosMemory[source]

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

Parameters:level
Returns:a memory
yOld(int i) -> array_like (np.float64, 1D)[source]

get yOld[i], derivative number i of output

Parameters:i – derivative number i of output
Returns:pointer on a SiconosVector
y_k(int i) -> array_like (np.float64, 1D)[source]