siconos.kernel#
Module documentation
A collection of low-level algorithms for solving basic algebra and optimization problem arising in the simulation of nonsmooth dynamical systems.
Example of usage:
>>> import siconos.kernel as sk
>>> help(sk.LagrangianDS)
- class siconos.kernel.MATRIX_UBLAS_TYPE[source]#
Bases:
object
Union of DenseMat pointer, TriangMat pointer BandedMat, SparseMat, SymMat, Zero and Identity mat pointers.
- class siconos.kernel.SiconosMatrix(*args, **kwargs)[source]#
Bases:
object
Abstract class to provide interface for matrices handling
Matrices can be either block or Simple. See Derived classes for details.
In Siconos, a “matrix” can be either a SimpleMatrix or a BlockMatrix, ie a container of several pointers to SiconosMatrix
You can find an overview on how to build and use vectors and matrices in siconos users guide .
- isPLUInversed()[source]#
determines if the matrix has been inversed in place
- Return type:
boolean
- Returns:
true if the matrix is inversed
- isSymmetric()[source]#
true if the matrix is symmetric (the flag is just returned)
- Return type:
boolean
- Returns:
true if the matrix is symmetric
- isPositiveDefinite()[source]#
true if the matrix is definite positive (the flag is just returned)
- Return type:
boolean
- Returns:
true if the matrix is
- checkSymmetry(tol)[source]#
determines if the matrix is symmetric up to a given tolerance
- Return type:
boolean
- Returns:
true if the matrix is inversed
- isPLUFactorized()[source]#
determines if the matrix has been PLU factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isPLUFactorizedInPlace()[source]#
determines if the matrix has been PLU factorized in place
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isCholeskyFactorized()[source]#
determines if the matrix has been Cholesky factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isQRFactorized()[source]#
determines if the matrix has been QR factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isFactorized()[source]#
determines if the matrix has been factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- tabRow()[source]#
reserved to BlockMatrix - get the index tab for rows
- Return type:
SP::Index
- Returns:
a pointer to a standard vector of int
- tabCol()[source]#
reserved to BlockMatrix - get the index tab of columns
- Return type:
SP::Index
- Returns:
a pointer to a standard vector of int
- getArray(row=0, col=0)[source]#
return the address of the array of double values of the matrix ( for block(i,j) if this is a block matrix)
- resize(nbrow, nbcol, lower=0, upper=0, preserve=True)[source]#
resize the matrix with nbrow rows and nbcol columns, upper and lower are only useful for BandedMatrix . The existing elements of the matrix are preseved when specified.
- toString()[source]#
put data of the matrix into a std::string
- Return type:
string
- Returns:
std::string
- block(row=0, col=0)[source]#
get block at position row-col if BlockMatrix, else if SimpleMatrix return this
- Parameters:
- Return type:
- Returns:
SP::SiconosMatrix
- getRow(index, vOut)[source]#
get row index of current matrix and save it into vOut
- Parameters:
index (int) – row we want to get
vOut (
SiconosVector
, out) – SiconosVector that will contain the desired row
- getCol(index, vOut)[source]#
get column index of current matrix and save it into vOut
- Parameters:
index (int) – column we want to get
vOut (
SiconosVector
, out) – SiconosVector that will contain the desired column
- setRow(index, vIn)[source]#
set line row of the current matrix with vector v
- Parameters:
index (int) – row we want to set
vIn (
SiconosVector
) – SiconosVector containing the new row
- setCol(index, vIn)[source]#
set column col of the current matrix with vector v
- Parameters:
index (int) – column we want to set
vIn (
SiconosVector
) – a SiconosVector containing the new column
- trans(*args)[source]#
Overload 1: transpose in place: x->trans() is x = transpose of x.
Overload 2: transpose a matrix: x->trans(m) is x = transpose of m.
- Parameters:
m (
SiconosMatrix
) – the matrix to be transposed.
- PLUFactorizationInPlace()[source]#
computes a LU factorization of a general M-by-N matrix with partial pivoting and row interchanges. The result is returned in this (InPlace). Based on Blas dgetrf function for dense matrix and ublas cholesky decomposition for sparse matrix (work only for a symmetric matrix and very slow because it uses matric accessor) use preferably PLUFactorize()
- Factorize()[source]#
computes a factorization of a general M-by-N matrix The implementation is based on an internal NumericsMatrix
- PLUInverseInPlace()[source]#
compute inverse of this thanks to LU factorization with partial pivoting. This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A). The result is returned in this (InPlace). Based on Blas dgetri function for dense function
- solve_matrix(B)[source]#
solves a system of linear equations A * X = B (A=this) for a general N-by-N matrix A using the LU factorization computed by PLUFactorize.
- Parameters:
B (
SiconosMatrix
, in/out) – on input the RHS matrix b; on output the result x
- PLUForwardBackwardInPlace(*args)[source]#
Overload 1: solves a system of linear equations A * X = B (A=this) for a general N-by-N matrix A using the LU factorization computed by PLUFactorizationInPlace. Based on Blas dgetrs function for dense matrix.
- Parameters:
B (
SiconosMatrix
, in/out) – on input the RHS matrix b; on output the result x
Overload 2: solves a system of linear equations A * X = B (A=this) for a general N-by-N matrix A using the LU factorization computed by PLUFactorizationInPlace. Based on Blas dgetrs function for dense matrix.
- Parameters:
B (
SiconosVector
, in/out) – on input the RHS matrix b; on output the result x
- solve_vector(B)[source]#
solves a system of linear equations A * X = B (A=this) for a general N-by-N matrix A using the LU factorization computed by PLUFactorize.
- Parameters:
B (
SiconosVector
, in/out) – on input the RHS matrix b; on output the result x
- resetFactorizationFlags()[source]#
- set to false all factorization indicators. Useful in case of
assignment for example.
- fillCSC(*args)[source]#
Overload 1: Fill CSparseMatrix compresses column sparse matrix
- Parameters:
- Return type:
boolean
- Returns:
true if function worked.
Warning: not clear that it works for an empty csr matrix with row_off =0 and col_off =0
Overload 2: Fill CSparseMatrix compresses column sparse matrix
- Parameters:
csc (CSparseMatrix) – the compressed column sparse matrix
tol (float, optional) – the tolerance under which a number is considered as equal to zero
- Return type:
boolean
- Returns:
true if function worked.
Overload 3: Fill CSparseMatrix compresses column sparse matrix
- Parameters:
csc (CSparseMatrix) – the compressed column sparse matrix
tol – the tolerance under which a number is considered as equal to zero
- Return type:
boolean
- Returns:
true if function worked.
- class siconos.kernel.SimpleMatrix(*args)[source]#
Bases:
SiconosMatrix
Matrix (embedded various types of Boost matrices of double)
SimpleMatrix is used in the platform to store matrices (mathematical object) of double.
Possible types: Siconos::DENSE (default), TRIANGULAR, SYMMETRIC, SPARSE, BANDED, ZERO, Siconos::IDENTITY, Siconos::SPARSE_COORDINATE.
TODO: : review resize function for Banded, Symetric and Triangular. Error in tests.
Overload 1: Default constructor
Overload 2: constructor with the type and the dimension of the Boost matrix
- Parameters:
row (int) – number of rows.
col (int) – number of columns.
typ (int, optional) – the type of matrix
upper (int, optional) – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal
lower (int, optional) – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal
Overload 3: constructor with the type and the dimension of the Boost matrix
- Parameters:
row (int) – number of rows.
col (int) – number of columns.
typ (int, optional) – the type of matrix
upper (int, optional) – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal
lower – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal
Overload 4: constructor with the type and the dimension of the Boost matrix
- Parameters:
row (int) – number of rows.
col (int) – number of columns.
typ (int, optional) – the type of matrix
upper – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal
lower – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal
Overload 5: constructor with the type and the dimension of the Boost matrix
- Parameters:
row (int) – number of rows.
col (int) – number of columns.
typ – the type of matrix
upper – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal
lower – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal
Overload 6: constructor with the the dimensions of the Boost matrix, a default value and the type.
- Parameters:
row (int) – number of rows.
col (int) – number of columns.
typ (int, optional) – the type of matrix
upper (int, optional) – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal
lower (int, optional) – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal
Overload 7: constructor with the the dimensions of the Boost matrix, a default value and the type.
- Parameters:
row (int) – number of rows.
col (int) – number of columns.
typ (int, optional) – the type of matrix
upper (int, optional) – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal
lower – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal
Overload 8: constructor with the the dimensions of the Boost matrix, a default value and the type.
- Parameters:
row (int) – number of rows.
col (int) – number of columns.
typ (int, optional) – the type of matrix
upper – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal
lower – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal
Overload 9: constructor with the the dimensions of the Boost matrix, a default value and the type.
- Parameters:
row (int) – number of rows.
col (int) – number of columns.
typ – the type of matrix
upper – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal
lower – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal
Overload 10: copy constructor
- Parameters:
smat (
SimpleMatrix
) – the matrix to copy
Overload 11: copy constructor of a block given by the coord = [r0A r1A c0A c1A]
- Parameters:
A (
SimpleMatrix
) – the matrix which contains the block to extractcoord (Index) – positions of the block to be extracted (row:start, row:end, col:start, col:end)
Overload 12: constructor with a DenseMat matrix (see SiconosMatrix.h for details)
- Parameters:
m (DenseMat) – a DenseMat
Overload 13: constructor with a TriangMat matrix (see SiconosMatrix.h for details)
- Parameters:
m (TriangMat) – a TriangMat
Overload 14: constructor with a SymMat matrix (see SiconosMatrix.h for details)
- Parameters:
m (SymMat) – a SymMat
Overload 15: constructor with a BandedMat matrix (see SiconosMatrix.h for details)
- Parameters:
m (BandedMat) – a BandedMat
Overload 16: constructor with a SparseMat matrix (see SiconosMatrix.h for details)
- Parameters:
m (SparseMat) – a SparseMat
Overload 17: constructor with a SparseCoordinateMat matrix (see SiconosMatrix.h for details)
- Parameters:
m (SparseCoordinateMat) – a SparseMat
Overload 18: constructor with a ZeroMat matrix (see SiconosMatrix.h for details)
- Parameters:
m (ZeroMat) – a ZeroMat
Overload 19: constructor with a IdentityMat matrix (see SiconosMatrix.h for details)
- Parameters:
m (IdentityMat) – a IdentityMat
Overload 20: constructor with an input file
- Parameters:
file (string) – the input file path
ascii (boolean, optional) – a boolean to indicate if the file is in ascii
Overload 21: constructor with an input file
- Parameters:
file (string) – the input file path
ascii – a boolean to indicate if the file is in ascii
- isPLUInversed()[source]#
determines if the matrix has been inversed
- Return type:
boolean
- Returns:
true if the matrix is inversed
- isPLUFactorized()[source]#
determines if the matrix has been factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isPLUFactorizedInPlace()[source]#
determines if the matrix has been factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isCholeskyFactorized()[source]#
determines if the matrix has been factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isCholeskyFactorizedInPlace()[source]#
determines if the matrix has been factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isQRFactorized()[source]#
determines if the matrix has been factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- checkSymmetry(tol)[source]#
determines if the matrix is symmetric up to a given tolerance
- Return type:
boolean
- Returns:
true if the matrix is inversed
- copyData(data)[source]#
copy the matrix data to the array given in parameter’ Works only for dense matrices !
- resize(row, col, lower=0, upper=0, preserve=True)[source]#
resize the matrix with nbrow rows and nbcol columns The existing elements of the matrix are preseved when specified.
- normInfByColumn(vIn)[source]#
Compute the normInf for each column
- Parameters:
vIn (
SiconosVector
) – column
- det()[source]#
compute the determinant of the matrix (use LU factorization)
- Return type:
- Returns:
a double
- toString()[source]#
put data of the matrix into a std::string
- Return type:
string
- Returns:
std::string
- getRow(row, vOut)[source]#
get row index of current matrix and save it into vOut
- Parameters:
row (int) – index row we want to get
vOut (
SiconosVector
, out) – SiconosVector that will contain the desired row
- getCol(col, vOut)[source]#
get column index of current matrix and save it into vOut
- Parameters:
col (int) – index column we want to get
vOut (
SiconosVector
, out) – SiconosVector that will contain the desired column
- setRow(row, vIn)[source]#
set line row of the current matrix with vector v
- Parameters:
row (int) – index row we want to set
vIn (
SiconosVector
) – SiconosVector containing the new row
- setCol(col, vIn)[source]#
set column col of the current matrix with vector v
- Parameters:
col (int) – index column we want to set
vIn (
SiconosVector
) – a SiconosVector containing the new column
- getSubCol(index, pos, vOut)[source]#
get column number index of current matrix, starting from element at position pos and save it into vOut
- Parameters:
index (int) – index of required column
pos (int) – index of the first required element in the column
vOut (
SiconosVector
, out) – a SP::SiconosVector
- getSubRow(index, pos, vOut)[source]#
get row number index of current matrix, starting from element at position pos and save it into vOut
- Parameters:
index (int) – index of the required row
pos (int) – index of the first required element in the row
vOut (
SiconosVector
, out) – a SP::SiconosVector that will contain the sub row
- setSubCol(index, pos, vIn)[source]#
set column number index of current matrix, starting from element at position pos, with vIn
- Parameters:
index (int) – index of required column
pos (int) – index of the first required element in the column
vIn (
SiconosVector
) – a vector
- setSubRow(index, pos, vIn)[source]#
set row number index of current matrix, starting from element at position pos, with vIn
- Parameters:
index (int) – index of required row
pos (int) – index of the first required element in the row
vIn (
SiconosVector
) – a vector
- addBlock(i, j, m)[source]#
add the input matrix to the elements starting from position i (row) and j (col).
- Parameters:
i (int) – an unsigned int
j (int) – an unsigned int
m (
SiconosMatrix
) – a SiconosMatrix
- subBlock(i, j, m)[source]#
subtract the input matrix to the elements starting from position i (row) and j (col).
- Parameters:
i (int) – an unsigned int
j (int) – an unsigned int
m (
SiconosMatrix
) – a SiconosMatrix
- trans(*args)[source]#
Overload 1: transpose in place: x->trans() is x = transpose of x.
Overload 2: transpose a matrix: x->trans(m) is x = transpose of m.
- Parameters:
mat (
SiconosMatrix
) – the matrix to be transposed.
- PLUFactorizationInPlace()[source]#
computes an LU factorization of a general M-by-N matrix using partial pivoting with row interchanges. The result is returned in this (InPlace). Based on Blas dgetrf function.
- PLUInverseInPlace()[source]#
compute inverse of this thanks to LU factorization with Partial pivoting. This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A). The result is returned in this (InPlace). Based on Blas dgetri function.
- solve_matrix(B)[source]#
solves a system of linear equations A * X = B (A=this) for a general N-by-N matrix A using the LU factorization computed by PLUFactorize.
- Parameters:
B (
SiconosMatrix
, in/out) – on input the RHS matrix b; on output the result x
- PLUForwardBackwardInPlace(*args)[source]#
Overload 1: solves a system of linear equations A * X = B (A=this) with a general N-by-N matrix A using the LU factorization computed by PLUFactorizationInPlace. Based on Blas dgetrs function.
- Parameters:
B (
SiconosMatrix
, in/out) – on input the RHS matrix b; on output the result x
Overload 2: solves a system of linear equations A * X = B (A=this) with a general N-by-N matrix A using the LU factorization computed by PLUFactorizationInPlace. Based on Blas dgetrs function.
- Parameters:
B (
SiconosVector
, in/out) – on input the RHS matrix b; on output the result x
- solve_vector(B)[source]#
solves a system of linear equations A * X = B (A=this) for a general N-by-N matrix A using the LU factorization computed by PLUFactorize.
- Parameters:
B (
SiconosVector
, in/out) – on input the RHS matrix b; on output the result x
- SolveByLeastSquares(*args)[source]#
Overload 1: solves a system of linear equations A * X = B (A=this) with a general N-by-N matrix A using the Least squares method
- Parameters:
B (
SiconosMatrix
, in/out) – on input the RHS matrix b; on output the result x
Overload 2: solves a system of linear equations A * X = B (A=this) with a general N-by-N matrix A using the Least squares method
- Parameters:
B (
SiconosVector
, in/out) – on input the RHS matrix b; on output the result x
- class siconos.kernel.VECTOR_UBLAS_TYPE[source]#
Bases:
object
Union to gather all types of ublas vectors used in Siconos
- class siconos.kernel.SiconosVector(*args)[source]#
Bases:
object
Vectors of double. (Interface to various types of Boost-Ublas vectors).
Two possible types: Siconos::DENSE (default) and Siconos:SPARSE.
Overload 1: Creates a zero-size vector.
Overload 2: creates a vector, all components set to zero.
- Parameters:
Overload 3: creates a vector, all components set to zero.
- Parameters:
row (int) – the size of the vector
type – the type of vector (dense or sparse)
Overload 4: creates a vector and initializes its content with a single value
- Parameters:
Overload 5: creates a vector and initializes its content with a single value
- Parameters:
Overload 6: creates a dense vector from a copy of a stl vector.
- Parameters:
vec (std::vector< double,std::allocator< double > >) – vector to be copied
type (int, optional) – of the vector (dense or sparse)
Overload 7: creates a dense vector from a copy of a stl vector.
- Parameters:
vec (std::vector< double,std::allocator< double > >) – vector to be copied
type – of the vector (dense or sparse)
Overload 8: copy constructor
- Parameters:
v (
SiconosVector
) – source vector to be copied
Overload 9: creates a dense vector, with a copy.
- Parameters:
v (DenseVect) – source vector (ublas dense)
Overload 10: creates a sparse vector, with a copy.
- Parameters:
v (SparseVect) – source vector (ublas sparse)
Overload 11: creates a vector from data in a file
- Parameters:
filename (string) – file name (possibly with path)
is_ascii (boolean) – file format (true if ascii, false if binary)
Overload 12: constructor from the concatenation of two vectors
- Parameters:
v1 (
SiconosVector
) – the first vectorv2 (
SiconosVector
) – the second vector
Overload 13: constructor from a BlockVector. explicit to forbid implicit conversion/conversion constructor.
- Parameters:
input (
BlockVector
) – source vector
- size()[source]#
get the vector size, ie the total number of (double) elements in the vector
- Return type:
- Returns:
unsigned int
- dense()[source]#
get a pointer to the ublas embedded vector if it’s type is Dense
- Return type:
DenseVect
- Returns:
a DenseVect*
- sparse()[source]#
get a pointer to the ublas embedded vector if it’s type is Sparse
- Return type:
SparseVect
- Returns:
a SparseVect*
- resize(size, preserve=True)[source]#
Resize the vector. The existing elements may be preseved if specified.
- Parameters:
size (int) – new size of the vector
preserve (boolean, optional) – true if the content of the vector must be preserved.
- toBlock(vOut, sizeB, startIn, startOut)[source]#
copy a part of the vector into another
- Parameters:
vOut (
SiconosVector
) – destination vectorsizeB (int) – number of the elements to copy
startIn (int) – the beginning of the range of elements to copy from
startOut (int) – the beginning of the destination range
- addBlock(i, v)[source]#
add the input vector to a sub-block of the current vector
- Parameters:
i (int) – the beginning of the destination range
v (
SiconosVector
) – the source vector to be added
- subBlock(i, v)[source]#
subtract the input vector to a sub-block of the current vector
- Parameters:
i (int) – the beginning of the destination range
v (
SiconosVector
) – the source vector to be added
- class siconos.kernel.BlockVector(*args)[source]#
Bases:
object
“Block” vector : container (list) of SiconosVector
A block vector is a stl vector that handles pointers to SiconosVector.
Insertion of nullptr SP::SiconosVector is not allowed.
Overload 1: default contructor
Overload 2: copy contructor
- Parameters:
v (
BlockVector
) – BlockVector
Overload 3: contructor with 2 SiconosVectors
- Parameters:
v1 (
SiconosVector
) – first vectorv2 (
SiconosVector
) – second vector
Overload 4: contructor with a BlockVector of n (numberOfBlocks) blocks of the same size (dim) filled with a new vector
Overload 5: contructor with a BlockVector of n (numberOfBlocks) blocks that point on nullptr
- Parameters:
numberOfBlocks (int) – number of blocks
- begin()[source]#
- Return type:
VectorOfVectors::iterator
- Returns:
an iterator pointing to the first block in the container.
- end()[source]#
- Return type:
VectorOfVectors::iterator
- Returns:
an iterator referring to the past-the-end element in the container.
- numberOfBlocks()[source]#
- Return type:
Index::size_type
- Returns:
the number of SiconosVectors in the container
- isDense()[source]#
- Return type:
boolean
- Returns:
true if all SiconosVector in the container are dense *
- toString()[source]#
put data of the vector into a std::string
- Return type:
string
- Returns:
std::string
- vector(pos)[source]#
get a block (SiconosVector) of the vector
- Parameters:
pos (int) – index of the required block
- Return type:
- Returns:
the expected block
- setVector(pos, v)[source]#
set a block with a given vector (copy!)
- Parameters:
pos (int) – index of the block to set
v (
SiconosVector
) – source vector to be copied at position i
- setVectorPtr(pos, v)[source]#
set a block with a given vector (pointer link!)
- Parameters:
pos (int) – index of the block to set
v (
SiconosVector
) – source vector to be inserted at position i
- setAllVect(v)[source]#
Fill the container with a list of SiconosVector. Warning: pointer links, no copy
- Parameters:
v (
VectorOfVectors
) – the vectors to be inserted
- insertPtr(v)[source]#
Insert a new block (no allocation and nor copy)
- Parameters:
v (
SiconosVector
) – the vector to be inserted
- prepareVectorForPlugin()[source]#
Tranform a BlockVector into a SiconosVector.
Required for plugins, that need contiguous memory for their parameters.
- Return type:
- Returns:
a vector (the result depends on the number of blocks in input. 1 block : link to first component of the container, more : copy of all components into a SiconosVector)
- class siconos.kernel.Callback[source]#
Bases:
object
Structure used to store user callbacks inside solvers
- property env#
general user environment
- property collectStatsIteration#
pointer on a function Its signature is: user env, problem size, reaction, velocity, error at end of solver iteration (when this makes sense) and an extra data structure
- class siconos.kernel.SolverOptions[source]#
Bases:
object
Structure used to send options (name, parameters and so on) to a specific solver (mainly from Kernel to Numerics).
Creation, update and destruction:
solver_options_create()
solver_options_update_internal()
solver_options_delete()
Details in users’guide.
- property solverId#
id number of the solver.
- property isSet#
true(1) if the structure is ready to be used by a numerics driver.
- property iSize#
iSize size of vector iparam
- property iparam#
list of solver parameters (integer type); Check solvers doc for details.
- property dSize#
size of vector dparam
- property dparam#
list of solver parameters (double type); Check solvers doc for details.
- property filterOn#
if true (1), check solution validity after the driver call. Default = 1. For example if filterOn = 1 for a LCP, lcp_compute_error() will be called at the end of the process).
- property dWorkSize#
size of double type internal work array.
- property dWork#
internal (double type) work array.
- property iWorkSize#
size of integer type internal work array.
- property iWork#
internal (integer type) work array.
- property numberOfInternalSolvers#
the number of internal or local ‘sub-solvers’ used by the solver (size of internalSolvers) .
- property internalSolvers#
list of internal solver options
- property callback#
pointer to user-defined callback
- property solverParameters#
additional parameters specific to the solver (GAMS and NewtonMethod only)
- property solverData#
additional data specific to the solver
- siconos.kernel.SICONOS_ERROR_FULL_EVALUATION = 0#
Complete error computation, including v computation
- siconos.kernel.SICONOS_ERROR_LIGHT_EVALUATION = 1#
Light error computation with incremental values on r verification of absolute error at the end
- siconos.kernel.SICONOS_ERROR_LIGHT_EVALUATION_NO_UPDATE = 2#
only light error computation, do not update v unknown)
- siconos.kernel.solver_options_print(options)[source]#
screen display of solver parameters
- Parameters:
options (
SolverOptions
) – the structure to be displayed
- siconos.kernel.solver_options_delete(options)[source]#
Clear and free all pointer members of the structure, then release memory
- Parameters:
options (
SolverOptions
) – the structure to be cleared.
- siconos.kernel.solver_options_create(solverId)[source]#
Create and initialize a SolverOptions struct: allocate internal memories, set default values depending on the id.
- Parameters:
id – solver id number It must belong to one of the available ids defined for each formulation, see users’guide for details
- Return type:
- Returns:
a pointer to options set, ready to use by a driver.
- siconos.kernel.solver_options_copy(source)[source]#
Copy an existing set of options, to create a new one. Warning : callback, solverData and solverParameters of the new structure are pointer links to those of the original one!
- Parameters:
source (
SolverOptions
) – an existing solver options structure- Return type:
- Returns:
a pointer to options set, ready to use by a driver.
- siconos.kernel.solver_options_update_internal(parent, internal_solver_number, solver_id)[source]#
Change one of the internal solver of a previously defined SolverOptions set. Allocate internal memories and set default values for the internal solver. Warning : the actual internal solver in position internal_solver_number and all its content will be destroyed and replaced by a new one.
- Parameters:
parent (
SolverOptions
) – the top-level SolverOptions which contains the internal solver to be updatedinternal_solver_number (int) – number of the internal solver to be update (warning : this is the position in the list of internal solvers, not the id!)
solver_id (int) – id number of the new internal solver to be created/updated
- siconos.kernel.solver_options_name_to_id(pName)[source]#
return the id of a solver based on its name
- Parameters:
pName (string) – the name of the solver
- Return type:
- Returns:
the id of the solver or 0 if it failed
- siconos.kernel.solver_options_id_to_name(Id)[source]#
return the name of a solver given its id
- Parameters:
Id (int) – the id of the solver
- Return type:
string
- Returns:
the name of the solver
- siconos.kernel.solver_options_get_internal_solver(options, n)[source]#
return the internal solver options set
- Parameters:
options (
SolverOptions
) – parent optionsnumber – of the targeted solver
- Return type:
- Returns:
a pointer to the internal solver options set
- siconos.kernel.solver_options_set_internal_solver(options, n, NSO)[source]#
set internal solver
- Parameters:
options (
SolverOptions
) – parent optionsnumber – of the targeted solver
the – solver options to be used as internal solver number n
- siconos.kernel.LEVELMAX = 999#
Internal bound max levels for time integrators. This value may be checked to see if initialization has occured.
- siconos.kernel.ioMatrix_read(fileName, mode, m)[source]#
Read a SiconosMatrix
- Parameters:
fileName (string, in) – the name of the file to read
mode (string, in) – the storage type used in the file (either ascii or binary)
m (
SiconosMatrix
, in/out) – the SiconosMatrix to be filled
- Return type:
boolean
- Returns:
true if read ok, else false …
- siconos.kernel.ioMatrix_write(*args)[source]#
Write a SiconosMatrix
- Parameters:
fileName (string, in) – the name of the file to write in
mode (string, in) – the storage type used in the file (either ascii or binary)
m (
SiconosMatrix
, in) – the SiconosMatrix to writeoutputType (string, in, optional) – type of output: - “python”(default): row col a00 a01 a02 … a10 … - “noDim”: a00 a01 a02 … a10 … Reading input format is the one corresponding to “python”.
- Return type:
boolean
- Returns:
true if read ok, else false …
- siconos.kernel.compareRefFile(*args)[source]#
Function to load data from a file and compare it with the provided data. Returns the measured difference between files if the file was loaded and the comparison was performed, which must be >= 0.0, otherwise -1.0 is returned. Caller needs to check diff <= epsilon to verify the result.
- Parameters:
data (
SimpleMatrix
) – The data to compare against the file.filename (string) – The name of the file to load and compare.
epsilon (float) – The comparison threshold.
index (Index, optional) – An optional list of column indexes, size==0 indicates all columns.
ref (
SimpleMatrix
, optional) – If provided, loaded matrix is returned in this pointer.mode (string, optional) – Mode string to pass to ioMatrix::read.
verbose (boolean, optional) – True to print verbose output.
- Return type:
- Returns:
Positive or 0.0 if the file was loaded and the comparison was performed, otherwise -1.
- siconos.kernel.TD_EVENT = 1#
Event constants
- siconos.kernel.DENSE = 1#
id for dense matrix or vector
- siconos.kernel.TRIANGULAR = 2#
id for triangular matrix
- siconos.kernel.SYMMETRIC = 3#
id for symmetric matrix
- siconos.kernel.SPARSE = 4#
id for sparse matrix or vector
- siconos.kernel.BANDED = 5#
id for banded matrix
- siconos.kernel.ZERO = 6#
id for zero matrix
- siconos.kernel.IDENTITY = 7#
id for identity matrix
- siconos.kernel.SPARSE_COORDINATE = 8#
id for sparse matrix or vector
- class siconos.kernel.SiconosMemory(*args)[source]#
Bases:
MemoryContainer
Interface to stl container of SiconosVector.
This class is used as a backup during simulation, to save vectors (e.g. state) computed during previous time steps.
The size of the container is fixed, with a first-in first-out mechanism
used through swap method. - All saved vectors must have the same dimension.
This class must be reviewed and backup should probably be moved to graph rather than in this object.
Overload 1: creates an empty SiconosMemory.
Overload 2: creates a SiconosMemory
- Parameters:
Overload 3: creates a SiconosMemory, copy constructor Required because of resize call in DS initMemory function.
- Parameters:
mem (
SiconosMemory
) – a SiconosMemory
- getSiconosVector(arg2)[source]#
To get SiconosVector number i of the memory
- Parameters:
int – i: the position in the memory of the wanted SiconosVector
- Return type:
- Returns:
a SP::SiconosVector
- getSiconosVectorMutable(arg2)[source]#
To get SiconosVector number i of the memory as mutable reference. Use should be avoided whenever possible. (Used in LinearSMC::actuate)
- Parameters:
int – i: the position in the memory of the wanted SiconosVector
- Return type:
- Returns:
a SP::SiconosVector
- setMemorySize(steps, vectorSize)[source]#
set size of the SiconosMemory (number of vectors and size of vector)
- class siconos.kernel.NonSmoothLaw(*args)[source]#
Bases:
object
Non Smooth Laws (NSL) Base Class
This class is the base class for all nonsmooth laws in Siconos. A nonsmooth law characterize the (nonsmooth) relationship between 2 variables, usually designated by \(y\) and \(\lambda\). \(y\) is most of time seen as the “input” from DynamicalSystems and is given by a Relation linked to this nonsmoothlaw. \(\lambda\) is then the “output” and through the same Relation is fed back to one or more DynamicalSystem.
classical examples of nonsmooth law include: - RelayNSL: \(-y \in \mathcal{N}_{[-1,1]}(\lambda)\quad \Longleftrightarrow\quad -\lambda \in \mbox{sgn} (y)\) - NormalConeNSL: given a polytope \(K\), \(-\lambda \in \partial \sigma_{-K}(y)\quad\Longleftrightarrow\quad y\in\mathcal{N}_{-K}(-\lambda)\) - ComplementarityConditionNSL: \(0\leq y \perp \lambda \geq 0\) - NewtonImpactNSL and NewtonImpactFrictionNSL for impact, without or with friction - MultipleImpactNSL for a multiple impact law - MixedComplementarityConditionNSL
The computation of both \(y\) and \(\lambda\) is carried on by a solver in Numerics through a OneStepNSProblem object.
basic constructor
- Parameters:
size (int) – the nonsmooth law size
- class siconos.kernel.NewtonImpactNSL(*args)[source]#
Bases:
NonSmoothLaw
Newton impact Non Smooth Law
This class formalizes the Newton Impact law together with a complementarity condition. i.e.
\[\left\{\begin{array}{l} y \geq 0, \lambda \geq 0, y^{T} \lambda=0\ \ if y \leq 0 \quad \mbox{then} \quad \dot y(t^{+}) - e \dot y(t^{-}) \geq 0, \quad \lambda \geq 0, (\dot y(t^{+}) - e \dot y(t^{-}))^{T} \lambda=0 \end{array}\right.\]nsLawSize is equal to 1.
Overload 1: default constructor
Overload 2: constructor with the value of the NewtonImpactNSL attributes
- Parameters:
e (float) – the value of the coefficient of restitution
Overload 3: Apply multiple-axis impact
- class siconos.kernel.NewtonImpactFrictionNSL(*args)[source]#
Bases:
NonSmoothLaw
Newton Impact-Friction Non Smooth Law
Overload 1: basic constructor
- Parameters:
size (int) – size of the ns law
Overload 2: constructor with the value of the NewtonImpactFrictionNSL attributes
- Parameters:
- class siconos.kernel.NewtonImpactRollingFrictionNSL(*args)[source]#
Bases:
NonSmoothLaw
Newton Impact-Friction Non Smooth Law
- Overload 1:
basic constructor
- type size:
int
- param size:
size of the ns law
- Overload 2:
constructor with the value of the NewtonImpactRollingFrictionNSL attributes :type en: float
- Parameters:
en –
double : normal e coefficient
- type et:
float
- param et:
double tangent e coefficient
- type mu:
float
- param mu:
double : friction coefficient
- type muR:
float
- param muR:
double : rolling friction coefficient
- type size:
int
- param size:
unsigned int: size of the ns law
- class siconos.kernel.MixedComplementarityConditionNSL(newSize, equalitySize)[source]#
Bases:
NonSmoothLaw
Complementarity NonSmoothLaw
basic constructor
- Parameters:
- class siconos.kernel.ComplementarityConditionNSL(size)[source]#
Bases:
NonSmoothLaw
Complementarity NonSmoothLaw
basic constructor
- Parameters:
size (int) – of the non smooth law
- class siconos.kernel.EqualityConditionNSL(size)[source]#
Bases:
NonSmoothLaw
Equality NonSmoothLaw
basic constructor
- Parameters:
size (int) – of the non smooth law
- class siconos.kernel.MultipleImpactNSL(*args)[source]#
Bases:
NonSmoothLaw
basic constructor
- Parameters:
size (int) – the nonsmooth law size
- class siconos.kernel.RelayNSL(size, lb=-1.0, ub=1.0)[source]#
Bases:
NonSmoothLaw
Relay NonSmoothLaw
This class formalizes the Relay nonsmooth law i.e.
\[-y \in \mathcal{N}_{[lb,ub]}(\lambda),\]where \(lb\) is the lower bound and \(ub\) is the upper bound of the Relay law.
In this default case, the lower bound is set to \(lb=-1\) and the upper bound ub is set to \(ub=1\). We get the well-known form of the RelayNSL as the multivalued sign function, i.e.
\[y \in -\mathcal{N}_{[-1,1]}(\lambda) \Longleftrightarrow \lambda \in -\mbox{sgn} (y)\]where the multi-valued sign function is defined as
\[\begin{split}\mbox{sgn} (y) = \left\{ \begin{array}{lcl} 1 && y >0 \\ [-1,1] && y =0 \\ -1 && y <0 \end{array}\right.\end{split}\]TODO: Build the Sgn NonSmoothLaw as the default instance of Relay
constructor with the value of the RelayNSL attributes
- Parameters:
- class siconos.kernel.NormalConeNSL(size, H, K)[source]#
Bases:
NonSmoothLaw
NormalCone NonSmoothLaw
This class formalizes a nonsmooth law in the form of a normal cone inclusion i.e.
\[0 \in y + \mathcal{N}_{P}(\lambda),\]where \(P\) is a polyhedral set. This is a generalization of the RelayNSL law, where the set \(P\) is a scaled box. Note that there exists an inverse of the previous relation in the form
\[\lambda \in \partial \sigma_{P} (-y),\]with \(\sigma_{P}\) the support function of \(P\) and \(\partial \sigma_{P}\) the subdifferential of this support function.
Note that the polyhedral set \(P\) is described as \(\{\lambda\mid H \lambda \geq K\}\), where \(H\) is a matrix and \(K\) a vector.
Constructor with the polyhedral representation of P as Hx >= K
- Parameters:
size (int) – size of the NonSmoothLaw
H (
SimpleMatrix
) – matrix in the (H-K)-representation of the polytope PK (
SiconosVector
) – vector in the (H-K)-representation of the polytope P
- class siconos.kernel.DynamicalSystem(*args)[source]#
Bases:
object
Abstract interface to Dynamical Systems
This class is used to describe dynamical systems of the form :
\(g(\dot x, x, t, z) = 0\)
where
\(x \in R^{n}\) is the state.
\(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. - \(g : R^{n} \times R \to R^{n}\) .
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\)
Under some specific conditions, the system can be written as:
\(\dot x = rhs(x, t, z)\)
In that case, \(\nabla_{\dot x} g\) must be invertible.
- Overload 1:
default constructor
- Overload 2:
- minimal constructor, from state dimension
result in \(\dot x = r\)
- type dimension:
int
- param dimension:
size of the system (n)
- Overload 3:
Copy constructor
- Parameters:
ds (
DynamicalSystem
) – the DynamicalSystem to copy
- initRhs(time)[source]#
allocate (if needed) and compute rhs and its jacobian.
- Parameters:
time (float) – of initialization
- initializeNonSmoothInput(level)[source]#
set nonsmooth input to zero
- Parameters:
level (int) – input-level to be initialized.
- update(time)[source]#
compute all component of the dynamical system, for the current state.
- Parameters:
time (float) – current time (the one used to update ds component)
- computeRhs(time)[source]#
update right-hand side for the current state
- Parameters:
time (float) – of interest
- computeJacobianRhsx(time)[source]#
update \(\nabla_x rhs\) for the current state
- Parameters:
time (float) – of interest
- resetNonSmoothPart(level)[source]#
set nonsmooth part of the rhs to zero for a given level
- Parameters:
level (int) –
- setNumber(new_number)[source]#
set the id of the DynamicalSystem
- Return type:
- Returns:
the previous value of number
- dimension()[source]#
returns the dimension of the system (depends on system type, e.g. n for first order, ndof for Lagrangian).
- setX0(newValue)[source]#
set initial state (copy)
- Parameters:
newValue (
SiconosVector
) – input vector to copy
- setX0Ptr(newPtr)[source]#
set initial state (pointer link)
- Parameters:
newPtr (
SiconosVector
) – vector (pointer) to set x0
- setX(newValue)[source]#
set content of current state vector \(x\)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setXPtr(newPtr)[source]#
set state vector \(x\) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector
- r()[source]#
returns a pointer to r vector (input due to nonsmooth behavior)
- Return type:
- Returns:
SP::SiconosVector
- getR()[source]#
get a copy of r vector (input due to nonsmooth behavior)
- Return type:
- Returns:
a SiconosVector
- setR(newValue)[source]#
set r vector (input due to nonsmooth behavior) content (copy)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setRPtr(newPtr)[source]#
set r vector (input due to nonsmooth behavior) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector newPtr
- rhs()[source]#
returns a pointer to the right-hand side vector, (i.e. \(\dot x\))
- Return type:
- Returns:
SP::SiconosVector
- getRhs()[source]#
get a copy of the right-hand side vector, (i.e. \(\dot x\))
- Return type:
- Returns:
SiconosVector
- setRhs(newValue)[source]#
set the value of the right-hand side, \(\dot x\)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setRhsPtr(newPtr)[source]#
set right-hand side, \(\dot x\) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector
- jacobianRhsx()[source]#
returns a pointer to \(\nabla_x rhs()\)
- Return type:
- Returns:
SP::SiconosMatrix
- setJacobianRhsx(newValue)[source]#
set the value of \(\nabla_x rhs()\)
- Parameters:
newValue (
SiconosMatrix
) – SiconosMatrix
- setJacobianRhsxPtr(newPtr)[source]#
set \(\nabla_x rhs()\), pointer link
- Parameters:
newPtr (
SiconosMatrix
) – SP::SiconosMatrix
- z()[source]#
returns a pointer to \(z\), the vector of algebraic parameters.
- Return type:
- Returns:
SP::SiconosVector
- getz()[source]#
get a copy of \(z\), the vector of algebraic parameters.
- Return type:
- Returns:
a SiconosVector
- setz(newValue)[source]#
set the value of \(z\) (copy)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setzPtr(newPtr)[source]#
set \(z\) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector
- xMemory()[source]#
get all the values of the state vector x stored in a SiconosMemory object (not const due to LinearSMC::actuate)
- Return type:
- Returns:
a reference to the SiconosMemory object
- stepsInMemory()[source]#
returns the number of step saved in memory for state vector
- Return type:
- Returns:
int
- initMemory(steps)[source]#
initialize the SiconosMemory objects: reserve memory for i vectors in memory and reset all to zero.
- Parameters:
steps (int) – the size of the SiconosMemory (i)
- swapInMemory()[source]#
push the current values of x and r in memory (index 0 of memory is the last inserted vector) xMemory and rMemory,
- updatePlugins(time)[source]#
call all plugged functions for the current state
- Parameters:
time (float) – the current time
- siconos.kernel.DynamicalSystem_resetCount(new_count=0)[source]#
reset the global DynamicSystem counter (for ids)
- Return type:
- Returns:
the previous value of count
- class siconos.kernel.NonSmoothDynamicalSystem(t0, T)[source]#
Bases:
object
the NonSmoothDynamicalSystem consists in Dynamical Systems and Interactions structured into a graph defined in a Topology. In the DynamicalSystem graph, DynamicalSystem objects are nodes and Interaction objects are edges.
To add a DynamicalSystem, use insertDynamicalSystem method. To add a new Interaction, use link method.
A dual graph is also contructed, where Interactions are vertices and DynamicalSystems are edges.
NSDS constructor.
- setT(newValue)[source]#
set final time
- Parameters:
newValue (float) – the new final time for the Simulatiom
- title()[source]#
get the title of the simulation
- Return type:
string
- Returns:
std::string : the title
- author()[source]#
get the author of the simulation
- Return type:
string
- Returns:
std::string : the author
- setAuthor(s)[source]#
set the author of the simulation
- Parameters:
s (string) – std::string : the author
- description()[source]#
allows to get the description of the simulation
- Return type:
string
- Returns:
std::string : the description
- setDescription(s)[source]#
set the author of the simulation
- Parameters:
s (string) – std::string : the author
- date()[source]#
allows to get the date of the simulation
- Return type:
string
- Returns:
std::string : the date
- setBVP(newBvp)[source]#
set the NonSmoothDynamicalSystem to BVP, else it is IVP
- Parameters:
newBvp (boolean) – true if BVP, false otherwise
- changeLog()[source]#
get a reference to the changelog for an NSDS.
- Return type:
NonSmoothDynamicalSystem::ChangeLog
- Returns:
a reference to the changelog.
- changeLogPosition()[source]#
get an iterator to the last item in the changelog.
- Return type:
NonSmoothDynamicalSystem::ChangeLogIter
- Returns:
an iterator pointing at the last item in the changelog.
- changeLogBegin()[source]#
get an iterator to the beginning of the changelog.
- Return type:
NonSmoothDynamicalSystem::ChangeLogIter
- Returns:
an iterator pointing at the beginning of the changelog.
- clearChangeLogTo(it)[source]#
clear the changelog up to a given position.
- Parameters:
it (NonSmoothDynamicalSystem::ChangeLogIter) – This iterator must point to somewhere in the changelog for this NSDS.
- dynamicalSystems()[source]#
get all the dynamical systems declared in the NonSmoothDynamicalSystem.
- Return type:
DynamicalSystemsGraph
- Returns:
a SP::DynamicalSystemsGraph
- dynamicalSystemsVector()[source]#
get all the dynamical systems declared in the NonSmoothDynamicalSystem. into a std::vector<SP::DynamicalSystem> Useful for iterates on DynamicalSystems in Python for instance
- Return type:
std::vector< SP::DynamicalSystem,std::allocator< SP::DynamicalSystem > >
- Returns:
std::vector<SP::DynamicalSystem>
- insertDynamicalSystem(ds)[source]#
add a dynamical system into the DS graph (as a vertex)
- Parameters:
ds (
DynamicalSystem
) – a pointer to the system to add
- dynamicalSystem(nb)[source]#
get Dynamical system number I
- Parameters:
nb (int) – the identifier of the DynamicalSystem to get
- Return type:
- Returns:
a pointer on DynamicalSystem
- removeDynamicalSystem(ds)[source]#
remove a dynamical system
- Parameters:
ds (
DynamicalSystem
) – a pointer to the dynamical system to remove
- getNumberOfInteractions()[source]#
get the number of Interactions present in the NSDS.
- Return type:
- Returns:
an unsigned int
- interactions()[source]#
return the graph of Interactions present in the NSDS.
- Return type:
InteractionsGraph
- Returns:
SP::InteractionGraph
- removeInteraction(inter)[source]#
remove an interaction to the system
- Parameters:
inter (
Interaction
) – a pointer to the interaction to remove
- interaction(*args)[source]#
Overload 1: get Interaction number I
- Parameters:
nb (int) – the identifier of the Interaction to get
- Return type:
- Returns:
a pointer to an Interaction
Overload 2: get Interaction named name
- Parameters:
name (string) – of the Interaction to get
- Return type:
- Returns:
a pointer to an Interaction
- InteractionsVector()[source]#
get all the interactions declared in the NonSmoothDynamicalSystem. into a std::vector<SP::Interaction> Useful for iterates on Interaction in Python for instance
- Return type:
std::vector< SP::Interaction,std::allocator< SP::Interaction > >
- Returns:
std::vector<SP::Interaction>
- link(*args)[source]#
link an interaction to two dynamical systems
- Parameters:
inter (
Interaction
) – the interactionds1 (
DynamicalSystem
) – a DynamicalSystemds2 (
DynamicalSystem
, optional) – a DynamicalSystem (optional)
- setName(*args)[source]#
Overload 1: set the name for this Dynamical System
- Parameters:
ds (
DynamicalSystem
) – a pointer to the systemname (string) – the name of the DynamicalSystem
Overload 2: set the name for this Interaction
- Parameters:
interaction (
Interaction
) – a pointer to the Interactionname (string) – the name of the Interaction
- name(*args)[source]#
Overload 1: get the name for this Dynamical System
- Parameters:
ds (
DynamicalSystem
) – a pointer to the system- Return type:
string
- Returns:
name the name of the DynamicalSystem, or empty string if not found.
Overload 2: get the name for this Interaction
- Parameters:
inter (
Interaction
) – a pointer to the Interaction- Return type:
string
- Returns:
name the name of the Interaction, or empty string if not found.
- setControlProperty(inter, isControlInteraction)[source]#
specify id the given Interaction is for controlling the DS
- Parameters:
inter (
Interaction
) – the InteractionisControlInteraction (boolean) – true if the Interaction is used for control purposes
- isLinear()[source]#
return false is one of the interations is not linear. else return true.
- Return type:
boolean
- Returns:
a bool
- setSymmetric(val)[source]#
set symmetry in the blocks computation
- Parameters:
val (boolean) – a bool
- resetNonSmoothPart(level)[source]#
Set all DS non-smooth part to zero for a given level.
- Parameters:
level (int) – the level to will be zeroed
- pushInteractionsInMemory()[source]#
- save interaction states in memories. Applied to all interactions
of the connected topology
- updateDSPlugins(time)[source]#
update the plugins of the DS
- Parameters:
time (float) – to be used for plugins
- updateOutput(*args)[source]#
Overload 1: compute output for all the interactions for a given level
Overload 2: compute output for all the interactions and for a level range
- computeInteractionJacobians(*args)[source]#
Overload 1: compute Jacobians for all the interactions (in indexSet0)
- Parameters:
time (float) –
Overload 2: compute Jacobians for all the interactions of a given index set
- Parameters:
time (float) –
indexSet (
InteractionsGraph
) – InteractionsGraph of interest
- class siconos.kernel.LinearComplementaritySystemsNSDS(t0, T, x0, A, B, C, D, a, b)[source]#
Bases:
NonSmoothDynamicalSystem
The LinearComplementaritySystemsNSDS_H inherits frim NSDS for a direct instanciation of a LCS
constructor with t0 and T
- interaction()[source]#
Overload 1: get Interaction number I
- Parameters:
nb (int) – the identifier of the Interaction to get
- Return type:
- Returns:
a pointer to an Interaction
Overload 2: get Interaction named name
- Parameters:
name (string) – of the Interaction to get
- Return type:
- Returns:
a pointer to an Interaction
- class siconos.kernel.Topology[source]#
Bases:
object
This class describes the topology of the non-smooth dynamical system. It holds all the “potential” Interactions”.
Topology is built in NSDS constructors but initialized in Simulation->initialize(), ie when all Interactions have been clearly defined.
Note that indexSet0 holds all the possible relations (declared by user) not only those which are “actives”.
Construction consists in: - link with the NSDS that owns the topology.
Initialization consists in: - scan of all the interactions of the NSDS - initialization of each interaction - insertion of the relations of all the Interaction into indexSet0
Insertion of an Interaction into the set indexSet0: addInteractionInIndexSet0(SP::Interaction inter) for each relation of the interaction, it creates a new Interaction and inserts it into indexSet0 It also counts the total number of “constraints” in the system.
default constructor
- hasDynamicalSystem(ds)[source]#
check if an dynamical system is already a vertex of the DSs graph.
- Parameters:
ds (
DynamicalSystem
) – the DS to test- Return type:
boolean
- Returns:
true if ds is in the graph
- hasInteraction(inter)[source]#
check if an interaction is already a vertex of the Interactions graph.
- Parameters:
inter (
Interaction
) – the Interaction to test- Return type:
boolean
- Returns:
true if inter is in the graph
- removeInteraction(inter)[source]#
remove an Interaction from the topology. The interaction is removed from Dynamical Systems graph and Interactions Graph. The interaction is not removed from actives subgraphs : see updateIndexSet
- Parameters:
inter (
Interaction
) – the interaction to remove
- insertDynamicalSystem(ds)[source]#
add a dynamical system
- Parameters:
ds (
DynamicalSystem
) – the DynamicalSystem to add
- removeDynamicalSystem(ds)[source]#
remove a Dynamical System from the topology. The dynamical system is removed from Dynamical Systems graph and Interactions Graph. The dynamical system is not removed from actives subgraphs : see updateIndexSet
- Parameters:
ds (
DynamicalSystem
) – the dynamical system to remove
- setName(*args)[source]#
Overload 1: set the name for this Dynamical System
- Parameters:
ds (
DynamicalSystem
) – a pointer to the systemname (string) – the name of the DynamicalSystem
Overload 2: set the name for an Interaction
- Parameters:
inter (
Interaction
) – a pointer to the Interactionname (string) – the name of the Interaction
- name(*args)[source]#
Overload 1: get the name for this Dynamical System
- Parameters:
ds (
DynamicalSystem
) – a pointer to the system- Return type:
string
- Returns:
name the name of the DynamicalSystem, or empty string if not found.
Overload 2: get the name for this Interaction
- Parameters:
inter (
Interaction
) – a pointer to the Interaction- Return type:
string
- Returns:
name the name of the Interaction, or empty string if not found.
- setOSI(ds, OSI)[source]#
set the OSI for this DynamicalSystem
- Parameters:
ds (
DynamicalSystem
) – the DynamicalSystemOSI (
OneStepIntegrator
) – the integrator to use for this DS
- link(*args)[source]#
link two dynamical systems to a relation
- Parameters:
inter (
Interaction
) – a SP::Interactionds (
DynamicalSystem
) – a SP::DynamicalSystemds2 (
DynamicalSystem
, optional) – a SP::DynamicalSystem (optional)
- Return type:
std::pair< DynamicalSystemsGraph::EDescriptor,InteractionsGraph::VDescriptor >
- Returns:
a vertex descriptor of the new vertex in IndexSet0
- setControlProperty(inter, isControlInteraction)[source]#
specify if the given Interaction is for controlling the DS
- Parameters:
inter (
Interaction
) – InteractionisControlInteraction (boolean) – true if the Interaction is used for control purposes
- indexSet0()[source]#
get a pointer to the graph of all Interactions.
- Return type:
InteractionsGraph
- Returns:
a SP::InteractionsGraph
- indexSet(num)[source]#
get a pointer to the graph at level num of Interactions
- Parameters:
num (int) – the number of indexSet
- Return type:
InteractionsGraph
- Returns:
a SP::InteractionsGraph
- numberOfIndexSet()[source]#
get a pointer to the graph at level num of Interactions
- Return type:
- Returns:
a SP::InteractionsGraph
- resetIndexSetPtr(num)[source]#
reset graph at level num of Interactions
- Parameters:
num (int) – the indexSet to reset
- dSG(num)[source]#
get a pointer to the graph at level num of Dynamical System
- Parameters:
num (int) – the level
- Return type:
DynamicalSystemsGraph
- Returns:
a SP::DynamicalSystemsGraph
- indexSetsSize()[source]#
get the number of Interactions Graphs
- Return type:
- Returns:
the number of Interactions Graphs
- indexSetsResize(newSize)[source]#
resize Interactions Graphs
- Parameters:
newSize (int) – the new size
- numberOfConstraints()[source]#
get the total number of scalar constraints
- Return type:
- Returns:
an unsigned int
- setSymmetric(val)[source]#
set symmetry in the blocks computation
- Parameters:
val (boolean) – a bool
- getDynamicalSystem(*args)[source]#
Overload 1: Get a dynamical system using its number Warning: O(n) complexity
- Parameters:
requiredNumber (int) – the required number
- Return type:
- Returns:
a DynamicalSystem
Overload 2: Get a dynamical system using its name Warning: O(n) complexity
- Parameters:
name (string) – the name of the dynamical system
- Return type:
- Returns:
a DynamicalSystem
- getInteraction(*args)[source]#
Overload 1: Get a interaction using its number Warning: O(n) complexity
- Parameters:
requiredNumber (int) – the required number
- Return type:
- Returns:
an Interaction
Overload 2: Get a interaction using its name Warning: O(n) complexity
- Parameters:
name (string) – the name of the Interaction
- Return type:
- Returns:
an Interaction pointer
- interactionsForDS(arg2)[source]#
get Interactions for a given DS
- Return type:
std::vector< SP::Interaction,std::allocator< SP::Interaction > >
- Returns:
a vector of pointers to Interaction
- interactionsForPairOfDS(*args)[source]#
get Interactions for a given pair of DSs
- Return type:
std::vector< SP::Interaction,std::allocator< SP::Interaction > >
- Returns:
a vector of pointers to Interaction
- dynamicalSystemsForInteraction(arg2)[source]#
get DynamicalSystems for a given Interaction
- Return type:
std::vector< SP::DynamicalSystem,std::allocator< SP::DynamicalSystem > >
- Returns:
a vector of pointers to DynamicalSystem
- getDSG0Descriptor(ds)[source]#
Helper to get the descriptor in DSG0 from a DynamicalSystem
- Parameters:
ds (
DynamicalSystem
) – DynamicalSystem of which we want the descriptor- Return type:
DynamicalSystemsGraph::VDescriptor
- Returns:
the descriptor in DSG0 from a DynamicalSystem
- class siconos.kernel.SecondOrderDS(*args, **kwargs)[source]#
Bases:
DynamicalSystem
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())
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: - initRhs() to allocate/initialize memory for these new operators, - rhs() to get the rhs vector - computeRhs(), computeJacobianRhsx() …, to update the content of rhs, its jacobians …
- Overload 1:
default constructor
- Overload 2:
- minimal constructor, from state dimension
result in \(\dot x = r\)
- type dimension:
int
- param dimension:
size of the system (n)
- Overload 3:
Copy constructor
- Parameters:
ds (
DynamicalSystem
) – the DynamicalSystem to copy
- p(level=2)[source]#
get p
- Parameters:
level (int, optional) – unsigned int, required level for p, default = 2
- Return type:
- Returns:
pointer on a SiconosVector
- inverseMass()[source]#
get (pointer) inverse or LU-factorization of the mass, used for LU-forward-backward computation
- Return type:
- Returns:
pointer SP::SimpleMatrix
- setMassPtr(newPtr)[source]#
set mass to pointer newPtr
- Parameters:
newPtr (
SimpleMatrix
) – a plugged matrix SP
- setRhs(newValue)[source]#
set the value of the right-hand side, \(\dot x\)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setRhsPtr(newPtr)[source]#
set right-hand side, \(\dot x\) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector
- computeForces(time, q, velocity)[source]#
Compute \(F(v,q,t,z)\)
- Parameters:
time (float) – the current time
q (
SiconosVector
) – SP::SiconosVector: pointers on qvelocity (
SiconosVector
) – SP::SiconosVector: pointers on velocity
- computeJacobianqForces(time)[source]#
Compute \(\nabla_qF(v,q,t,z)\) for current \(q,v\) Default function to compute forces
- Parameters:
time (float) – the current time
- computeJacobianvForces(time)[source]#
Compute \(\nabla_{\dot q}F(v,q,t,z)\) for current \(q,v\)
- Parameters:
time (float) – the current time
- dimension()[source]#
return the number of degrees of freedom of the system
- Return type:
- Returns:
an unsigned int.
- q()[source]#
generalized coordinates of the system (vector of size dimension())
- Return type:
- Returns:
pointer on a SiconosVector
- setQ(newValue)[source]#
set value of generalized coordinates vector (copy)
- Parameters:
newValue (
SiconosVector
) –
- setQPtr(newPtr)[source]#
set value of generalized coordinates vector (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- setQ0(newValue)[source]#
set initial state (copy)
- Parameters:
newValue (
SiconosVector
) –
- setQ0Ptr(newPtr)[source]#
set initial state (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- velocity()[source]#
get velocity vector (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- setVelocity(newValue)[source]#
set velocity vector (copy)
- Parameters:
newValue (
SiconosVector
) –
- setVelocityPtr(newPtr)[source]#
set velocity vector (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- velocity0()[source]#
get initial velocity (pointer)
- Return type:
- Returns:
pointer on a SiconosVector
- setVelocity0(newValue)[source]#
set initial velocity (copy)
- Parameters:
newValue (
SiconosVector
) –
- setVelocity0Ptr(newPtr)[source]#
set initial velocity (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- acceleration()[source]#
get acceleration (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- forces()[source]#
get \(F(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- jacobianvForces()[source]#
get \(\nabla_{\dot q}F(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- qMemory()[source]#
get all the values of the state vector q stored in memory. note: not const due to SchatzmanPaoliOSI::initializeWorkVectorsForDS
- Return type:
- Returns:
a memory
- velocityMemory()[source]#
get all the values of the state vector velocity stored in memory. note: not const due to SchatzmanPaoliOSI::initializeWorkVectorsForDS
- Return type:
- Returns:
a memory
- initMemory(size)[source]#
initialize the SiconosMemory objects with a positive size.
- Parameters:
size (int) – the size of the SiconosMemory. must be >= 0
- computeMass(*args)[source]#
Overload 1: default function to compute the mass
Overload 2: function to compute the mass
- Parameters:
position (
SiconosVector
) – value used to evaluate the mass matrix
- setBoundaryConditions(newbd)[source]#
set Boundary Conditions
- Parameters:
newbd (
BoundaryCondition
) – BoundaryConditions
- boundaryConditions()[source]#
get Boundary Conditions
- Return type:
- Returns:
SP::BoundaryCondition pointer on a BoundaryConditions
- setReactionToBoundaryConditions(newrbd)[source]#
set Reaction to Boundary Conditions
- Parameters:
newrbd (
SiconosVector
) – BoundaryConditions pointer
- reactionToBoundaryConditions()[source]#
get Reaction to Boundary Conditions
- Return type:
- Returns:
pointer on a BoundaryConditions
- init_inverse_mass()[source]#
Allocate memory for the lu factorization of the mass of the system. Useful for some integrators with system inversion involving the mass
- class siconos.kernel.LagrangianDS(*args)[source]#
Bases:
SecondOrderDS
Lagrangian non linear dynamical systems - \(M(q,z) \dot v = F(v, q, t, z) + p\)
This class defines and computes a generic ndof-dimensional Lagrangian Non Linear Dynamical System of the form :
\[\begin{split}M(q,z) \dot v + F_{gyr}(v, q, z) + F_{int}(v , q , t, z) = F_{ext}(t, z) + p \\ \dot q = v\end{split}\]where
\(q \in R^{ndof}\) is the set of the generalized coordinates,
\(\dot q =v \in R^{ndof}\) the velocity, i. e. the time
derivative of the generalized coordinates (Lagrangian systems). - \(\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_{gyr}(\dot q, q) \in R^{ndof}\) is the non linear inertia term (access fGyr() method). - \(F_{int}(\dot q , q , t) \in R^{ndof}\) are the internal forces (access fInt() method). - \(F_{ext}(t) \in R^{ndof}\) are the external forces (access fExt() method). - \(z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discrete state.
The equation of motion is also shortly denoted as \(M(q,z) \dot v = F(v, q, t, z) + p\)
where \(F(v, q, t, z) \in R^{ndof}\) collects the total forces acting on the system, that is \(F(v, q, t, z) = F_{ext}(t, z) - F_{gyr}(v, q, z) + F_{int}(v, q , t, z)\)
This vector is saved and may be accessed using forces() method.
q[i] is the derivative number i of q. Thus: q[0]=:math: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_{gyr}(v, q, z)\) (computeFGyr())
\(F_{int}(v , q , t, z)\) (computeFInt())
\(F_{ext}(t, z)\) (computeFExt())
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] ndverbatim\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: - initRhs() to allocate/initialize memory for these new operators, - rhs() to get the rhs vector - computeRhs(), computeJacobianRhsx() …, to update the content of rhs, its jacobians …
- Overload 1:
Default constructor
- Overload 2:
constructor from initial state only, \(dv = p\)
- type position:
- param position:
SiconosVector : initial coordinates of this DynamicalSystem :type velocity:
SiconosVector
- Parameters:
velocity – SiconosVector : initial velocity of this DynamicalSystem
- Overload 3:
constructor from initial state and mass, \(Mdv = p\)
- type position:
- param position:
SiconosVector : initial coordinates of this DynamicalSystem :type velocity:
SiconosVector
- Parameters:
velocity – SiconosVector : initial velocity of this DynamicalSystem :type mass:
SiconosMatrix
mass – SiconosMatrix : mass matrix
- Overload 4:
constructor from initial state and mass (plugin) \(Mdv = p\)
- type position:
- param position:
SiconosVector : initial coordinates of this DynamicalSystem :type velocity:
SiconosVector
- Parameters:
velocity – SiconosVector : initial velocity of this DynamicalSystem :type plugin: string
plugin – std::string: plugin path to compute mass matrix
- initRhs(time)[source]#
allocate (if needed) and compute rhs and its jacobian.
- Parameters:
time (float) – of initialization
- initializeNonSmoothInput(level)[source]#
set nonsmooth input to zero
- Parameters:
level (int) – input-level to be initialized.
- computeRhs(time)[source]#
update right-hand side for the current state
- Parameters:
time (float) – of interest
- computeJacobianRhsx(time)[source]#
update \(\nabla_x rhs\) for the current state
- Parameters:
time (float) – of interest
- resetNonSmoothPart(level)[source]#
set nonsmooth part of the rhs (i.e. p) to zero for a given level
- Parameters:
level (int) –
- setRhs(newValue)[source]#
set the value of the right-hand side, \(\dot x\)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setRhsPtr(newPtr)[source]#
set right-hand side, \(\dot x\) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector
- computeForces(time, q, velocity)[source]#
Compute \(F(v,q,t,z)\)
- Parameters:
time (float) – the current time
q (
SiconosVector
) – SP::SiconosVector: pointers on qvelocity (
SiconosVector
) – SP::SiconosVector: pointers on velocity
- computeJacobianqForces(time)[source]#
Compute \(\nabla_qF(v,q,t,z)\) for current \(q,v\) Default function to compute forces
- Parameters:
time (float) – the current time
- computeJacobianqDotForces(time)[source]#
Compute \(\nabla_{\dot q}F(v,q,t,z)\) for current \(q,v\)
- Parameters:
time (float) – the current time
- computeJacobianvForces(time)[source]#
Compute \(\nabla_{\dot q}F(v,q,t,z)\) for current \(q,v\)
- Parameters:
time (float) – the current time
- q()[source]#
generalized coordinates of the system (vector of size dimension())
- Return type:
- Returns:
pointer on a SiconosVector
- setQ(newValue)[source]#
set value of generalized coordinates vector (copy)
- Parameters:
newValue (
SiconosVector
) –
- setQPtr(newPtr)[source]#
set value of generalized coordinates vector (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- setQ0(newValue)[source]#
set initial state (copy)
- Parameters:
newValue (
SiconosVector
) –
- setQ0Ptr(newPtr)[source]#
set initial state (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- velocity()[source]#
get velocity vector (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- setVelocity(newValue)[source]#
set velocity vector (copy)
- Parameters:
newValue (
SiconosVector
) –
- setVelocityPtr(newPtr)[source]#
set velocity vector (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- velocity0()[source]#
get initial velocity (pointer)
- Return type:
- Returns:
pointer on a SiconosVector
- setVelocity0(newValue)[source]#
set initial velocity (copy)
- Parameters:
newValue (
SiconosVector
) –
- setVelocity0Ptr(newPtr)[source]#
set initial velocity (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- acceleration()[source]#
get acceleration (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- setFIntPtr(newPtr)[source]#
set $F_{int}$ (pointer link)
- Parameters:
newPtr (
SiconosVector
) – a SP to plugged vector
- setFExtPtr(newPtr)[source]#
set \(F_{ext}\) , (pointer link)
- Parameters:
newPtr (
SiconosVector
) – a SP to a Simple vector
- setFGyrPtr(newPtr)[source]#
set \(F_{gyr}\) , (pointer link)
- Parameters:
newPtr (
SiconosVector
) – a SP to plugged vector
- jacobianFIntq()[source]#
get \(\nabla_qF_{int}\) , (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- jacobianFIntqDot()[source]#
get \(\nabla_{\dot q}F_{int}\) , (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- setJacobianFIntqPtr(newPtr)[source]#
set \(\nabla_{q}F_{int}\) , (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – a pointer to a SiconosMatrix
- setJacobianFIntqDotPtr(newPtr)[source]#
set \(\nabla_{\dot q}F_{int}\) , (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – a pointer to a SiconosMatrix
- jacobianFGyrq()[source]#
get \(\nabla_{q}F_{gyr}\) , (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- jacobianFGyrqDot()[source]#
get \(\nabla_{\dot q}F_{gyr}\) , (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- setJacobianFGyrqPtr(newPtr)[source]#
get \(\nabla_{q}F_{gyr}\) , (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – a SP SiconosMatrix
- setJacobianFGyrqDotPtr(newPtr)[source]#
get \(\nabla_{\dot q}F_{gyr}\) , (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – a SP SiconosMatrix
- forces()[source]#
get \(F(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- jacobianqForces()[source]#
get \(\nabla_qF(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- jacobianvForces()[source]#
get \(\nabla_{\dot q}F(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- qMemory()[source]#
get all the values of the state vector q stored in memory. note: not const due to SchatzmanPaoliOSI::initializeWorkVectorsForDS
- Return type:
- Returns:
a memory
- velocityMemory()[source]#
get all the values of the state vector velocity stored in memory. note: not const due to SchatzmanPaoliOSI::initializeWorkVectorsForDS
- Return type:
- Returns:
a memory
- pMemory(level)[source]#
get all the values of the state vector p stored in memory
- Parameters:
level (int) –
- Return type:
- Returns:
a memory
- initMemory(size)[source]#
initialize the SiconosMemory objects with a positive size.
- Parameters:
size (int) – the size of the SiconosMemory. must be >= 0
- swapInMemory()[source]#
push the current values of x, q and r in the stored previous values xMemory, qMemory, rMemory, TODO: Modify the function swapIn Memory with the new Object Memory
- setComputeMassFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the mass
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute Mass
- Parameters:
fct (FPtr7) – a pointer on the plugin function
- setComputeFIntFunction(*args)[source]#
Overload 1: allow to set a specified function to compute FInt
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute fInt
- Parameters:
fct (FPtr6) – a pointer on the plugin function
- setComputeFExtFunction(*args)[source]#
Overload 1: allow to set a specified function to compute Fext
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute fExt
- Parameters:
fct (VectorFunctionOfTime) – a pointer on the plugin function
- setComputeFGyrFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the inertia
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute FGyr
- Parameters:
fct (FPtr5) – a pointer on the plugin function
- setComputeJacobianFIntqFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian w.r.t q of the internal forces
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute jacobian following q of the FInt
- Parameters:
fct (FPtr6) – a pointer on the plugin function
- setComputeJacobianFIntqDotFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian of the internal forces w.r.t. q
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute jacobian following qDot of the FInt
- Parameters:
fct (FPtr6) – a pointer on the plugin function
- setComputeJacobianFGyrqFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian w.r.t q of the the external forces
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute the jacobian following q of FGyr
- Parameters:
fct (FPtr5) – a pointer on the plugin function
- setComputeJacobianFGyrqDotFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian w.r.t qDot of the the external strength
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute the jacobian following qDot of FGyr
- Parameters:
fct (FPtr5) – a pointer on the plugin function
- computeMass(*args)[source]#
Overload 1: default function to compute the mass
Overload 2: function to compute the mass
- Parameters:
position (
SiconosVector
) – value used to evaluate the mass matrix
- computeFInt(*args)[source]#
Overload 1: default function to compute the internal strengths
- Parameters:
time (float) – the current time
Overload 2: function to compute the internal strengths with some specific values for position and velocity (ie not those of the current state).
- Parameters:
time (float) – the current time,
position (
SiconosVector
) – value used to evaluate the internal forcesvelocity (
SiconosVector
) – value used to evaluate the internal forces
- computeFExt(time)[source]#
default function to compute the external strengths
- Parameters:
time (float) – the current time
- computeFGyr(*args)[source]#
Overload 1: default function to compute the inertia
Overload 2: function to compute the inertia with some specific values for q and velocity (ie not those of the current state).
- Parameters:
position (
SiconosVector
) – value used to evaluate the inertia forcesvelocity (
SiconosVector
) – value used to evaluate the inertia forces
- computeJacobianFIntq(*args)[source]#
Overload 1: To compute the jacobian w.r.t q of the internal forces
- Parameters:
time (float) – the current time
Overload 2: To compute the jacobian w.r.t q of the internal forces
- Parameters:
time (float) – the current time
position (
SiconosVector
) – value used to evaluate the jacobianvelocity (
SiconosVector
) – value used to evaluate the jacobian
- computeJacobianFIntqDot(*args)[source]#
Overload 1: To compute the jacobian w.r.t qDot of the internal forces
- Parameters:
time (float) – the current time
Overload 2: To compute the jacobian w.r.t. qDot of the internal forces
- Parameters:
time (float) – the current time
position (
SiconosVector
) – value used to evaluate the jacobianvelocity (
SiconosVector
) – value used to evaluate the jacobian
- computeJacobianFGyrq(*args)[source]#
Overload 1: function to compute the jacobian w.r.t. q of the inertia forces
Overload 2: function to compute the jacobian w.r.t. q of the inertia forces
- Parameters:
position (
SiconosVector
) – value used to evaluate the jacobianvelocity (
SiconosVector
) – value used to evaluate the jacobian
- computeJacobianFGyrqDot(*args)[source]#
Overload 1: function to compute the jacobian w.r.t. qDot of the inertia forces
Overload 2: function to compute the jacobian w.r.t. qDot of the inertia forces
- Parameters:
position (
SiconosVector
) – value used to evaluate the jacobianvelocity (
SiconosVector
) – value used to evaluate the jacobian
- updatePlugins(time)[source]#
default function to update the plugins functions using a new time:
- Parameters:
time (float) – the current time
- computePostImpactVelocity()[source]#
Computes post-impact velocity, using pre-impact velocity and impulse (p) value. Used in EventDriven (LsodarOSI->updateState)
- init_generalized_coordinates(level)[source]#
Allocate memory for q[level], level > 1 Useful for some integrators that need q[2] or other coordinates vectors.
- Parameters:
level (int) – the required level
- init_inverse_mass()[source]#
Allocate memory for the lu factorization of the mass of the system. Useful for some integrators with system inversion involving the mass
- class siconos.kernel.LagrangianLinearTIDS(*args)[source]#
Bases:
LagrangianDS
Lagrangian Linear Systems with time invariant coefficients - \(M\dot v + Cv + Kq = F_{ext}(t,z) + p\)
The class LagrangianLinearTIDS allows to define and compute a generic ndof-dimensional Lagrangian Linear Time Invariant Dynamical System of the form:
\[M \ddot q + C \dot q + K q = F_{ext}(t,z) + p,\]where - \(q \in R^{ndof}\) is the set of the generalized coordinates, - \(\dot q \in R^{ndof}\) the velocity, i. e. the time derivative of the generalized coordinates. - \(\ddot q \in R^{ndof}\) the acceleration, i. e. the second time derivative of the generalized coordinates. - \(p \in R^{ndof}\) the forces due to the Non Smooth Interaction. In particular case of Non Smooth evolution, the variable p contains the impulse and not the force. - \(M \in R^{ndof \times ndof}\) is the Mass matrix (access : mass() method). - \(K \in R^{ndof \times ndof}\) is the stiffness matrix (access : K() method). - \(C \in R^{ndof \times ndof}\) is the viscosity matrix (access : C() method). - \(z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discret state.
The equation of motion is also shortly denoted as:
\[M(q,z) \dot v = F(v, q, t, z) + p\]where - \(F(v, q, t, z) \in R^{ndof}\) collects the total forces acting on the system, that is \(F(v, q, t, z) = F_{ext}(t, z) - Cv - Kq\).
This vector is saved and may be accessed using forces() method.
If required (e.g. for Event-Driven like simulation), reformulation 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}rhs(x,t,z) = \left[\begin{array}{c} \dot q \\ \ddot q = M^{-1}\left[F_{ext}(t, z) - C \dot q - K q + p \right] \\ \end{array}\right]\end{split}\]Its jacobian is:
\[\begin{split}\nabla_{x}rhs(x,t) = \left[\begin{array}{cc} 0 & I \\ -M^{-1}K & -M^{-1}C \\ \end{array}\right]\end{split}\]with the input due to the non smooth law:
\[\begin{split}r = \left[\begin{array}{c}0 \\ p \end{array}\right]\end{split}\]Overload 1: default constructor
Overload 2: constructor from initial state and all matrix operators.
- Parameters:
q0 (
SiconosVector
) – initial coordinatesv0 (
SiconosVector
) – initial velocityM (
SiconosMatrix
) – mass matrixK (
SiconosMatrix
) – stiffness matrixC (
SiconosMatrix
) – damping matrix
Overload 3: constructor from initial state and mass matrix only. Leads to \(M\dot v = F_{ext}(t,z) + p\) .
- Parameters:
q0 (
SiconosVector
) – initial coordinatesv0 (
SiconosVector
) – initial velocityM (
SiconosMatrix
) – mass matrix
- initRhs(t)[source]#
allocate (if needed) and compute rhs and its jacobian.
- Parameters:
t (float) – time of initialization
- computeForces(time, q, velocity)[source]#
Compute \(F(v,q,t,z)\)
- Parameters:
time (float) – the current time
q (
SiconosVector
) – SP::SiconosVector: pointers on qvelocity (
SiconosVector
) – SP::SiconosVector: pointers on velocity
- setK(K)[source]#
set (copy) the value of the stiffness matrix
- Parameters:
K (
SiconosMatrix
) – new stiffness matrix
- setKPtr(newPtr)[source]#
set stiffness matrix (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – pointer to the new Stiffness matrix
- setC(C)[source]#
set (copy) the value of the damping matrix
- Parameters:
C (
SiconosMatrix
) – new damping matrix
- setCPtr(newPtr)[source]#
set damping matrix (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – pointer to the new damping matrix
- jacobianqForces()[source]#
get \(\nabla_qF(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- class siconos.kernel.LagrangianLinearDiagonalDS(*args)[source]#
Bases:
LagrangianDS
Lagrangian Linear Systems with time invariant and diagonal coefficients - \(M\dot v + Cv + Kq = F_{ext}(t,z) + p\)
where
\(q \in R^{ndof}\) is the set of the generalized coordinates,
\(\dot q = v \in R^{ndof}\) the velocity, i. e. the time derivative of the generalized coordinates.
\(\ddot q \in R^{ndof}\) the acceleration, i. e. the second time derivative of the generalized coordinates.
\(p \in R^{ndof}\) the forces due to the nonsmooth interaction. In the particular case of a nonsmooth evolution,
the variable p contains the impulse and not the force. - \(M \in R^{ndof \times ndof}\) is the mass matrix (access : mass() method). - \(K \in R^{ndof \times ndof}\) is the stiffness matrix (access : stiffness() method). - \(C \in R^{ndof \times ndof}\) is the viscosity matrix (access : damping() method). - \(z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discret state.
Remind that the specificity of this class is that all matrices are diagonal (and hence only diagonal coefficients are saved in memory).
For details about dynamical systems in Siconos, please read user’s guide.
Overload 1: default constructor
Overload 2: constructor from initial state and all operators.
- Parameters:
q0 (
SiconosVector
) – initial coordinatesv0 (
SiconosVector
) – initial velocitystiffness (
SiconosVector
) – diagonal of the stiffness matrixdamping (
SiconosVector
) – diagonal of the damping matrixmass (
SiconosVector
) – diagonal of the mass matrix
Overload 3: constructor for complete system with identity mass matrix
- Parameters:
q0 (
SiconosVector
) – initial coordinatesv0 (
SiconosVector
) – initial velocitystiffness (
SiconosVector
) – diagonal of the stiffness matrixdamping (
SiconosVector
) – diagonal of the damping matrix
Overload 4: constructor for undamped system and identity mass matrix
- Parameters:
q0 (
SiconosVector
) – initial coordinatesv0 (
SiconosVector
) – initial velocitystiffness (
SiconosVector
) – diagonal of the stiffness matrix
- get_stiffness()[source]#
get a copy of the stiffness matrix (diagonal only)
- Return type:
- Returns:
SiconosVector
- stiffness()[source]#
get stiffness matrix (diagonal only, pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- get_damping()[source]#
get a copy of the damping matrix (diagonal only)
- Return type:
- Returns:
SiconosVector
- damping()[source]#
get damping matrix (diagonal only, pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- initRhs(t)[source]#
allocate (if needed) and compute rhs and its jacobian.
- Parameters:
t (float) – time of initialization
- computeForces(time, q, velocity)[source]#
Compute \(F(v,q,t,z)\)
- Parameters:
time (float) – the current time
q (
SiconosVector
) – generalized coordinatesvelocity (
SiconosVector
) – time derivative of the generalized coordinates
- siconos.kernel.computeExtForceAtPos(q, isMextExpressedInInertialFrame, force, forceAbsRef, pos, posAbsRef, fExt, mExt, accumulate)[source]#
Compute the force and moment vectors applied to a body with state q from a force vector at a given position.
- class siconos.kernel.NewtonEulerDS(*args)[source]#
Bases:
SecondOrderDS
NewtonEuler non linear dynamical systems
The equations of motion in the Newton-Euler formalism can be stated as
\[\begin{split}\left\{\begin{array}{rcl} M \dot v + F_{int}(q,v, \Omega, t)&=& F_{ext}(t), \\ I \dot \Omega + \Omega \wedge I\Omega + M_{int}(q,v, \Omega, t) &=& M_{ext}(t), \\ \dot q &=& T(q) [ v, \Omega] \\ \dot R &=& R \tilde \Omega,\quad R^{-1}=R^T,\quad \det(R)=1 . \end{array}\right.\end{split}\]with
\(x_G,v_G\) position and velocity of the center of mass expressed in a
inertial frame of reference (world frame) - \(\Omega\) angular velocity vector expressed in the body-fixed frame (frame attached to the object) - \(R\) rotation matrix form the inertial frame to the body-fixed frame \(R^{-1}=R^T, \det(R)=1\), i.e \(R\in SO^+(3)\) - \(M=m\,I_{3\times 3}\) diagonal mass matrix with \(m \in \mathbb{R}\) the scalar mass - \(I\) constant inertia matrix - \(F_{ext}\) and \(M_{ext}\) are the external applied forces and moment
In the current implementation, \(R\) is parametrized by a unit quaternion.
Overload 1: Default constructor
Overload 2: constructor from a minimum set of data
- Parameters:
position (
SiconosVector
) – initial coordinates of this DynamicalSystemtwist (
SiconosVector
) – initial twist of this DynamicalSystemmass (float) – the mass
inertia (
SiconosMatrix
) – the inertia matrix
- initRhs(time)[source]#
allocate (if needed) and compute rhs and its jacobian.
- Parameters:
time (float) – of initialization
- initializeNonSmoothInput(level)[source]#
set nonsmooth input to zero
- Parameters:
level (int) – input-level to be initialized.
- computeRhs(time)[source]#
update right-hand side for the current state
- Parameters:
time (float) – of interest
- computeJacobianRhsx(time)[source]#
update \(\nabla_x rhs\) for the current state
- Parameters:
time (float) – of interest
- resetNonSmoothPart(level)[source]#
set nonsmooth part of the rhs (i.e. p) to zero for a given level
- Parameters:
level (int) –
- setQ(newValue)[source]#
set value of generalized coordinates vector (copy)
- Parameters:
newValue (
SiconosVector
) –
- setQPtr(newPtr)[source]#
set value of generalized coordinates vector (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- setQ0(newValue)[source]#
set initial state (copy)
- Parameters:
newValue (
SiconosVector
) –
- setQ0Ptr(newPtr)[source]#
set initial state (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- velocity()[source]#
get twist
- Return type:
- Returns:
pointer on a SiconosVector this accessor is left to get a uniform access to velocity. This should be removed with MechanicalDS class
- velocity0()[source]#
get initial velocity (pointer)
- Return type:
- Returns:
pointer on a SiconosVector
- setVelocity(newValue)[source]#
set velocity (copy)
- Parameters:
newValue (
SiconosVector
) –
- setVelocityPtr(newPtr)[source]#
set velocity (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- setVelocity0(newValue)[source]#
set initial velocity (copy)
- Parameters:
newValue (
SiconosVector
) –
- setVelocity0Ptr(newPtr)[source]#
set initial velocity (pointer link)
- Parameters:
newPtr (
SiconosVector
) –
- acceleration()[source]#
get acceleration (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- computeMass(*args)[source]#
Overload 1: default function to compute the mass
Overload 2: function to compute the mass
- Parameters:
position (
SiconosVector
) – value used to evaluate the mass matrix
- linearVelocity(*args)[source]#
Overload 1: Get the linear velocity in the absolute (inertial) or relative (body) frame of reference.
- Parameters:
absoluteRef (boolean) – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.
- Return type:
- Returns:
A SiconosVector of size 3 containing the linear velocity of this dynamical system.
Overload 2: Fill a SiconosVector with the linear velocity in the absolute (inertial) or relative (body) frame of reference.
- Parameters:
absoluteRef (boolean) – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.
v (
SiconosVector
) – A SiconosVector of size 3 to receive the linear velocity.
- angularVelocity(*args)[source]#
Overload 1: Get the angular velocity in the absolute (inertial) or relative (body) frame of reference.
- Parameters:
absoluteRef (boolean) – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.
- Return type:
- Returns:
A SiconosVector of size 3 containing the angular velocity of this dynamical system.
Overload 2: Fill a SiconosVector with the angular velocity in the absolute (inertial) or relative (body) frame of reference.
- Parameters:
absoluteRef (boolean) – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.
w (
SiconosVector
) – A SiconosVector of size 3 to receive the angular velocity.
- setInertia(*args)[source]#
Overload 1:
Modify the inertia matrix (pointer link)
- Parameters:
newInertia (
SiconosMatrix
) – the new inertia matrix
Overload 2:
Modify the inertia matrix.
- setFExtPtr(newPtr)[source]#
set fExt to pointer newPtr
- Parameters:
newPtr (
SiconosVector
) – a SP to a Simple vector
- setMExtPtr(newPtr)[source]#
set mExt to pointer newPtr
- Parameters:
newPtr (
SiconosVector
) – a SP to a Simple vector
- qMemory()[source]#
get all the values of the state vector q stored in memory
- Return type:
- Returns:
a memory
- twistMemory()[source]#
get all the values of the state vector twist stored in memory
- Return type:
- Returns:
a memory
- velocityMemory()[source]#
get all the values of the state vector twist stored in memory
- Return type:
- Returns:
a memory
- initMemory(steps)[source]#
initialize the SiconosMemory objects with a positive size.
- Parameters:
steps (int) – the size of the SiconosMemory (i)
- swapInMemory()[source]#
push the current values of x, q and r in the stored previous values xMemory, qMemory, rMemory, TODO: Modify the function swapIn Memory with the new Object Memory
- init_inverse_mass()[source]#
Allocate memory for the lu factorization of the mass of the system. Useful for some integrators with system inversion involving the mass
- update_inverse_mass()[source]#
Update the content of the lu factorization of the mass of the system, if required.
- setComputeFExtFunction(*args)[source]#
Overload 1: allow to set a specified function to compute _fExt
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the name of the function to use in this plugin
Overload 2: set a specified function to compute _fExt
- Parameters:
fct (void) – a pointer on the plugin function
- setComputeMExtFunction(*args)[source]#
Overload 1: allow to set a specified function to compute _mExt
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the name of the function to use in this plugin
Overload 2: set a specified function to compute _mExt
- Parameters:
fct (void) – a pointer on the plugin function
- setComputeFIntFunction(*args)[source]#
Overload 1: allow to set a specified function to compute _fInt
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the name of the function to use in this plugin
Overload 2: set a specified function to compute _fInt
- Parameters:
fct (void) – a pointer on the plugin function
- setComputeMIntFunction(*args)[source]#
Overload 1: allow to set a specified function to compute _mInt
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the name of the function to use in this plugin
Overload 2: set a specified function to compute _mInt
- Parameters:
fct (void) – a pointer on the plugin function
- setComputeJacobianFIntqFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian w.r.t q of the internal forces
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute jacobian following q of the FInt
- Parameters:
fct (void) – a pointer on the plugin function
- setComputeJacobianFIntvFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian following v of the internal forces w.r.t.
- Parameters:
pluginPath: – the complete path to the plugin
functionName: – the name of the function to use in this plugin
Overload 2: set a specified function to compute jacobian following v of the FInt
- Parameters:
fct (void) – a pointer on the plugin function
- setComputeJacobianMIntqFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian w.r.t q of the internal forces
- Parameters:
pluginPath: – the complete path to the plugin
functionName: – the name of the function to use in this plugin
Overload 2: set a specified function to compute jacobian following q of the FInt
- Parameters:
fct (void) – a pointer on the plugin function
- setComputeJacobianMIntvFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian following v of the internal forces w.r.t.
- Parameters:
pluginPath: – the complete path to the plugin
functionName: – the name of the function to use in this plugin
Overload 2: set a specified function to compute jacobian following v of the FInt
- Parameters:
fct (void) – a pointer on the plugin function
- computeFExt(*args)[source]#
Overload 1: function to compute the external forces
- Parameters:
time (float) – the current time
Overload 2: default function to compute the external forces
- Parameters:
time (float) – the current time
fExt (
SiconosVector
) – the computed external force (in-out param)
- addExtForceAtPos(*args)[source]#
Adds a force/torque impulse to a body’s FExt and MExt vectors in either absolute (inertial) or relative (body) frame. Modifies contents of _fExt and _mExt! Therefore these must have been set as constant vectors using setFExtPtr and setMExtPtr prior to calling this function. Adjustments to _mExt will take into account the value of _isMextExpressedInInertialFrame.
- Parameters:
force (
SiconosVector
) – A force vector to be added.forceAbsRef (boolean) – If true, force is in inertial frame, otherwise it is in body frame.
pos (
SiconosVector
, optional) – A position at which force should be applied. If nullptr, the center of mass is assumed.posAbsRef (boolean, optional) – If true, pos is in inertial frame, otherwise it is in body frame.
- computeFInt(*args)[source]#
Overload 1: default function to compute the internal forces
- Parameters:
time (float) – the current time function to compute the internal forces
time – the current time
q (
SiconosVector
) –v (
SiconosVector
) –
Overload 2: default function to compute the internal forces
- Parameters:
time (float) – the current time
q (
SiconosVector
) –v (
SiconosVector
) –fInt (
SiconosVector
) – the computed internal force vector
- computeMInt(*args)[source]#
Overload 1: default function to compute the internal moments
- Parameters:
time (float) – the current time
q (
SiconosVector
) –v (
SiconosVector
) –
Overload 2: default function to compute the internal moments
- Parameters:
time (float) – the current time
q (
SiconosVector
) –v (
SiconosVector
) –mInt (
SiconosVector
) – the computed internal moment vector
- updatePlugins(time)[source]#
default function to update the plugins functions using a new time:
- Parameters:
time (float) – the current time
- computeForces(*args)[source]#
- Overload 1:
Default function to compute forces
- type time:
float
- param time:
double, the current time
- Overload 2:
function to compute forces with some specific values for q and twist (ie not those of the current state). :type time: float
- Parameters:
time –
double : the current time
- type q:
- param q:
SP::SiconosVector: pointers on q
- type twist:
- param twist:
SP::SiconosVector: pointers on twist
- computeJacobianqForces(time)[source]#
Default function to compute the jacobian w.r.t. q of forces
- Parameters:
time (float) – double, the current time
- computeJacobianvForces(time)[source]#
Default function to compute the jacobian w.r.t. v of forces
- Parameters:
time (float) – double, the current time
- computeMGyr(*args)[source]#
Overload 1: function to compute gyroscopic forces with some specific values for q and twist (ie not those of the current state).
- Parameters:
twist (
SiconosVector
) – SP::SiconosVector: pointers on twist vector
Overload 2: function to compute gyroscopic forces with some specific values for q and twist (ie not those of the current state).
- Parameters:
twist (
SiconosVector
) – pointer to twist vectormGyr (
SiconosVector
) – pointer to gyroscopic forces
- computeJacobianMGyrtwist(time)[source]#
Default function to compute the jacobian following q of mGyr
- Parameters:
time (float) – the current time
- computeJacobianMGyrtwistByFD(time, q, twist)[source]#
Default function to compute the jacobian following q of mGyr by forward finite difference
- Parameters:
time (float) – the current time
q (
SiconosVector
) – current statetwist (
SiconosVector
) – pointer to twist vector
- computeJacobianFIntq(*args)[source]#
Overload 1: To compute the jacobian w.r.t q of the internal forces
- Parameters:
time (float) – double : the current time
Overload 2: To compute the jacobian w.r.t q of the internal forces
- Parameters:
time (float) – double
position (
SiconosVector
) – SP::SiconosVectortwist (
SiconosVector
) – SP::SiconosVector
- computeJacobianFIntqByFD(time, position, twist)[source]#
To compute the jacobian w.r.t q of the internal forces by forward finite difference
- Parameters:
time (float) – double
position (
SiconosVector
) – SP::SiconosVectortwist (
SiconosVector
) – SP::SiconosVector
- computeJacobianFIntv(*args)[source]#
Overload 1: To compute the jacobian w.r.t v of the internal forces
- Parameters:
time (float) – double : the current time
Overload 2: To compute the jacobian w.r.t. v of the internal forces
- Parameters:
time (float) – double: the current time
position (
SiconosVector
) – SP::SiconosVectortwist (
SiconosVector
) – SP::SiconosVector
- computeJacobianFIntvByFD(time, position, twist)[source]#
To compute the jacobian w.r.t v of the internal forces by forward finite difference
- Parameters:
time (float) – double
position (
SiconosVector
) – SP::SiconosVectortwist (
SiconosVector
) – SP::SiconosVector
- computeJacobianMIntq(*args)[source]#
Overload 1: To compute the jacobian w.r.t q of the internal forces
- Parameters:
time (float) – double : the current time
Overload 2: To compute the jacobian w.r.t q of the internal forces
- Parameters:
time (float) – double : the current time,
position (
SiconosVector
) – SP::SiconosVectortwist (
SiconosVector
) – SP::SiconosVector
- computeJacobianMIntqByFD(time, position, twist)[source]#
To compute the jacobian w.r.t q of the internal moments by forward finite difference
- Parameters:
time (float) – double
position (
SiconosVector
) – SP::SiconosVectortwist (
SiconosVector
) – SP::SiconosVector
- computeJacobianMIntv(*args)[source]#
Overload 1: To compute the jacobian w.r.t v of the internal forces
- Parameters:
time (float) – double : the current time
Overload 2: To compute the jacobian w.r.t. v of the internal forces
- Parameters:
time (float) – double: the current time
position (
SiconosVector
) – SP::SiconosVectortwist (
SiconosVector
) – SP::SiconosVector
- computeJacobianMIntvByFD(time, position, twist)[source]#
To compute the jacobian w.r.t v of the internal moments by forward finite difference
- Parameters:
time (float) – double
position (
SiconosVector
) – SP::SiconosVectortwist (
SiconosVector
) – SP::SiconosVector
- class siconos.kernel.FirstOrderNonLinearDS(*args)[source]#
Bases:
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)\)
Overload 1: default constructor
Overload 2: constructor from initial state, leads to \(\dot x = r\)
- Parameters:
newX0 (
SiconosVector
) – initial state
Warning: you need to set explicitely the plugin for f and its jacobian if needed (e.g. if used with an EventDriven scheme)
Overload 3: constructor from initial state and f (plugins), \(\dot x = f(x, t, z) + r\)
- Parameters:
newX0 (
SiconosVector
) – initial statefPlugin (string) – name of the plugin function to be used for f(x,t,z)
jacobianfxPlugin (string) – name of the plugin to be used for the jacobian of f(x,t,z)
Overload 4: Copy constructor
- Parameters:
FONLDS (
FirstOrderNonLinearDS
) – the FirstOrderNonLinearDS to copy
- initRhs(time)[source]#
allocate (if needed) and compute rhs and its jacobian.
- Parameters:
time (float) – of initialization
- initializeNonSmoothInput(level)[source]#
set nonsmooth input to zero
- Parameters:
level (int) – input-level to be initialized.
- computeRhs(time)[source]#
update right-hand side for the current state
- Parameters:
time (float) – of interest
- computeJacobianRhsx(time)[source]#
update \(\nabla_x rhs\) for the current state
- Parameters:
time (float) – of interest
- resetNonSmoothPart(level)[source]#
set nonsmooth part of the rhs (i.e. r) to zero for a given level
- Parameters:
level (int) –
- setMPtr(newM)[source]#
set M, matrix coeff of left-hand side (pointer link)
- Parameters:
newM (
SiconosMatrix
) – the new M matrix
- getInvM()[source]#
get a copy of the LU factorisation of M operator
- Return type:
- Returns:
SimpleMatrix
- invM()[source]#
get the inverse of LU fact. of M operator (pointer link)
- Return type:
- Returns:
pointer to a SiconosMatrix
- setFPtr(newPtr)[source]#
set f(x,t,z) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – a SP::SiconosVector
- jacobianfx()[source]#
get jacobian of f(x,t,z) with respect to x (pointer link)
- Return type:
- Returns:
SP::SiconosMatrix
- setJacobianfxPtr(newPtr)[source]#
set jacobian of f(x,t,z) with respect to x (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – the new value
- rMemory()[source]#
get all the values of the state vector r stored in memory
- Return type:
- Returns:
a memory vector
- initMemory(steps)[source]#
- initialize the SiconosMemory objects: reserve memory for i
vectors in memory and reset all to zero.
- type steps:
int
- param steps:
the size of the SiconosMemory (i)
- swapInMemory()[source]#
push the current values of x and r in memory (index 0 of memory is the last inserted vector) xMemory and rMemory,
- updatePlugins(time)[source]#
Call all plugged-function to initialize plugged-object values
- Parameters:
time (float) – value
- setComputeMFunction(*args)[source]#
Overload 1: to set a specified function to compute M
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – function name to use in this library
Overload 2: set a specified function to compute M
- Parameters:
fct (FPtr1) – a pointer on the plugin function
- setComputeFFunction(*args)[source]#
Overload 1: to set a specified function to compute f(x,t)
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this library
Overload 2: set a specified function to compute the vector f
- Parameters:
fct (FPtr1) – a pointer on the plugin function
- setComputeJacobianfxFunction(*args)[source]#
Overload 1: to set a specified function to compute jacobianfx
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – function name to use in this library
Overload 2: set a specified function to compute jacobianfx
- Parameters:
fct (FPtr1) – a pointer on the plugin function
- computeM(time)[source]#
Default function to compute \(M: (x,t)\)
- Parameters:
time (float) – time instant used in the computations
- computef(time, state)[source]#
Default function to compute \(f: (x,t)\)
- Parameters:
time (float) – time instant used in the computations function to compute \(f: (x,t)\)
time – time instant used in the computations
state (
SiconosVector
) – x value
- computeJacobianfx(time, state)[source]#
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 (float) – instant used in the computations
state (
SiconosVector
) – a SiconosVector to store the resuting value
- class siconos.kernel.FirstOrderLinearDS(*args)[source]#
Bases:
FirstOrderNonLinearDS
First Order Linear Systems - \(M(t) \dot x = A(t)x(t)+ b(t) + r, \quad x(t_0)=x_0\).
This class represents first order linear systems of the form:
\[M(t) \dot x = A(t)x(t)+ b(t) + r, x(t_0)=x_0\]where
\(x \in R^{n}\) is the state,
\(r \in R^{n}\) the input due to the Non Smooth Interaction.
\(M \in R^{n\times n}\) is an invertible matrix
\(A \in R^{n\times n}\)
\(b \in R^{n}\)
The following operators can be plugged, in the usual way (see User Guide)
\(A(t)\)
\(b(t)\)
\(M(t)\)
Overload 1: default constructor
Overload 2: constructor from initial state and plugins
- Parameters:
newX0 (
SiconosVector
) – the initial state of this DynamicalSystemAPlugin (string) – plugin for A
bPlugin (string) – plugin for b
Overload 3: constructor from initial state and plugin for A
- Parameters:
newX0 (
SiconosVector
) – the initial state of this DynamicalSystemnewA (
SiconosMatrix
) – matrix A
Overload 4: constructor from initial state
- Parameters:
newX0 (
SiconosVector
) – the initial state of this DynamicalSystem
Overload 5: constructor from a initial state and constant matrices
- Parameters:
newX0 (
SiconosVector
) – the initial state of this DynamicalSystemnewA (
SiconosMatrix
) – matrix AnewB (
SiconosVector
) – b
Overload 6: Copy constructor
- Parameters:
FOLDS (
FirstOrderLinearDS
) – the original FirstOrderLinearDS we want to copy
- initRhs(time)[source]#
Initialization function for the rhs and its jacobian.
- Parameters:
time (float) – time of initialization.
- computeRhs(time)[source]#
update right-hand side for the current state
- Parameters:
time (float) – of interest
- computeJacobianRhsx(time)[source]#
update \(\nabla_x rhs\) for the current state
- Parameters:
time (float) – of interest
- jacobianfx()[source]#
get jacobian of f(x,t,z) with respect to x (pointer link)
- Return type:
- Returns:
SP::SiconosMatrix
- setAPtr(newA)[source]#
set A to pointer newPtr
- Parameters:
newA (
SiconosMatrix
) – the new A matrix
- setA(newA)[source]#
set A to a new matrix
- Parameters:
newA (
SiconosMatrix
) – the new A matrix
- setbPtr(b)[source]#
set b vector (pointer link)
- Parameters:
b (
SiconosVector
) – a SiconosVector
- setb(b)[source]#
set b vector (copy)
- Parameters:
b (
SiconosVector
) – a SiconosVector
- updatePlugins(time)[source]#
Call all plugged-function to initialize plugged-object values
- Parameters:
time (float) – value
- setComputeAFunction(*args)[source]#
Overload 1: set a specified function to compute the matrix A => same action as setComputeJacobianfxFunction
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
Overload 2: set a specified function to compute the matrix A
- Parameters:
fct (void) – a pointer on a function
- setComputebFunction(*args)[source]#
Overload 1: set a specified function to compute the vector b
- Parameters:
pluginPath (string) – the complete path to the plugin file
functionName (string) – the function name to use in this plugin
Overload 2: set a specified function to compute the vector b
- Parameters:
fct (void) – a pointer on a function
- computeA(time)[source]#
default function to compute matrix A => same action as computeJacobianfx
- Parameters:
time (float) – time instant used to compute A
- computeb(time)[source]#
default function to compute vector b
- Parameters:
time (float) – time instant used to compute b
- setPluginA(newPluginA)[source]#
Set _pluginA
- Parameters:
newPluginA (SP::PluggedObject) – the new plugin
- class siconos.kernel.FirstOrderLinearTIDS(*args)[source]#
Bases:
FirstOrderLinearDS
First order linear and time-invariant coeff systems - \(M \dot x = Ax(t)+ b + r, x(t_0)=x_0\) .
This class represents first order linear systems of the form:
\[M\dot x(t) = A x(t) + b + r, x(t_0)=x_0\]where - \(x \in R^{n}\) is the state, - \(r \in R^{n}\) the input due to the Non Smooth Interaction. - \(M \in R^{n\times n}\) is a constant invertible matrix - \(A \in R^{n\times n}\) - \(b \in R^{n}\)
No plugged operators for this class.
Overload 1: initial state and constant A matrix
- Parameters:
x0 (
SiconosVector
) – the initial state vectorA (
SiconosMatrix
) – the A matrix
Overload 2: initial state, constant A matrix, constant b vector
- Parameters:
x0 (
SiconosVector
) – the initial state vectorA (
SiconosMatrix
) – matrixb (
SiconosVector
) – vector
Overload 3: Copy constructor
- Parameters:
FOLTIDS (
FirstOrderLinearTIDS
) – the FirstOrderLinearTIDS to copy
- initRhs(time)[source]#
Initialization function for the rhs and its jacobian.
- Parameters:
time (float) – of initialization.
- computeRhs(time)[source]#
Default function to the right-hand side term
- Parameters:
time (float) – current time
- class siconos.kernel.Relation(*args)[source]#
Bases:
object
General Non Linear Relation (Abstract Base class for Relations).
The present class is an interface to all relations and provides tools to define and describe them.
A relation is a link between global variables of the Dynamical Systems and some local ones, named y and lambda; belonging to one and only one Interaction.
All relations are specified by their type (First order or Lagrangian) accessed by getType() and their sub-type (linear, scleronomous …), returned by getSubType().
A relation provides functions to compute:
a function computeOutput() that updates y using dynamical systems global
variables, - a function computeInput() that updates non-smooth dynamical systems parts (e.g. r or p) using \(\lambda\) .
- setComputehFunction(pluginPath, functionName)[source]#
To set a plug-in function to compute output function h
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- setComputeJachxFunction(pluginPath, functionName)[source]#
To set a plug-in function to compute \(\nabla_x h(..)\)
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- setComputeJachzFunction(pluginPath, functionName)[source]#
To set a plug-in function to compute \(\nabla_z h(..)\)
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- setComputeJachlambdaFunction(pluginPath, functionName)[source]#
To set a plug-in function to compute \(\nabla_{\lambda} h(..)\)
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- setComputegFunction(pluginPath, functionName)[source]#
To set a plug-in function to compute input function g
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- setComputeFFunction(pluginPath, functionName)[source]#
To set a plug-in function to compute input function F
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- setComputeEFunction(pluginPath, functionName)[source]#
To set a plug-in function to compute input function E
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- setComputeJacgxFunction(pluginPath, functionName)[source]#
To set a plug-in function to compute the jacobian of \(g\) w.r.t. x
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- setComputeJacglambdaFunction(pluginPath, functionName)[source]#
To set a plug-in function to compute the jacobian of \(g\) w.r.t. \(\lambda\)
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- initialize(inter)[source]#
initialize the relation (check sizes, memory allocation …)
- Parameters:
inter (
Interaction
) – the interaction using this relation
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- computeJach(time, inter)[source]#
compute all the H Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relation
- computeJacg(time, inter)[source]#
compute all the G Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relationinterProp –
- computeOutput(time, inter, derivativeNumber=0)[source]#
default function to compute y
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relationderivativeNumber (int, optional) – number of the derivative to compute (optional, default = 0)
- computeInput(time, inter, level=0)[source]#
default function to compute r
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relationlevel (int, optional) – the input “derivative” order of lambda used to compute input
- requireResidu()[source]#
return true if the relation requires the computation of residu
- Return type:
boolean
- Returns:
true if residu are required, false otherwise
- getPluginh()[source]#
Get _pluginh
- Return type:
SP::PluggedObject
- Returns:
a shared pointer to the plugin
- getPluginJachx()[source]#
Get _pluginJachx
- Return type:
SP::PluggedObject
- Returns:
a shared pointer to the plugin
- getPluginJachlambda()[source]#
Get _pluginJachlambda
- Return type:
SP::PluggedObject
- Returns:
a shared pointer to the plugin
- getPluging()[source]#
Get _pluging
- Return type:
SP::PluggedObject
- Returns:
a shared pointer to the plugin
- getPluginJacLg()[source]#
Get _pluginJacglambda
- Return type:
SP::PluggedObject
- Returns:
a shared pointer to the plugin
- class siconos.kernel.LagrangianR(lagType)[source]#
Bases:
Relation
Lagrangian Non Linear Relation (generic interface)
This class is an interface for specific Lagrangian Relations used for Lagrangian dynamical systems.
\(y = h(t,q,\dot q,\ldots)\) describes the constraint (the relation)
The Jacobian of the constraints with respect to the coodinates \(q\)
i.e. \(\nabla^T_q h(t,q,\dot q,\ldots)\) , is accessed with jachq().
This Jacobian is mainly used for Newton linearization and to compute the time-derivative of the constraint,
\(y = h(q,\ldots)\) that is \(\dot y (t) = \nabla^T_q h(t,q,\dot q,\ldots) (q) \dot q +\ldots\)
This object can also store more general linearized part of the gap function. If \(y=h(q)\) models a gap function, then the time derivative can be generically written as
\(\dot y (t) = H(q,\ldots) \dot q +\ldots.\) The matrix \(H(q,\ldots)\) can also be accessed using jachq().
The Jacobian of the constraints with respect to the generalized velocities \(\dot q\)
i.e. \(\nabla^\top_{\dot q} h(t,q,\dot q,\ldots)\) is accessed using jachqDot().
The time-derivative of Jacobian of the constraints with respect to the generalized coordinates \(q\)
i.e. \(\frac{d}{dt} \nabla^\top_{q} h(t,q,\dot q,\ldots).\) , is accessed using dotJachq().
This value is useful to compute the second-order time–derivative of the constraints with respect to time.
All these operators can be defined with user-defined plugins.
basic constructor
- Parameters:
lagType (int) – the sub-type of the relation
- initialize(inter)[source]#
initialize the relation (check sizes, memory allocation …)
- Parameters:
inter (
Interaction
) – the interaction using this relation
- jachq()[source]#
get a pointer on matrix Jach[index]
- Return type:
- Returns:
a pointer on a SimpleMatrix
- setJachqPtr(newPtr)[source]#
set Jach[index] to pointer newPtr (pointer link)
- Parameters:
newPtr (
SimpleMatrix
) – the new matrix
- class siconos.kernel.LagrangianLinearTIR(*args)[source]#
Bases:
LagrangianR
Lagrangian Linear Relation.
Lagrangian Relation with:
\(y= Cq + e + Fz\)
\(p = C^t \lambda\)
C is the only required input to built a LagrangianLinearTIR.
Overload 1: Default constructor
Overload 2: create the Relation from a set of data
- Parameters:
C (
SimpleMatrix
) – the matrix C
Overload 3: create the Relation from a set of data
- Parameters:
C (
SimpleMatrix
) – the matrix CF (
SimpleMatrix
) – the matrix Fe (
SiconosVector
) – the vector e
Overload 4: create the Relation from a set of data
- Parameters:
C (
SimpleMatrix
) – the matrix Ce (
SiconosVector
) – the vector e
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- computeOutput(time, inter, derivativeNumber=0)[source]#
default function to compute y
- Parameters:
time (float) – not used
inter (
Interaction
) – the Interaction we want to updatederivativeNumber (int, optional) – the derivative of y we want to compute
- computeInput(time, inter, level=0)[source]#
default function to compute r
- Parameters:
time (float) – not used
inter (
Interaction
) – the Interaction we want to updatelevel (int, optional) – the derivative of lambda we want to compute
- computeJach(time, inter)[source]#
compute all the H Jacobian
- Parameters:
time (float) – not used
inter (
Interaction
) – the Interaction we want to updateinterProp – interaction properties
- computeJacg(time, inter)[source]#
compute all the G Jacobian
- Parameters:
time (float) – not used
inter (
Interaction
) – the Interaction we want to updateinterProp – interaction properties
- setCPtr(newPtr)[source]#
set C to pointer newPtr
- Parameters:
newPtr (
SimpleMatrix
) – a SP to plugged matrix
- setDPtr(newPtr)[source]#
set D to pointer newPtr
- Parameters:
newPtr (
SimpleMatrix
) – a SP to plugged matrix
- setFPtr(newPtr)[source]#
set F to pointer newPtr
- Parameters:
newPtr (
SimpleMatrix
) – a SP to plugged matrix
- setEPtr(newPtr)[source]#
set e to pointer newPtr
- Parameters:
newPtr (
SiconosVector
) – a SP to plugged vector
- class siconos.kernel.LagrangianRheonomousR(*args)[source]#
Bases:
LagrangianR
Lagrangian (Non Linear) Rheonomous Relation
This class provides tools to describe non linear relation of the type:
\[\begin{split}y = h(q,t,z) \\ \dot y = \nabla^\top_q(q,t,z)\dot q + \frac{\partial }{\partial t}h(q,t,z) \\\end{split}\]or more generally
\[\dot y = H(q,t,z)\dot q + \frac{\partial }{\partial t}h(q,t,z)\]and by duality
\[p = H^\top(q,t,z)\lambda\]The following operators (and their jacobians) can be plugged, in the usual way (see User Guide, ‘User-defined plugins’)
\(h(q,t,z)\)
\(\nabla_q h(q,t,z)\)
\(\dot h(q,t,z)\)
The plugin functions must fit with the following signature (FPtr4):
void func(unsigned int qsize, double* q, double time, unsigned int ysize, double* buffer , unsigned int sizez, double* z)
buffer being either \(y\) , \(\dot h\) or \(\nabla_qh\) .
Overload 1: default constructor
Overload 2: constructor from a set of data
- Parameters:
pluginh (string) – name of the plugin to compute h. Its signature must be “void userPluginH(unsigned int, double*, double, unsigned int, double*, unsigned int, double*)”
pluginJacobianhq (string) – name of the plugin to compute jacobian h according to q. Its signature must be “void userPluginG0(unsigned int, double*, double, unsigned int, double*, unsigned int, double*)”
pluginDoth (string) – name of the plugin to compute hDot. Its signature must be “void userPluginHDot(unsigned int, double*,double, unsigned int, double*, unsigned int, double*)
- initialize(inter)[source]#
initialize G matrices or components specific to derived classes.
- Parameters:
inter (
Interaction
) – the Interaction
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- hDot()[source]#
get a pointer on vector hDot
- Return type:
- Returns:
a smart pointer on a SiconosVector
- setComputehDotFunction(pluginpath, name)[source]#
to set a specified function to compute function hDot
- Parameters:
pluginpath (string) – the complete path to the plugin
name (string) – the name of the function to use in this plugin
- computeh(time, q, z, y)[source]#
to compute the output y = h(t,q,z) of the Relation
- Parameters:
time (float) – current time value
q (
BlockVector
) – coordinates of the dynamical systems involved in the relationz (
BlockVector
) – user defined parameters (optional)y (
SiconosVector
) – the resulting vector
- computehDot(time, q, z)[source]#
to compute the time-derivative of the output y = h(t,q,z), saved in attribute _hDot (access: hDot())
- Parameters:
time (float) – current time value
q (
BlockVector
) – coordinates of the dynamical systems involved in the relationz (
BlockVector
) – user defined parameters (optional)
- computeJachq(time, q, z)[source]#
to compute the jacobian of h(…). Set attribute _jachq (access: jacqhq())
- Parameters:
time (float) – current time value
q (
BlockVector
) – coordinates of the dynamical systems involved in the relationz (
BlockVector
) – user defined parameters (optional)
- computeOutput(time, inter, derivativeNumber=0)[source]#
to compute output
- Parameters:
time (float) – current time
inter (
Interaction
) – the InteractionderivativeNumber (int, optional) – number of the derivative to compute, optional, default = 0.
- computeInput(time, inter, level=0)[source]#
to compute p
- Parameters:
time (float) – current time
inter (
Interaction
) – the Interactionlevel (int, optional) – “derivative” order of lambda used to compute input
- class siconos.kernel.LagrangianScleronomousR(*args)[source]#
Bases:
LagrangianR
Scleronomic Lagrangian (Non Linear) Relations
\[y = h(q,z)\]\[\dot y = \nabla^\top_q h(q,z) \dot q\]or more generally
\[\dot y = H(q,z) \dot q\]and by duality
\[p = \nabla_q h(q,z)\lambda\]or more generally
\[p = H^\top(q,z)\lambda\]with
\[H^\top(q,z) = \nabla_q h(q,z)\]is the pure Lagrangian setting.
y (or its discrete approximation) is stored in y[0] \(\dot y\) (or its discrete approximation) is stored in y[1] higher level y[i] can be used for storing higher levels of derivatives.
Jacobians and h are connected to plug-in functions.
The plugin function to compute h(q,z) needs the following parameters:
–> sizeQ: size of q = sum of the sizes of all the DynamicalSystems involved in the interaction
–> q : pointer to the first element of q
–> sizeY : size of vector y (ie of the interaction)
–> [in,out] y : pointer to the first element of y
–> sizeZ : size of vector z
–> [in,out] z: pointer to z vector(s) from DS.
Its signature must be “void plugin(unsigned int, double*, unsigned int, double*, unsigned int, double*)”
The plugin function to compute G0(q,z), gradient of h according to q, needs the following parameters:
–> sizeQ: size of q = sum of the sizes of all the DynamicalSystems involved in the interaction
–> q : pointer to the first element of q
–> sizeY : size of vector y (ie of the intercation)
–> [in,out] H : pointer to the first element of H (sizeY X sizeDS matrix)
–> sizeZ : size of vector z
–>[in,out] z: pointer to z vector(s) from DS.
Its signature must be “void plugin(unsigned int, double*, unsigned int, double*, unsigned int, double*)”
Overload 1: basic constructor
Overload 2: constructor from a set of data
- Parameters:
pluginh (string) – the name of the plugin to compute h(q,z). The signature of the plugged function must be: “void pluginH(unsigned int, double*, unsigned int, double*, unsigned int, double*)”
pluginJacobianhq (string) – the name of the plugin to compute jacobian h according to q. The signature of the plugged function must be: “void pluginG0(unsigned int, double*, unsigned int, double*, unsigned int, double*)”
Overload 3: constructor from a set of data used for EventDriven Scheme
- Parameters:
pluginh (string) – the name of the plugin to compute h(q,z). The signature of the plugged function must be: “void pluginH(unsigned int, double*, unsigned int, double*, unsigned int, double*)”
pluginJacobianhq (string) – the name of the plugin to compute jacobian h according to q. The signature of the plugged function must be: “void pluginG0(unsigned int, double*, unsigned int, double*, unsigned int, double*)”
pluginDotJacobianhq (string) – the name of the plugin to compute the derivative of H Jacobian with respect to time The signature of the plugged function must be: “void pluginS0(unsigned int, double*,unsigned int, double*, unsigned int, double*, unsigned int, double*)”
- initialize(inter)[source]#
initialize the relation (check sizes, memory allocation …)
- Parameters:
inter (
Interaction
) – the interaction using this relation
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- dotjacqhXqdot()[source]#
- Return type:
- Returns:
the product of the time–derivative of Jacobian with the velocity qdot
- computeh(q, z, y)[source]#
to compute the output y = h(q,z) of the Relation
- Parameters:
q (
BlockVector
) – coordinates of the dynamical systems involved in the relationz (
BlockVector
) – user defined parameters (optional)y (
SiconosVector
) – the resulting vector
- computeJachq(q, z)[source]#
to compute the jacobian of h(…). Set attribute _jachq (access: jacqhq())
- Parameters:
q (
BlockVector
) – coordinates of the dynamical systems involved in the relationz (
BlockVector
) – user defined parameters (optional)
- computeDotJachq(q, z, qDot)[source]#
to compute the time derivative of the Jacobian. Result in _dotjachq (access: dotjachq())
- Parameters:
q (
BlockVector
) – coordinates of the dynamical systems involved in the relationz (
BlockVector
) – user defined parameters (optional)time – derivatives of q
- computedotjacqhXqdot(time, inter, DSlink)[source]#
to compute the product of the time–derivative of Jacobian with the velocity qdot
- Parameters:
time (float) – double, current time
inter (
Interaction
) – interactionDSlink (
VectorOfBlockVectors
) –
- computeJach(time, inter)[source]#
compute all the H Jacobian
- Parameters:
time (float) – double, current time
inter (
Interaction
) – interaction that owns the relationinterProp –
- computeJacg(time, inter)[source]#
compute all the G Jacobian
- Parameters:
time (float) – double, current time
inter (
Interaction
) – interaction that owns the relationinterProp –
- computeOutput(time, inter, derivativeNumber=0)[source]#
to compute output
- Parameters:
time (float) – the current time
inter (
Interaction
) – interaction that owns the relationderivativeNumber (int, optional) – number of the derivative to compute, optional, default = 0.
- computeInput(time, inter, level=0)[source]#
to compute p
- Parameters:
time (float) – the current time
inter (
Interaction
) – interaction that owns the relationlevel (int, optional) – “derivative” order of lambda used to compute input
- class siconos.kernel.LagrangianCompliantR(*args)[source]#
Bases:
LagrangianR
Lagrangian Compliant Relation: Scleronomous, Non-Holonomic (function of lambda)
\(Y[0] = y = h(q,\lambda(t),z)\)
\(Y[1] = \dot y = G0(q,\lambda(t),z)\dot q + G1((q,\lambda(t),z)\dot\lambda(t)\)
\(p = G0^t(q,\lambda(t),z)\lambda(t)\)
with \(G0(q,\lambda(t),z) = \nabla_q h(q,\lambda(t),z)\)
\(G1(q,\lambda(t),z) = \nabla_{\lambda}h(q,\lambda(t),z)\)
h, G0 and G1 are connected to user-defined functions.
Overload 1: default constructor
Overload 2: constructor from a set of data
- Parameters:
pluginh (string) – the name of the plugin to compute h
pluginJacobianhq (string) – the name of the plugin to compute the gradient of h w.r.t q
pluginJacobianhlambda (string) – the name of the plugin to compute the gradient of h w.r.t \(\lambda\)
- initialize(inter)[source]#
initialize G matrices or components specific to derived classes
- Parameters:
inter (
Interaction
) – : the Interaction
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- computeh(time, q, lambda_, z, y)[source]#
to compute the output y = h(q,z) of the Relation
- Parameters:
time (float) – current time value
q (
BlockVector
) – coordinates of the dynamical systems involved in the relationlambda (
SiconosVector
) – interaction \(\lambda\) vectorz (
BlockVector
) – user defined parameters (optional)y (
SiconosVector
) – the resulting vector
- computeJachq(time, q, lambda_, z)[source]#
to compute the jacobian of h(…). Set attribute _jachq (access: jacqhq())
- Parameters:
time (float) – current time value
q (
BlockVector
) – coordinates of the dynamical systems involved in the relationlambda (
SiconosVector
) – interaction \(\lambda\) vectorz (
BlockVector
) – user defined parameters (optional)
- computeJachlambda(time, q0, lambda_, z)[source]#
compute the jacobian of h w.r.t. \(\lambda\) . Set attribute _jachlambda (access: jacqhlambda())
- Parameters:
time (float) – current time value
q – coordinates of the dynamical systems involved in the relation
lambda (
SiconosVector
) – interaction \(\lambda\) vectorz (
BlockVector
) – user defined parameters
- computeOutput(time, inter, derivativeNumber=0)[source]#
to compute output
- Parameters:
time (float) – the current time
inter (
Interaction
) – the Interaction owning yderivativeNumber (int, optional) – the number of the derivative to compute, optional, default = 0.
- computeInput(time, inter, level=0)[source]#
to compute the input
- Parameters:
time (float) – the current time
inter (
Interaction
) – the Interaction owning lambdalevel (int, optional) – “derivative” order of lambda used to compute input
- class siconos.kernel.NewtonEulerR(*args)[source]#
Bases:
Relation
NewtonEuler (Non Linear) Relation (generic interface)
Relations for NewtonEuler Dynamical Systems. This class is only an interface for specific (Linear, Scleronomous …) NewtonEuler Relations (see derived classes).
Class name = type+subType.
If y = h(…), all the gradients of are handled by G object. For example, G[0] = \(\nabla_q h(q,...)\).
In corresponding derived classes, h and Gi are connected to plug-in functions (user-defined). For more details, see the DevNotes.pdf, chapter NewtonEuler.
Overload 1: basic constructor
- Parameters:
lagType (int) – the sub-type of the relation
Overload 2: Default constructor
- jachq()[source]#
get a pointer on matrix Jach[index]
- Return type:
- Returns:
a pointer on a SimpleMatrix
- setJachqPtr(newPtr)[source]#
set Jach[index] to pointer newPtr (pointer link)
- Parameters:
newPtr (
SimpleMatrix
) – the new matrix
- initialize(inter)[source]#
initialize components specific to derived classes.
- Parameters:
inter (
Interaction
) – Interaction associated with the Relation
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- computeh(time, q0, y)[source]#
to compute the output y = h(t,q,z) of the Relation
- Parameters:
time (float) – current time value
q – coordinates of the dynamical systems involved in the relation
y (
SiconosVector
) – the resulting vector
- computeJachlambda(time, inter)[source]#
default function to compute jacobianH
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relation
- computeJachq(time, inter, q0)[source]#
compute the jacobian of h w.r.t. q
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relationq0 (
BlockVector
) – the container of the block vector to the dynamical system
- computeJachqDot(time, inter)[source]#
compute the jacobian of h w.r.t. \(\dot{q}\)
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relation
- computeJacglambda(time, inter)[source]#
compute the jacobian of h w.r.t. \(\dot{q}\)
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relation
- computeJacgq(time, inter)[source]#
compute the jacobian of h w.r.t. \(\dot{q}\)
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relation
- computeJacgqDot(time, inter)[source]#
compute the jacobian of h w.r.t. \(\dot{q}\)
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relation
- computeJachqT(inter, q0)[source]#
default implementation consists in multiplying jachq and T in this implementation we use _T which is consitent which directly computed with computeT(q) when q is given this one in more consistent with the notion of function of q
- Parameters:
inter (
Interaction
) – interaction that owns the relationq0 (
BlockVector
) – the block vector to the dynamical system position
- computeJach(time, inter)[source]#
compute all the jacobian of h
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relation
- computeJacg(time, inter)[source]#
compute all the jacobian of g
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relation
- computeSecondOrderTimeDerivativeTerms(time, inter, DSlink, ds1, ds2)[source]#
To compute the terms of the second order time derivative of y \(\nabla_q h(q) \dot T v + \frac{d}{dt}(\nabla_q h(q) ) T v\)
- Parameters:
time (float) – current time
inter (
Interaction
) – interaction that owns the relationDSlink (
VectorOfBlockVectors
) – the container of the link to DynamicalSystem attributesds1 (
DynamicalSystem
) – dynamical system linked to this interaction (source)ds2 (
DynamicalSystem
) – second ds linked to this interaction (target). If there is only one ds in the inter, call this function with …, ds, ds)
- computeOutput(time, inter, derivativeNumber=0)[source]#
to compute output
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relationderivativeNumber (int, optional) – number of the derivative to compute, optional, default = 0.
- computeInput(time, inter, level=0)[source]#
to compute the input
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relationlevel (int, optional) – number of the derivative to compute, optional, default = 0.
- C()[source]#
return a SP on the C matrix. The matrix C in the linear case, else it returns Jacobian of the output with respect to x.
- D()[source]#
return a SP on the D matrix. The matrix D in the linear case, else it returns Jacobian of the output with respect to lambda.
- B()[source]#
return a SP on the B matrix. The matrix B in the linear case, else it returns Jacobian of the input with respect to lambda.
- class siconos.kernel.NewtonEuler1DR[source]#
Bases:
NewtonEulerR
This class is an interface for a relation with impact. It implements the computation of the jacoboian of h from the points of contacts and the normal. Use this class consists in overloading the method computeh, by setting the member pc1, pc2, nc and y. The matrix jachq is used both for the building of the OSNSP (with T) and for the predictor of activation of deactivation of the Interaction.
constructor
- setpc1(npc)[source]#
Set the coordinates of first contact point. Must only be done in a computeh() override.
- Parameters:
npc (
SiconosVector
) – new coordinates
- setpc2(npc)[source]#
Set the coordinates of second contact point. Must only be done in a computeh() override.
- Parameters:
npc (
SiconosVector
) – new coordinates
- setnc(nnc)[source]#
Set the coordinates of inside normal vector at the contact point. Must only be done in a computeh() override.
- Parameters:
nnc (
SiconosVector
) – new coordinates
- computeJachq(time, inter, q0)[source]#
compute the jacobian of h w.r.t. q
- Parameters:
time (float) – current time
inter (
Interaction
) – the interaction using this relationq0 (
BlockVector
) – the container of the block vector to the dynamical system
- initialize(inter)[source]#
initialize components specific to derived classes.
- Parameters:
inter (
Interaction
) – Interaction associated with the Relation
- computeJachqT(inter, q0)[source]#
Default implementation consists in multiplying jachq and T (see NewtonEulerR::computeJachqT) but here we compute the operator from the the contact point locations and the local frame at contact
- Parameters:
inter (
Interaction
) – interaction that owns the relationq0 (
BlockVector
) – the block vector to the dynamical system position
- computeh(time, q0, y)[source]#
to compute the output y = h(t,q,z) of the Relation
- Parameters:
time (float) – current time value
q – coordinates of the dynamical systems involved in the relation
y (
SiconosVector
) – the resulting vector
- computehFromRelativeContactPoints(time, q0, y)[source]#
to compute the output y = h(t,q,z) of the Relation with the relative contact points :type time: float :param time: current time value :param q: coordinates of the dynamical systems involved in the relation :type y:
SiconosVector
:param y: the resulting vector
- setRelPc1(npc)[source]#
Set the coordinates of first contact point in ds1 frame. It will be used to compute _Pc1 during computeh().
- Parameters:
npc (
SiconosVector
) – new coordinates
- setRelPc2(npc)[source]#
Set the coordinates of second contact point in ds2 frame It will be used to compute _Pc2 during computeh().
- Parameters:
npc (
SiconosVector
) – new coordinates
- setRelNc(nnc)[source]#
Set the coordinates of inside normal vector at the contact point in ds2 frame. It will be used to compute _Nc during computeh().
- Parameters:
nnc (
SiconosVector
) – new coordinates
- class siconos.kernel.NewtonEuler3DR[source]#
Bases:
NewtonEuler1DR
This class is an interface for relation with impact and FC3D. From NewtonEuler1DR, it inherits to the computation of the jacobian, this operator is use for the predictor of activation and deactivation of the Interaction. The OSNSP is build using the matrix jachqT, that is computed from the point if contact pc1, pc2 and Nc. Use this class consists in overload the method computeh, and children class has to set the menber pc1, pc2 and nc.
constructor
- initialize(inter)[source]#
initialize components specific to derived classes.
- Parameters:
inter (
Interaction
) – the interaction using this relation
- computeJachqT(inter, q0)[source]#
Default implementation consists in multiplying jachq and T (see NewtonEulerR::computeJachqT) but here we compute the operator from the the contact point locations and the local frame at contact
- Parameters:
inter (
Interaction
) – interaction that owns the relationq0 (
BlockVector
) – the block vector to the dynamical system position
- class siconos.kernel.NewtonEuler5DR[source]#
Bases:
NewtonEuler1DR
This class is an interface for relation with impact and RFC3D.
constructor
- initialize(inter)[source]#
initialize components specific to derived classes.
- Parameters:
inter (
Interaction
) – the interaction using this relation
- computeJachqT(inter, q0)[source]#
Default implementation consists in multiplying jachq and T (see NewtonEulerR::computeJachqT) but here we compute the operator from the the contact point locations and the local frame at contact
- Parameters:
inter (
Interaction
) – interaction that owns the relationq0 (
BlockVector
) – the block vector to the dynamical system position
- class siconos.kernel.FirstOrderR(newType)[source]#
Bases:
Relation
FirstOrder Relation
This is an abstract class for all relation operating on first order systems. The following subclasses can be used:
FirstOrderNonlinearR: for fully nonlinear relations: \(y = h(t, X, \lambda, Z)\) , \(R = g(t, X, \lambda, Z)\) .
FirstOrderType2R: specialization with \(y = h(t, X, \lambda, Z)\) , \(R = g(t, \lambda, Z)\) .
FirstOrderType1R: further specialization with \(y = h(t, X, Z)\) , \(R = g(t, \lambda, Z)\) .
FirstOrderLinearR: linear case: \(y = C(t)x + D(t)\lambda + F(t) z + e\) , \(R = B(t)\lambda\) .
FirstOrderLinearTIR: time-invariant linear case: \(y = Cx + D\lambda + F z + e\) , \(R = B\lambda\) .
If the relation involves only one DynamicalSystem, then \(R = r\) , \(X = x\) , and \(Z = z\) . With two, then \(R = [r_1, r_2]\), \(X = [x_1 x_2]\), and \(Z = [z_1 z_2]\) .
Remember that \(y\) and \(\lambda\) are relation from the Interaction, and have the same size.
basic constructor
- Parameters:
newType (int) – the type of the relation
- initialize(inter)[source]#
initialize the relation (check sizes, memory allocation …)
- Parameters:
inter (
Interaction
) – the interaction using this relation
- setCPtr(newC)[source]#
set C to pointer newC
- Parameters:
newC (
SimpleMatrix
) – the C matrix
- setBPtr(newB)[source]#
set B to pointer newB
- Parameters:
newB (
SimpleMatrix
) – the B matrix
- setDPtr(newD)[source]#
set D to pointer newPtr
- Parameters:
newD (
SimpleMatrix
) – the D matrix
- setFPtr(newF)[source]#
set F to pointer newPtr
- Parameters:
newF (
SimpleMatrix
) – the F matrix
- class siconos.kernel.FirstOrderNonLinearR[source]#
Bases:
FirstOrderR
FirstOrder Non Linear Relation.
This is the most generic relation for First Order Dynamical Systems, with:
\[\begin{split}y &=& h(X,t,\lambda,Z) \\ R &=& g(X,t,\lambda,Z)\end{split}\]where X, Z, and R corresponds to DynamicalSystem variables. If more than 2 DynamicalSystem are involved in the Interaction, then X = [x1 x2], Z=[z1 z2] R = [r1 r2].
\(y\) and \(\lambda\) are specific variables of the Interaction (see this class for more details).
Let us define the following jacobians:
\[\begin{split}C &=& \nabla_x h\\ B &=& \nabla_{\lambda} g\\ D &=& \nabla_{\lambda} h\\ K &=& \nabla_x g.\end{split}\]There are 2 ways to define this relation: - by using the plugin mechanism of calling C functions - by using the inheritance mechanism (of C++ or Python) and overloading methods.
For the plugins, the following definitions are mandatory: - A function to compute \(h\) with signature
(double time, unsigned x_size, double *x, unsigned size_lambda, double* lambda, double *y, unsigned z_size, double *z)
A function to compute \(g\) with signature
(double time, unsigned x_size, double *x, unsigned size_lambda, double* lambda, double *r, unsigned z_size, double *z)
Note that the size of \(y\) is the same as \(\lambda\), and the size of \(R\) is the same as \(X\) . Thus those are not specified in the plugin function signatures.
For the various jacobians, there are two possibilities: If one is constant, the value may directly be set: for instance, if \(C\) is constant, then one can use setCPtr to fix the value. A word of cautions: whenever a jacobian matrix is fixed using this call, then the corresponding C++ function (and not plugin) is not called anymore. A small example: if \(C\) is fixed via setCPtr, then computeJachx is never called again.
The other option is to use the plugin mechanism. They all share the same signature:
(double time, unsigned x_size, double *x, unsigned size_lambda, double* lambda, double *mat, unsigned z_size, double *z) where mat
is the pointer to the array of values for each Jacobian. This implies that only dense matrix are supported.
basic constructor
- initialize(inter)[source]#
initialize the relation (check sizes, memory allocation …)
- Parameters:
inter (
Interaction
) – the interaction using this relation
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- computeh(time, x, lambda_, z, y)[source]#
default function to compute \(h\)
- Parameters:
time (float) – current time
x (
BlockVector
) – current state variableslambda (
SiconosVector
) – current nonsmooth variablesz (
BlockVector
) – current auxiliary variabley (
SiconosVector
, out) – output value
- computeg(time, x, lambda_, z, r)[source]#
default function to compute \(g\)
- Parameters:
time (float) – current time
x (
BlockVector
) – current state variableslambda (
SiconosVector
) – current nonsmooth variablesz (
BlockVector
) – current auxiliary variabler (
BlockVector
, out) – input value
- computeJachx(time, x, lambda_, z, C)[source]#
default function to compute \(C = \nabla_x h\)
- Parameters:
time (float) – current time
x (
BlockVector
) – current state variableslambda (
SiconosVector
) – current nonsmooth variablesz (
BlockVector
) – current auxiliary variableC (
SimpleMatrix
, out) – jacobian matrix
- computeJachlambda(time, x, lambda_, z, D)[source]#
default function to compute \(D = \nabla_{\lambda} h\)
- Parameters:
time (float) – current time
x (
BlockVector
) – current state variableslambda (
SiconosVector
) – current nonsmooth variablesz (
BlockVector
) – current auxiliary variablesD (
SimpleMatrix
, out) – jacobian matrix
- computeJach(time, inter)[source]#
compute all the H Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relation
- computeJacglambda(time, x, lambda_, z, B)[source]#
default function to compute \(B = \nabla_{\lambda}g\)
- Parameters:
time (float) – current time
x (
BlockVector
) – current state variableslambda (
SiconosVector
) – current nonsmooth variablesz (
BlockVector
) – current auxiliary variablesB (
SimpleMatrix
, out) – jacobian matrix
- computeJacgx(time, x, lambda_, z, K)[source]#
default function to compute \(K = \nabla_{\lambda}g\)
- Parameters:
time (float) – current time
x (
BlockVector
) – current state variableslambda (
SiconosVector
) – current nonsmooth variablesz (
BlockVector
) – current auxiliary variablesK (
SimpleMatrix
, out) – jacobian matrix
- computeJacg(time, inter)[source]#
compute all the G Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relationinterProp –
- computeOutput(time, inter, level=0)[source]#
default function to compute y, using the data from the Interaction and DS
- Parameters:
time (float) – current time (not used)
inter (
Interaction
) – Interaction using this Relationlevel (int, optional) – not used
- computeInput(time, inter, level=0)[source]#
default function to compute r, using the data from the Interaction and DS
- Parameters:
time (float) – current time (not used)
inter (
Interaction
) – Interaction using this Relationlevel (int, optional) – not used
- class siconos.kernel.FirstOrderType1R(*args)[source]#
Bases:
FirstOrderR
FirstOrder Non Linear Relation.
Derived from FirstOrderR - See this class for more comments.
Relation for First Order Dynamical Systems, with:
\[\begin{split}y &= h(x,z)\\ r &= g(\lambda,z)\end{split}\]Operators (and their corresponding plug-in): - h: saved in Interaction as y (plug-in: output[0]) - \(\nabla_x h\): jacobianH[0] ( output[1] ) - g: saved in DS as r ( input[0]) - \(\nabla_\lambda g\): jacobianG[0] ( input[1] )
- Overload 1:
default constructor
- Overload 2:
build from plugin for \(h(x,z)\) and \(g(\lambda, z)\)
- type pluginh:
string
- param pluginh:
the plugin to compute h
- type pluging:
string
- param pluging:
the plugin to compute g
- Overload 3:
build from plugin for \(h(x,z)\) , \(g(\lambda, z)\) and their gradients :type pluginh: string
- Parameters:
pluginh – the plugin to compute h :type pluging: string
pluging – the plugin to compute g :type pluginJachx: string
pluginJachx –
the plugin to compute \(\nabla_x h\)
- type pluginJacglambda:
string
- param pluginJacglambda:
the plugin to compute \(\nabla_{\lambda} g\)
- initialize(inter)[source]#
initialize the relation (check sizes, memory allocation …)
- Parameters:
inter (
Interaction
) – the interaction that owns this relation
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- computeh(time, x, z, y)[source]#
to compute the output y = h(t,x,…) of the Relation
- Parameters:
time (float) – current time value
x (
BlockVector
) – coordinates of the dynamical systems involved in the relationz (
BlockVector
) – user defined parameters (optional)y (
SiconosVector
) – the resulting vector
- computeg(time, lambda_, z, r)[source]#
to compute the nonsmooth input r = g(t,x,…) of the Relation
- Parameters:
time (float) – current time value
lambda (
SiconosVector
) – interaction \(\lambda\) vectorz (
BlockVector
) – user defined parameters (optional)r (
BlockVector
) – the resulting vector
- computeJachx(time, x, z, C)[source]#
to compute \(C = \nabla_x h\)
- Parameters:
time (float) – current time value
x (
BlockVector
) – coordinates of the dynamical systems involved in the relationz (
BlockVector
) – user defined parameters (optional)C (
SimpleMatrix
, out) – the resulting matrix
- computeJachz(time, x, z, F)[source]#
default function to compute \(\nabla_z h\)
- Parameters:
time (float) – current time value
x (
BlockVector
) – coordinates of the dynamical systems involved in the relationz (
BlockVector
) – user defined parameters (optional)F (
SimpleMatrix
, out) – the resulting matrix
- computeJacglambda(time, lambda_, z, B)[source]#
to compute \(B = \nabla_{\lambda}g\)
- Parameters:
time (float) – current time value
x – coordinates of the dynamical systems involved in the relation
lambda (
SiconosVector
) – interaction \(\lambda\) vectorz (
BlockVector
) – user defined parameters (optional)B (
SimpleMatrix
, out) – the resulting matrix
- computeOutput(time, inter, level=0)[source]#
default function to compute y, using the data from the Interaction and DS
- Parameters:
time (float) – current time (not used)
inter (
Interaction
) – Interaction using this Relationlevel (int, optional) – not used
- computeInput(time, inter, level=0)[source]#
default function to compute r, using the data from the Interaction and DS
- Parameters:
time (float) – current time (not used)
inter (
Interaction
) – Interaction using this Relationlevel (int, optional) – not used
- computeJach(time, inter)[source]#
compute all the H Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relation
- computeJacg(time, inter)[source]#
compute all the G Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relationinterProp –
- class siconos.kernel.FirstOrderType2R(*args)[source]#
Bases:
FirstOrderR
First order non linear Relation.
Relation for First Order Dynamical Systems, with:
\[\begin{split}y &= h(x,\lambda,z)\\ r &= g(\lambda,z)\end{split}\]Operators (and their corresponding plug-in): - h: saved in Interaction as y (plug-in: output[0]) - \(\nabla_x h\): jacobianH[0] ( output[1] ) - g: saved in DS as r ( input[0]) - \(\nabla_\lambda g\): jacobianG[0] ( input[1] )
Remark FP: at the time, this class works only on the linear case, when: - \(\nabla_x h = C\), \(\nabla_\lambda h = D\) and \(\nabla_\lambda g = K\) are constants. Trying to update these jacobians with plugins functions leads to an exception. Solution: create a derived class and overide computeJachx and computeJach.
Overload 1: Basic contructor
Overload 2: data constructor
- Parameters:
pluginh (string) – name of the plugin to compute h
pluging (string) – name of the plugin to compute g
Overload 3: data constructor
- Parameters:
pluginh (string) – name of the plugin to compute h
pluging (string) – name of the plugin to compute g
pluginJacobianhx (string) – name of the plugin to compute the Jacobian of h according to x \(\nabla_x h\)
pluginJacobianglambda (string) – name of the plugin to compute the jacobian of g according to lambda
- initialize(inter)[source]#
initialize the relation (check sizes, memory allocation …)
- Parameters:
inter (
Interaction
) – the interaction that owns this relation
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- computeh(time, x, lambda_, y)[source]#
to compute the output y = h(t,x,…) of the Relation
- Parameters:
time (float) – current time value
x (
BlockVector
) – coordinates of the dynamical systems involved in the relationlambda (
SiconosVector
) – interaction \(\lambda\) vectory (
SiconosVector
) – the resulting vector
- computeg(time, lambda_, r)[source]#
to compute the nonsmooth input r = g(t,x,…) of the Relation
- Parameters:
time (float) – current time value
lambda (
SiconosVector
) – interaction \(\lambda\) vectorr (
BlockVector
) – the resulting vector
- computeJachx(time, x, lambda_, C)[source]#
to compute \(C = \nabla_x h\)
- Parameters:
time (float) – current time value
x (
BlockVector
) – coordinates of the dynamical systems involved in the relationlambda (
SiconosVector
) – interaction \(\lambda\) vectorC (
SimpleMatrix
, out) – the resulting matrix
- computeJacglambda(time, lambda_, B)[source]#
to compute \(B = \nabla_{\lambda}g\)
- Parameters:
time (float) – current time value
lambda (
SiconosVector
) – interaction \(\lambda\) vectorB (
SimpleMatrix
, out) – the resulting matrix
- computeJachlambda(time, x, lambda_, D)[source]#
to compute \(D = \nabla_{\lambda}h\)
- Parameters:
time (float) – current time value
x (
BlockVector
) – coordinates of the dynamical systems involved in the relationlambda (
SiconosVector
) – interaction \(\lambda\) vectorD (
SimpleMatrix
, out) – the resulting matrix
- computeOutput(time, inter, level=0)[source]#
default function to compute y, using the data from the Interaction and DS
- Parameters:
time (float) – current time (not used)
inter (
Interaction
) – Interaction using this Relationlevel (int, optional) – not used
- computeInput(time, inter, level=0)[source]#
default function to compute r, using the data from the Interaction and DS
- Parameters:
time (float) – current time (not used)
inter (
Interaction
) – Interaction using this Relationlevel (int, optional) – not used
- requireResidu()[source]#
return true if the relation requires the computation of residu
- Return type:
boolean
- Returns:
true if residu are required, false otherwise
- computeJach(time, inter)[source]#
compute all the H Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relation
- computeJacg(time, inter)[source]#
compute all the G Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relationinterProp –
- class siconos.kernel.FirstOrderLinearR(*args)[source]#
Bases:
FirstOrderR
First Order Linear Relation
Linear Relation for First Order Dynamical Systems:
\[\begin{split}y &=& C(t,z)x(t) + F(t,z)z + D(t,z)\lambda + e(t,z) \\ R &=& B(t,z) \lambda\end{split}\]The following operators can be plugged: B(t,z), C(t,z), D(t,z), e(t,z), F(t,z)
Overload 1: default constructor
Overload 2: Constructor with C and B plugin names
- Parameters:
Cname (string) – the plugin name for computing the C matrix
Bname (string) – the plugin name for computing the B matrix
Overload 3: Constructor with all plugin names
- Parameters:
Cname (string) – the plugin name for computing the C matrix
Dname (string) – the plugin name for computing the D matrix
Fname (string) – the plugin name for computing the F matrix
Ename (string) – the plugin name for computing the e vector
Bname (string) – the plugin name for computing the B matrix
Overload 4: create the Relation from constant matrices (only B and C operators)
- Parameters:
C (
SimpleMatrix
) – the C matrixB (
SimpleMatrix
) – the B matrix
Overload 5: create the Relation from a set of data
- Parameters:
C (
SimpleMatrix
) – the C matrixD (
SimpleMatrix
) – the D matrixF (
SimpleMatrix
) – the F matrixe (
SiconosVector
) – the e matrixB (
SimpleMatrix
) – the B matrix
- initialize(inter)[source]#
initialize the relation (check sizes, memory allocation in workV and workM …)
- Parameters:
inter (
Interaction
) – Interaction using this Relation
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- setComputeCFunction(pluginPath, functionName)[source]#
set a specified function to compute the matrix C
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- setComputeDFunction(pluginPath, functionName)[source]#
set a specified function to compute the matrix D
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- setComputeBFunction(pluginPath, functionName)[source]#
set a specified function to compute the matrix B
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the function name to use in this plugin
- computeC(time, z, C)[source]#
Function to compute the matrix C
- Parameters:
time (float) – the current time
z (
BlockVector
) – the auxiliary input vectorC (
SimpleMatrix
) – the C matrix
- computeD(time, z, D)[source]#
Function to compute the matrix D
- Parameters:
time (float) – the current time
z (
BlockVector
) – the auxiliary input vectorD (
SimpleMatrix
) – the D matrix
- computeF(time, z, F)[source]#
Function to compute the matrix F
- Parameters:
time (float) – the current time
z (
BlockVector
) – the auxiliary input vectorF (
SimpleMatrix
) – the F matrix
- computee(time, z, e)[source]#
Function to compute the vector e
- Parameters:
time (float) – the current time
z (
BlockVector
) – the auxiliary input vectore (
SiconosVector
) – the e vector
- computeB(time, z, B)[source]#
Function to compute the matrix B
- Parameters:
time (float) – the current time
z (
BlockVector
) – the auxiliary input vectorB (
SimpleMatrix
) – the B matrix
- computeh(time, x, lambda_, z, y)[source]#
to compute the output y = h(t,x,…) of the Relation
- Parameters:
time (float) – current time value
x (
BlockVector
) – coordinates of the dynamical systems involved in the relationlambda (
SiconosVector
) – interaction \(\lambda\) vectorz (
BlockVector
) – user defined parameters (optional)y (
SiconosVector
) – the resulting vector
- computeg(time, lambda_, z, r)[source]#
to compute the nonsmooth input r = g(t,x,…) of the Relation
- Parameters:
time (float) – current time value
lambda (
SiconosVector
) – interaction \(\lambda\) vectorz (
BlockVector
) – user defined parameters (optional)r (
BlockVector
) – the resulting vector
- computeOutput(time, inter, level=0)[source]#
default function to compute y
- Parameters:
time (float) – current time
inter (
Interaction
) – Interaction using this Relationlevel (int, optional) – not used
- computeInput(time, inter, level=0)[source]#
default function to compute r
- Parameters:
time (float) – current time
inter (
Interaction
) – Interaction using this Relationlevel (int, optional) – not used
- setePtr(newe)[source]#
set e operator
- Parameters:
newe (
SiconosVector
) – the new value of e
- isLinear()[source]#
determines if the Relation is linear
- Return type:
boolean
- Returns:
true if the relation is linear.
- computeJach(time, inter)[source]#
compute all the H Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relation
- computeJacg(time, inter)[source]#
compute all the G Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relationinterProp –
- class siconos.kernel.FirstOrderLinearTIR(*args)[source]#
Bases:
FirstOrderR
Linear Time Invariant Relation, derived from class FirstOrderR
Linear Relation for First Order Dynamical Systems with time-independant operators
\[\begin{split}y &=& Cx(t) + Fz + D\lambda + e \\ R &=& B\lambda\end{split}\]Overload 1: create the Relation from a set of data
- Parameters:
C (
SimpleMatrix
) – the matrix CB (
SimpleMatrix
) – the matrix B
Overload 2: create the Relation from a set of data
- Parameters:
C (
SimpleMatrix
) – the C matrixD (
SimpleMatrix
) – the D matrixF (
SimpleMatrix
) – the F matrixe (
SiconosVector
) – the e matrixB (
SimpleMatrix
) – the B matrix
- initialize(inter)[source]#
initialize the relation (check sizes, memory allocation …)
- Parameters:
inter (
Interaction
) – the interaction that owns this relation
- checkSize(inter)[source]#
check sizes of the relation specific operators.
- Parameters:
inter (
Interaction
) – an Interaction using this relation
- computeh(x, lambda_, z, y)[source]#
default function to compute h = y = Cx(t) + Fz + Dlambda + e
- Parameters:
x (
BlockVector
) –lambda (
SiconosVector
) –z (
BlockVector
) –y (
SiconosVector
) – the resulting vector
- computeg(lambda_, r)[source]#
default function to compute g = Blambda
- Parameters:
lambda (
SiconosVector
) –r (
BlockVector
) – non-smooth input
- computeOutput(time, inter, level=0)[source]#
default function to compute y
- Parameters:
time (float) – current time
inter (
Interaction
) – Interaction using this Relationlevel (int, optional) –
- computeInput(time, inter, level=0)[source]#
default function to compute r
- Parameters:
time (float) – current time
inter (
Interaction
) – Interaction using this Relationlevel (int, optional) –
- setePtr(newe)[source]#
set e
- Parameters:
newe (
SiconosVector
) – the new value of e
- isLinear()[source]#
determine if the Relation is linear
- Return type:
boolean
- Returns:
true if the relation is linear.
- computeJach(time, inter)[source]#
compute all the H Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relation
- computeJacg(time, inter)[source]#
compute all the G Jacobian
- Parameters:
time (float) – the current time
inter (
Interaction
) – the interaction using this relationinterProp –
- class siconos.kernel.Interaction(NSL, rel)[source]#
Bases:
object
Description of a non-smooth interaction. The object Interaction is used to defined a “link” between one or two DynamicalSystem, like unilateral constraints and some nonsmooth law (e.g. complementarity).
It holds two vectors of “local” variables, \(y\) and \(\lambda\) and their derivatives, which are related to the state variables and the inputs of the DynamicalSystem (x,R) through constraints defined in a Relation and completed with a NonSmoothLaw involving those variables.
Remarks:
one and only one Relation (access: relation()) per Interaction
one and only one NonSmoothLaw (access: nonSmoothLaw()) per Interaction
dimension() is the size of the interaction and so the size of vectors y, lambda
and their derivatives. - output: y(i), to get derivative i of y - input: lambda(i), to get derivative i of lambda
Interaction constructor
- Parameters:
NSL (
NonSmoothLaw
) – pointer object describing the nonsmooth law; the interaction size if infered from the size of this law.rel (
Relation
) – a pointer object describing the functions used to compute the constraints
- initializeLinkToDsVariables(ds1, ds2)[source]#
set the links to the DynamicalSystem(s) and allocate the required workspaces
- Parameters:
interProp – the InteractionProperties of this Interaction
ds1 (
DynamicalSystem
) – first ds linked to this Interaction (i.e IG->vertex.source)workV1 – work vectors of ds1
ds2 (
DynamicalSystem
) – second ds linked to this Interaction (i.e IG->vertex.target) ds1 == ds2 is allowed.workV2 – work vectors of ds2
set the links between the interaction and the DynamicalSystem(s) members.
- Parameters:
ds1 (
DynamicalSystem
) – first ds linked to this Interaction (i.e IG->vertex.source)ds2 (
DynamicalSystem
) – second ds linked to this Interaction (i.e IG->vertex.target) ds1 == ds2 is allowed
- initializeMemory(steps)[source]#
build memories vectors for y and \(\lambda\)
- Parameters:
computeResiduY – true if interaction should compute extra residu value
steps (int) – number of required memories (depends on the OSI)
- setLowerLevelForOutput(newVal)[source]#
Set the lower level for output y.
- Parameters:
newVal (int) – : an unsigned int
- setUpperLevelForOutput(newVal)[source]#
Set the upper level for output y.
- Parameters:
newVal (int) – : an unsigned int
- lowerLevelForOutput()[source]#
Get the lower level for output y.
- Return type:
- Returns:
an unsigned int.
- upperLevelForOutput()[source]#
Get the upper level for output y.
- Return type:
- Returns:
an unsigned int.
- setLowerLevelForInput(newVal)[source]#
Set the lower level for input Lambda.
- Parameters:
newVal (int) – : an unsigned int
- setUpperLevelForInput(newVal)[source]#
Set the upper level for input Lambda.
- Parameters:
newVal (int) – : an unsigned int.
- lowerLevelForInput()[source]#
Get the lower level for input Lambda.
- Return type:
- Returns:
an unsigned int.
- upperLevelForInput()[source]#
Get the upper level for input Lambda.
- Return type:
- Returns:
an unsigned int.
- setHas2Bodies(val)[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 (boolean) – : true if two ds, else false
- has2Bodies()[source]#
Check the number of dynamical systems concerned by this interaction.
- Return type:
boolean
- Returns:
bool : true if two ds, else false
- getCopyOfy(i)[source]#
Get y[i], derivative number i of output
- Parameters:
i (int) – : the derivative number
- Return type:
- Returns:
BlockVector
- y(*args)[source]#
Overload 1: get vector of output derivatives
- Return type:
VectorOfVectors
- Returns:
a VectorOfVectors
Overload 2: get y[i], derivative number i of output
- Parameters:
i (int) – derivative number i of output
- Return type:
- Returns:
pointer on a SiconosVector
- setY(*args)[source]#
Overload 1: set the output vector y to newVector with copy of the y[i] (ie memory allocation)
- Parameters:
v (
VectorOfVectors
) – VectorOfVectors
Overload 2: set y[i] to newValue
- Parameters:
i (int) – derivative number i of output
v (
SiconosVector
) – a SiconosVector and an unsigned int
- setYPtr(*args)[source]#
Overload 1: set the output vector y to newVector with direct pointer equality for the y[i]
- Parameters:
v (
VectorOfVectors
) – VectorOfVectors
Overload 2: set y[i] to pointer newPtr
- Parameters:
i (int) – derivative number i of output
v (
SiconosVector
) – a SP::SiconosVector and an unsigned int
- yMemory(level)[source]#
get all the values of the output y stored in memory
- Parameters:
level (int) –
- Return type:
- Returns:
a memory
- y_k(i)[source]#
get the last value of the output y stored in memory
- Parameters:
level –
- Return type:
- Returns:
a SiconosVector reference
- getLambda(*args)[source]#
Overload 1: get vector of input derivatives
- Return type:
VectorOfVectors
- Returns:
a VectorOfVectors
Overload 2: get _lambda[i], derivative number i of input
- Parameters:
i (int) – derivative number i of output
- Return type:
- Returns:
SiconosVector
- lambda_(i)[source]#
get _lambda[i], derivative number i of input
- Parameters:
i (int) – derivative number i of output
- Return type:
- Returns:
pointer on a SiconosVector
- lambdaMemory(level)[source]#
get all the values of the multiplier lambda stored in memory
- Parameters:
level (int) –
- Return type:
- Returns:
a memory
- lambda_k(i)[source]#
get the last value of the multiplier lambda stored in memory
- Parameters:
level –
- Return type:
- Returns:
a SiconosVector reference
- setLambda(*args)[source]#
Overload 1: set the input vector _lambda to newVector
- Parameters:
v (
VectorOfVectors
) – VectorOfVectors
Overload 2: set _lambda[i] to newValue
- Parameters:
i (int) – derivative number i of output
newValue (
SiconosVector
) – a SiconosVector
- setLambdaPtr(*args)[source]#
Overload 1: set vector _lambda to newVector with direct pointer equality for the _lambda[i]
- Parameters:
v (
VectorOfVectors
) – VectorOfVectors
Overload 2: set _lambda[i] to pointer newPtr
- Parameters:
i (int) – derivative number i of output
newPtr (
SiconosVector
) – a SP::SiconosVector
- relation()[source]#
get the Relation of this Interaction
- Return type:
- Returns:
a pointer on this Relation
- nonSmoothLaw()[source]#
get the NonSmoothLaw of this Interaction
- Return type:
- Returns:
a pointer on this NonSmoothLaw
- setDSSizes(s1)[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) – int sum of ds sizes
- swapInMemory()[source]#
Must be call to fill the memory. (after convergence of the Newton iterations)
- static resetCount(new_count=0)[source]#
reset the global Interaction counter (for ids)
- Return type:
- Returns:
the previous value of count
- computeInput(time, level=0)[source]#
Compute input r of all Dynamical Systems involved in the present Interaction.
- getLeftInteractionBlock()[source]#
gets the matrix used in interactionBlock computation, (left * W * right), depends on the relation type (ex, LinearTIR, left = C, right = B)..
- Return type:
- Returns:
InteractionBlock a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
- getLeftInteractionBlockForDS(pos, size, sizeDS)[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:
- Return type:
- Returns:
InteractionBlock a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
- getLeftInteractionBlockForDSProjectOnConstraints(pos, InteractionBlock)[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) – int, relative position of the beginning of the required block in relation matrix.
InteractionBlock (
SiconosMatrix
) – a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
- getRightInteractionBlockForDS(pos, sizeDS, size)[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:
- Return type:
- Returns:
InteractionBlock a pointer to SiconosMatrix (in-out parameter): the resulting interactionBlock matrix
- getExtraInteractionBlock(InteractionBlock)[source]#
gets extra interactionBlock corresponding to the present Interaction
- Parameters:
InteractionBlock (
SiconosMatrix
, in/out) – SP::SiconosMatrix
- siconos.kernel.Interaction_resetCount(new_count=0)[source]#
reset the global Interaction counter (for ids)
- Return type:
- Returns:
the previous value of count
- class siconos.kernel.TimeDiscretisation(*args)[source]#
Bases:
object
A time discretisation scheme
A TimeDiscretisation object is used to discretized a given time interval. TimeDiscretisation are used: - in the simulation, as a user-input to discretized [t0,T] - in Sensor and Actuator, to define the set of time instants where the sensor or actuator must operate.
A TimeDiscretisation is defined with a starting time (t0), a time step size (h, non necessarily constant), the number of the current time step (k). The time instant values are saved in a vector tk. Depending on the way of construction of the TimeDiscretisation, all or only current and next times are saved in tk. The difference is just a question of saving memory.
Note that the TimeDiscretisation is not linked to the Model. It’s up to the user to check that the way he builds his time-discretisation fits with the t0 and T given in the model.
Main functions: - setCurrentTimeStep(), to set current h. This value will be used for all future time steps, until next change. - increment(), shift to next time step (increment k, and shift t[k] and t[k+1]) - currentTime(), return t[k]
Construction
input = the complete vector tk. This defines t0, T, number of time steps and time step size
(which is not necessarily constant). In this case, the whole vector is saved in the memory. - inputs = number of time steps, t0 and T. size h is computed with t0,T and nSteps. Only two values are saved: t[k] and t[k+1] = t[k] + h. h can be changed at any time. - inputs = h and t0. Only two values are saved: t[k] and t[k+1] = t[k] + h. h can be changed at any time. - inputs = t0 and h. Only two values are saved: t[k] and t[k+1] = t[k] + h. h can be changed at any time.
Overload 1: constructor with tk vector of instant times values.
- Parameters:
newTk (TkVector) – a TkVector describing the discretisation
Overload 2: constructor with the size of the default time step and t0
Overload 3: constructor with the number of steps, t0 and T
- Parameters:
Overload 4: Constructor with the size of the default timestep and t0. It creates a TimeDiscretisation using GMP for all its computation
- Parameters:
t0 (float) – initial time value
str (string) – the time step in form of a string
Overload 5: Copy constructor
- Parameters:
td (
TimeDiscretisation
) – the TimeDiscretisation to copy
- currentTimeStep(*args)[source]#
Overload 1: get the timestep \(t_{k+1} - t_k\)
Overload 2: get the timestep in gmp format
- Return type:
mpf_t
- Returns:
a pointer to the timestep in mpf_t format
- hConst()[source]#
determine whether the timestep is constant
- Return type:
boolean
- Returns:
true if the timestep is constant
- hGmp()[source]#
determine whether the TimeDiscretisation is using GMP
- Return type:
boolean
- Returns:
true if the TimeDiscretisation is using GMP
- getTkVector()[source]#
get the TkVector _tkV
- Return type:
TkVector
- Returns:
a reference to the TkVector _tkV
- setTkVector(newTk)[source]#
set the TkVector _tkV
- Parameters:
newTk (TkVector) – the new value for _tkV
- 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 - MultipleImpact - GlobalFrictionContact
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.
Overload 1: default constructor
Overload 2: constructor from a pre-defined solver options set.
- Parameters:
options (
SolverOptions
) – the options set
- numericsSolverOptions()[source]#
To get the SolverOptions structure
- Return type:
- Returns:
, the numerics structure used to save solver parameters
- simulation()[source]#
get the simulation which owns this nonsmooth problem
- Return type:
- Returns:
a pointer on Simulation
- setSimulationPtr(newS)[source]#
set the Simulation of the OneStepNSProblem
- Parameters:
newS (
Simulation
) – a pointer to Simulation
- setIndexSetLevel(newVal)[source]#
set the value of level min
- Parameters:
newVal (int) – an unsigned int
- setInputOutputLevel(newVal)[source]#
set the value of Input/Output level
- Parameters:
newVal (int) – an unsigned int
- maxSize()[source]#
get maximum value allowed for the dimension of the problem
- Return type:
- Returns:
an unsigned int
- hasInteractions()[source]#
Check if the OSNSPb has interactions
- Return type:
boolean
- Returns:
bool = true if the osnsp has interactions, i.e. indexSet(_indexSetLevel)->size >0
- displayBlocks(indexSet)[source]#
Display the set of blocks for a given indexSet
- Parameters:
indexSet (
InteractionsGraph
) – the concerned index set
- updateInteractionBlocks()[source]#
compute interactionBlocks if necessary (this depends on the type of OSNS, on the indexSets …)
- computeInteractionBlock(ed)[source]#
compute extra-diagonal interactionBlock-matrix
- Parameters:
ed (InteractionsGraph::EDescriptor) – an edge descriptor
- computeDiagonalInteractionBlock(vd)[source]#
compute diagonal Interaction block
- Parameters:
vd (InteractionsGraph::VDescriptor) – a vertex descriptor
- setHasBeenUpdated(v)[source]#
turn activation flag
- Parameters:
v (boolean) – to set _hasBeenUpdated.
- initialize(sim)[source]#
initialize the problem (topology and so on)
- Parameters:
sim (
Simulation
) – the simulation that owns this OSNSPB
- preCompute(time)[source]#
prepare data of the osns for solving
- Parameters:
time (float) – the current time
- Return type:
boolean
- Returns:
true if the computation of the OSNS has to be carry on, false otherwise
- setSolverId(solverId)[source]#
change the solver type and its default parameters
clear memory for the existing options set
create and initialize a new one
- Parameters:
solverId (int) – the new solver
- class siconos.kernel.OneStepIntegrator(*args)[source]#
Bases:
object
Generic class to manage DynamicalSystem(s) time-integration
This is a virtual class, interface for some specific integrators.
At the time, available integrators are:
EulerMoreauOSI
MoreauJeanOSI
MoreauJeanCombinedProjectionOSI
MoreauJeanDirectProjectionOSI
MoreauJeanBilbaoOSI
D1MinusLinearOSI
SchatzmanPaoliOSI
LsodarOSI
Hem5OSI
NewMarkAlphaOSI
ZeroOrderHoldOSI
Overload 1: basic constructor with OSI Id
- Parameters:
type (OSI::TYPES) – integrator type/name
Overload 2: default constructor
- getType()[source]#
- Return type:
OSI::TYPES
- Returns:
the id of the integrator (see list in OSI::TYPES enum)
- dynamicalSystemsGraph()[source]#
get the graph of dynamical systems associated with the Integrator warning: returns the whole ds graph, not only ds integrated by the present osi.
- Return type:
DynamicalSystemsGraph
- Returns:
a SP::DynamicalSystemsGraph
- setDynamicalSystemsGraph(dsg)[source]#
set the graph of dynamical systems associated with the Integrator
- getSizeMem()[source]#
get number of internal memory vectors needed in dynamical systems integrated with this osi.
- Return type:
- Returns:
an unsigned int
- simulation()[source]#
get the Simulation that owns the OneStepIntegrator (pointer link)
- Return type:
- Returns:
a pointer to Simulation
- setSimulationPtr(newS)[source]#
set the Simulation of the OneStepIntegrator
- Parameters:
newS (
Simulation
) – a pointer to Simulation
- levelMinForOutput()[source]#
minimal level required for output var used with this integration scheme. var[level] is the derivative of order ‘level’ of var.
- levelMaxForOutput()[source]#
maximal level required for output var used with this integration scheme. var[level] is the derivative of order ‘level’ of var.
- levelMinForInput()[source]#
minimal level required for input var used with this integration scheme. var[level] is the derivative of order ‘level’ of var.
- levelMaxForInput()[source]#
maximal level required for input var used with this integration scheme. var[level] is the derivative of order ‘level’ of var.
- numberOfIndexSets()[source]#
get the number of index sets required for the simulation
- Return type:
- Returns:
unsigned int
- initialize_nonsmooth_problems()[source]#
Initialization process of the nonsmooth problems linked to this OSI
- initializeWorkVectorsForDS(t, ds)[source]#
initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi
- Parameters:
t (float) – time of initialization
ds (
DynamicalSystem
) – the dynamical system
- initializeWorkVectorsForInteraction(inter, interProp, DSG)[source]#
initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi
- Parameters:
inter (
Interaction
) – the interactioninterProp (InteractionProperties) – the properties on the graph
DSG (
DynamicalSystemsGraph
) – the dynamical systems graph
- update_interaction_output(inter, time, interaction_properties)[source]#
compute interaction output (y) for all levels and swaps in memory
- Parameters:
inter (
Interaction
) – the interaction to updatetime (float) – value for output computation
interaction_properties (InteractionProperties) – properties of the interaction, in the Interaction Graph I0
- computeInitialNewtonState()[source]#
compute the initial state (for dynamical system variables) of the Newton loop.
- computeResidu()[source]#
return the maximum of all norms for the discretized residus of DS
- Return type:
- Returns:
a double
- computeFreeState()[source]#
integrates the Dynamical System linked to this integrator, without taking constraints into account.
- computeFreeOutput(vertex_inter, osnsp)[source]#
integrates the Interaction linked to this integrator, without taking non-smooth effects into account
- Parameters:
vertex_inter (InteractionsGraph::VDescriptor) – of the interaction graph
osnsp (
OneStepNSProblem
) – pointer to OneStepNSProblem
- computeResiduOutput(time, indexSet)[source]#
compute the residu of the output of the relation (y) This computation depends on the type of OSI
- Parameters:
time (float) – time of computation
indexSet (
InteractionsGraph
) – the index set of the interaction that are concerned
- computeResiduInput(time, indexSet)[source]#
compute the residu of the input of the relation (R or p) This computation depends on the type of OSI
- Parameters:
time (float) – time of computation
indexSet (
InteractionsGraph
) – the index set of the interaction that are concerned
- integrate(tinit, tend, tout, idid)[source]#
integrate the system, between tinit and tend, with possible stop at tout
- resetAllNonSmoothParts()[source]#
set to zero all the r vectors of the DynamicalSystems integrated by this OSI
- resetNonSmoothPart(level)[source]#
set to zero all the r vectors of the DynamicalSystems of the present OSI for a given level
- Parameters:
level (int) –
- updateState(*args)[source]#
Overload 1: update the state of the DynamicalSystem attached to this Integrator
- Parameters:
level (int) – level of interest for the dynamics level is set to 0 by default since in all time-stepping schemes we update all the state whatever the value of level
Overload 2: update the state of the DynamicalSystem attached to this Integrator level is set to 0 by default since in all time-stepping schemes we update all the state whatever the value of level
- updateOutput(*args)[source]#
Overload 1: update the output of the Interaction attached to this Integrator
Overload 2: update the output of the Interaction attached to this Integrator
- updateInput(*args)[source]#
Overload 1: update the input of the Interaction attached to this Integrator
Overload 2: update the input of the Interaction attached to this Integrator
Warning: VA: 27/10/2022 Whatever the level, the updateInput method loops over indexSet0 This is sometimes necessary for some OSI but for some others it may burden the computational time for nothing. For instance, in standard MoreauJEANOSI, p[1] is only defined on indexSet1. we should go towards virtual void updateInput(double time, unsigned int pLevel, unsigned int indexSetLevel );
- addInteractionInIndexSet(inter, i)[source]#
Apply the rule to one Interaction to known if is it should be included in the IndexSet of level i
- Parameters:
inter (
Interaction
) –i (int) –
- Return type:
boolean
- Returns:
bool
- removeInteractionFromIndexSet(inter, i)[source]#
Apply the rule to one Interaction to know if is it should be removed from the IndexSet of level i
- Parameters:
inter (
Interaction
) –i (int) –
- Return type:
boolean
- Returns:
bool
- extraAdditionalTerms()[source]#
get the ExtraAdditionalTerms.
- Return type:
SP::ExtraAdditionalTerms
- Returns:
the ExtraAdditionalTerms
- setExtraAdditionalTerms(eat)[source]#
set the ExtraAdditionalTerms to add smooth terms for the integration process. Useful when a control loop is added to a DynamicalSystem.
- Parameters:
eat (SP::ExtraAdditionalTerms) – the ExtraAdditionalTerms to use
- checkOSI(*args)[source]#
Overload 1:
True if the dynamical system (a vertex in the ds graph) is integrated by this osi.
- Parameters:
dsi (DynamicalSystemsGraph::VIterator) – the iterator on the node of the graph corresponding to the dynamical system of interest.
Overload 2:
True if the dynamical system (a vertex in the ds graph) is integrated by this osi.
- Parameters:
dsgv (DynamicalSystemsGraph::VDescriptor) – the descriptor of the node in the graph corresponding to the dynamical system of interest.
- class siconos.kernel.LinearOSNS(*args)[source]#
Bases:
OneStepNSProblem
Base (abstract) class for linear non-smooth problems
Usually in the form:
\(w = q + M z\)
where - \(w \in R^{n}\) and \(z \in R^{n}\) are the unknowns, - \(M \in R^{n \times n }\) and \(q \in R^{n}\)
examples: LCP, FrictionContact …
Overload 1: default constructor (private)
Overload 2: constructor from a pre-defined solver options set.
- Parameters:
options (
SolverOptions
) – the options setassemblytype – the method used to build the assembled matrix - default=REDUCED_BLOCK
Overload 3: constructor from a pre-defined solver options set.
- Parameters:
options (
SolverOptions
) – the options setassemblytype – the method used to build the assembled matrix - default=REDUCED_BLOCK
- setWPtr(newPtr)[source]#
set w vector (pointer link)
- Parameters:
newPtr (
SiconosVector
) – the new SP::SiconosVector
- setzPtr(newPtr)[source]#
set z vector (pointer link)
- Parameters:
newPtr (
SiconosVector
) – the new SP::SiconosVector
- setMPtr(newM)[source]#
set M to pointer newPtr
- Parameters:
newM (
OSNSMatrix
) – the new M matrix
- setH(H)[source]#
set the value of H
- Parameters:
H (
OSNSMatrix
) – the new matrix
- getQ()[source]#
get the value of q, the constant vector in the LinearOSNS
- Return type:
- Returns:
SiconosVector
- q()[source]#
get q, the the constant vector in the LinearOSNS
- Return type:
- Returns:
pointer on a SiconosVector
- setQPtr(newQ)[source]#
set q to pointer newPtr
- Parameters:
newQ (
SiconosVector
) – the new q vector
- getMStorageType()[source]#
get the type of storage used for M
- Return type:
- Returns:
NM_types (NM_DENSE, NM_SPARSE_BLOCK)
- setMStorageType(i)[source]#
set which type of storage will be used for M Warning: this function does not allocate any memory for M, it just sets an indicator for future use
- Parameters:
i (int) – (NM_DENSE, NM_SPARSE_BLOCK)
- initialize(sim)[source]#
To initialize the LinearOSNS problem(computes topology …)
- Parameters:
sim (
Simulation
) – the simulation owning this OSNSPB
- computeInteractionBlock(ed)[source]#
compute extra-diagonal interactionBlock-matrix
- Parameters:
ed (InteractionsGraph::EDescriptor) – an edge descriptor
- computeDiagonalInteractionBlock(vd)[source]#
compute diagonal Interaction block
- Parameters:
vd (InteractionsGraph::VDescriptor) – a vertex descriptor
- computeqBlock(vertex, pos)[source]#
To compute a part of the q vector of the OSNS
- Parameters:
vertex (InteractionsGraph::VDescriptor) – vertex (interaction) which corresponds to the considered block
pos (int) – the position of the first element of yOut to be set
- preCompute(time)[source]#
build problem coefficients (if required)
- Parameters:
time (float) – the current time
- Return type:
boolean
- Returns:
true if the indexSet is not empty
- class siconos.kernel.LsodarOSI[source]#
Bases:
OneStepIntegrator
LsodarOSI solver (odepack)
Many parameters are required as input/output for LSODAR. See the documentation of this function in externals/odepack/opkdmain.f to have a full description of these parameters. Most of them are read-only parameters (ie can not be set by user).
Except:
jt: Jacobian type indicator (1 means a user-supplied full Jacobian, 2
means an internally generated full Jacobian). Default = 2. - itol, rtol and atol
ITOL = an indicator for the type of error control.
RTOL = a relative error tolerance parameter, either a scalar or array of length NEQ.
ATOL = an absolute error tolerance parameter, either a scalar or an array of length NEQ. Input only.
Default constructor
- property count_NST#
Number of steps taken for the problem so far.
- Type:
Lsodar counter
- property count_NFE#
Number of RHS evaluations for the problem so far.
- intData(*args)[source]#
Overload 1: get vector of integer parameters for lsodar
- Return type:
std::vector< integer,std::allocator< integer > >
- Returns:
a vector<integer>
Overload 2: get _intData[i]
- getRtol()[source]#
get relative tolerance parameter for lsodar
- Return type:
SA::doublereal
- Returns:
a doublereal*
- getAtol()[source]#
get absolute tolerance parameter for lsodar
- Return type:
SA::doublereal
- Returns:
a doublereal*
- getMaxNstep()[source]#
get the maximum number of steps for one call
- Return type:
- Returns:
an interger
- getRwork()[source]#
get real work vector parameter for lsodar
- Return type:
SA::doublereal
- Returns:
a doublereal*
- getJroot()[source]#
get output of root information
- Return type:
SA::integer
- Returns:
a pointer to integer
- setJT(newJT)[source]#
set Jt value, Jacobian type indicator. Excerpts from the lsodar documentation. 1 means a user-supplied full (neq by neq) jacobian. 2 means an internally generated (difference quotient) full jacobian (using neq extra calls to f per df/dy value). 4 means a user-supplied banded jacobian. 5 means an internally generated banded jacobian (using ml+mu+1 extra calls to f per df/dy evaluation). if jt = 1 or 4, the user must supply a subroutine jac (the name is arbitrary) as described above under jac. if jt = 2 or 5, a dummy argument can be used.
- Parameters:
newJT (int) – new value for the jt parameter.
- setTol(*args)[source]#
Overload 1: set itol, rtol and atol (tolerance parameters for lsodar)
- Parameters:
newItol (int) – itol value
newRtol (SA::doublereal) – rtol value
newAtol (SA::doublereal) – atol value
Overload 2: set itol, rtol and atol (scalar tolerance parameters for lsodar)
- setMaxNstep(maxNumberSteps)[source]#
set the maximum number of steps for one call of Lsodar
- Parameters:
maxNumberSteps (int) – the maximum number of steps
- computeRhs(t)[source]#
compute rhs(t) for all dynamical systems in the set
- Parameters:
t (float) – current time of simulation
- computeJacobianRhs(t, DSG0)[source]#
compute jacobian of the rhs at time t for all dynamical systems in the set
- Parameters:
t (float) – current time of simulation
DSG0 (
DynamicalSystemsGraph
) – the graph of DynamicalSystem
- initializeWorkVectorsForDS(t, ds)[source]#
initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi
- Parameters:
t (float) – time of initialization
ds (
DynamicalSystem
) – the dynamical system
- initializeWorkVectorsForInteraction(inter, interProp, DSG)[source]#
initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi
- Parameters:
inter (
Interaction
) – the interactioninterProp (InteractionProperties) – the properties on the graph
DSG (
DynamicalSystemsGraph
) – the dynamical systems graph
- numberOfIndexSets()[source]#
get the number of index sets required for the simulation
- Return type:
- Returns:
unsigned int
- integrate(tinit, tend, tout, ioparam)[source]#
integrate the system, between tinit and tend (->iout=true), with possible stop at tout (->iout=false)
- updateState(level)[source]#
update the state of the DynamicalSystems attached to this Integrator
- Parameters:
level (int) – level of interest for the dynamics
- computeFreeOutput(vertex_descr, osnsp)[source]#
integrates the Interaction linked to this integrator, without taking non-smooth effects into account
- Parameters:
vertex_descr (InteractionsGraph::VDescriptor) – descriptor vertex of the interaction graph
osnsp (
OneStepNSProblem
) – pointer to OneStepNSProblem
- siconos.kernel.LsodarOSI_count_rhs_call()[source]#
Return current number of rhs call (for all lsodar-like OSIs!)
- Return type:
- Returns:
int
- siconos.kernel.LsodarOSI_count_steps()[source]#
Return the number of lsodar steps already done (for all lsodar-like OSIs!)
- Return type:
- Returns:
int
- class siconos.kernel.LCP(*args)[source]#
Bases:
LinearOSNS
Formalization and Resolution of a Linear Complementarity Problem (LCP)
This class is devoted to the formalization and the resolution of the Linear Complementarity Problem (LCP) defined by :
\[\begin{split}w = q + M z \\ w \geq 0, z \geq 0, z^{T} w =0\end{split}\]where - \(w \in R^{n}\) and \(z \in R^{n}\) are the unknowns, - \(M \in R^{n \times n }\) and \(q \in R^{n}\)
The LCP main components are: - a problem (variables M,q and size of the problem), which directly corresponds to the LinearComplementarityProblem structure of Numerics - the unknowns z and w
For details regarding the available options, see Nonsmooth problems formulations and available solvers in users’ guide.
Overload 1: constructor from numerics solver id
- Parameters:
numericsSolverId (int, optional) – id of numerics solver, default = SICONOS_LCP_LEMKE
Overload 2: constructor from a pre-defined solver options set
- Parameters:
options (
SolverOptions
) – the options set
- solve()[source]#
Call numerics solver.
- Return type:
- Returns:
int information about the solver convergence (output from numerics driver, linearComplementarity_driver, check numerics doc. for details).
- class siconos.kernel.AVI(*args)[source]#
Bases:
LinearOSNS
Formalization and Resolution of an Affine Variational Inequality (AVI)
This class is devoted to the formalization and the resolution of Affine variational Inequalities (AVI): given a polytopic set \(P\), \(M\in R^{p\times p}\) and \(q\in R^p\),
\[\text{find }z \in P\text{ such that}\quad \langle Mz+q, x - z\rangle \geq 0 \qquad \forall x \in P\]TODO: : add “recover” function to start from old values of z and w.
For details regarding the available options, see Nonsmooth problems formulations and available solvers in users’ guide.
Overload 1: constructor from numerics solver id
- Parameters:
numericsSolverId (int, optional) – id of numerics solver, default = SICONOS_AVI_CAOFERRIS
Overload 2: constructor from a pre-defined solver options set
- Parameters:
options (
SolverOptions
) – the options set
- initialize(sim)[source]#
To initialize the LinearOSNS problem(computes topology …)
- Parameters:
sim (
Simulation
) – the simulation owning this OSNSPB
- class siconos.kernel.QP[source]#
Bases:
OneStepNSProblem
Quadratic Problem
Overload 1: default constructor
Overload 2: constructor from a pre-defined solver options set.
- Parameters:
options (
SolverOptions
) – the options set
- setQ(newValue)[source]#
set the value of Q to newValue
- Parameters:
newValue (
SiconosMatrix
) – SiconosMatrix
- setQPtr(newPtr)[source]#
set Q to pointer newPtr
- Parameters:
newPtr (
SiconosMatrix
) – the new matrix
- getP()[source]#
get the value of p, the initial state of the DynamicalSystem
- Return type:
- Returns:
SiconosVector
Warning: : SiconosVector is an abstract class => can not be an lvalue => return SiconosVector
- p()[source]#
get p, the initial state of the DynamicalSystem
- Return type:
- Returns:
pointer on a SiconosVector
- setP(newValue)[source]#
set the value of p to newValue
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setPPtr(newPtr)[source]#
set p to pointer newPtr
- Parameters:
newPtr (
SiconosVector
) – SiconosVector *
- computeInteractionBlock(arg0)[source]#
compute extra-diagonal interactionBlock-matrix
- Parameters:
ed (InteractionsGraph::EDescriptor) – an edge descriptor
- computeDiagonalInteractionBlock(arg0)[source]#
compute diagonal Interaction block
- Parameters:
vd (InteractionsGraph::VDescriptor) – a vertex descriptor
- class siconos.kernel.Relay(*args)[source]#
Bases:
LinearOSNS
Formalization and Resolution of a Linear Complementarity Problem (Relay)
This class is devoted to the formalization and the resolution of the Relay NonSmooth problems.
\[w = q + M z\]\[w \geq 0, z \geq 0, z^{T} w =0\]where - \(w \in R^{n}\) and \(z \in R^{n}\) are the unknowns, - \(M \in R^{n \times n }\) and \(q \in R^{n}\)
TODO: : add “recover” function to start from old values of z and w. : review this introduction …
Overload 1: constructor from numerics solver id
- Parameters:
numericsSolverId (int, optional) – id of numerics solver, default = SICONOS_RELAY_AVI_CAOFERRIS
Overload 2: constructor from a pre-defined solver options set
- Parameters:
options (
SolverOptions
) – the options set
- getLb()[source]#
get the value of lb, the lower bounds of the Relay system
- Return type:
- Returns:
the vector of lower bounds
- lb()[source]#
get lb, the lower bounds of the Relay system
- Return type:
- Returns:
the vector of lower bounds
- setLb(newLb)[source]#
set lb to pointer newPtr
- Parameters:
newLb (
SiconosVector
) – new lower bound
- getUb()[source]#
get the value of ub, the upper bounds of the Relay system
- Return type:
- Returns:
the vector of upper bounds
- ub()[source]#
get lb, the lower bounds of the Relay system
- Return type:
- Returns:
the vector of upper bounds
- setUb(newUb)[source]#
set ub to pointer newPtr
- Parameters:
newUb (
SiconosVector
) – new upper bound
- initialize(sim)[source]#
To initialize the LinearOSNS problem(computes topology …)
- Parameters:
sim (
Simulation
) – the simulation owning this OSNSPB
- class siconos.kernel.MLCP(*args)[source]#
Bases:
LinearOSNS
Formalization and Resolution of a Mixed Linear Complementarity Problem (MLCP)
This class is devoted to the formalization and the resolution of the Mixed Linear Complementarity Problem (MLCP) defined by :
\[\begin{split}0 = Au + Cv + a \\ \\ z = Du + Bv + b \\ \\ v \geq 0, z \geq 0, z^{T} v =0\end{split}\]where - \(u \in R^{n}\) \(v \in R^{m}\) and \(z \in R^{m}\) are the unknowns, - \(a \in R^{n}\) and \(b \in R^{m}\) - \(A \in R^{n \times n }\) - \(B \in R^{m \times m }\) - \(C \in R^{n \times m }\) - \(D \in R^{m \times n }\)
The MLCP main components are: - a problem (variables A,B,C,D,a,b and size of the problem), which directly corresponds to the MixedLinearComplementarityProblem structure of Numerics - the unknowns u,v and z
Overload 1: constructor from data
- Parameters:
numericsSolverId (int, optional) – id of Numerics solver (optional, default = SICONOS_MLCP_ENUM the enumerative solver)
Overload 2: constructor from a pre-defined solver options set
- Parameters:
options (
SolverOptions
) – the options set
- computeOptions(inter1, inter2)[source]#
compute equalities/inequalities sizes and set corresponding values in numerics problem
- Parameters:
inter1 (
Interaction
) – Interaction used to get a non-smooth law and the constraints sizes.inter2 (
Interaction
) – another interaction, not used indeed (?)
- getNumericsMLCP()[source]#
get the pointer on the Numerics MLCP,
- Return type:
SP::MixedLinearComplementarityProblem
- Returns:
SP::MixedLinearComplementarityProblem
- computeInteractionBlock(ed)[source]#
compute extra-diagonal interactionBlock-matrix
- Parameters:
ed (InteractionsGraph::EDescriptor) – an edge descriptor
- computeDiagonalInteractionBlock(vd)[source]#
compute diagonal Interaction block
- Parameters:
vd (InteractionsGraph::VDescriptor) – a vertex descriptor
- class siconos.kernel.MLCPProjectOnConstraints(*args)[source]#
Bases:
MLCP
Formalization and Resolution of a Mixed Linear Complementarity Problem (MLCP)
This class is devoted to the formalization and the resolution of the Mixed Linear Complementarity Problem (MLCP) for the specific problem of the projection onto the constraints in Mechanics
Overload 1: constructor from data
- Parameters:
- Overload 2:
constructor from a pre-defined solver options set.
- type options:
- param options:
the options set,
- type alpha:
float, optional
- param alpha:
alpha parameter value
- Overload 3:
constructor from a pre-defined solver options set.
- type options:
- param options:
the options set,
- param alpha:
alpha parameter value
- computeOptions(inter1, inter2)[source]#
compute the number of inequality and equality for a given tuple of Interactions update the global number of equality(_n) and inequality (_m) set up _numerics_problem parameters (blocksRows and blocksIsComp )
- Parameters:
inter1 (
Interaction
) – first interaction consideredinter2 (
Interaction
) – second interaction
- setAlpha(newval)[source]#
- setter for alpha
- type newval:
float, in
- param newval:
new value for alpha parameter
- displayBlocks(indexSet)[source]#
- Display the set of blocks for a given indexSet
- type indexSet:
InteractionsGraph
- param indexSet:
the graph of interactions
- updateInteractionBlocks()[source]#
compute interactionBlocks if necessary (this depends on the type of OSNS, on the indexSets …)
- updateInteractionBlocksOLD()[source]#
compute interactionBlocks if necessary (this depends on the type of OSNS, on the indexSets …)
- computeDiagonalInteractionBlock(vd)[source]#
- compute diagonal Interaction block
- type vd:
InteractionsGraph::VDescriptor
- param vd:
a vertex (interaction) descriptor
- computeInteractionBlock(vd)[source]#
- compute diagonal Interaction block
- type vd:
InteractionsGraph::EDescriptor
- param vd:
a vertex (interaction) descriptor
- computeqBlock(vd, pos)[source]#
- To compute a part of the “q” vector of the OSNS
- type vd:
InteractionsGraph::VDescriptor
- param vd:
vertex (interaction) which corresponds to the considered block
- type pos:
int
- param pos:
the position of the first element of yOut to be set
- postComputeLagrangianR(inter, pos)[source]#
- post-treatment for MLCPProjectOnConstraints for LagrangianR
- type inter:
- param inter:
the considered interaction
- type pos:
int
- param pos:
interaction position in the global vector
- class siconos.kernel.GenericMechanical(*args)[source]#
Bases:
LinearOSNS
Formalization and Resolution of a generic mechanical problem: It mixes bilateral equality, complementarity, impact and friction problems.
This class is devoted to contains of a set of Non-Smooth Problem.
Main functions: - formalization of the problem: computes M,q using the set of “active” Interactions from the simulation and the interactionBlock-matrices saved in the field interactionBlocks. Functions: initialize(), computeInteractionBlock(), preCompute() - solving of the GenericMechanical problem: function compute(), used to call solvers from Numerics through the gmp_driver() interface of Numerics. - post-treatment of data: set values of y/lambda variables of the active Interaction (ie Interactions) using ouput results from the solver (velocity,reaction); function postCompute().
For details regarding the available options, see Nonsmooth problems formulations and available solvers in users’ guide.
Overload 1: constructor from solver id
- Parameters:
numericsSolverId – id of the internal friction solver of the generic problem default = SICONOS_FRICTION_3D_ONECONTACT_NSN
Overload 2: constructor from a pre-defined solver options set
- Parameters:
options (
SolverOptions
) – the options set
- initialize(sim)[source]#
initialize the GenericMechanical problem(compute topology …)
- Parameters:
sim (
Simulation
) – the simulation, owner of this OSNSPB
- compute(time)[source]#
Compute the unknown reaction and velocity and update the Interaction (y and lambda )
- computeInteractionBlock(ed)[source]#
compute extra-diagonal interactionBlock-matrix
- Parameters:
ed (InteractionsGraph::EDescriptor) – an edge descriptor
- computeDiagonalInteractionBlock(vd)[source]#
compute diagonal Interaction block
- Parameters:
vd (InteractionsGraph::VDescriptor) – a vertex descriptor
- class siconos.kernel.FrictionContact(*args)[source]#
Bases:
LinearOSNS
Formalization and Resolution of a Friction-Contact Problem
This class is devoted to the formalization and the resolution of friction contact problems defined by :
\[\begin{split}velocity = q + M reaction \\ \\ velocity \geq 0, reaction \geq 0, reaction^{T} velocity =0\end{split}\]and a Coulomb friction law.
With: - \(velocity \in R^{n}\) and \(reaction \in R^{n}\) the unknowns, - \(M \in R^{n \times n }\) and \(q \in R^{n}\)
The dimension of the problem (2D or 3D) is given by the variable contactProblemDim and the proper Numerics driver will be called according to this value.
Construction: just set Numerics Solver id
Main functions:
Usage: - compute(time) formalize, solve and post-process the problem.
pre- and post-pro are common to all LinearOSNS and defined in this class.
For details regarding the available options, see Nonsmooth problems formulations and available solvers in users’ guide.
Overload 1: constructor (solver id and dimension)
- Parameters:
Overload 2: constructor from a pre-defined solver options set
- Parameters:
options (
SolverOptions
) – the options set
- getFrictionContactDim()[source]#
get the type of FrictionContact problem (2D or 3D)
- Return type:
- Returns:
an int (2 or 3)
- mu()[source]#
get a pointer to mu, the list of the friction coefficients
- Return type:
SP::MuStorage
- Returns:
pointer on a std::vector<double>
- getMu(*args)[source]#
- Overload 1:
get the vector mu, list of the friction coefficients
- rtype:
MuStorage
- return:
a vector of double
- Overload 2:
get the value of the component number i of mu, the vector of the friction coefficients :type i: int
- Parameters:
i – the component number (starting from 0) :rtype: float
- Returns:
double value of mu
- setNumericsDriver(newFunction)[source]#
set the driver-function used to solve the problem
- Parameters:
newFunction (int) – function of prototype Driver
- initialize(simulation)[source]#
initialize the FrictionContact problem(compute topology …)
- Parameters:
simulation (
Simulation
) – the simulation, owner of this OSNSPB
- frictionContactProblem()[source]#
- Return type:
SP::FrictionContactProblem
- Returns:
the friction contact problem from Numerics
- frictionContactProblemPtr()[source]#
- Return type:
- Returns:
the friction contact problem from Numerics (raw ptr, do not free)
- solve(*args)[source]#
solve a friction contact problem
- Parameters:
problem (SP::FrictionContactProblem, optional) – the friction contact problem
- Return type:
- Returns:
info solver information result
- class siconos.kernel.GlobalFrictionContact(*args)[source]#
Bases:
LinearOSNS
Formalization and Resolution of a Friction-Contact Problem
This class is devoted to the formalization and the resolution of primal friction contact problems defined by :
\[\begin{split}M velocity = q + H reaction \\ globalVelocities = H^T velocity + tildeGlobalVelocities\end{split}\]and \(globalVelocities, reaction\) belongs to the Coulomb friction law with unilateral contact.
With: - \(velocity \in R^{n}\) and \(reaction \in R^{n}\) the unknowns, - \(M \in R^{n \times n }\) and \(q \in R^{n}\) - \(globalVelocities \in R^{m}\) and \(reaction \in R^{m}\) the unknowns, - \(tildeGlobalVelocities \in R^{m}\) is the modified local velocity (\(e U_{N,k}\)) - \(M \in R^{n \times n }\) and \(q \in R^{n}\) - \(H \in R^{n \times m }\)
The dimension of the problem (2D or 3D) is given by the variable contactProblemDim and the right Numerics driver will be called according to this value.
Construction: - Constructor from data (inputs = Simulations*, id, SP::NonSmoothSolver) - The solver is optional. Main functions:
Main functions: - formalization of the problem: computes M,q using the set of “active” Interactions from the simulation and the interactionBlock-matrices saved in the field interactionBlocks. Functions: initialize(), computeInteractionBlock(), preCompute() - solving of the GlobalFrictionContact problem: function compute(), used to call solvers from Numerics through the frictionContact2D_driver() or frictionContact3D_driver() interface of Numerics. - post-treatment of data: set values of y/lambda variables of the active Interaction (ie Interactions) using ouput results from the solver (velocity,reaction); function postCompute().
For details regarding the available options, see Nonsmooth problems formulations and available solvers in users’ guide.
Overload 1: default constructor
Overload 2: constructor (solver id and dimension)
- Parameters:
Overload 3: constructor (solver id and dimension)
- Parameters:
dimPb (int) – dimension (2D or 3D) of the friction-contact problem
numericsSolverId – id of the solver to be used, optional, default : SICONOS_GLOBAL_FRICTION_3D_NSGS
Overload 4: constructor from a pre-defined solver options set
- Parameters:
options (
SolverOptions
) – the options set
- getGlobalFrictionContactDim()[source]#
get the type of GlobalFrictionContact problem (2D or 3D)
- Return type:
- Returns:
an int (2 or 3)
- setGlobalVelocities(newPtr)[source]#
set globalVelocities to pointer newPtr
- Parameters:
newPtr (
SiconosVector
) – the new vector
- mu()[source]#
get a pointer to mu, the list of the friction coefficients
- Return type:
SP::MuStorage
- Returns:
pointer on a std::vector<double>
- getMu(i)[source]#
get the value of the component number i of mu, the vector of the friction coefficients
- Return type:
- Returns:
the friction coefficient for the ith contact
- initialize(sim)[source]#
initialize the GlobalFrictionContact problem(compute topology …)
- Parameters:
sim (
Simulation
) – the simulation, owner of this OSNSPB
- globalFrictionContactProblem()[source]#
- Return type:
SP::GlobalFrictionContactProblem
- Returns:
the friction contact problem from Numerics
- globalFrictionContactProblemPtr()[source]#
- Return type:
- Returns:
the friction contact problem from Numerics (raw ptr, do not free)
- solve(*args)[source]#
solve a friction contact problem
- Parameters:
problem (SP::GlobalFrictionContactProblem, optional) – the friction contact problem
- Return type:
- Returns:
info solver information result
- compute(time)[source]#
Compute the unknown reaction and velocity and update the Interaction (y and lambda )
- Parameters:
time (float) – current time
- class siconos.kernel.RollingFrictionContact(*args)[source]#
Bases:
LinearOSNS
Formalization and Resolution of a Friction-Contact Problem
This class is devoted to the formalization and the resolution of friction contact problems defined by :
\[\begin{split}velocity = q + M reaction \\ \\ velocity \geq 0, reaction \geq 0, reaction^{T} velocity =0\end{split}\]and a Coulomb friction law.
With: - \(velocity \in R^{n}\) and \(reaction \in R^{n}\) the unknowns, - \(M \in R^{n \times n }\) and \(q \in R^{n}\)
The dimension of the problem (2D or 3D) is given by the variable contactProblemDim and the proper Numerics driver will be called according to this value.
Construction: just set Numerics Solver id
Main functions:
Usage: - compute(time) formalize, solve and post-process the problem.
pre- and post-pro are common to all LinearOSNS and defined in this class.
Overload 1: constructor (solver id and dimension)
- Parameters:
Overload 2: constructor from a pre-defined solver options set.
- Parameters:
dim – pb dimension, 5 only
options (
SolverOptions
) – the options set
- getRollingFrictionContactDim()[source]#
get the type of RollingFrictionContact problem (2D or 3D)
- Return type:
- Returns:
an int (2 or 3)
- mu()[source]#
get a pointer to mu, the list of the friction coefficients
- Return type:
SP::MuStorage
- Returns:
pointer on a std::vector<double>
- getMu(*args)[source]#
Overload 1: get the vector mu, list of the friction coefficients
- Return type:
MuStorage
- Returns:
a vector of double
Overload 2: get the value of the component number i of mu, the vector of the friction coefficients
- setNumericsDriver(newFunction)[source]#
set the driver-function used to solve the problem
- Parameters:
newFunction (int) – function of prototype Driver
- initialize(simulation)[source]#
initialize the RollingFrictionContact problem(compute topology …)
- Parameters:
simulation (
Simulation
) – the simulation, owner of this OSNSPB
- frictionContactProblem()[source]#
- Return type:
SP::RollingFrictionContactProblem
- Returns:
the friction contact problem from Numerics
- frictionContactProblemPtr()[source]#
- Return type:
- Returns:
the friction contact problem from Numerics (raw ptr, do not free)
- solve(*args)[source]#
solve a friction contact problem
- Parameters:
problem (SP::RollingFrictionContactProblem, optional) – the friction contact problem
- Return type:
- Returns:
info solver information result
- class siconos.kernel.GlobalRollingFrictionContact(*args)[source]#
Bases:
GlobalFrictionContact
Formalization and Resolution of a Friction-Contact Problem
This class is devoted to the formalization and the resolution of primal friction contact problems defined by :
\[\begin{split}M velocity = q + H reaction \\ globalVelocities = H^T velocity + tildeGlobalVelocities\end{split}\]and \(globalVelocities, reaction\) belongs to the Coulomb friction law with unilateral contact.
With: - \(velocity \in R^{n}\) and \(reaction \in R^{n}\) the unknowns, - \(M \in R^{n \times n }\) and \(q \in R^{n}\) - \(globalVelocities \in R^{m}\) and \(reaction \in R^{m}\) the unknowns, - \(tildeGlobalVelocities \in R^{m}\) is the modified local velocity (\(e U_{N,k}\)) - \(M \in R^{n \times n }\) and \(q \in R^{n}\) - \(H \in R^{n \times m }\)
The dimension of the problem (2D or 3D) is given by the variable contactProblemDim and the right Numerics driver will be called according to this value.
Construction: - Constructor from data (inputs = Simulations*, id, SP::NonSmoothSolver) - The solver is optional. Main functions:
Main functions: - formalization of the problem: computes M,q using the set of “active” Interactions from the simulation and
the interactionBlock-matrices saved in the field interactionBlocks.
Functions: initialize(), computeInteractionBlock(), preCompute() - solving of the GlobalRollingFrictionContact problem: function compute(), used to call solvers from Numerics through
the frictionContact2D_driver() or frictionContact3D_driver() interface of Numerics. - post-treatment of data: set values of y/lambda variables of the active Interaction (ie Interactions) using
ouput results from the solver (velocity,reaction); function postCompute().
For details regarding the available options, see Nonsmooth problems formulations and available solvers in users’ guide.
Overload 1: constructor (solver id and dimension)
- Parameters:
Overload 2: constructor from a pre-defined solver options set
- Parameters:
options (
SolverOptions
) – the options set
- getGlobalRollingFrictionContactDim()[source]#
get the type of GlobalRollingFrictionContact problem (2D or 3D)
- Return type:
- Returns:
an int (2 or 3)
- mur()[source]#
get a pointer to mu, the list of the friction coefficients
- Return type:
SP::MuStorage
- Returns:
pointer on a std::vector<double>
- getMur(i)[source]#
get the value of the component number i of mu, the vector of the friction coefficients
- Return type:
- Returns:
the friction coefficient for the ith contact
- initialize(sim)[source]#
initialize the GlobalRollingFrictionContact problem(compute topology …)
- Parameters:
sim (
Simulation
) – the simulation, owner of this OSNSPB
- globalRollingFrictionContactProblem()[source]#
- Return type:
SP::GlobalRollingFrictionContactProblem
- Returns:
the friction contact problem from Numerics
- globalRollingFrictionContactProblemPtr()[source]#
- Return type:
- Returns:
the friction contact problem from Numerics (raw ptr, do not free)
- solve(*args)[source]#
solve a friction contact problem
- Parameters:
problem (SP::GlobalRollingFrictionContactProblem, optional) – the friction contact problem
- Return type:
- Returns:
info solver information result
- class siconos.kernel.EulerMoreauOSI(*args)[source]#
Bases:
OneStepIntegrator
One Step time Integrator for First Order Dynamical Systems.
This integrator is the work horse of the event–capturing time stepping schemes for first order systems. It is mainly based on some extensions of the Backward Euler and \(\theta-\gamma\) schemes proposed in the pionnering work of J.J. Moreau for the sweeping process
J.J. Moreau. Evolution problem associated with a moving convex set in a Hilbert space. Journal of Differential Equations, 26, pp 347–374, 1977.
Variants are now used to integrate LCS, Relay systems, Higher order sweeping process see for instance
Consistency of a time-stepping method for a class of piecewise linear networks
M.K. Camlibel, W.P.M.H. Heemels, and J.M. Schumacher IEEE Transactions on Circuits and Systems I, 2002, 49(3):349–357
Numerical methods for nonsmooth dynamical systems: applications in mechanics and electronics
V Acary, B Brogliato Springer Verlag 2008
Convergence of time-stepping schemes for passive and extended linear complementarity systems L. Han, A. Tiwari, M.K. Camlibel, and J.-S. Pang SIAM Journal on Numerical Analysis 2009, 47(5):3768-3796
On preserving dissipativity properties of linear complementarity dynamical systems with the &theta-method
Greenhalgh Scott, Acary Vincent, Brogliato Bernard Numer. Math., , 2013.
Main time–integration schemes are based on the following \(\theta-\gamma\) scheme
\[\begin{split}\begin{cases} \label{eq:toto1} M x_{k+1} = M x_{k} +h\theta f(x_{k+1},t_{k+1})+h(1-\theta) f(x_k,t_k) + h \gamma r(t_{k+1}) + h(1-\gamma)r(t_k) \\[2mm] y_{k+1} = h(t_{k+1},x_{k+1},\lambda _{k+1}) \\[2mm] r_{k+1} = g(x_{k+1},\lambda_{k+1},t_{k+1})\\[2mm] \mbox{nslaw} ( y_{k+1} , \lambda_{k+1}) \end{cases}\end{split}\]where \(\theta = [0,1]\) and \(\gamma \in [0,1]\). As in Acary & Brogliato 2008, we call the previous problem the ``one–step nonsmooth problem’’.
Another variant can also be used (FullThetaGamma scheme)
\[\begin{split}\begin{cases} M x_{k+1} = M x_{k} +h f(x_{k+\theta},t_{k+1}) + h r(t_{k+\gamma})\\[2mm] y_{k+\gamma} = h(t_{k+\gamma},x_{k+\gamma},\lambda _{k+\gamma})\\[2mm] r_{k+\gamma} = g(x_{k+\gamma},\lambda_{k+\gamma},t_{k+\gamma})\\[2mm] \mbox{nslaw} ( y_{k+\gamma} , \lambda_{k+\gamma}) \end{cases}\end{split}\]EulerMoreauOSI class is used to define some time-integrators methods for a list of first order dynamical systems. A EulerMoreauOSI instance is defined by the value of theta and possibly gamma and the list of concerned dynamical systems.
Each DynamicalSystem is associated to a SiconosMatrix, named “W”, which is the “iteration” matrix. W matrices are initialized and computed in initializeIterationMatrixW and computeW. Depending on the DS type, they may depend on time t and DS state x.
For first order systems, the implementation uses _r for storing the the input due to the nonsmooth law. This EulerMoreauOSI scheme assumes that the relative degree is zero or one and one level for _r is sufficient
Main functions:
computeFreeState(): computes xfree (or vfree), dynamical systems state without taking non-smooth part into account
- updateState(): computes x (q,v), the complete dynamical systems
states.
See User’s guide, for details.
Overload 1: Default constructor
Overload 2: constructor from theta value only
- Parameters:
theta (float) – value for all DS.
Overload 3: constructor from theta value only
- getW(*args)[source]#
get the value of W corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
, optional) – a pointer to DynamicalSystem, optional, default = nullptr. get W[0] in that case- Return type:
- Returns:
SimpleMatrix
- W(ds)[source]#
get W corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
) – a pointer to DynamicalSystem- Return type:
- Returns:
pointer to a SiconosMatrix
- getWBoundaryConditions(*args)[source]#
get the value of WBoundaryConditions corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
, optional) – a pointer to DynamicalSystem, optional, default = nullptr. get WBoundaryConditions[0] in that case- Return type:
- Returns:
SimpleMatrix
- WBoundaryConditions(ds)[source]#
get WBoundaryConditions corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
) – a pointer to DynamicalSystem, optional, default = nullptr. get WBoundaryConditions[0] in that case- Return type:
- Returns:
pointer to a SiconosMatrix
- setUseGamma(b)[source]#
set the boolean to indicate that we use gamma
- Parameters:
b (boolean) – true if gamma has to be used, false otherwise
- useGammaForRelation()[source]#
get bool gammaForRelation for the relation
- Return type:
boolean
- Returns:
a
- setUseGammaForRelation(newUseGammaForRelation)[source]#
set the boolean to indicate that we use gamma for the relation
- Parameters:
newUseGammaForRelation (boolean) – a bool
- initializeWorkVectorsForDS(t, ds)[source]#
initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi
- Parameters:
t (float) – time of initialization
ds (
DynamicalSystem
) – the dynamical system
- initializeWorkVectorsForInteraction(inter, interProp, DSG)[source]#
initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi
- Parameters:
inter (
Interaction
) – the interactioninterProp (InteractionProperties) – the properties on the graph
DSG (
DynamicalSystemsGraph
) – the dynamical systems graph
- numberOfIndexSets()[source]#
get the number of index sets required for the simulation
- Return type:
- Returns:
unsigned int
- initializeIterationMatrixW(time, ds)[source]#
initialize iteration matrix W EulerMoreauOSI matrix at time t
- Parameters:
time (float) – the time (double)
ds (
DynamicalSystem
) – a pointer to DynamicalSystem
- computeW(time, ds, dsv, W)[source]#
compute W EulerMoreauOSI matrix at time t
- Parameters:
time (float) – the current time
ds (
DynamicalSystem
) – the DynamicalSystemdsv (DynamicalSystemsGraph::VDescriptor) – a descriptor of the ds on the graph (redundant to avoid invocation)
W (
SiconosMatrix
) – the matrix to compute
- computeWBoundaryConditions(ds)[source]#
compute WBoundaryConditionsMap[ds] EulerMoreauOSI matrix at time t
- Parameters:
ds (
DynamicalSystem
) – a pointer to DynamicalSystem
- initializeIterationMatrixWBoundaryConditions(ds)[source]#
initialize iteration matrix WBoundaryConditionsMap[ds] EulerMoreauOSI
- Parameters:
ds (
DynamicalSystem
) – a pointer to DynamicalSystem
- computeResidu()[source]#
Computes the residuFree and residu of all the DynamicalSystems
- Return type:
- Returns:
the maximum of the 2-norm over all the residu
- computeFreeState()[source]#
Perform the integration of the dynamical systems linked to this integrator without taking into account the nonsmooth input r
- updateOutput(*args)[source]#
Overload 1: update the output of the Interaction attached to this Integrator
Overload 2: update the output of the Interaction attached to this Integrator
- updateInput(*args)[source]#
Overload 1: update the input of the Interaction attached to this Integrator
Overload 2: update the input of the Interaction attached to this Integrator
- computeResiduOutput(time, indexSet)[source]#
compute the residu of the output of the relation (y) This computation depends on the type of OSI
- Parameters:
time (float) – time of computation
indexSet (
InteractionsGraph
) – the index set of the interaction that are concerned
- computeResiduInput(time, indexSet)[source]#
compute the residu of the input of the relation (R or p) This computation depends on the type of OSI
- Parameters:
time (float) – time of computation
indexSet (
InteractionsGraph
) – the index set of the interaction that are concerned
- computeFreeOutput(vertex_inter, osnsp)[source]#
integrates the Interaction linked to this integrator, without taking non-smooth effects into account
- Parameters:
vertex_inter (InteractionsGraph::VDescriptor) – of the interaction graph
osnsp (
OneStepNSProblem
) – pointer to OneStepNSProblem
- prepareNewtonIteration(time)[source]#
computes all the W matrices
- Parameters:
time (float) – current time
- integrate(tinit, tend, tout, useless)[source]#
integrate the system, between tinit and tend (->iout=true), with possible stop at tout (->iout=false)
- class siconos.kernel.MoreauJeanOSI(*args)[source]#
Bases:
OneStepIntegrator
One Step time Integrator, Moreau-Jean algorithm. This integrator is the work horse of the event–capturing time stepping schemes for mechanical systems. It is mainly based on the pioneering works of M. Jean and J.J. Moreau for the time integration of mechanical systems with unilateral contact, impact and Coulomb’s friction with \(\theta\) scheme
For the linear Lagrangian system, the scheme reads as
\[\begin{split}\begin{cases} M (v_{k+1}-v_k) + h K q_{k+\theta} + h C v_{k+\theta} - h F_{k+\theta} = p_{k+1} = G P_{k+1},\label{eq:MoreauTS-motion}\\[1mm] q_{k+1} = q_{k} + h v_{k+\theta}, \quad \\[1mm] U_{k+1} = G^\top\, v_{k+1}, \\[1mm] \begin{array}{lcl} 0 \leq U^\alpha_{k+1} + e U^\alpha_{k} \perp P^\alpha_{k+1} \geq 0,& \quad&\alpha \in \mathcal I_1, \\[1mm] P^\alpha_{k+1} =0,&\quad& \alpha \in \mathcal I \setminus \mathcal I_1, \end{array} \end{cases}\end{split}\]with \(\theta \in [0,1]\). The index set \(\mathcal I_1\) is the discrete equivalent to the rule that allows us to apply the Signorini condition at the velocity level. In the numerical practice, we choose to define this set by
\[\mathcal I_1 = \{\alpha \in \mathcal I \mid G^\top (q_{k} + h v_{k}) + w \leq 0\text{ and } U_k \leq 0 \}.\]For more details, we refer to
M. Jean and J.J. Moreau. Dynamics in the presence of unilateral contacts and dry friction: a numerical approach. In G. Del Pietro and F. Maceri, editors, Unilateral problems in structural analysis. II, pages 151–196. CISM 304, Spinger Verlag, 1987.
J.J. Moreau. Unilateral contact and dry friction in finite freedom dynamics. In J.J. Moreau and Panagiotopoulos P.D., editors, Nonsmooth Mechanics and Applications, number 302 in CISM, Courses and lectures, pages 1–82. CISM 302, Spinger Verlag, Wien- New York, 1988a.
J.J. Moreau. Numerical aspects of the sweeping process. Computer Methods in Applied Mechanics and Engineering, 177:329–349, 1999.
M. Jean. The non smooth contact dynamics method. Computer Methods in Applied Mechanics and Engineering, 177:235–257, 1999.
and for a review :
V. Acary and B. Brogliato. Numerical Methods for Nonsmooth Dynamical Systems: Applications in Mechanics and Electronics, volume 35 of Lecture Notes in Applied and Computational Mechanics. Springer Verlag, 2008.
MoreauJeanOSI class is used to define some time-integrators methods for a list of dynamical systems. A MoreauJeanOSI instance is defined by the value of theta and the list of concerned dynamical systems.
Each DynamicalSystem is associated to a SiconosMatrix, named “W”, the “teration” matrix” W matrices are initialized and computed in initializeIterationMatrixW and computeW. Depending on the DS type, they may depend on time t and DS state x.
For mechanical systems, the implementation uses _p for storing the the input due to the nonsmooth law. This MoreauJeanOSI scheme assumes that the relative degree is two.
For Lagrangian systems, the implementation uses _p[1] for storing the discrete impulse.
Main functions:
computeFreeState(): computes xfree (or vfree), dynamical systems
state without taking non-smooth part into account n
updateState(): computes x (q,v), the complete dynamical systems
states. See User’s guide for details.
constructor from theta value only
- Parameters:
- getW(*args)[source]#
get the value of W corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
, optional) – a pointer to DynamicalSystem, optional, default = nullptr. get W[0] in that case- Return type:
- Returns:
SimpleMatrix
- W(ds)[source]#
get W corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
) – a pointer to DynamicalSystem- Return type:
- Returns:
pointer to a SiconosMatrix
- getWBoundaryConditions(*args)[source]#
Get the value of WBoundaryConditions corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
, optional) – a pointer to DynamicalSystem, optional, default = nullptr. get WBoundaryConditions[0] in that case- Return type:
- Returns:
SimpleMatrix
- WBoundaryConditions(ds)[source]#
get WBoundaryConditions corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
) – a pointer to DynamicalSystem, optional, default = nullptr. get WBoundaryConditions[0] in that case- Return type:
- Returns:
pointer to a SiconosMatrix
- setUseGamma(newUseGamma)[source]#
set the Boolean to indicate that we use gamma
- Parameters:
newUseGamma (boolean) – a Boolean variable
- useGammaForRelation()[source]#
get bool gammaForRelation for the relation
- Return type:
boolean
- Returns:
a Boolean
- setUseGammaForRelation(newUseGammaForRelation)[source]#
set the boolean to indicate that we use gamma for the relation
- Parameters:
newUseGammaForRelation (boolean) – a Boolean
- explicitNewtonEulerDSOperators()[source]#
get boolean _explicitNewtonEulerDSOperators for the relation
- Return type:
boolean
- Returns:
a Boolean
- setExplicitNewtonEulerDSOperators(newExplicitNewtonEulerDSOperators)[source]#
set the boolean to indicate that we use gamma for the relation
- Parameters:
newExplicitNewtonEulerDSOperators (boolean) – a Boolean
- initialize_nonsmooth_problems()[source]#
initialization of the MoreauJeanOSI integrator; for linear time invariant systems, we compute time invariant operator (example : W)
- Initialization process of the nonsmooth problems
linked to this OSI
- initializeWorkVectorsForDS(t, ds)[source]#
initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi
- Parameters:
t (float) – time of initialization
ds (
DynamicalSystem
) – the dynamical system
- initializeWorkVectorsForInteraction(inter, interProp, DSG)[source]#
initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi
- Parameters:
inter (
Interaction
) – the interactioninterProp (InteractionProperties) – the properties on the graph
DSG (
DynamicalSystemsGraph
) – the dynamical systems graph
- numberOfIndexSets()[source]#
get the number of index sets required for the simulation
- Return type:
- Returns:
unsigned int
- initializeIterationMatrixW(time, ds)[source]#
initialize iteration matrix W MoreauJeanOSI matrix at time t
- Parameters:
time (float) –
ds (
SecondOrderDS
) – a pointer to DynamicalSystem
- computeW(time, ds, W)[source]#
compute W MoreauJeanOSI matrix at time t
- Parameters:
time (float) – (double)
ds (
SecondOrderDS
) – a DynamicalSystemW (
SiconosMatrix
) – the result in W
- Winverse(ds, keepW=False)[source]#
get and compute if needed W MoreauJeanOSI matrix at time t
- Parameters:
time – (double)
ds (
SecondOrderDS
) – a DynamicalSystemWinverse – the result in Winverse
keepW (boolean, optional) –
- computeResidu()[source]#
return the maximum of all norms for the “MoreauJeanOSI-discretized” residus of DS
- Return type:
- Returns:
a double
- computeFreeState()[source]#
Perform the integration of the dynamical systems linked to this integrator without taking into account the nonsmooth input (_r or _p)
- computeFreeOutput(vertex_inter, osnsp)[source]#
integrates the Interaction linked to this integrator, without taking non-smooth effects into account
- Parameters:
vertex_inter (InteractionsGraph::VDescriptor) – vertex of the interaction graph
osnsp (
OneStepNSProblem
) – pointer to OneStepNSProblem
- addInteractionInIndexSet(inter, i)[source]#
Apply the rule to one Interaction to know if it should be included in the IndexSet of level i
- Parameters:
inter (
Interaction
) – the Interaction to testi (int) – level of the IndexSet
- Return type:
boolean
- Returns:
Boolean
- removeInteractionFromIndexSet(inter, i)[source]#
Apply the rule to one Interaction to know if it should be removed from the IndexSet of level i
- Parameters:
inter (
Interaction
) – the Interaction to testi (int) – level of the IndexSet
- Return type:
boolean
- Returns:
Boolean
- prepareNewtonIteration(time)[source]#
- method to prepare the fist Newton iteration
- type time:
float
- param time:
- integrate(tinit, tend, tout, notUsed)[source]#
integrate the system, between tinit and tend (->iout=true), with possible stop at tout (->iout=false)
- updatePosition(ds)[source]#
update the state of the dynamical systems
- Parameters:
ds (
DynamicalSystem
) – the dynamical to update
- class siconos.kernel.MoreauJeanBilbaoOSI[source]#
Bases:
OneStepIntegrator
One-step integrator for event-capturing simulation combining Moreau-Jean and Bilbao numerical scheme.
Numerical scheme which combines an exact method (Bilbao) for the linear (non-contacting) part of the equations of motion with a Moreau-Jean time-stepping for the nonsmooth part.
Check details in users’guide.
Constructor - No extra parameters: depends only on connected ds and simulation time step
- initializeWorkVectorsForDS(t, ds)[source]#
initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi
- Parameters:
t (float) – time of initialization
ds (
DynamicalSystem
) – the dynamical system
- initializeWorkVectorsForInteraction(inter, interProp, DSG)[source]#
initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi
- Parameters:
inter (
Interaction
) – the interactioninterProp (InteractionProperties) – the properties on the graph
DSG (
DynamicalSystemsGraph
) – the dynamical systems graph
- initialize_nonsmooth_problems()[source]#
- Initialization process of the nonsmooth problems
linked to this OSI
- numberOfIndexSets()[source]#
get the number of index sets required for the simulation
- Return type:
- Returns:
unsigned int
- iteration_matrix(ds)[source]#
get iteration_matrix (pointer link) corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
) – a pointer to DynamicalSystem- Return type:
- Returns:
pointer to a SiconosMatrix
- integrate(tinit, tend, tout, idid)[source]#
integrate the system, between tinit and tend (->iout=true), with possible stop at tout (->iout=false)
- computeResidu()[source]#
- return the maximum of all norms for the “MoreauJeanOSI-discretized”
residus of DS
- rtype:
float
- return:
a double
- computeFreeState()[source]#
Perform the integration of the dynamical systems linked to this integrator without taking into account the nonsmooth input ( _p)
- computeFreeOutput(vertex_inter, osnsp)[source]#
integrates the Interaction linked to this integrator, without taking non-smooth effects into account
- Parameters:
vertex_inter (InteractionsGraph::VDescriptor) – vertex of the interaction graph
osnsp (
OneStepNSProblem
) – pointer to OneStepNSProblem
- updatePosition(ds)[source]#
- update the state of the dynamical systems
- type ds:
- param ds:
the dynamical to update
- updateState(level)[source]#
update the state of the DynamicalSystem attached to this Integrator
- Parameters:
level (int) – level of interest for the dynamics level is set to 0 by default since in all time-stepping schemes we update all the state whatever the value of level is.
- addInteractionInIndexSet(inter, i)[source]#
Apply the rule to one Interaction to know if it should be included in the IndexSet of level i
- Parameters:
inter (
Interaction
) – the Interaction to testi (int) – level of the IndexSet
- Return type:
boolean
- Returns:
Boolean
- removeInteractionFromIndexSet(inter, i)[source]#
Apply the rule to one Interaction to know if it should be removed from the IndexSet of level i
- Parameters:
inter (
Interaction
) – the Interaction to testi (int) – level of the IndexSet
- Return type:
boolean
- Returns:
Boolean
- class siconos.kernel.MoreauJeanCombinedProjectionOSI(*args)[source]#
Bases:
MoreauJeanOSI
One Step time Integrator for First Order Dynamical Systems for mechanical Systems (LagrangianDS and NewtonEulerDS) with Combined Projection Algorithm
This class reimplement a special activation of constraints in the MoreauJeanOSI for the Combined Projection Algorithm
References :
V. Acary. Projected event-capturing time-stepping schemes for nonsmooth mechanical systems with unilateral contact and coulomb’s friction. Computer Methods in Applied Mechanics and Engineering, 256:224 – 250, 2013. ISSN 0045-7825. URL http://www.sciencedirect.com/science/article/pii/S0045782512003829.
Overload 1: Default constructor
Overload 2: constructor from theta value only
- Parameters:
theta (float) – value for all these DS.
- initializeWorkVectorsForDS(t, ds)[source]#
initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi
- Parameters:
t (float) – time of initialization
ds (
DynamicalSystem
) – the dynamical system
- initializeWorkVectorsForInteraction(inter, interProp, DSG)[source]#
initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi
- Parameters:
inter (
Interaction
) – the interactioninterProp (InteractionProperties) – the properties on the graph
DSG (
DynamicalSystemsGraph
) – the dynamical systems graph
- numberOfIndexSets()[source]#
get the number of index sets required for the simulation
- Return type:
- Returns:
unsigned int
- addInteractionInIndexSet(inter, i)[source]#
Apply the rule to one Interaction to known if is it should be included in the IndexSet of level i
- Parameters:
inter (
Interaction
) – concerned interactioni (int) – level
- Return type:
boolean
- Returns:
bool
- removeInteractionFromIndexSet(inter, i)[source]#
Apply the rule to one Interaction to known if is it should be removed in the IndexSet of level i
- Parameters:
inter (
Interaction
) – concerned interactioni (int) – level
- Return type:
boolean
- Returns:
bool
- class siconos.kernel.MoreauJeanDirectProjectionOSI(*args)[source]#
Bases:
MoreauJeanOSI
One Step time Integrator for First Order Dynamical Systems for mechanical Systems (LagrangianDS and NewtonEulerDS) with Direct Projection Algorithm
This class reimplement a special activation of constraints in the MoreauJeanOSI for the Direct Projection Algorithm
References :
V. Acary. Projected event-capturing time-stepping schemes for nonsmooth mechanical systems with unilateral contact and coulomb’s friction. Computer Methods in Applied Mechanics and Engineering, 256:224 – 250, 2013. ISSN 0045-7825. URL http://www.sciencedirect.com/science/article/pii/S0045782512003829.
Overload 1: Default constructor
Overload 2: constructor from theta value only
- Parameters:
theta (float) – value for all these DS.
Overload 3: constructor from theta value only
- initializeWorkVectorsForDS(t, ds)[source]#
initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi
- Parameters:
t (float) – time of initialization
ds (
DynamicalSystem
) – the dynamical system
- initializeWorkVectorsForInteraction(inter, interProp, DSG)[source]#
initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi
- Parameters:
inter (
Interaction
) – the interactioninterProp (InteractionProperties) – the properties on the graph
DSG (
DynamicalSystemsGraph
) – the dynamical systems graph
- numberOfIndexSets()[source]#
get the number of index sets required for the simulation
- Return type:
- Returns:
unsigned int
- addInteractionInIndexSet(inter, i)[source]#
Apply the rule to one Interaction to known if is it should be included in the IndexSet of level i
- Parameters:
inter (
Interaction
) – concerned interactioni (int) – level
- Return type:
boolean
- Returns:
bool
- removeInteractionFromIndexSet(inter, i)[source]#
Apply the rule to one Interaction to known if is it should be removed in the IndexSet of level i
- Parameters:
inter (
Interaction
) – concerned interactioni (int) – level
- Return type:
boolean
- Returns:
bool
- class siconos.kernel.MoreauJeanGOSI(*args)[source]#
Bases:
MoreauJeanOSI
A global version of the MoreauJeanOSI integrator
constructor from theta value only
- Parameters:
- initializeWorkVectorsForDS(t, ds)[source]#
initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi
- Parameters:
t (float) – time of initialization
ds (
DynamicalSystem
) – the dynamical system
- initializeWorkVectorsForInteraction(inter, interProp, DSG)[source]#
initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi
- Parameters:
inter (
Interaction
) – the interactioninterProp (InteractionProperties) – the properties on the graph
DSG (
DynamicalSystemsGraph
) – the dynamical systems graph
- computeResidu()[source]#
- Return type:
- Returns:
the maximum of all norms for the “MoreauJeanGOSI-discretized” residus of DS
- computeFreeState()[source]#
Perform the integration of the dynamical systems linked to this integrator without taking into account the nonsmooth input (_r or _p)
- integrate(tinit, tend, tout, notUsed)[source]#
integrate the system, between tinit and tend (->iout=true), with possible stop at tout (->iout=false)
- updateState(level)[source]#
update the state of the dynamical systems
- Parameters:
level (int) – the level of interest for the dynamics: not used at the time
- NonSmoothLawContributionToOutput(inter, osnsp)[source]#
Compute the nonsmooth law contribution to the output
- Parameters:
inter (
Interaction
) – the interaction (for y_k)osnsp (
OneStepNSProblem
) – the non-smooth integrator
- class siconos.kernel.ZeroOrderHoldOSI[source]#
Bases:
OneStepIntegrator
ZeroOrderHoldOSI Time-Integrator for Dynamical Systems
See User’s guide for details.
ZeroOrderHoldOSI class is used to define some time-integrators methods for a list of dynamical systems. A ZeroOrderHoldOSI instance is defined by the value of theta and the list of concerned dynamical systems. Each DynamicalSystem is associated to
computeFreeState(): computes xfree of dynamical systems
state without taking the non-smooth part into account
updateState(): update the state x of the dynamical systems
basic constructor
- Ad(ds)[source]#
get \(\Phi\) corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
) – the DynamicalSystem- Return type:
- Returns:
pointer to a SiconosMatrix
- Bd(ds)[source]#
get \(B_d\) corresponding to DynamicalSystem ds
- Parameters:
ds (
DynamicalSystem
) – the DynamicalSystem- Return type:
- Returns:
pointer to a SiconosMatrix
- initializeWorkVectorsForDS(t, ds)[source]#
initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi
- Parameters:
t (float) – time of initialization
ds (
DynamicalSystem
) – the dynamical system
- initializeWorkVectorsForInteraction(inter, interProp, DSG)[source]#
initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi
- Parameters:
inter (
Interaction
) – the interactioninterProp (InteractionProperties) – the properties on the graph
DSG (
DynamicalSystemsGraph
) – the dynamical systems graph
- numberOfIndexSets()[source]#
get the number of index sets required for the simulation
- Return type:
- Returns:
unsigned int
- computeResidu()[source]#
- return the maximum of all norms for the “ZeroOrderHoldOSI-discretized”
residus of DS
- rtype:
float
- return:
a double
- computeFreeState()[source]#
Perform the integration of the dynamical systems linked to this integrator without taking into account the nonsmooth input (_r or _p)
- computeFreeOutput(vertex_inter, osnsp)[source]#
- Compute the Output (y) which corresponds to the free state (state without
taking into account the nonsmooth input) plus the possible contribution of the nslaw
- type vertex_inter:
InteractionsGraph::VDescriptor
- param vertex_inter:
of the interaction graph
- type osnsp:
- param osnsp:
a pointer to the OneStepNSProblem
- addInteractionInIndexSet(inter, i)[source]#
Apply the rule to one Interaction to known if is it should be included in the IndexSet of level i
- Parameters:
inter (
Interaction
) – a pointer to the Interaction to be addedi (int) – the level of the IndexSet
- Return type:
boolean
- Returns:
true if y<=0
- removeInteractionFromIndexSet(inter, i)[source]#
Apply the rule to one Interaction to known if is it should be removed in the IndexSet of level i
- Parameters:
inter (
Interaction
) – a pointer to the Interaction to be removedi (int) – the level of the IndexSet
- Return type:
boolean
- Returns:
true if y>0
- integrate(tinit, tend, tout, notUsed)[source]#
integrate the system, between tinit and tend (->iout=true), with possible stop at tout (->iout=false)
- class siconos.kernel.Simulation(*args)[source]#
Bases:
object
Description of the simulation process (integrators, time discretisation and so on).
This is an abstract class.
The available simulations are TimeStepping, EventDriven and TimeSteppingD1Minus.
Overload 1: default constructor, for serialization
Overload 2: default constructor
- Parameters:
nsds (
NonSmoothDynamicalSystem
) – current nonsmooth dynamical systemtd (
TimeDiscretisation
) – the timeDiscretisation for this Simulation
Overload 3: constructor with only a TimeDiscretisation
- Parameters:
td (
TimeDiscretisation
) – the timeDiscretisation for this Simulation
- clear()[source]#
clear all maps. This function should not exist, but there is a cycle with the shared_ptr: the OneStepIntegrator and OneStepNSProblem have both a link to the Simulation, and here we have all the OneStepIntegrator and OneStepNSProblem in maps. Then the memory is never freed. The clumsy way to deal with it is to call this function from the Model destructor to free the maps and then the cycle is broken Warning: do not call this yourself, it is meant to be called from the desctructor of the Model
- name()[source]#
get the name of the Simulation
- Return type:
string
- Returns:
std::string : the name of the Simulation
- setName(newName)[source]#
- set the name of the Simulation
- type newName:
string
- param newName:
the new name
- getTkp1()[source]#
get time instant k+1 of the time discretisation Warning: : this instant may be different from nextTime(), if for example some non-smooth events or some sensor events are present
- Return type:
- Returns:
a double. If the simulation is near the end (t_{k+1} > T), it returns NaN.
- getTkp2()[source]#
get time instant k+2 of the time discretisation Warning: : this instant may be different from nextTime(), if for example some non-smooth events or some sensor events are present
- Return type:
- Returns:
a double. If the simulation is near the end (t_{k+2} > T), it returns NaN.
- startingTime()[source]#
- get “current time” (ie starting point for current integration,
time of currentEvent of eventsManager.)
- rtype:
float
- return:
a double.
- nextTime()[source]#
- get “next time” (ie ending point for current integration, time
of nextEvent of eventsManager.)
- rtype:
float
- return:
a double.
- timeStep()[source]#
get the current time step size (“next time”-“current time”)
- Return type:
- Returns:
a double.
- hasNextEvent()[source]#
- true if a future event is to be treated or not (ie if some
events remain in the eventsManager).
- oneStepIntegrators()[source]#
get all the Integrators of the Simulation
- Return type:
SP::OSISet
- Returns:
an OSISset
- numberOfOSI()[source]#
get the number of OSIs in the Simulation (ie the size of allOSI)
- Return type:
- Returns:
an unsigned int
- insertIntegrator(osi)[source]#
insert an Integrator into the simulation list of integrators
- Parameters:
osi (
OneStepIntegrator
) – the OneStepIntegrator to add
- indexSet(i)[source]#
get a pointer to indexSets[i]
- Parameters:
i (int) – number of the required index set
- Return type:
InteractionsGraph
- Returns:
a graph of interactions
- oneStepNSProblems()[source]#
get allNSProblems
- Return type:
SP::OneStepNSProblems
- Returns:
a pointer to OneStepNSProblems object (container of SP::OneStepNSProblem)
- numberOfOSNSProblems()[source]#
get the number of OSNSP in the Simulation (ie the size of allNSProblems)
- Return type:
- Returns:
an unsigned int
- oneStepNSProblem(id)[source]#
get a OneStep nonsmooth problem of the simulation, identify with its number.
- Parameters:
id (int) – number of the required osnspb
- Return type:
- Returns:
a pointer to OneStepNSProblem
- insertNonSmoothProblem(osns, Id=0)[source]#
add a OneStepNSProblem in the Simulation
- Parameters:
osns (
OneStepNSProblem
) – the OneStepNSProblem to insertId (int, optional) – its id: default is SICONOS_OSNSP_DEFAULT, at impact level SICONOS_OSNSP_ED_IMPACT, at acceleration level SICONOS_OSNSP_ED_ACCELERATION
- nonSmoothDynamicalSystem()[source]#
get the NonSmoothDynamicalSystem
- Return type:
- Returns:
NonSmoothDynamicalSystem
- setNonSmoothDynamicalSystemPtr(newPtr)[source]#
set the NonSmoothDynamicalSystem of the Simulation
- Parameters:
newPtr (
NonSmoothDynamicalSystem
) – a pointer on NonSmoothDynamicalSystem
- setTolerance(inputVal)[source]#
- set the value of offset for q dof vector in dynamical systems
(to avoid events accumulation)
- type inputVal:
float
- param inputVal:
new tolerance
- setPrintStat(newVal)[source]#
set printStat value: if true, print solver stats.
- Parameters:
newVal (boolean) – true to activate stats
- updateIndexSets()[source]#
update all index sets of the topology, using current y and lambda values of Interactions
- updateIndexSet(level)[source]#
- update indexSets[i] of the topology, using current y and lambda
values of Interactions.
- type level:
int
- param level:
the number of the set to be updated
- initialize()[source]#
- Complete initialisation of the Simulation (OneStepIntegrators,
OneStepNSProblem, TImediscretisation).
- initializeInteraction(time, inter)[source]#
Initialize a single Interaction for this Simulation, used for dynamic topology updates.
- insertInteractionManager(manager)[source]#
Set an object to automatically manage interactions during the simulation
- Parameters:
manager (
InteractionManager
) –
- updateDSPlugins(time)[source]#
update the plugins of the DS
- Parameters:
time (float) – to be used for plugins
- updateInput(level)[source]#
update input :type level: int :param level: lambda order used to compute input
- updateOutput(level=0)[source]#
update output
- Parameters:
level (int, optional) – lambda order used to compute output level is set to 0 by default since in all time-stepping schemes we update all the state
- update(level=0)[source]#
update output, state, and input
- Parameters:
level (int, optional) – lambda order used to compute input level is set to 0 by default since in all time-stepping schemes we update all the state
- run()[source]#
run the simulation, from t0 to T with default parameters if any particular settings has been done
- clearNSDSChangeLog()[source]#
clear the NSDS changelog up to current position. If you have a particularly dynamic simulation (DS and Interactions created and destroyed frequently), then it is important to call this periodically.
- setUseRelativeConvergenceCriteron(use)[source]#
- Set the option to specify if a relative convergence criterion must
be used to stop the Newton iterations.
- type use:
boolean
- param use:
true if relative critarion activated
- useRelativeConvergenceCriteron()[source]#
- Return type:
boolean
- Returns:
true if the relative convergence criterion is activated.
- setRelativeConvergenceTol(v)[source]#
Set the relative convergence tolerance
- Parameters:
v (float) – tolerance value
- setRelativeConvergenceCriterionHeld(newVal)[source]#
- Parameters:
newVal (boolean) – a new relative convergence criterion
- relativeConvergenceCriterionHeld()[source]#
- Return type:
boolean
- Returns:
true if the relative convergence criterion held.
- lambda_(level=0, coor=0)[source]#
return input lambda[level](coor) for all the interactions
- Parameters:
- Return type:
- Returns:
a SP::SiconosVector that contains the concatenated value
- y(level=0, coor=0)[source]#
return output y[level](coor) for all the interactions
- Parameters:
- Return type:
- Returns:
a SP::SiconosVector that contains the concatenated value
- setStaticLevels(b)[source]#
set staticLevels
- Parameters:
b (boolean) – decides whether levels should be computed at each iteration
- updateT(T)[source]#
This updates the end of the Simulation. Warning: this should be called only from the Model, to synchronise the 2 values
- Parameters:
T (float) – the new final time
- link(*args)[source]#
Add a new Interaction between one or a pair of DSs.
- Parameters:
inter (
Interaction
) – the SP::Interaction to addds1 (
DynamicalSystem
) – the first SP::DynamicalSystem in the Interactionds2 (
DynamicalSystem
, optional) – the second SP::DynamicalSystem in the Interaction, if any
- unlink(inter)[source]#
Remove an Interaction from the simulation.
- Parameters:
inter (
Interaction
) – the SP::Interaction to remove
- updateInteractions()[source]#
Call the interaction manager one if is registered, otherwise do nothing.
- siconos.kernel.SICONOS_TS_LINEAR = 1#
Event-capturing Time-Stepping simulation
This class implements the basic algorithm for Event-capturing Time-Stepping simulations.
References :
V. Acary and B. Brogliato. Numerical Methods for Nonsmooth Dynamical Systems: Applications in Mechanics and Electronics, volume 35 of Lecture Notes in Applied and Computational Mechanics. Springer Verlag, 2008.
- class siconos.kernel.TimeStepping(*args)[source]#
Bases:
Simulation
Overload 1: Default Constructor
Overload 2: Standard constructor
- Parameters:
nsds (
NonSmoothDynamicalSystem
) – NonSmoothDynamicalSystem to be simulatedtd (
TimeDiscretisation
) – pointer to a timeDiscretisation used in the integrationosi (
OneStepIntegrator
) – one step integrator (default none)osnspb (
OneStepNSProblem
) – one step non smooth problem (default none)
Overload 3: Constructor with the time-discretisation.
- Parameters:
nsds (
NonSmoothDynamicalSystem
) – NonSmoothDynamicalSystem to be simulatedtd (
TimeDiscretisation
) – pointer to a timeDiscretisation used in the integrationnb (int, optional) – number of non smooth problem
Overload 4: Constructor with the time-discretisation.
- Parameters:
nsds (
NonSmoothDynamicalSystem
) – NonSmoothDynamicalSystem to be simulatedtd (
TimeDiscretisation
) – pointer to a timeDiscretisation used in the integrationnb – number of non smooth problem
- insertIntegrator(osi)[source]#
insert an Integrator into the simulation list of integrators
- Parameters:
osi (
OneStepIntegrator
) – the OneStepIntegrator to add
- updateIndexSet(i)[source]#
update indexSets[i] of the topology, using current y and lambda values of Interactions
- Parameters:
i (int) – the number of the set to be updated
- nextStep()[source]#
increment model current time according to User TimeDiscretisation and call SaveInMemory.
- computeFreeState()[source]#
integrates all the DynamicalSystems taking not into account nslaw, reactions (ie non-smooth part) …
- getNewtonNbIterations()[source]#
To known the number of steps performed by the Newton algorithm.
- Return type:
- Returns:
the number of steps performed by the Newton algorithm
- getNewtonCumulativeNbIterations()[source]#
To known the number of steps performed by the Newton algorithm.
- Return type:
- Returns:
the cumulative number of steps performed by the Newton algorithm
- initializeNewtonSolve()[source]#
initialize the Newton It computes the initial residu and set the, if needed to Newton variable to start the newton algorithm.
- newtonCheckConvergence(criterion)[source]#
check the convergence of Newton algorithm according to criterion
- Parameters:
criterion (float) – convergence criterion
- Return type:
boolean
- Returns:
bool = true if Newton method has converged
- run()[source]#
run the simulation, from t0 to T with default parameters if any setting has been done
- DefaultCheckSolverOutput(info)[source]#
check returning value from computeOneStepNSProblem and process
- Parameters:
info (int) – solver-specific error code return by the nonsmooth solver
- setCheckSolverFunction(newF)[source]#
Set CheckSolverOutput function
- Parameters:
newF (void) – pointer to function steering the behavior of simulation when nonsmooth solver failed
- setComputeResiduY(v)[source]#
To specify if the output interaction residu must be computed.
- Parameters:
v (boolean) – set to true when the output interaction residu must be computed
- computeResiduY()[source]#
To know if the output interaction residu must be computed.
- Return type:
boolean
- Returns:
bool _computeResiduY
- setComputeResiduR(v)[source]#
To specify if the input interaction residu must be computed.
- Parameters:
v (boolean) – set to true when the input interaction residu must be computed
- computeResiduR()[source]#
To known if the input interaction residu must be computed.
- Return type:
boolean
- Returns:
bool _computeResiduR
- setNewtonTolerance(tol)[source]#
set the Default Newton tolerance
- Parameters:
tol (float) – Newton solver tolerance
- newtonTolerance()[source]#
get the Newton tolerance
- Return type:
- Returns:
default Newton solver tolerance
- setNewtonMaxIteration(maxStep)[source]#
set the maximum number of Newton iteration
- Parameters:
maxStep (int) – maximum number of Newton solver iterations
- newtonMaxIteration()[source]#
get the maximum number of Newton iteration
- Return type:
- Returns:
maximum number of Newton solver iterations
- newtonOptions()[source]#
get the NewtonOptions
- Return type:
- Returns:
Newton solver options - SICONOS_TS_LINEAR 1, SICONOS_TS_LINEAR_IMPLICIT 2, SICONOS_TS_NONLINEAR 3
- newtonResiduDSMax()[source]#
accessor to _newtonResiduDSMax
- Return type:
- Returns:
_newtonResiduDSMax
- class siconos.kernel.TimeSteppingCombinedProjection(*args)[source]#
Bases:
TimeStepping
Time-Stepping scheme
- Overload 1:
Constructor with the time-discretisation.
- type nsds:
- param nsds:
the nsds that we want to simulate
- type td:
- param td:
a pointer to a timeDiscretisation (linked to the model that owns this simulation)
- type osi:
- param osi:
a one step integrator
- type osnspb_velo:
- param osnspb_velo:
a one step non smooth problem for the velocity formulation :type osnspb_pos:
OneStepNSProblem
- Parameters:
osnspb_pos – a one step non smooth problem for the position formulation :type _level: int, optional
_level –
- Overload 2:
default constructor
- updateIndexSet(level)[source]#
update indexSets[i] of the topology, using current y and lambda values of Interactions
- Parameters:
level (int) – unsigned int: the level of the set to be updated
- nbProjectionIteration()[source]#
get the Number of iteration of projection
- Return type:
- Returns:
unsigned int nbProjectionIteration
- nbCumulatedProjectionIteration()[source]#
get the Number of cumulated iteration of projection
- Return type:
- Returns:
unsigned int
- cumulatedNewtonNbIterations()[source]#
get the Cumulated Number of steps performed in the Newton Loop
- Return type:
- Returns:
unsigned int
- class siconos.kernel.TimeSteppingDirectProjection(*args)[source]#
Bases:
TimeStepping
Time-Stepping scheme with a direct projection onto the constraint thanks to the GGL augmentation of the system
For details, have a look on Projected event-capturing time-stepping schemes for nonsmooth mechanical systems with unilateral contact and Coulomb’s friction Vincent Acary Computer Methods in Applied Mechanics and Engineering, Elsevier, 2013, 256, pp. 224-250
- Overload 1:
Constructor with the time-discretisation.
- type nsds:
- param nsds:
the nsds that we want to simulate
- type td:
- param td:
a pointer to a timeDiscretisation (linked to the model that owns this simulation)
- type osi:
- param osi:
a one step integrator
- type osnspb_velo:
- param osnspb_velo:
a one step non smooth problem for the velocity formulation :type osnspb_pos:
OneStepNSProblem
- Parameters:
osnspb_pos – a one step non smooth problem for the position formulation :type _level: int, optional
_level –
- Overload 2:
default constructor
- class siconos.kernel.EventDriven(*args)[source]#
Bases:
Simulation
Simulation based on event driven method, ie events detection (see theoretical manual for more details).
WARNING: at the time only written for Lagrangian systems !!!
Overload 1: defaut constructor
- Parameters:
nsds (
NonSmoothDynamicalSystem
) – current nonsmooth dynamical systemtd (
TimeDiscretisation
) – time discretisation
Overload 2: constructor with data
- Parameters:
nsds (
NonSmoothDynamicalSystem
) – current nonsmooth dynamical systemtd (
TimeDiscretisation
) – time discretisationnb (int) – number of NSProblem
Overload 3: defaut constructor (needed for serialization)
- isNewtonConverge()[source]#
To know if Newton Iteratio is convergent
- Return type:
boolean
- Returns:
_isNewtonConverge
- getNewtonNbIterations()[source]#
To known the number of steps performed by the Newton algorithm
- Return type:
- Returns:
_newtonNbIterations
- setNewtonMaxIteration(maxStep)[source]#
Set value to the maximum number of iterations
- Parameters:
maxStep (int) – maximum number of step
- setLocalizeEventsMaxIteration(maxIter)[source]#
To set maximum number of iterations to localize events
- Parameters:
maxIter (int) – maximum number of iterations
- newtonMaxIteration()[source]#
get the maximum number of Newton iteration
- Return type:
- Returns:
unsigned int
- LocalizeEventsMaxIteration()[source]#
get the maximum number of iterations to localize events
- Return type:
- Returns:
unsigned int: maximum number of iterations
- newtonResiduDSMax()[source]#
accessor to _newtonResiduDSMax
- Return type:
- Returns:
double _newtonResiduDSMax
- newtonResiduYMax()[source]#
accessor to _newtonResiduYMax
- Return type:
- Returns:
double _newtonResiduYMax
- setNewtonTolerance(tol)[source]#
set the Default Newton tolerance
- Parameters:
tol (float) – new tolerance
- updateIndexSet(i)[source]#
update indexSets[i] of the topology, using current y and lambda values of Interactions.
- Parameters:
i (int) – the number of the set to be updated
- updateIndexSetsWithDoubleCondition()[source]#
update indexSets[1] and [2] (using current y and lambda values of Interactions) with conditions on y[2] AND lambda[2].
- computef(osi, sizeOfX, time, x, xdot)[source]#
compute right-hand side of xdot = f(x,t), for the integrator osi.
- Parameters:
osi (
OneStepIntegrator
) – the integrator (Lsodar)sizeOfX (int) – size of vector x
time (float) – current time given by the integrator
x (float) – state vector
xdot (float) – derivative of x
- computeJacobianfx(osi, sizeOfX, time, x, jacob)[source]#
compute jacobian of the right-hand side
- Parameters:
osi (
OneStepIntegrator
) – the integrator (Lsodar)sizeOfX (int) – size of vector x
time (float) – current time given by the integrator
x (float) – state vector
jacob (float) – jacobian of f according to x
- computeSizeOfg()[source]#
compute the size of constraint function g(x,t,…) for osi
- Return type:
- Returns:
unsigned int
- updateSmoothState()[source]#
update state for smooth dynamic case (i.e. compute p[2] and update acceleration)
- updateOutput(level)[source]#
update output and indexSets.
- Parameters:
level (int) – of lambda used to compute input
- advanceToEvent()[source]#
run simulation from one Event to the next, according to events manager settings.
- computeResiduConstraints()[source]#
Methods for NewMarkAlphaOSI scheme compute maximum residu over all gap functions of Index2 contacts
- Return type:
- Returns:
double: maximum residu for all gap functions
- prepareNewtonIteration()[source]#
prepare for Newton iterations for all OSIs
- Return type:
void
- Returns:
maximum residu over all DSs
- newtonCheckConvergence(arg2)[source]#
Check convergence of Newton iteration
- Return type:
boolean
- Returns:
bool: true if convergent, false otherwise
- predictionNewtonIteration()[source]#
Predict the state of all Dynamical Systems before Newton iterations
- correctionNewtonIteration()[source]#
Correct the state of all Dynamical Systems during Newton iterations
- newtonSolve(criterion, maxStep)[source]#
Newton iteration to get the state of all Dynamical Systems at the end of step
- detectEvents(updateIstate=True)[source]#
Detect whether or not events occur during each integration step
- Parameters:
updateIstate (boolean, optional) – true if we need to update the flag _istate, false otherwise
- Return type:
- Returns:
double, maximum of absolute values of constraint fonctions over all activated ot deactivated contacts
- class siconos.kernel.EventsManager(*args)[source]#
Bases:
object
Tools to handle a set of Events for the Simulation
The EventsManager handles a set of events (from user time-discretisation, sensors, non-smooth …), and is supposed to provide to the simulation the values of “current” and “next” events to define the time-integration interval.
Events: - currentEvent: starting time for integration. Initialized with t0 of the simulation time-discretisation. - ETD: corresponds to the instant t[k+1] of the Simulation (user) TimeDiscretisation. - ENonSmooth: for EventDriven simulation only. Present only if one or more non-smooth events have been detected between currentEvent and the next event. - Sensor or Actuators Events. To each Sensor or Actuator declared in the ControlManager, corresponds an Event in the manager. When this event is processed, its time value is increased to next instant in the time-discretisation of the sensor/actuator.
Examples: - for a TimeStepping, with one Sensor, the EventsManager looks like:
{currentEvent(tk), ESensor(tsensor), ETD(tk+1)} - for an EventDriven, with one actuator, an non-smooth event detected at time tns:
{currentEvent(tk), EActuator(tact), ENonSmooth(tns), ETD(tk+1)}.
After each process, the time values of each event are updated and nextEvent points to the first event after currentEvent.
Main functions - initialize(): process all events which have the same time as currentEvent - processEvents(): process all events simultaneous to nextEvent, increment them to next step, update index sets, increment currentEvent.
Overload 1: default constructor
- Overload 2:
constructor
- Parameters:
td (
TimeDiscretisation
) – the TimeDiscretisation used in the Simulation
- update(sim)[source]#
Update the set of events
- Parameters:
sim (
Simulation
) – the Simulation using this EventsManager
- initialize(T)[source]#
Initialize: just set the final time
- Parameters:
T (float) – the final time of the Simulation
- setGapLimitEvents(var)[source]#
Set the gap limit between two events
- Parameters:
var (int) – the new _GapLimit2Events
- getGapLimitEvents()[source]#
Get the gap limit between two events
- Return type:
- Returns:
the gap limit
- noSaveInMemory(sim)[source]#
Change TimeDiscretisationEvent to TimeDiscretisationEventNoSaveInMemory
Warning: use this at your own risk, many integrators needs previous values to integrate properly
- Parameters:
sim (
Simulation
) – the Simulation that owns this EventsManager
- events()[source]#
return all the events
- Return type:
EventsContainer
- Returns:
a reference to the events set
- hasNextEvent()[source]#
check if there are some unprocessed events
- Return type:
boolean
- Returns:
true if there are unprocessed events
- startingTime()[source]#
get the time of current event, in double format
- Return type:
- Returns:
the time of the last processed events
- nextTime()[source]#
get the time of next event, in double format
- Return type:
- Returns:
the time of the next events
- needsIntegration()[source]#
is an integration step required ? The current event and the next one may have the same time instant in which case no integration as to be performed
- Return type:
boolean
- Returns:
true if the simulation needs to be integrate, no otherwise
- scheduleNonSmoothEvent(sim, time, yes_update=True)[source]#
add a new Event in the allEvents list and update nextEvent value
- Parameters:
sim (
Simulation
) – the simulation that owns this EventsManagertime (float) – the time (double format) of occurence of the event
yes_update (boolean, optional) – indicator to update or not the next event (default value is true)
- processEvents(sim)[source]#
Process the next event, update the indexSets if necessary
- Parameters:
sim (
Simulation
) – the simulation that owns this EventsManager
- preUpdate(sim)[source]#
Function to be called once after initialization. It is used to process NonSmoothEvents at the beginning of the Simulation, if there is any.
- Parameters:
sim (
Simulation
) – the simulation that owns this EventsManager
- insertEvent(*args)[source]#
Overload 1: insert an event of a certain type. The event is created on the fly.
- Parameters:
- Return type:
- Returns:
a reference to the Event
Overload 2: insert an event of a certain type. The event is created on the fly, and the SP::TimeDiscretisation given in argument is stored inside
- Parameters:
type (int) – the type of the event
td (
TimeDiscretisation
) – a TimeDiscretisation for the Event
- Return type:
- Returns:
a reference to the Event
- getTkp1()[source]#
get time instant k+1 of the time discretisation
- Return type:
- Returns:
a double. If the simulation is near the end (t_{k+1} >= T), it returns NaN.
- getTkp2()[source]#
get time instant k+2 of the time discretisation
- Return type:
- Returns:
a double. If the simulation is near the end (t_{k+2} >= T), it returns NaN.
- getTkp3()[source]#
get time instant k+3 of the time discretisation. It is used when we have to reschedule a TD Event in scheduleNonSmoothEvent
- Return type:
- Returns:
a double. If the simulation is near the end (t_{k+3} >= T), it returns NaN.
- class siconos.kernel.Event(*args)[source]#
Bases:
object
Abstract class that represents generic time events.
This base class simply records the time at which the event will take place. A pure virtual function named process will be invoked to execute the event. The time is represented with a mpz_t, from gmp library. See http://gmplib.org.
Derived classes: - TimeDiscretisationEvent: events that corresponds to user-defined time-discretisation points - NonSmoothEvent: specific events, detected during simulation, when constraints are violated (thanks to roots-finding algorithm) - SensorEvent: event dedicated to data capture through user-defined sensors.
Existing types of events: 0 -> undef 1 -> TimeDiscretisation 2 -> NonSmooth 3 -> Sensor 4 -> Observer 5 -> Actuator
Overload 1: Default constructor
Overload 2: constructor with time value and type as input
- Parameters:
Overload 3: constructor with time value and type as input
- Parameters:
Overload 4: constructor with time value and type as input
- Parameters:
time (float) – the starting type (a double)
newType – the Event type (an int)
reschedule – set this to true if the event has to be rescheduled
- getTimeOfEvent()[source]#
get the time of the present event (mpz_t format)
- Return type:
__mpz_struct
- Returns:
a mpz_t
- getDoubleTimeOfEvent()[source]#
get the time of the present event (double format)
- Return type:
- Returns:
a double
- setTime(time)[source]#
set the time of the present event (double format)
- Parameters:
time (float) – the new time
- setType(newType)[source]#
set a new type for the present Event
- Parameters:
newType (int) – the new Event type
- setTimeDiscretisation(td)[source]#
Set the TimeDiscretisation
- Parameters:
td (
TimeDiscretisation
) – a TimeDiscretisation for this Event
- getTimeDiscretisation()[source]#
Get the TimeDiscretisation
- Return type:
- Returns:
the TimeDiscretisation used in this Event
- process(sim)[source]#
virtual function which actions depends on event type
- Parameters:
sim (
Simulation
) – the simulation that owns this Event (through the EventsManager)
- siconos.kernel.Event_setTick(newTick)[source]#
set tick value
- Parameters:
newTick (float) – the new tick value
- class siconos.kernel.BoundaryCondition(*args)[source]#
Bases:
object
This class models simple boundary conditions for prescribing the velocities in a Dynamical System. A simple boundary condition is considered to fix a component \(j\) of the velocity vector, i.e., \(v_j(t) = bc(t)\) where \(bc(t)\) is a given function of time.
Overload 1: Basic constructor
- Parameters:
newVelocityIndices (
UnsignedIntVector
) – the indices of the velocity subjected to prescribed velocities
Overload 2: Constructor with constant prescribed values
- Parameters:
newVelocityIndices (
UnsignedIntVector
) – the indices of the velocity subjected to prescribed velocitiesnewVelocityValues (
SiconosVector
) – the values of the prescribed velocities
Overload 3: protected default constructor
- velocityIndices()[source]#
to get the velocityIndices
- Return type:
UnsignedIntVector
- Returns:
a pointer on _velocityIndices
- prescribedVelocity()[source]#
to get the prescribedVelocity
- Return type:
- Returns:
a pointer on _prescribedVelocity
- prescribedVelocityOld()[source]#
to get the prescribedVelocityOld
- Return type:
- Returns:
a pointer on _prescribedVelocityOld
- setComputePrescribedVelocityFunction(pluginPath, functionName)[source]#
allow to set a specified function to compute prescribedVelocity
- Parameters:
pluginPath (string) – the complete path to the plugin
functionName (string) – the name of the function to use in this plugin
- class siconos.kernel.HarmonicBC(*args)[source]#
Bases:
BoundaryCondition
- This class models a simple harmonic boundary conditions for
prescribing the velocities in a Dynamical System. A simple boundary condition is considered to fix a component \(j\) of the velocity vector, i.e., \(v_j(t) = a + b cos( \omega t+ \phi)\).
- Overload 1:
Constructor
- Parameters:
- Overload 2:
protected default constructor
- class siconos.kernel.FixedBC(*args)[source]#
Bases:
BoundaryCondition
This class models a simple fixed boundary conditions for prescribing the velocities in a Dynamical System. A simple boundary condition is considered to fix a component \(j\) of the velocity vector, i.e., \(v_j(t) = 0\)
Overload 1: Basic constructor
- Parameters:
newVelocityIndices (
UnsignedIntVector
) – the indices of the velocity subjected to prescribed velocities
Overload 2: protected default constructor
- class siconos.kernel.OSNSMatrix(*args)[source]#
Bases:
object
Interface to some specific storage types for matrices used in OneStepNSProblem
This class is used to define an interface for various storage methods used for matrices in OneStepNSProblem. Its aim is to fill the Numerics structure NumericsMatrix, required in many XXX_problem structures of Numerics as input argument for drivers.
The idea is to remove all matrix storage management problems from OSNS classes (LCP …) and to leave it into this class.
Two main functions: - fill(indexSet, interactionBlocks): fill the matrix using a list of “active” Interaction, in indexSet, and a MapOfMapOfInteractionMatrices, interactionBlocks, which determines which Interaction are connected or not (ie have common DynamicalSystem). - convert(): fill the NumericsMatrix structure (indeed only pointers links to the components of the present class)
Note that OSNSMatrix are square.
For example, if in a LCP, constraints of interest are indexSet={inter2,inter3,inter8,inter12}, whith common DynamicalSystem between 2 and 3, 2 and 8 and 8 and 12.
interactionBlocks contains matrices for all (interi,interj) which have common DS, for (interi,interj) in I0, the set of all Interaction.
(for details on how interactionBlocks is computed see OneStepNSProblem.h).
We denote interactionBlocks[interi][interj] = mij.
Then, a call to fill(indexSet, interactionBlock) results in a matrix which looks like:
\[\begin{split}M=\left\lbrace\begin{array}{cccc} m22 & m23 & m28 & 0 \\ m32 & m33 & 0 & 0 \\ 0 & 0 & m88 & m812 \\ 0 & 0 & m128& m1212 \end{array}\right.\end{split}\]Note: at the time the available storage types are:
full matrix in a SiconosMatrix (_storageType = NM_DENSE). In this case,
for each call to fill(), the SiconosMatrix M is resized according to the sizes of the Interaction present in indexSet and then all the required interactionBlocks mij are COPIED into M.
Sparse Block Storage (_storageType = NM_SPARSE_BLOCK): corresponds to
SparseBlockStructuredMatrix structure of Numerics. Only non-null interactionBlocks are saved in the matrix M and there is no copy of sub-interactionBlocks, only links thanks to pointers.
Sparse matrix (_storageType = NM_SPARSE): at the time of writting, only csc (compressed-sparse column).
Could also be triplet (coo or coordinate) or csr (compressed-sparse row).
Overload 1: Default constructor -> empty matrix
Overload 2: Constructor with _dimRow. of the matrix
- Parameters:
Overload 3: Constructor with _dimRow and DimColumn of the matrix
- Parameters:
Overload 4: Constructor from index set and map
- Parameters:
indexSet (
InteractionsGraph
) – InteractionsGraph* the index set of the active constraintsstor (int) – storage type
Overload 5: Constructor with copy of a SiconosMatrix => _storageType = NM_DENSE
- Parameters:
MSource (
SiconosMatrix
) – matrix to be copied
- storagetype()[source]#
get the type of storage for current matrix
- Return type:
- Returns:
unsigned int
- setStorageType(i)[source]#
set which type of storage will be used for current matrix
- Parameters:
i (int) – the type of storage
- numericsMatrix()[source]#
get the numerics-readable structure
- Return type:
NumericsMatrix
- Returns:
SP::NumericsMatrix
- defaultMatrix()[source]#
get the matrix used for default storage
- Return type:
- Returns:
SP::NumericsMatrix
- fillM(indexSet, update=True)[source]#
fill the current class using an index set
- Parameters:
indexSet (
InteractionsGraph
) – the index set of the active constraintsupdate (boolean, optional) – if true update the size of the Matrix (default true)
- computeM(Winverse, H)[source]#
Compute the M matrix given the inverse of W and H
- Parameters:
Winverse (
NumericsMatrix
) – the NumericsMatrix that contains the inverse of WWinverse – the NumericsMatrix that contains H
- fillW(DSG, update=True)[source]#
fill the current class using an index set with the W matrix of DS
- Parameters:
DSG (
DynamicalSystemsGraph
) – the index set of the dynamicalSystemsupdate (boolean, optional) – if true update the size of the Matrix (default true)
- fillWinverse(DSG, update=True)[source]#
fill the current class using an index set with the inverse of W matrix of DS
- Parameters:
DSG (
DynamicalSystemsGraph
) – the index set of the dynamicalSystemsupdate (boolean, optional) – if true update the size of the Matrix (default true)
- fillH(DSG, indexSet, update=True)[source]#
fill the current class using an index set
- Parameters:
DSG (
DynamicalSystemsGraph
) – the index set of the dynamicalSystemsindexSet (
InteractionsGraph
) – the index set of the Interactionsupdate (boolean, optional) – if true update the size of the Matrix (default true)
- fillHtrans(DSG, indexSet, update=True)[source]#
fill the current class using an index set
- Parameters:
DSG (
DynamicalSystemsGraph
) – the index set of the dynamicalSystemsindexSet (
InteractionsGraph
) – the index set of the Interactionsupdate (boolean, optional) – if true update the size of the Matrix (default true)
- class siconos.kernel.BlockCSRMatrix(*args)[source]#
Bases:
object
Definition of a compressed sparse row matrix of SiconosMatrix, used in OneStepNSProblem to store the M matrix.
This class defines a specific compressed row sparse storage for blocks matrices, each block being a SiconosMatrix*.
It handles:
a SparseMat (boost-ublas) of SiconosMatrix*
a vector<SiconosMatrix*> which handles the non-null blocks
three vector<int> (IndexInt) to save non-null blocks position in
row, columns and the list of the sizes of diagonal blocks.
two int, the number of blocks in a row and the number of non null blocks.
Each block of the current object represents the connection between two coupled Interactions,
(for example for Lagrangian systems, a single \(H W^{-1} H^t\) block or for first order systems \(hCW^{-1}B\) …).
This objects is built using an index set of SP::Interaction, that represents the “active” constraints in the OSNS problem and a map<SP::Interaction u1, <SP::Interaction u2, SP::SiconosMatrix block> >, block being the link between u1 and u2. Only Interaction present in the index set are picked out in the map.
A convert method is also implemented to create a SparseBlockStructuredMatrix which is Numerics-readable.
As an example, consider the index set I={u1, u3, u5, u8} and the map where non null blocks are (ui,ui), (u1,u3), (u1,u8), (u3,u1), (u8,u1). Each block being a pointer to a 3x3 matrix. Then the resulting matrix has 4 X 4 blocks, with 8 non-null blocks and looks like:
\[\begin{split}M=\left\lbrace\begin{array}{cccc} b11 & b13 & 0 & b18 \\ b31 & b22 & 0 & 0 \\ 0 & 0 & b33&0 \\ b81 & 0 & 0 & b44 \end{array}\right.\end{split}\]with nc = 4, nbNonNullBlocks = 8, RowPos = [0 0 0 1 1 2 3 3], RowCol = [0 1 3 0 1 2 0 3] and _diagsize0 = [3 6 9 12].
We use std::vector (which may seems redundent with the double* of the numerics SparseBlockStructuredMatrix) because memory can be reserved during construction or initialized and then vectors are resized when the object is filled in. This avoid some call to malloc/free at each iteration.
Overload 1: Default constructor -> empty matrix
Overload 2: Constructor with dimension (number of blocks)
- Parameters:
n (int) – number of blocks in a row/column (only square matrices allowed)
Overload 3: Constructor from index set
- Parameters:
indexSet (
InteractionsGraph
) – the index set of the active constraints
- numberOfBlocksInARow()[source]#
get size (in block-components)
- Return type:
- Returns:
unsigned int NumberOfBlocksInARow
- getNbNonNullBlocks()[source]#
get total number of non-null blocks
- Return type:
- Returns:
unsigned int
- getNumericsMatSparse()[source]#
get the numerics-readable structure
- Return type:
SparseBlockStructuredMatrix
- Returns:
SP::SparseBlockStructuredMatrix
- getMSparse()[source]#
get the ublas sparse mat
- Return type:
SP::CompressedRowMat
- Returns:
SP::CompressedRowMat
- getPositionsIndex(i)[source]#
get the index of blocks position (i=0 -> rows, i=1 -> columns)
- Parameters:
i (boolean) – unsigned int, 0 for rows, 1 for columns
- Return type:
IndexInt
- Returns:
SP::IndexInt
- fill(indexSet)[source]#
fill the current class using an index set
- Parameters:
indexSet (
InteractionsGraph
) – set of the active constraints
- fillW(indexSet)[source]#
fill the matrix with the Mass matrix
Warning: only for NewtonEulerDS
- Parameters:
indexSet (
InteractionsGraph
) – of the active constraints