siconos.kernel#
Module documentation
A collection of low-level algorithms for solving basic algebra and optimization problem arising in the simulation of nonsmooth dynamical systems.
Example of usage:
>>> import siconos.kernel as sk
>>> help(sk.LagrangianDS)
- class siconos.kernel.MATRIX_UBLAS_TYPE[source]#
Bases:
object
Union of DenseMat pointer, TriangMat pointer BandedMat, SparseMat, SymMat, Zero and Identity mat pointers.
- class siconos.kernel.SiconosMatrix(*args, **kwargs)[source]#
Bases:
object
Abstract class to provide interface for matrices handling
Matrices can be either block or Simple. See Derived classes for details.
In Siconos, a “matrix” can be either a SimpleMatrix or a BlockMatrix, ie a container of several pointers to SiconosMatrix
You can find an overview on how to build and use vectors and matrices in siconos users guide .
- isPLUInversed()[source]#
determines if the matrix has been inversed in place
- Return type:
boolean
- Returns:
true if the matrix is inversed
- isSymmetric()[source]#
true if the matrix is symmetric (the flag is just returned)
- Return type:
boolean
- Returns:
true if the matrix is symmetric
- isPositiveDefinite()[source]#
true if the matrix is definite positive (the flag is just returned)
- Return type:
boolean
- Returns:
true if the matrix is
- checkSymmetry(tol)[source]#
determines if the matrix is symmetric up to a given tolerance
- Return type:
boolean
- Returns:
true if the matrix is inversed
- isPLUFactorized()[source]#
determines if the matrix has been PLU factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isPLUFactorizedInPlace()[source]#
determines if the matrix has been PLU factorized in place
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isCholeskyFactorized()[source]#
determines if the matrix has been Cholesky factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isQRFactorized()[source]#
determines if the matrix has been QR factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- isFactorized()[source]#
determines if the matrix has been factorized
- Return type:
boolean
- Returns:
true if the matrix is factorized
- tabRow()[source]#
reserved to BlockMatrix - get the index tab for rows
- Return type:
SP::Index
- Returns:
a pointer to a standard vector of int
- tabCol()[source]#
reserved to BlockMatrix - get the index tab of columns
- Return type:
SP::Index
- Returns:
a pointer to a standard vector of int
- getArray(row=0, col=0)[source]#
return the address of the array of double values of the matrix ( for block(i,j) if this is a block matrix)
- resize(nbrow, nbcol, lower=0, upper=0, preserve=True)[source]#
resize the matrix with nbrow rows and nbcol columns, upper and lower are only useful for BandedMatrix . The existing elements of the matrix are preseved when specified.
- toString()[source]#
put data of the matrix into a std::string
- Return type:
string
- Returns:
std::string
- block(row=0, col=0)[source]#
get block at position row-col if BlockMatrix, else if SimpleMatrix return this
- Parameters:
- Return type:
- Returns:
SP::SiconosMatrix
- getRow(index, vOut)[source]#
get row index of current matrix and save it into vOut
- Parameters:
index (int) – row we want to get
vOut (
SiconosVector
, out) – SiconosVector that will contain the desired row
- getCol(index, vOut)[source]#
get column index of current matrix and save it into vOut
- Parameters:
index (int) – column we want to get
vOut (
SiconosVector
, out) – SiconosVector that will contain the desired column
- setRow(index, vIn)[source]#
set line row of the current matrix with vector v
- Parameters:
index (int) – row we want to set
vIn (
SiconosVector
) – SiconosVector containing the new row
- setCol(index, vIn)[source]#
set column col of the current matrix with vector v
- Parameters:
index (int) – column we want to set
vIn (
SiconosVector
) – a SiconosVector containing the new column
- trans(*args)[source]#
Overload 1: transpose in place: x->trans() is x = transpose of x.
Overload 2: transpose a matrix: x->trans(m) is x = transpose of m.
- Parameters:
m (
SiconosMatrix
) – the matrix to be transposed.
- PLUFactorizationInPlace()[source]#
computes a LU factorization of a general M-by-N matrix with partial pivoting and row interchanges. The result is returned in this (InPlace). Based on Blas dgetrf function for dense matrix and ublas cholesky decomposition for sparse matrix (work only for a symmetric matrix and very slow because it uses matric accessor) use preferably PLUFactorize()
- Factorize()[source]#
computes a factorization of a general M-by-N matrix The implementation is based on an internal NumericsMatrix
- PLUInverseInPlace()[source]#
compute inverse of this thanks to LU factorization with partial pivoting. This method inverts U and then computes inv(A) by solving the system inv(A)*L = inv(U) for inv(A). The result is returned in this (InPlace). Based on Blas dgetri function for dense function
- solve_matrix(B)[source]#
solves a system of linear equations A * X = B (A=this) for a general N-by-N matrix A using the LU factorization computed by PLUFactorize.
- Parameters:
B (
SiconosMatrix
, in/out) – on input the RHS matrix b; on output the result x
- PLUForwardBackwardInPlace(*args)[source]#
Overload 1: solves a system of linear equations A * X = B (A=this) for a general N-by-N matrix A using the LU factorization computed by PLUFactorizationInPlace. Based on Blas dgetrs function for dense matrix.
- Parameters:
B (
SiconosMatrix
, in/out) – on input the RHS matrix b; on output the result x
Overload 2: solves a system of linear equations A * X = B (A=this) for a general N-by-N matrix A using the LU factorization computed by PLUFactorizationInPlace. Based on Blas dgetrs function for dense matrix.
- Parameters:
B (
SiconosVector
, in/out) – on input the RHS matrix b; on output the result x
- solve_vector(B)[source]#
solves a system of linear equations A * X = B (A=this) for a general N-by-N matrix A using the LU factorization computed by PLUFactorize.
- Parameters:
B (
SiconosVector
, in/out) – on input the RHS matrix b; on output the result x
- resetFactorizationFlags()[source]#
- set to false all factorization indicators. Useful in case of
assignment for example.
- fillCSC(*args)[source]#
Overload 1: Fill CSparseMatrix compresses column sparse matrix
- Parameters:
- Return type:
boolean
- Returns:
true if function worked.
Warning: not clear that it works for an empty csr matrix with row_off =0 and col_off =0
Overload 2: Fill CSparseMatrix compresses column sparse matrix
- Parameters:
csc (CSparseMatrix) – the compressed column sparse matrix
tol (float, optional) – the tolerance under which a number is considered as equal to zero
- Return type:
boolean
- Returns:
true if function worked.
Overload 3: Fill CSparseMatrix compresses column sparse matrix
- Parameters:
csc (CSparseMatrix) – the compressed column sparse matrix
tol – the tolerance under which a number is considered as equal to zero
- Return type:
boolean
- Returns:
true if function worked.
- class siconos.kernel.SimpleMatrix(*args)[source]#
Bases:
SiconosMatrix
Matrix (embedded various types of Boost matrices of double)
SimpleMatrix is used in the platform to store matrices (mathematical object) of double.
Possible types: siconos::DENSE (default), TRIANGULAR, SYMMETRIC, SPARSE, BANDED, ZERO, siconos::IDENTITY, siconos::SPARSE_COORDINATE.
TODO: : review resize function for Banded, Symetric and Triangular. Error in tests.
- Overload 1:
Default constructor
- Overload 2:
constructor with the type and the dimension of the Boost matrix
- type row:
int
- param row:
number of rows.
- type col:
int
- param col:
number of columns.
- type typ:
int, optional
- param typ:
the type of matrix
- type upper:
int, optional
- param upper:
if siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal :type lower: int, optional
- Parameters:
lower – 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
- type row:
int
- param row:
number of rows.
- type col:
int
- param col:
number of columns.
- type typ:
int, optional
- param typ:
the type of matrix
- type upper:
int, optional
- param upper:
if siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal :param 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
- type row:
int
- param row:
number of rows.
- type col:
int
- param col:
number of columns.
- type typ:
int, optional
- param typ:
the type of matrix
- param upper:
if siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal :param 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
- type row:
int
- param row:
number of rows.
- type col:
int
- param col:
number of columns.
- param typ:
the type of matrix
- param upper:
if siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal :param 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.
- type row:
int
- param row:
number of rows.
- type col:
int
- param col:
number of columns.
- type inputValue:
float
- param inputValue:
double a, so that *this = [a a a …]
- type typ:
int, optional
- param typ:
the type of matrix
- type upper:
int, optional
- param upper:
if siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal :type lower: int, optional
- Parameters:
lower – 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.
- type row:
int
- param row:
number of rows.
- type col:
int
- param col:
number of columns.
- type inputValue:
float
- param inputValue:
double a, so that *this = [a a a …]
- type typ:
int, optional
- param typ:
the type of matrix
- type upper:
int, optional
- param upper:
if siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal :param 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.
- type row:
int
- param row:
number of rows.
- type col:
int
- param col:
number of columns.
- type inputValue:
float
- param inputValue:
double a, so that *this = [a a a …]
- type typ:
int, optional
- param typ:
the type of matrix
- param upper:
if siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal :param 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.
- type row:
int
- param row:
number of rows.
- type col:
int
- param col:
number of columns.
- type inputValue:
float
- param inputValue:
double a, so that *this = [a a a …]
- param typ:
the type of matrix
- param upper:
if siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal :param lower: if siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal
- Overload 10:
copy constructor
- type smat:
- param smat:
the matrix to copy
- Overload 11:
copy constructor of a block given by the coord = [r0A r1A c0A c1A]
- type A:
- param A:
the matrix which contains the block to extract
- type coord:
Index
- param coord:
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)
- type m:
DenseMat
- param m:
a DenseMat
- Overload 13:
constructor with a TriangMat matrix (see SiconosMatrix.h for details)
- type m:
TriangMat
- param m:
a TriangMat
- Overload 14:
constructor with a SymMat matrix (see SiconosMatrix.h for details)
- type m:
SymMat
- param m:
a SymMat
- Overload 15:
constructor with a BandedMat matrix (see SiconosMatrix.h for details)
- type m:
BandedMat
- param m:
a BandedMat
- Overload 16:
constructor with a SparseMat matrix (see SiconosMatrix.h for details)
- type m:
SparseMat
- param m:
a SparseMat
- Overload 17:
constructor with a SparseCoordinateMat matrix (see SiconosMatrix.h for details)
- type m:
SparseCoordinateMat
- param m:
a SparseMat
- Overload 18:
constructor with a ZeroMat matrix (see SiconosMatrix.h for details)
- type m:
ZeroMat
- param m:
a ZeroMat
- Overload 19:
constructor with a IdentityMat matrix (see SiconosMatrix.h for details)
- type m:
IdentityMat
- param m:
a IdentityMat
- Overload 20:
constructor with an input file
- type file:
string
- param file:
the input file path
- type ascii:
boolean, optional
- param ascii:
a boolean to indicate if the file is in ascii
- Overload 21:
constructor with an input file
- type file:
string
- param file:
the input file path
- param 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.
- type row:
int
- param row:
the new number of rows
- type col:
int
- param col:
the mew number of columns
- type lower:
int, optional
- param lower:
(only for Banded)
- type upper:
int, optional
- param upper:
(only for Banded)
- type preserve:
boolean, optional
- param preserve:
preserve existing elements
- 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
- type index:
int
- param index:
index of required column
- type pos:
int
- param pos:
index of the first required element in the column
- type vOut:
SiconosVector
, out- param vOut:
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
- type index:
int
- param index:
index of the required row
- type pos:
int
- param pos:
index of the first required element in the row
- type vOut:
SiconosVector
, out- param vOut:
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
- type index:
int
- param index:
index of required column
- type pos:
int
- param pos:
index of the first required element in the column
- type vIn:
- param vIn:
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.
- type B:
SiconosMatrix
, in/out- param B:
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.
- type B:
SiconosVector
, in/out- param B:
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.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.NonSmoothLaw(*args)[source]#
Bases:
object
Non Smooth Laws (NSL) Base Class
This class is the base class for all nonsmooth laws in Siconos. A nonsmooth law characterize the (nonsmooth) relationship between 2 variables, usually designated by \(y\) and \(\lambda\). \(y\) is most of time seen as the “input” from DynamicalSystems and is given by a Relation linked to this nonsmoothlaw. \(\lambda\) is then the “output” and through the same Relation is fed back to one or more DynamicalSystem.
classical examples of nonsmooth law include: - RelayNSL: \(-y \in \mathcal{N}_{[-1,1]}(\lambda)\quad \Longleftrightarrow\quad -\lambda \in \mbox{sgn} (y)\) - NormalConeNSL: given a polytope \(K\), \(-\lambda \in \partial \sigma_{-K}(y)\quad\Longleftrightarrow\quad y\in\mathcal{N}_{-K}(-\lambda)\) - ComplementarityConditionNSL: \(0\leq y \perp \lambda \geq 0\) - NewtonImpactNSL and NewtonImpactFrictionNSL for impact, without or with friction - MultipleImpactNSL for a multiple impact law - MixedComplementarityConditionNSL
The computation of both \(y\) and \(\lambda\) is carried on by a solver in Numerics through a OneStepNSProblem object.
basic constructor
- Parameters:
size (int) – the nonsmooth law size
- class siconos.kernel.NewtonImpactNSL(*args)[source]#
Bases:
NonSmoothLaw
Newton impact Non Smooth Law
This class formalizes the Newton Impact law together with a complementarity condition. i.e.
\[\left\{\begin{array}{l} y \geq 0, \lambda \geq 0, y^{T} \lambda=0\ \ if y \leq 0 \quad \mbox{then} \quad \dot y(t^{+}) - e \dot y(t^{-}) \geq 0, \quad \lambda \geq 0, (\dot y(t^{+}) - e \dot y(t^{-}))^{T} \lambda=0 \end{array}\right.\]nsLawSize is equal to 1.
Overload 1: default constructor
Overload 2: constructor with the value of the NewtonImpactNSL attributes
- Parameters:
e (float) – the value of the coefficient of restitution
Overload 3: Apply multiple-axis impact
- class siconos.kernel.NewtonImpactFrictionNSL(*args)[source]#
Bases:
NonSmoothLaw
Newton Impact-Friction Non Smooth Law
Overload 1: basic constructor
- Parameters:
size (int) – size of the ns law
Overload 2: constructor with the value of the NewtonImpactFrictionNSL attributes
- Parameters:
- class siconos.kernel.FremondImpactFrictionNSL(*args)[source]#
Bases:
NonSmoothLaw
Fremond 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 FremondImpactFrictionNSL attributes
- Parameters:
- class siconos.kernel.NewtonImpactRollingFrictionNSL(*args)[source]#
Bases:
NonSmoothLaw
Newton Impact-Friction Non Smooth Law
- Overload 1:
basic constructor
- type size:
int
- param size:
size of the ns law
- Overload 2:
constructor with the value of the NewtonImpactRollingFrictionNSL attributes :type en: float
- Parameters:
en –
double : normal e coefficient
- type et:
float
- param et:
double tangent e coefficient
- type mu:
float
- param mu:
double : friction coefficient
- type muR:
float
- param muR:
double : rolling friction coefficient
- type size:
int
- param size:
unsigned int: size of the ns law
- class siconos.kernel.MixedComplementarityConditionNSL(newSize, equalitySize)[source]#
Bases:
NonSmoothLaw
Complementarity NonSmoothLaw
basic constructor
- Parameters:
- class siconos.kernel.ComplementarityConditionNSL(size)[source]#
Bases:
NonSmoothLaw
Complementarity NonSmoothLaw
basic constructor
- Parameters:
size (int) – of the non smooth law
- class siconos.kernel.EqualityConditionNSL(size)[source]#
Bases:
NonSmoothLaw
Equality NonSmoothLaw
basic constructor
- Parameters:
size (int) – of the non smooth law
- class siconos.kernel.MultipleImpactNSL(*args)[source]#
Bases:
NonSmoothLaw
basic constructor
- Parameters:
size (int) – the nonsmooth law size
- class siconos.kernel.RelayNSL(size, lb=-1.0, ub=1.0)[source]#
Bases:
NonSmoothLaw
Relay NonSmoothLaw
This class formalizes the Relay nonsmooth law i.e.
\[-y \in \mathcal{N}_{[lb,ub]}(\lambda),\]where \(lb\) is the lower bound and \(ub\) is the upper bound of the Relay law.
In this default case, the lower bound is set to \(lb=-1\) and the upper bound ub is set to \(ub=1\). We get the well-known form of the RelayNSL as the multivalued sign function, i.e.
\[y \in -\mathcal{N}_{[-1,1]}(\lambda) \Longleftrightarrow \lambda \in -\mbox{sgn} (y)\]where the multi-valued sign function is defined as
\[\begin{split}\mbox{sgn} (y) = \left\{ \begin{array}{lcl} 1 && y >0 \\ [-1,1] && y =0 \\ -1 && y <0 \end{array}\right.\end{split}\]TODO: Build the Sgn NonSmoothLaw as the default instance of Relay
constructor with the value of the RelayNSL attributes
- Parameters:
- class siconos.kernel.NormalConeNSL(size, H, K)[source]#
Bases:
NonSmoothLaw
NormalCone NonSmoothLaw
This class formalizes a nonsmooth law in the form of a normal cone inclusion i.e.
\[0 \in y + \mathcal{N}_{P}(\lambda),\]where \(P\) is a polyhedral set. This is a generalization of the RelayNSL law, where the set \(P\) is a scaled box. Note that there exists an inverse of the previous relation in the form
\[\lambda \in \partial \sigma_{P} (-y),\]with \(\sigma_{P}\) the support function of \(P\) and \(\partial \sigma_{P}\) the subdifferential of this support function.
Note that the polyhedral set \(P\) is described as \(\{\lambda\mid H \lambda \geq K\}\), where \(H\) is a matrix and \(K\) a vector.
Constructor with the polyhedral representation of P as Hx >= K
- Parameters:
size (int) – size of the NonSmoothLaw
H (
SimpleMatrix
) – matrix in the (H-K)-representation of the polytope PK (
SiconosVector
) – vector in the (H-K)-representation of the polytope P
- class siconos.kernel.DynamicalSystem(*args)[source]#
Bases:
object
Abstract interface to Dynamical Systems
This class is used to describe dynamical systems of the form :
\(g(\dot x, x, t, z) = 0\)
where
\(x \in R^{n}\) is the state.
\(z \in R^{zSize}\) is a vector of arbitrary algebraic
variables, some sort of discret state. For example, z may be used to set some perturbation parameters, to control the system (z set by actuators) and so on. - \(g : R^{n} \times R \to R^{n}\) .
By default, the DynamicalSystem is considered to be an Initial Value Problem (IVP) and the initial conditions are given by
\(x(t_0)=x_0\)
Under some specific conditions, the system can be written as:
\(\dot x = rhs(x, t, z)\)
In that case, \(\nabla_{\dot x} g\) must be invertible.
- Overload 1:
default constructor
- Overload 2:
- minimal constructor, from state dimension
result in \(\dot x = r\)
- type dimension:
int
- param dimension:
size of the system (n)
- Overload 3:
Copy constructor
- Parameters:
ds (
DynamicalSystem
) – the DynamicalSystem to copy
- initRhs(time)[source]#
allocate (if needed) and compute rhs and its jacobian.
- Parameters:
time (float) – of initialization
- initializeNonSmoothInput(level)[source]#
set nonsmooth input to zero
- Parameters:
level (int) – input-level to be initialized.
- update(time)[source]#
compute all component of the dynamical system, for the current state.
- Parameters:
time (float) – current time (the one used to update ds component)
- computeRhs(time)[source]#
update right-hand side for the current state
- Parameters:
time (float) – of interest
- computeJacobianRhsx(time)[source]#
update \(\nabla_x rhs\) for the current state
- Parameters:
time (float) – of interest
- resetNonSmoothPart(level)[source]#
set nonsmooth part of the rhs to zero for a given level
- Parameters:
level (int)
- setNumber(new_number)[source]#
set the id of the DynamicalSystem
- Return type:
- Returns:
the previous value of number
- dimension()[source]#
returns the dimension of the system (depends on system type, e.g. n for first order, ndof for Lagrangian).
- setX0(newValue)[source]#
set initial state (copy)
- Parameters:
newValue (
SiconosVector
) – input vector to copy
- setX0Ptr(newPtr)[source]#
set initial state (pointer link)
- Parameters:
newPtr (
SiconosVector
) – vector (pointer) to set x0
- setX(newValue)[source]#
set content of current state vector \(x\)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setXPtr(newPtr)[source]#
set state vector \(x\) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector
- r()[source]#
returns a pointer to r vector (input due to nonsmooth behavior)
- Return type:
- Returns:
SP::SiconosVector
- getR()[source]#
get a copy of r vector (input due to nonsmooth behavior)
- Return type:
- Returns:
a SiconosVector
- setR(newValue)[source]#
set r vector (input due to nonsmooth behavior) content (copy)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setRPtr(newPtr)[source]#
set r vector (input due to nonsmooth behavior) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector newPtr
- rhs()[source]#
returns a pointer to the right-hand side vector, (i.e. \(\dot x\))
- Return type:
- Returns:
SP::SiconosVector
- getRhs()[source]#
get a copy of the right-hand side vector, (i.e. \(\dot x\))
- Return type:
- Returns:
SiconosVector
- setRhs(newValue)[source]#
set the value of the right-hand side, \(\dot x\)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setRhsPtr(newPtr)[source]#
set right-hand side, \(\dot x\) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector
- jacobianRhsx()[source]#
returns a pointer to \(\nabla_x rhs()\)
- Return type:
- Returns:
SP::SiconosMatrix
- setJacobianRhsx(newValue)[source]#
set the value of \(\nabla_x rhs()\)
- Parameters:
newValue (
SiconosMatrix
) – SiconosMatrix
- setJacobianRhsxPtr(newPtr)[source]#
set \(\nabla_x rhs()\), pointer link
- Parameters:
newPtr (
SiconosMatrix
) – SP::SiconosMatrix
- z()[source]#
returns a pointer to \(z\), the vector of algebraic parameters.
- Return type:
- Returns:
SP::SiconosVector
- getz()[source]#
get a copy of \(z\), the vector of algebraic parameters.
- Return type:
- Returns:
a SiconosVector
- setz(newValue)[source]#
set the value of \(z\) (copy)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setzPtr(newPtr)[source]#
set \(z\) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector
- xMemory()[source]#
get all the values of the state vector x stored in a SiconosMemory object (not const due to LinearSMC::actuate)
- Return type:
SiconosMemory
- 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
- class siconos.kernel.NonSmoothDynamicalSystem(t0, T)[source]#
Bases:
object
the NonSmoothDynamicalSystem consists in Dynamical Systems and Interactions structured into a graph defined in a Topology. In the DynamicalSystem graph, DynamicalSystem objects are nodes and Interaction objects are edges.
To add a DynamicalSystem, use insertDynamicalSystem method. To add a new Interaction, use link method.
A dual graph is also contructed, where Interactions are vertices and DynamicalSystems are edges.
NSDS constructor.
- setT(newValue)[source]#
set final time
- Parameters:
newValue (float) – the new final time for the Simulatiom
- title()[source]#
get the title of the simulation
- Return type:
string
- Returns:
std::string : the title
- author()[source]#
get the author of the simulation
- Return type:
string
- Returns:
std::string : the author
- setAuthor(s)[source]#
set the author of the simulation
- Parameters:
s (string) – std::string : the author
- description()[source]#
allows to get the description of the simulation
- Return type:
string
- Returns:
std::string : the description
- setDescription(s)[source]#
set the author of the simulation
- Parameters:
s (string) – std::string : the author
- date()[source]#
allows to get the date of the simulation
- Return type:
string
- Returns:
std::string : the date
- setBVP(newBvp)[source]#
set the NonSmoothDynamicalSystem to BVP, else it is IVP
- Parameters:
newBvp (boolean) – true if BVP, false otherwise
- changeLog()[source]#
get a reference to the changelog for an NSDS.
- Return type:
NonSmoothDynamicalSystem::ChangeLog
- Returns:
a reference to the changelog.
- changeLogPosition()[source]#
get an iterator to the last item in the changelog.
- Return type:
NonSmoothDynamicalSystem::ChangeLogIter
- Returns:
an iterator pointing at the last item in the changelog.
- changeLogBegin()[source]#
get an iterator to the beginning of the changelog.
- Return type:
NonSmoothDynamicalSystem::ChangeLogIter
- Returns:
an iterator pointing at the beginning of the changelog.
- clearChangeLogTo(it)[source]#
clear the changelog up to a given position.
- Parameters:
it (NonSmoothDynamicalSystem::ChangeLogIter) – This iterator must point to somewhere in the changelog for this NSDS.
- dynamicalSystems()[source]#
get all the dynamical systems declared in the NonSmoothDynamicalSystem.
- Return type:
DynamicalSystemsGraph
- Returns:
a SP::DynamicalSystemsGraph
- dynamicalSystemsVector()[source]#
get all the dynamical systems declared in the NonSmoothDynamicalSystem. into a std::vector<SP::DynamicalSystem> Useful for iterates on DynamicalSystems in Python for instance
- Return type:
std::vector< SP::DynamicalSystem,std::allocator< SP::DynamicalSystem > >
- Returns:
std::vector<SP::DynamicalSystem>
- insertDynamicalSystem(ds)[source]#
add a dynamical system into the DS graph (as a vertex)
- Parameters:
ds (
DynamicalSystem
) – a pointer to the system to add
- dynamicalSystem(nb)[source]#
get Dynamical system number I
- Parameters:
nb (int) – the identifier of the DynamicalSystem to get
- Return type:
- Returns:
a pointer on DynamicalSystem
- removeDynamicalSystem(ds)[source]#
remove a dynamical system
- Parameters:
ds (
DynamicalSystem
) – a pointer to the dynamical system to remove
- getNumberOfInteractions()[source]#
get the number of Interactions present in the NSDS.
- Return type:
- Returns:
an unsigned int
- interactions()[source]#
return the graph of Interactions present in the NSDS.
- Return type:
InteractionsGraph
- Returns:
SP::InteractionGraph
- removeInteraction(inter)[source]#
remove an interaction to the system
- Parameters:
inter (
Interaction
) – a pointer to the interaction to remove
- interaction(*args)[source]#
Overload 1: get Interaction number I
- Parameters:
nb (int) – the identifier of the Interaction to get
- Return type:
- Returns:
a pointer to an Interaction
Overload 2: get Interaction named name
- Parameters:
name (string) – of the Interaction to get
- Return type:
- Returns:
a pointer to an Interaction
- InteractionsVector()[source]#
get all the interactions declared in the NonSmoothDynamicalSystem. into a std::vector<SP::Interaction> Useful for iterates on Interaction in Python for instance
- Return type:
std::vector< SP::Interaction,std::allocator< SP::Interaction > >
- Returns:
std::vector<SP::Interaction>
- link(*args)[source]#
link an interaction to two dynamical systems
- Parameters:
inter (
Interaction
) – the interactionds1 (
DynamicalSystem
) – a DynamicalSystemds2 (
DynamicalSystem
, optional) – a DynamicalSystem (optional)
- setName(*args)[source]#
Overload 1: set the name for this Dynamical System
- Parameters:
ds (
DynamicalSystem
) – a pointer to the systemname (string) – the name of the DynamicalSystem
Overload 2: set the name for this Interaction
- Parameters:
interaction (
Interaction
) – a pointer to the Interactionname (string) – the name of the Interaction
- name(*args)[source]#
Overload 1: get the name for this Dynamical System
- Parameters:
ds (
DynamicalSystem
) – a pointer to the system- Return type:
string
- Returns:
name the name of the DynamicalSystem, or empty string if not found.
Overload 2: get the name for this Interaction
- Parameters:
inter (
Interaction
) – a pointer to the Interaction- Return type:
string
- Returns:
name the name of the Interaction, or empty string if not found.
- setControlProperty(inter, isControlInteraction)[source]#
specify id the given Interaction is for controlling the DS
- Parameters:
inter (
Interaction
) – the InteractionisControlInteraction (boolean) – true if the Interaction is used for control purposes
- isLinear()[source]#
return false is one of the interations is not linear. else return true.
- Return type:
boolean
- Returns:
a bool
- setSymmetric(val)[source]#
set symmetry in the blocks computation
- Parameters:
val (boolean) – a bool
- resetNonSmoothPart(level)[source]#
Set all DS non-smooth part to zero for a given level.
- Parameters:
level (int) – the level to will be zeroed
- pushInteractionsInMemory()[source]#
- save interaction states in memories. Applied to all interactions
of the connected topology
- updateDSPlugins(time)[source]#
update the plugins of the DS
- Parameters:
time (float) – to be used for plugins
- updateOutput(*args)[source]#
Overload 1: compute output for all the interactions for a given level
Overload 2: compute output for all the interactions and for a level range
- computeInteractionJacobians(*args)[source]#
Overload 1: compute Jacobians for all the interactions (in indexSet0)
- Parameters:
time (float)
Overload 2: compute Jacobians for all the interactions of a given index set
- Parameters:
time (float)
indexSet (
InteractionsGraph
) – InteractionsGraph of interest
- class siconos.kernel.LinearComplementaritySystemsNSDS(t0, T, x0, A, B, C, D, a, b)[source]#
Bases:
NonSmoothDynamicalSystem
The LinearComplementaritySystemsNSDS_H inherits frim NSDS for a direct instanciation of a LCS
constructor with t0 and T
- interaction()[source]#
Overload 1: get Interaction number I
- Parameters:
nb (int) – the identifier of the Interaction to get
- Return type:
- Returns:
a pointer to an Interaction
Overload 2: get Interaction named name
- Parameters:
name (string) – of the Interaction to get
- Return type:
- Returns:
a pointer to an Interaction
- class siconos.kernel.Topology[source]#
Bases:
object
This class describes the topology of the non-smooth dynamical system. It holds all the “potential” Interactions”.
Topology is built in NSDS constructors but initialized in Simulation->initialize(), ie when all Interactions have been clearly defined.
Note that indexSet0 holds all the possible relations (declared by user) not only those which are “actives”.
Construction consists in: - link with the NSDS that owns the topology.
Initialization consists in: - scan of all the interactions of the NSDS - initialization of each interaction - insertion of the relations of all the Interaction into indexSet0
Insertion of an Interaction into the set indexSet0: addInteractionInIndexSet0(SP::Interaction inter) for each relation of the interaction, it creates a new Interaction and inserts it into indexSet0 It also counts the total number of “constraints” in the system.
default constructor
- hasDynamicalSystem(ds)[source]#
check if an dynamical system is already a vertex of the DSs graph.
- Parameters:
ds (
DynamicalSystem
) – the DS to test- Return type:
boolean
- Returns:
true if ds is in the graph
- hasInteraction(inter)[source]#
check if an interaction is already a vertex of the Interactions graph.
- Parameters:
inter (
Interaction
) – the Interaction to test- Return type:
boolean
- Returns:
true if inter is in the graph
- removeInteraction(inter)[source]#
remove an Interaction from the topology. The interaction is removed from Dynamical Systems graph and Interactions Graph. The interaction is not removed from actives subgraphs : see updateIndexSet
- Parameters:
inter (
Interaction
) – the interaction to remove
- insertDynamicalSystem(ds)[source]#
add a dynamical system
- Parameters:
ds (
DynamicalSystem
) – the DynamicalSystem to add
- removeDynamicalSystem(ds)[source]#
remove a Dynamical System from the topology. The dynamical system is removed from Dynamical Systems graph and Interactions Graph. The dynamical system is not removed from actives subgraphs : see updateIndexSet
- Parameters:
ds (
DynamicalSystem
) – the dynamical system to remove
- setName(*args)[source]#
Overload 1: set the name for this Dynamical System
- Parameters:
ds (
DynamicalSystem
) – a pointer to the systemname (string) – the name of the DynamicalSystem
Overload 2: set the name for an Interaction
- Parameters:
inter (
Interaction
) – a pointer to the Interactionname (string) – the name of the Interaction
- name(*args)[source]#
Overload 1: get the name for this Dynamical System
- Parameters:
ds (
DynamicalSystem
) – a pointer to the system- Return type:
string
- Returns:
name the name of the DynamicalSystem, or empty string if not found.
Overload 2: get the name for this Interaction
- Parameters:
inter (
Interaction
) – a pointer to the Interaction- Return type:
string
- Returns:
name the name of the Interaction, or empty string if not found.
- setOSI(ds, OSI)[source]#
set the OSI for this DynamicalSystem
- Parameters:
ds (
DynamicalSystem
) – the DynamicalSystemOSI (
OneStepIntegrator
) – the integrator to use for this DS
- link(*args)[source]#
link two dynamical systems to a relation
- Parameters:
inter (
Interaction
) – a SP::Interactionds (
DynamicalSystem
) – a SP::DynamicalSystemds2 (
DynamicalSystem
, optional) – a SP::DynamicalSystem (optional)
- Return type:
std::pair< DynamicalSystemsGraph::EDescriptor,InteractionsGraph::VDescriptor >
- Returns:
a vertex descriptor of the new vertex in IndexSet0
- setControlProperty(inter, isControlInteraction)[source]#
specify if the given Interaction is for controlling the DS
- Parameters:
inter (
Interaction
) – InteractionisControlInteraction (boolean) – true if the Interaction is used for control purposes
- indexSet0()[source]#
get a pointer to the graph of all Interactions.
- Return type:
InteractionsGraph
- Returns:
a SP::InteractionsGraph
- indexSet(num)[source]#
get a pointer to the graph at level num of Interactions
- Parameters:
num (int) – the number of indexSet
- Return type:
InteractionsGraph
- Returns:
a SP::InteractionsGraph
- numberOfIndexSet()[source]#
get a pointer to the graph at level num of Interactions
- Return type:
- Returns:
a SP::InteractionsGraph
- resetIndexSetPtr(num)[source]#
reset graph at level num of Interactions
- Parameters:
num (int) – the indexSet to reset
- dSG(num)[source]#
get a pointer to the graph at level num of Dynamical System
- Parameters:
num (int) – the level
- Return type:
DynamicalSystemsGraph
- Returns:
a SP::DynamicalSystemsGraph
- indexSetsSize()[source]#
get the number of Interactions Graphs
- Return type:
- Returns:
the number of Interactions Graphs
- indexSetsResize(newSize)[source]#
resize Interactions Graphs
- Parameters:
newSize (int) – the new size
- numberOfConstraints()[source]#
get the total number of scalar constraints
- Return type:
- Returns:
an unsigned int
- setSymmetric(val)[source]#
set symmetry in the blocks computation
- Parameters:
val (boolean) – a bool
- getDynamicalSystem(*args)[source]#
Overload 1: Get a dynamical system using its number Warning: O(n) complexity
- Parameters:
requiredNumber (int) – the required number
- Return type:
- Returns:
a DynamicalSystem
Overload 2: Get a dynamical system using its name Warning: O(n) complexity
- Parameters:
name (string) – the name of the dynamical system
- Return type:
- Returns:
a DynamicalSystem
- getInteraction(*args)[source]#
Overload 1: Get a interaction using its number Warning: O(n) complexity
- Parameters:
requiredNumber (int) – the required number
- Return type:
- Returns:
an Interaction
Overload 2: Get a interaction using its name Warning: O(n) complexity
- Parameters:
name (string) – the name of the Interaction
- Return type:
- Returns:
an Interaction pointer
- interactionsForDS(arg2)[source]#
get Interactions for a given DS
- Return type:
std::vector< SP::Interaction,std::allocator< SP::Interaction > >
- Returns:
a vector of pointers to Interaction
- interactionsForPairOfDS(*args)[source]#
get Interactions for a given pair of DSs
- Return type:
std::vector< SP::Interaction,std::allocator< SP::Interaction > >
- Returns:
a vector of pointers to Interaction
- dynamicalSystemsForInteraction(arg2)[source]#
get DynamicalSystems for a given Interaction
- Return type:
std::vector< SP::DynamicalSystem,std::allocator< SP::DynamicalSystem > >
- Returns:
a vector of pointers to DynamicalSystem
- getDSG0Descriptor(ds)[source]#
Helper to get the descriptor in DSG0 from a DynamicalSystem
- Parameters:
ds (
DynamicalSystem
) – DynamicalSystem of which we want the descriptor- Return type:
DynamicalSystemsGraph::VDescriptor
- Returns:
the descriptor in DSG0 from a DynamicalSystem
- class siconos.kernel.SecondOrderDS(*args, **kwargs)[source]#
Bases:
DynamicalSystem
Second Order non linear dynamical systems - \(M(q,z) \dot v = F(v, q, t, z) + p\)
This class defines and computes a generic ndof-dimensional second order Non Linear Dynamical System of the form :
\[\begin{split}M(q,z) \dot v = F(v, q, t, z) + p \\ \dot q = G(q,v)\end{split}\]where
\(q \in R^{ndof}\) is the set of the coordinates,
\(\dot q =v \in R^{ndof}\) the velocity,
\(\ddot q = \dot v \in R^{ndof}\) the acceleration, i. e. the second
time derivative of the generalized coordinates. - \(p \in R^{ndof}\) the reaction forces due to the Non Smooth Interaction. - \(M(q) \in R^{ndof \times ndof}\) is the inertia term (access : mass() method). - \(F( \dot q , q , t) \in R^{ndof}\) are the forces (access forces() method). - \(z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discrete state.
q[i] is the derivative number i of q. Thus: q[0]= \(q\), global coordinates, q[1]= \(\dot q\), velocity, q[2]= \(\ddot q\), acceleration.
The following operators (and their jacobians) can be plugged, in the usual way (see User Guide, ‘User-defined plugins’)
\(M(q)\) (computeMass())
\(F(v , q , t, z)\) (computeF())
If required (e.g. for Event-Driven like simulation), formulation as a first-order system is also available, and writes:
\(n= 2 ndof\)
\(x = \left[\begin{array}{c}q \\ \dot q\end{array}\right]\)
rhs given by:
\[\begin{split}\dot x = \left[\begin{array}{c} \dot q\\ \ddot q = M^{-1}(q)\left[F(v, q , t, z) + p \right]\\ \end{array}\right]\end{split}\]jacobian of the rhs, with respect to x
\[\begin{split}\nabla_{x}rhs(x,t) = \left[\begin{array}{cc} 0 & I \\ \nabla_{q}(M^{-1}(q)F(v, q , t, z)) & \nabla_{\dot q}(M^{-1}(q)F(v, q , t, z)) \\ \end{array}\right]\end{split}\]with the input due to the non smooth law:
\[\begin{split}\left[\begin{array}{c} 0 \\ p \end{array}\right]\end{split}\]In that case, use the following methods: - initRhs() to allocate/initialize memory for these new operators, - rhs() to get the rhs vector - computeRhs(), computeJacobianRhsx() …, to update the content of rhs, its jacobians …
- Overload 1:
default constructor
- Overload 2:
- minimal constructor, from state dimension
result in \(\dot x = r\)
- type dimension:
int
- param dimension:
size of the system (n)
- Overload 3:
Copy constructor
- Parameters:
ds (
DynamicalSystem
) – the DynamicalSystem to copy
- p(level=2)[source]#
get p
- Parameters:
level (int, optional) – unsigned int, required level for p, default = 2
- Return type:
- Returns:
pointer on a SiconosVector
- inverseMass()[source]#
get (pointer) inverse or LU-factorization of the mass, used for LU-forward-backward computation
- Return type:
- Returns:
pointer SP::SimpleMatrix
- setMassPtr(newPtr)[source]#
set mass to pointer newPtr
- Parameters:
newPtr (
SimpleMatrix
) – a plugged matrix SP
- setRhs(newValue)[source]#
set the value of the right-hand side, \(\dot x\)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setRhsPtr(newPtr)[source]#
set right-hand side, \(\dot x\) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector
- computeForces(time, q, velocity)[source]#
Compute \(F(v,q,t,z)\)
- Parameters:
time (float) – the current time
q (
SiconosVector
) – SP::SiconosVector: pointers on qvelocity (
SiconosVector
) – SP::SiconosVector: pointers on velocity
- computeJacobianqForces(time)[source]#
Compute \(\nabla_qF(v,q,t,z)\) for current \(q,v\) Default function to compute forces
- Parameters:
time (float) – the current time
- computeJacobianvForces(time)[source]#
Compute \(\nabla_{\dot q}F(v,q,t,z)\) for current \(q,v\)
- Parameters:
time (float) – the current time
- dimension()[source]#
return the number of degrees of freedom of the system
- Return type:
- Returns:
an unsigned int.
- q()[source]#
generalized coordinates of the system (vector of size dimension())
- Return type:
- Returns:
pointer on a SiconosVector
- setQ(newValue)[source]#
set value of generalized coordinates vector (copy)
- Parameters:
newValue (
SiconosVector
)
- setQPtr(newPtr)[source]#
set value of generalized coordinates vector (pointer link)
- Parameters:
newPtr (
SiconosVector
)
- setQ0(newValue)[source]#
set initial state (copy)
- Parameters:
newValue (
SiconosVector
)
- setQ0Ptr(newPtr)[source]#
set initial state (pointer link)
- Parameters:
newPtr (
SiconosVector
)
- velocity()[source]#
get velocity vector (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- setVelocity(newValue)[source]#
set velocity vector (copy)
- Parameters:
newValue (
SiconosVector
)
- setVelocityPtr(newPtr)[source]#
set velocity vector (pointer link)
- Parameters:
newPtr (
SiconosVector
)
- velocity0()[source]#
get initial velocity (pointer)
- Return type:
- Returns:
pointer on a SiconosVector
- setVelocity0(newValue)[source]#
set initial velocity (copy)
- Parameters:
newValue (
SiconosVector
)
- setVelocity0Ptr(newPtr)[source]#
set initial velocity (pointer link)
- Parameters:
newPtr (
SiconosVector
)
- acceleration()[source]#
get acceleration (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- forces()[source]#
get \(F(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- jacobianvForces()[source]#
get \(\nabla_{\dot q}F(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- qMemory()[source]#
get all the values of the state vector q stored in memory. note: not const due to SchatzmanPaoliOSI::initializeWorkVectorsForDS
- Return type:
SiconosMemory
- 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:
SiconosMemory
- Returns:
a memory
- forcesMemory()[source]#
get forces in memory buff
- Return type:
SiconosMemory
- Returns:
pointer on a SiconosMemory
- initMemory(size)[source]#
initialize the SiconosMemory objects with a positive size.
- Parameters:
size (int) – the size of the SiconosMemory. must be >= 0
- computeMass(*args)[source]#
Overload 1: default function to compute the mass
Overload 2: function to compute the mass
- Parameters:
position (
SiconosVector
) – value used to evaluate the mass matrix
- setBoundaryConditions(newbd)[source]#
set Boundary Conditions
- Parameters:
newbd (
BoundaryCondition
) – BoundaryConditions
- boundaryConditions()[source]#
get Boundary Conditions
- Return type:
- Returns:
SP::BoundaryCondition pointer on a BoundaryConditions
- setReactionToBoundaryConditions(newrbd)[source]#
set Reaction to Boundary Conditions
- Parameters:
newrbd (
SiconosVector
) – BoundaryConditions pointer
- reactionToBoundaryConditions()[source]#
get Reaction to Boundary Conditions
- Return type:
- Returns:
pointer on a BoundaryConditions
- init_inverse_mass()[source]#
Allocate memory for the lu factorization of the mass of the system. Useful for some integrators with system inversion involving the mass
- class siconos.kernel.LagrangianDS(*args)[source]#
Bases:
SecondOrderDS
Lagrangian non linear dynamical systems - \(M(q,z) \dot v = F(v, q, t, z) + p\)
This class defines and computes a generic ndof-dimensional Lagrangian Non Linear Dynamical System of the form :
\[\begin{split}M(q,z) \dot v + F_{gyr}(v, q, z) + F_{int}(v , q , t, z) = F_{ext}(t, z) + p \\ \dot q = v\end{split}\]where
\(q \in R^{ndof}\) is the set of the generalized coordinates,
\(\dot q =v \in R^{ndof}\) the velocity, i. e. the time
derivative of the generalized coordinates (Lagrangian systems). - \(\ddot q =\\dot v \in R^{ndof}\) the acceleration, i. e. the second time derivative of the generalized coordinates. - \(p \in R^{ndof}\) the reaction forces due to the Non Smooth Interaction. - \(M(q) \in R^{ndof \times ndof}\) is the inertia term (access : mass() method). - \(F_{gyr}(\dot q, q) \in R^{ndof}\) is the non linear inertia term (access fGyr() method). - \(F_{int}(\dot q , q , t) \in R^{ndof}\) are the internal forces (access fInt() method). - \(F_{ext}(t) \in R^{ndof}\) are the external forces (access fExt() method). - \(z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discrete state.
The equation of motion is also shortly denoted as \(M(q,z) \dot v = F(v, q, t, z) + p\)
where \(F(v, q, t, z) \in R^{ndof}\) collects the total forces acting on the system, that is \(F(v, q, t, z) = F_{ext}(t, z) - F_{gyr}(v, q, z) + F_{int}(v, q , t, z)\)
This vector is saved and may be accessed using forces() method.
q[i] is the derivative number i of q. Thus: q[0]=:math:q, global coordinates, q[1]= \(\dot q\) , velocity, q[2]= \(\ddot q\), acceleration.
The following operators (and their jacobians) can be plugged, in the usual way (see User Guide, ‘User-defined plugins’)
\(M(q)\) (computeMass())
\(F_{gyr}(v, q, z)\) (computeFGyr())
\(F_{int}(v , q , t, z)\) (computeFInt())
\(F_{ext}(t, z)\) (computeFExt())
If required (e.g. for Event-Driven like simulation), formulation as a first-order system is also available, and writes:
\(n= 2 ndof\)
\(x = \left[\begin{array}{c}q \\ \dot q\end{array}\right]\)
rhs given by:
\[\begin{split}\dot x = \left[\begin{array}{c} \dot q\\ \ddot q = M^{-1}(q)\left[F(v, q , t, z) + p \right]\\ \end{array}\right] ndverbatim\end{split}\]jacobian of the rhs, with respect to x
\[\begin{split}\nabla_{x}rhs(x,t) = \left[\begin{array}{cc} 0 & I \\ \nabla_{q}(M^{-1}(q)F(v, q , t, z)) & \nabla_{\dot q}(M^{-1}(q)F(v, q , t, z)) \\ \end{array}\right]\end{split}\]with the input due to the non smooth law:
\[\begin{split}\left[\begin{array}{c} 0 \\ p \end{array}\right]\end{split}\]In that case, use the following methods: - initRhs() to allocate/initialize memory for these new operators, - rhs() to get the rhs vector - computeRhs(), computeJacobianRhsx() …, to update the content of rhs, its jacobians …
- Overload 1:
Default constructor
- Overload 2:
constructor from initial state only, \(dv = p\)
- type position:
- param position:
SiconosVector : initial coordinates of this DynamicalSystem :type velocity:
SiconosVector
- Parameters:
velocity – SiconosVector : initial velocity of this DynamicalSystem
- Overload 3:
constructor from initial state and mass, \(Mdv = p\)
- type position:
- param position:
SiconosVector : initial coordinates of this DynamicalSystem :type velocity:
SiconosVector
- Parameters:
velocity – SiconosVector : initial velocity of this DynamicalSystem :type mass:
SiconosMatrix
mass – SiconosMatrix : mass matrix
- Overload 4:
constructor from initial state and mass (plugin) \(Mdv = p\)
- type position:
- param position:
SiconosVector : initial coordinates of this DynamicalSystem :type velocity:
SiconosVector
- Parameters:
velocity – SiconosVector : initial velocity of this DynamicalSystem :type plugin: string
plugin – std::string: plugin path to compute mass matrix
- initRhs(time)[source]#
allocate (if needed) and compute rhs and its jacobian.
- Parameters:
time (float) – of initialization
- initializeNonSmoothInput(level)[source]#
set nonsmooth input to zero
- Parameters:
level (int) – input-level to be initialized.
- computeRhs(time)[source]#
update right-hand side for the current state
- Parameters:
time (float) – of interest
- computeJacobianRhsx(time)[source]#
update \(\nabla_x rhs\) for the current state
- Parameters:
time (float) – of interest
- resetNonSmoothPart(level)[source]#
set nonsmooth part of the rhs (i.e. p) to zero for a given level
- Parameters:
level (int)
- setRhs(newValue)[source]#
set the value of the right-hand side, \(\dot x\)
- Parameters:
newValue (
SiconosVector
) – SiconosVector
- setRhsPtr(newPtr)[source]#
set right-hand side, \(\dot x\) (pointer link)
- Parameters:
newPtr (
SiconosVector
) – SP::SiconosVector
- computeForces(time, q, velocity)[source]#
Compute \(F(v,q,t,z)\)
- Parameters:
time (float) – the current time
q (
SiconosVector
) – SP::SiconosVector: pointers on qvelocity (
SiconosVector
) – SP::SiconosVector: pointers on velocity
- computeJacobianqForces(time)[source]#
Compute \(\nabla_qF(v,q,t,z)\) for current \(q,v\) Default function to compute forces
- Parameters:
time (float) – the current time
- computeJacobianqDotForces(time)[source]#
Compute \(\nabla_{\dot q}F(v,q,t,z)\) for current \(q,v\)
- Parameters:
time (float) – the current time
- computeJacobianvForces(time)[source]#
Compute \(\nabla_{\dot q}F(v,q,t,z)\) for current \(q,v\)
- Parameters:
time (float) – the current time
- q()[source]#
generalized coordinates of the system (vector of size dimension())
- Return type:
- Returns:
pointer on a SiconosVector
- setQ(newValue)[source]#
set value of generalized coordinates vector (copy)
- Parameters:
newValue (
SiconosVector
)
- setQPtr(newPtr)[source]#
set value of generalized coordinates vector (pointer link)
- Parameters:
newPtr (
SiconosVector
)
- setQ0(newValue)[source]#
set initial state (copy)
- Parameters:
newValue (
SiconosVector
)
- setQ0Ptr(newPtr)[source]#
set initial state (pointer link)
- Parameters:
newPtr (
SiconosVector
)
- velocity()[source]#
get velocity vector (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- setVelocity(newValue)[source]#
set velocity vector (copy)
- Parameters:
newValue (
SiconosVector
)
- setVelocityPtr(newPtr)[source]#
set velocity vector (pointer link)
- Parameters:
newPtr (
SiconosVector
)
- velocity0()[source]#
get initial velocity (pointer)
- Return type:
- Returns:
pointer on a SiconosVector
- setVelocity0(newValue)[source]#
set initial velocity (copy)
- Parameters:
newValue (
SiconosVector
)
- setVelocity0Ptr(newPtr)[source]#
set initial velocity (pointer link)
- Parameters:
newPtr (
SiconosVector
)
- acceleration()[source]#
get acceleration (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- setFIntPtr(newPtr)[source]#
set $F_{int}$ (pointer link)
- Parameters:
newPtr (
SiconosVector
) – a SP to plugged vector
- setFExtPtr(newPtr)[source]#
set \(F_{ext}\) , (pointer link)
- Parameters:
newPtr (
SiconosVector
) – a SP to a Simple vector
- setFGyrPtr(newPtr)[source]#
set \(F_{gyr}\) , (pointer link)
- Parameters:
newPtr (
SiconosVector
) – a SP to plugged vector
- jacobianFIntq()[source]#
get \(\nabla_qF_{int}\) , (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- jacobianFIntqDot()[source]#
get \(\nabla_{\dot q}F_{int}\) , (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- setJacobianFIntqPtr(newPtr)[source]#
set \(\nabla_{q}F_{int}\) , (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – a pointer to a SiconosMatrix
- setJacobianFIntqDotPtr(newPtr)[source]#
set \(\nabla_{\dot q}F_{int}\) , (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – a pointer to a SiconosMatrix
- jacobianFGyrq()[source]#
get \(\nabla_{q}F_{gyr}\) , (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- jacobianFGyrqDot()[source]#
get \(\nabla_{\dot q}F_{gyr}\) , (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- setJacobianFGyrqPtr(newPtr)[source]#
get \(\nabla_{q}F_{gyr}\) , (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – a SP SiconosMatrix
- setJacobianFGyrqDotPtr(newPtr)[source]#
get \(\nabla_{\dot q}F_{gyr}\) , (pointer link)
- Parameters:
newPtr (
SiconosMatrix
) – a SP SiconosMatrix
- forces()[source]#
get \(F(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosVector
- jacobianqForces()[source]#
get \(\nabla_qF(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- jacobianvForces()[source]#
get \(\nabla_{\dot q}F(v,q,t,z)\) (pointer link)
- Return type:
- Returns:
pointer on a SiconosMatrix
- qMemory()[source]#
get all the values of the state vector q stored in memory. note: not const due to SchatzmanPaoliOSI::initializeWorkVectorsForDS
- Return type:
SiconosMemory
- 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:
SiconosMemory
- Returns:
a memory
- pMemory(level)[source]#
get all the values of the state vector p stored in memory
- Parameters:
level (int)
- Return type:
SiconosMemory
- Returns:
a memory
- forcesMemory()[source]#
get forces in memory buff
- Return type:
SiconosMemory
- Returns:
pointer on a SiconosMemory
- initMemory(size)[source]#
initialize the SiconosMemory objects with a positive size.
- Parameters:
size (int) – the size of the SiconosMemory. must be >= 0
- swapInMemory()[source]#
push the current values of x, q and r in the stored previous values xMemory, qMemory, rMemory, TODO: Modify the function swapIn Memory with the new Object Memory
- setComputeMassFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the mass
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute Mass
- Parameters:
fct (FPtr7) – a pointer on the plugin function
- setComputeFIntFunction(*args)[source]#
Overload 1: allow to set a specified function to compute FInt
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute fInt
- Parameters:
fct (FPtr6) – a pointer on the plugin function
- setComputeFExtFunction(*args)[source]#
Overload 1: allow to set a specified function to compute Fext
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute fExt
- Parameters:
fct (VectorFunctionOfTime) – a pointer on the plugin function
- setComputeFGyrFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the inertia
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute FGyr
- Parameters:
fct (FPtr5) – a pointer on the plugin function
- setComputeJacobianFIntqFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian w.r.t q of the internal forces
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute jacobian following q of the FInt
- Parameters:
fct (FPtr6) – a pointer on the plugin function
- setComputeJacobianFIntqDotFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian of the internal forces w.r.t. q
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute jacobian following qDot of the FInt
- Parameters:
fct (FPtr6) – a pointer on the plugin function
- setComputeJacobianFGyrqFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian w.r.t q of the the external forces
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute the jacobian following q of FGyr
- Parameters:
fct (FPtr5) – a pointer on the plugin function
- setComputeJacobianFGyrqDotFunction(*args)[source]#
Overload 1: allow to set a specified function to compute the jacobian w.r.t qDot of the the external strength
- Parameters:
pluginPath (string) – std::string : the complete path to the plugin
functionName (string) – std::string : the name of the function to use in this plugin
Overload 2: set a specified function to compute the jacobian following qDot of FGyr
- Parameters:
fct (FPtr5) – a pointer on the plugin function
- computeMass(*args)[source]#
Overload 1: default function to compute the mass
Overload 2: function to compute the mass
- Parameters:
position (
SiconosVector
) – value used to evaluate the mass matrix
- computeFInt(*args)[source]#
Overload 1: default function to compute the internal strengths
- Parameters:
time (float) – the current time
Overload 2: function to compute the internal strengths with some specific values for position and velocity (ie not those of the current state).
- Parameters:
time (float) – the current time,
position (
SiconosVector
) – value used to evaluate the internal forcesvelocity (
SiconosVector
) – value used to evaluate the internal forces
- computeFExt(time)[source]#
default function to compute the external strengths
- Parameters:
time (float) – the current time
- computeFGyr(*args)[source]#
Overload 1: default function to compute the inertia
Overload 2: function to compute the inertia with some specific values for q and velocity (ie not those of the current state).
- Parameters:
position (
SiconosVector
) – value used to evaluate the inertia forcesvelocity (
SiconosVector
) – value used to evaluate the inertia forces
- computeJacobianFIntq(*args)[source]#
Overload 1: To compute the jacobian w.r.t q of the internal forces
- Parameters:
time (float) – the current time
Overload 2: To compute the jacobian w.r.t q of the internal forces
- Parameters:
time (float) – the current time
position (
SiconosVector
) – value used to evaluate the jacobianvelocity (
SiconosVector
) – value used to evaluate the jacobian
- computeJacobianFIntqDot(*args)[source]#
Overload 1: To compute the jacobian w.r.t qDot of the internal forces
- Parameters:
time (float) – the current time
Overload 2: To compute the jacobian w.r.t. qDot of the internal forces
- Parameters:
time (float) – the current time
position (
SiconosVector
) – value used to evaluate the jacobianvelocity (
SiconosVector
) – value used to evaluate the jacobian
- computeJacobianFGyrq(*args)[source]#
Overload 1: function to compute the jacobian w.r.t. q of the inertia forces
Overload 2: function to compute the jacobian w.r.t. q of the inertia forces
- Parameters:
position (
SiconosVector
) – value used to evaluate the jacobianvelocity (
SiconosVector
) – value used to evaluate the jacobian
- computeJacobianFGyrqDot(*args)[source]#
Overload 1: function to compute the jacobian w.r.t. qDot of the inertia forces
Overload 2: function to compute the jacobian w.r.t. qDot of the inertia forces
- Parameters:
position (
SiconosVector
) – value used to evaluate the jacobianvelocity (
SiconosVector
) – value used to evaluate the jacobian
- updatePlugins(time)[source]#
default function to update the plugins functions using a new time:
- Parameters:
time (float) – the current time
- computePostImpactVelocity()[source]#
Computes post-impact velocity, using pre-impact velocity and impulse (p) value. Used in EventDriven (LsodarOSI->updateState)
- init_generalized_coordinates(level)[source]#
Allocate memory for q[level], level > 1 Useful for some integrators that need q[2] or other coordinates vectors.
- Parameters:
level (int) – the required level
- init_inverse_mass()[source]#
Allocate memory for the lu factorization of the mass of the system. Useful for some integrators with system inversion involving the mass
- class siconos.kernel.LagrangianLinearTIDS(*args)[source]#
Bases:
LagrangianDS
Lagrangian Linear Systems with time invariant coefficients - \(M\dot v + Cv + Kq = F_{ext}(t,z) + p\)
The class LagrangianLinearTIDS allows to define and compute a generic ndof-dimensional Lagrangian Linear Time Invariant Dynamical System of the form:
\[M \ddot q + C \dot q + K q = F_{ext}(t,z) + p,\]where - \(q \in R^{ndof}\) is the set of the generalized coordinates, - \(\dot q \in R^{ndof}\) the velocity, i. e. the time derivative of the generalized coordinates. - \(\ddot q \in R^{ndof}\) the acceleration, i. e. the second time derivative of the generalized coordinates. - \(p \in R^{ndof}\) the forces due to the Non Smooth Interaction. In particular case of Non Smooth evolution, the variable p contains the impulse and not the force. - \(M \in R^{ndof \times ndof}\) is the Mass matrix (access : mass() method). - \(K \in R^{ndof \times ndof}\) is the stiffness matrix (access : K() method). - \(C \in R^{ndof \times ndof}\) is the viscosity matrix (access : C() method). - \(z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discret state.
The equation of motion is also shortly denoted as:
\[M(q,z) \dot v = F(v, q, t, z) + p\]where - \(F(v, q, t, z) \in R^{ndof}\) collects the total forces acting on the system, that is \(F(v, q, t, z) = F_{ext}(t, z) - Cv - Kq\).
This vector is saved and may be accessed using forces() method.
If required (e.g. for Event-Driven like simulation), reformulation as a first-order system is also available, and writes:
\(n= 2 ndof\)
\(x = \left[\begin{array}{c}q \\ \dot q\end{array}\right]\)
rhs given by:
\[\begin{split}rhs(x,t,z) = \left[\begin{array}{c} \dot q \\ \ddot q = M^{-1}\left[F_{ext}(t, z) - C \dot q - K q + p \right] \\ \end{array}\right]\end{split}\]Its jacobian is:
\[\begin{split}\nabla_{x}rhs(x,t) = \left[\begin{array}{cc} 0 & I \\ -M^{-1}K & -M^{-1}C \\ \end{array}\right]\end{split}\]with the input due to the non smooth law:
\[\begin{split}r = \left[\begin{array}{c}0 \\ p \end{array}\right]\end{split}\]Overload 1: default constructor
Overload 2: constructor from initial state and all matrix operators.
- Parameters:
- <