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:
siconos.kernel.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:
siconos.kernel.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:
siconos.kernel.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:
siconos.kernel.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:
siconos.kernel.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:
siconos.kernel.NonSmoothLaw
Complementarity NonSmoothLaw
basic constructor
- Parameters
- class siconos.kernel.ComplementarityConditionNSL(size)[source]¶
Bases:
siconos.kernel.NonSmoothLaw
Complementarity NonSmoothLaw
basic constructor
- Parameters
size (int) – of the non smooth law
- class siconos.kernel.EqualityConditionNSL(size)[source]¶
Bases:
siconos.kernel.NonSmoothLaw
Equality NonSmoothLaw
basic constructor
- Parameters
size (int) – of the non smooth law
- class siconos.kernel.MultipleImpactNSL(*args)[source]¶
Bases:
siconos.kernel.NonSmoothLaw
basic constructor
- Parameters
size (int) – the nonsmooth law size
- class siconos.kernel.RelayNSL(size, lb=- 1.0, ub=1.0)[source]¶
Bases:
siconos.kernel.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:
siconos.kernel.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
- 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
- reset(*args)[source]¶
Overload 1: Set all DS non-smooth part to zero.
Overload 2: 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:
siconos.kernel.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
- 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:
siconos.kernel.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
) –
- 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
- 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:
siconos.kernel.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
) –
- 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
- 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:
siconos.kernel.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:
siconos.kernel.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:
siconos.kernel.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
- 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:
siconos.kernel.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:
siconos.kernel.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:
siconos.kernel.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:
siconos.kernel.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:
siconos.kernel.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:
siconos.kernel.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
- 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:
siconos.kernel.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:
siconos.kernel.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