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 .

isBlock()[source]#

true if the matrix is block else false.

Return type:

boolean

Returns:

a bool

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

setIsSymmetric(b)[source]#

set the flag _isSymmetric

isPositiveDefinite()[source]#

true if the matrix is definite positive (the flag is just returned)

Return type:

boolean

Returns:

true if the matrix is

setIsPositiveDefinite(b)[source]#

set the flag _isPositiveDefinite

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

size(index)[source]#

get the number of rows or columns of the matrix

Parameters:

index (int) – 0 for rows, 1 for columns

Return type:

int

Returns:

an int

num()[source]#

get the attribute num of current matrix

Return type:

int

Returns:

an unsigned int.

numberOfBlocks(i)[source]#

get the number of block (i=0, row, i=1 col)

Parameters:

i (int) – unsigned int(i=0, row, i=1 col)

Return type:

int

Returns:

an unsigned int. 1 as default for SimpleMatrix.

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

getDense(row=0, col=0)[source]#

get DenseMat matrix

Parameters:
  • row (int, optional) – an unsigned int position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int position of the block (column) - Useless for SimpleMatrix

Return type:

DenseMat

Returns:

a DenseMat

getTriang(row=0, col=0)[source]#

get TriangMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

TriangMat

Returns:

a TriangMat

getSym(row=0, col=0)[source]#

get SymMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

SymMat

Returns:

a SymMat

getBanded(row=0, col=0)[source]#

get BandedMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

BandedMat

Returns:

a BandedMat

getSparse(row=0, col=0)[source]#

get SparseMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

SparseMat

Returns:

a SparseMat

getSparseCoordinate(row=0, col=0)[source]#

get SparseCoordinateMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

SparseCoordinateMat

Returns:

a SparseCoordinateMat

getZero(row=0, col=0)[source]#

get ZeroMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

ZeroMat

Returns:

a ZeroMat

getIdentity(row=0, col=0)[source]#

get getIdentity matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

IdentityMat

Returns:

an IdentityMat

dense(row=0, col=0)[source]#

get a pointer on DenseMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

DenseMat

Returns:

a DenseMat*

triang(row=0, col=0)[source]#

get a pointer on TriangMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

TriangMat

Returns:

a TriangMat*

sym(row=0, col=0)[source]#

get a pointer on SymMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

SymMat

Returns:

a SymMat*

banded(row=0, col=0)[source]#

get a pointer on BandedMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

BandedMat

Returns:

a BandedMat*

sparse(row=0, col=0)[source]#

get a pointer on SparseMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

SparseMat

Returns:

a SparseMat*

sparseCoordinate(row=0, col=0)[source]#

get a pointer on SparseCoordinateMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

SparseCoordinateMat

Returns:

a SparseCoordinateMat*

zero_mat(row=0, col=0)[source]#

get a pointer on ZeroMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

ZeroMat

Returns:

a ZeroMat*

identity(row=0, col=0)[source]#

get a pointer on Identity matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block (row) - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block (column) - Useless for SimpleMatrix

Return type:

IdentityMat

Returns:

an IdentityMat*

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)

Parameters:
  • row (int, optional) – position for the required block

  • col (int, optional) – position for the required block

Return type:

float

Returns:

double* : the pointer on the double array

zero()[source]#

sets all the values of the matrix to 0.0

randomize()[source]#

Initialize the matrix with random values

randomize_sym()[source]#

Initialize a symmetric matrix with random values

eye()[source]#

set an identity 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.

Parameters:
  • nbrow (int) –

  • nbcol (int) –

  • lower,upper – for banded matrices

  • preserve (boolean, optional) –

normInf()[source]#

compute the infinite norm of the matrix

Return type:

float

Returns:

a double

display()[source]#

display data on standard output

displayExpert(brief=True)[source]#

display data on standard output

toString()[source]#

put data of the matrix into a std::string

Return type:

string

Returns:

std::string

getValue(i, j)[source]#

return the element matrix[i,j]

Parameters:
  • i (int) – an unsigned int i

  • j (int) – an unsigned int j

Return type:

float

Returns:

a double

setValue(i, j, value)[source]#

set the element matrix[i,j]

Parameters:
  • i (int) – an unsigned int i

  • j (int) – an unsigned int j

  • value (float) –

block(row=0, col=0)[source]#

get block at position row-col if BlockMatrix, else if SimpleMatrix return this

Parameters:
  • row (int, optional) – unsigned int row

  • col (int, optional) – unsigned int col

Return type:

SiconosMatrix

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

resetLU()[source]#
set to false all LU indicators. Useful in case of

assignment for example.

resetFactorizationFlags()[source]#
set to false all factorization indicators. Useful in case of

assignment for example.

nnz(tol=1e-14)[source]#

return the number of non-zero in the matrix

Parameters:

tol (float, optional) – the tolerance to consider a number zero (not used if the matrix is sparse)

Return type:

int

Returns:

the number of non-zeros

fillCSC(*args)[source]#

Overload 1: Fill CSparseMatrix compresses column sparse matrix

Parameters:
  • csc (CSparseMatrix) – the compressed column sparse matrix

  • row_off (int) –

  • col_off (int) –

  • tol (float, optional) – the tolerance under which a number is considered as equal to zero

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.

fillTriplet(csc, row_off, col_off, tol=1e-14)[source]#

return the number of non-zero in the matrix

Parameters:
  • csc (CSparseMatrix) – the compressed column sparse matrix

  • row_off (int) –

  • col_off (int) –

  • tol (float, optional) – the tolerance to consider a number zero (not used if the matrix is sparse)

Return type:

boolean

Returns:

the number of non-zeros

class siconos.kernel.SimpleMatrix(*args)[source]#

Bases: SiconosMatrix

Matrix (embedded various types of Boost matrices of double)

SimpleMatrix is used in the platform to store matrices (mathematical object) of double.

Possible types: Siconos::DENSE (default), TRIANGULAR, SYMMETRIC, SPARSE, BANDED, ZERO, Siconos::IDENTITY, Siconos::SPARSE_COORDINATE.

TODO: : review resize function for Banded, Symetric and Triangular. Error in tests.

Overload 1: Default constructor


Overload 2: constructor with the type and the dimension of the Boost matrix

Parameters:
  • row (int) – number of rows.

  • col (int) – number of columns.

  • typ (int, optional) – the type of matrix

  • upper (int, optional) – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal

  • lower (int, optional) – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal


Overload 3: constructor with the type and the dimension of the Boost matrix

Parameters:
  • row (int) – number of rows.

  • col (int) – number of columns.

  • typ (int, optional) – the type of matrix

  • upper (int, optional) – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal

  • lower – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal


Overload 4: constructor with the type and the dimension of the Boost matrix

Parameters:
  • row (int) – number of rows.

  • col (int) – number of columns.

  • typ (int, optional) – the type of matrix

  • upper – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal

  • lower – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal


Overload 5: constructor with the type and the dimension of the Boost matrix

Parameters:
  • row (int) – number of rows.

  • col (int) – number of columns.

  • typ – the type of matrix

  • upper – if Siconos::UBLAS_TYPE==SPARSE, number of non-zero terms, if Siconos::UBLAS_TYPE == BANDED, number of diags. under the main diagonal

  • lower – if Siconos::UBLAS_TYPE == BANDED, number of diags. over the main diagonal


Overload 6: constructor with the the dimensions of the Boost matrix, a default value and the type.

Parameters:
  • row (int) – number of rows.

  • col (int) – number of columns.

  • inputValue (float) – double a, so that *this = [a a a …]

  • 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.

  • inputValue (float) – double a, so that *this = [a a a …]

  • 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.

  • inputValue (float) – double a, so that *this = [a a a …]

  • 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.

  • inputValue (float) – double a, so that *this = [a a a …]

  • 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 extract

  • coord (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

getDense(row=0, col=0)[source]#

get DenseMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

DenseMat

Returns:

a DenseMat

getTriang(row=0, col=0)[source]#

get TriangMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

TriangMat

Returns:

a TriangMat

getSym(row=0, col=0)[source]#

get SymMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

SymMat

Returns:

a SymMat

getBanded(row=0, col=0)[source]#

get BandedMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

BandedMat

Returns:

a BandedMat

getSparse(row=0, col=0)[source]#

get SparseMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

SparseMat

Returns:

a SparseMat

getSparseCoordinate(row=0, col=0)[source]#

get SparseCoordinateMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

SparseCoordinateMat

Returns:

a SparseCoordinateMat

getZero(row=0, col=0)[source]#

get ZeroMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

ZeroMat

Returns:

a ZeroMat

getIdentity(row=0, col=0)[source]#

get getIdentity matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

IdentityMat

Returns:

an IdentityMat

dense(row=0, col=0)[source]#

get a pointer on DenseMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

DenseMat

Returns:

a DenseMat*

triang(row=0, col=0)[source]#

get a pointer on TriangMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

TriangMat

Returns:

a TriangMat*

sym(row=0, col=0)[source]#

get a pointer on SymMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

SymMat

Returns:

a SymMat*

banded(row=0, col=0)[source]#

get a pointer on BandedMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

BandedMat

Returns:

a BandedMat*

sparse(row=0, col=0)[source]#

get a pointer on SparseMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

SparseMat

Returns:

a SparseMat*

sparseCoordinate(row=0, col=0)[source]#

get a pointer on SparseCoordinateMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

SparseCoordinateMat

Returns:

a SparseCoordinateMat*

zero_mat(row=0, col=0)[source]#

get a pointer on ZeroMat matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

ZeroMat

Returns:

a ZeroMat*

identity(row=0, col=0)[source]#

get a pointer on Identity matrix

Parameters:
  • row (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

  • col (int, optional) – an unsigned int, position of the block - Useless for SimpleMatrix

Return type:

IdentityMat

Returns:

an IdentityMat*

getArray(row=0, col=0)[source]#

return the address of the array of double values of the matrix

Parameters:
  • row (int, optional) – position for the required block ->useless for SimpleMatrix

  • col (int, optional) – position for the required block ->useless for SimpleMatrix

Return type:

float

Returns:

double* : the pointer on the double array

zero()[source]#

sets all the values of the matrix to 0.0

randomize()[source]#

Initialize the matrix with random values

randomize_sym()[source]#

Initialize a symmetric matrix with random values

eye()[source]#

set an identity matrix

copyData(data)[source]#

copy the matrix data to the array given in parameter’ Works only for dense matrices !

Parameters:

data (float) – array where the matrix is copied

Return type:

int

Returns:

the size of the matrix

size(index)[source]#

get the number of rows or columns of the matrix

Parameters:

index (int) – 0 for rows, 1 for columns

Return type:

int

Returns:

the size

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.

Parameters:
  • row (int) – the new number of rows

  • col (int) – the mew number of columns

  • lower (int, optional) – (only for Banded)

  • upper (int, optional) – (only for Banded)

  • preserve (boolean, optional) – preserve existing elements

normInf()[source]#

compute the infinite norm of the matrix

Return type:

float

Returns:

a double

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:

float

Returns:

a double

display()[source]#

display data on standard output

displayExpert(brief=True)[source]#

display data on standard output

toString()[source]#

put data of the matrix into a std::string

Return type:

string

Returns:

std::string

getValue(i, j)[source]#

return the element matrix[i,j]

Parameters:
  • i (int) – an unsigned int

  • j (int) – an unsigned int

Return type:

float

Returns:

a double

setValue(i, j, value)[source]#

set the element matrix[i,j]

Parameters:
  • i (int) – an unsigned int

  • j (int) – an unsigned int

  • value (float) –

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.

Factorize()[source]#

computes a factorization of a general M-by-N matrix

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

resetLU()[source]#
set to false all LU indicators. Useful in case of

assignment for example.

resetCholesky()[source]#
set to false all Cholesky indicators. Useful in case of

assignment for example.

resetQR()[source]#
set to false all QR indicators. Useful in case of

assignment for example.

resetFactorizationFlags()[source]#
set to false all factorization indicators. Useful in case of

assignment for example.

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:
  • row (int) – the size of the vector

  • type (int, optional) – the type of vector (dense or sparse)


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:
  • row (int) – size of the new vector

  • val (float) – value to initialize its content

  • type (int, optional) – type of vector (dense or sparse)


Overload 5: creates a vector and initializes its content with a single value

Parameters:
  • row (int) – size of the new vector

  • val (float) – value to initialize its content

  • type – type of vector (dense or sparse)


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:

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:

int

Returns:

unsigned int

num()[source]#

Get the type number of the current vector.

Return type:

int

Returns:

an 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*

getArray()[source]#
Return type:

float

Returns:

the array of double values of the vector

zero()[source]#

sets all the values of the vector to 0.0

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.

normInf()[source]#
Return type:

float

Returns:

the infinite norm of the vector

norm2()[source]#
Return type:

float

Returns:

the Euclidian norm of the vector

vector_sum()[source]#
Return type:

float

Returns:

the sum of all elements of the vector

display()[source]#

display vector content

fill(a)[source]#

set all values of the vector to input value.

Parameters:

a (float) – input value

toString()[source]#
Return type:

string

Returns:

the content of the vector as a string

getValue(i)[source]#

Get a component of the vector

Parameters:

i (int) – index of the required component

Return type:

float

Returns:

the component value

setValue(i, value)[source]#

set a component of the vector

Parameters:
  • i (int) – index of the required component

  • value (float) – of the component

toBlock(vOut, sizeB, startIn, startOut)[source]#

copy a part of the vector into another

Parameters:
  • vOut (SiconosVector) – destination vector

  • sizeB (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

copyData(data)[source]#

copy the vector into an array

Parameters:

data (float) – the memory where to copy the data

Return type:

int

Returns:

the number of element written (size of the vector)

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:

Overload 4: contructor with a BlockVector of n (numberOfBlocks) blocks of the same size (dim) filled with a new vector

Parameters:
  • numberOfBlocks (int) – number of blocks

  • dim (int) – dimension of the vector


Overload 5: contructor with a BlockVector of n (numberOfBlocks) blocks that point on nullptr

Parameters:

numberOfBlocks (int) – number of blocks

size()[source]#
Return type:

int

Returns:

the size of the vector (sum of the sizes of all its 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.

getAllVect()[source]#
Return type:

VectorOfVectors

Returns:

the complete stl 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 *

zero()[source]#

sets all the values of the vector to 0.0

fill(a)[source]#

set all values of the vector component to value.

Parameters:

a (float) – double

display()[source]#

display data on standard output

toString()[source]#

put data of the vector into a std::string

Return type:

string

Returns:

std::string

getValue(i)[source]#

Get a component of the vector

Parameters:

i (int) – index of the required component

Return type:

float

Returns:

the component value

setValue(i, value)[source]#

set a component of the vector

Parameters:
  • i (int) – index of the required component

  • value (float) – of the component

vector(pos)[source]#

get a block (SiconosVector) of the vector

Parameters:

pos (int) – index of the required block

Return type:

SiconosVector

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

tabIndex()[source]#
Return type:

SP::Index

Returns:

a pointer to the index tab

getNumVectorAtPos(pos)[source]#

get the number of the vector that handles element at position “pos”

Parameters:

pos (int) – unsigned int, position of the element

Return type:

int

Returns:

unsigned int number of the searched vector

insertPtr(v)[source]#

Insert a new block (no allocation and nor copy)

Parameters:

v (SiconosVector) – the vector to be inserted

norm2()[source]#
Return type:

float

Returns:

the Euclidian norm of the vector

normInf()[source]#
Return type:

float

Returns:

the infinite norm of the vector

prepareVectorForPlugin()[source]#

Tranform a BlockVector into a SiconosVector.

Required for plugins, that need contiguous memory for their parameters.

Return type:

SiconosVector

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:

SolverOptions

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:

SolverOptions

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 updated

  • internal_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:

int

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 options

  • number – of the targeted solver

Return type:

SolverOptions

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 options

  • number – 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 write

  • outputType (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:

float

Returns:

Positive or 0.0 if the file was loaded and the comparison was performed, otherwise -1.

siconos.kernel.TD_EVENT = 1#

Event constants

siconos.kernel.DENSE = 1#

id for dense matrix or vector

siconos.kernel.TRIANGULAR = 2#

id for triangular matrix

siconos.kernel.SYMMETRIC = 3#

id for symmetric matrix

siconos.kernel.SPARSE = 4#

id for sparse matrix or vector

siconos.kernel.BANDED = 5#

id for banded matrix

siconos.kernel.ZERO = 6#

id for zero matrix

siconos.kernel.IDENTITY = 7#

id for identity matrix

siconos.kernel.SPARSE_COORDINATE = 8#

id for sparse matrix or vector

class siconos.kernel.SiconosMemory(*args)[source]#

Bases: MemoryContainer

Interface to stl container of SiconosVector.

This class is used as a backup during simulation, to save vectors (e.g. state) computed during previous time steps.

  • The size of the container is fixed, with a first-in first-out mechanism

used through swap method. - All saved vectors must have the same dimension.

This class must be reviewed and backup should probably be moved to graph rather than in this object.

Overload 1: creates an empty SiconosMemory.


Overload 2: creates a SiconosMemory

Parameters:
  • size (int) – number of elements in the container

  • vectorSize (int) – size of each vector in the container


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:

SiconosVector

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:

SiconosVector

Returns:

a SP::SiconosVector

setMemorySize(steps, vectorSize)[source]#

set size of the SiconosMemory (number of vectors and size of vector)

Parameters:
  • steps (int) – the max size for this SiconosMemory, size of the container

  • vectorSize (int) – size of each vector of the container

nbVectorsInMemory()[source]#

gives the numbers of SiconosVectors currently stored in the memory

Return type:

int

Returns:

int >= 0

display()[source]#

displays the data of the memory object

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

isVerified()[source]#
Return type:

boolean

Returns:

a boolean value which determines if the NS Law is verified. Not implemented for the moment.

size()[source]#
Return type:

int

Returns:

the size of the NS law

display()[source]#

display the data of the NonSmoothLaw on the standard output

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

isVerified()[source]#

check the ns law to see if it is verified

Return type:

boolean

Returns:

a boolean value whioch determines if the NS Law is verified

e()[source]#
Return type:

float

Returns:

the value of e

setE(newVal)[source]#

setter of e

Parameters:

newVal (float) – a double to set e

display()[source]#

print the data to the screen

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:
  • en (float) – double : normal e coefficient

  • et (float) – double : tangent e coefficient

  • mu (float) – double : friction coefficient

  • size (int) – unsigned int: size of the ns law

isVerified()[source]#

check the ns law to see if it is verified

Return type:

boolean

Returns:

a boolean value whioch determines if the NS Law is verified

en()[source]#
Return type:

float

Returns:

the value of en

setEn(newVal)[source]#

setter of en

Parameters:

newVal (float) – a double to set en

et()[source]#
Return type:

float

Returns:

the value of et

setEt(newVal)[source]#

setter of et

Parameters:

newVal (float) – a double to set et

mu()[source]#
Return type:

float

Returns:

the value of mu

setMu(newVal)[source]#

setter of mu

Parameters:

newVal (float) – a double to set mu

display()[source]#

print the data to the screen

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

isVerified()[source]#

check the ns law to see if it is verified

Return type:

boolean

Returns:

a boolean value whioch determines if the NS Law is verified

en()[source]#
Return type:

float

Returns:

the value of en

setEn(newVal)[source]#

setter of en

Parameters:

newVal (float) – a double to set en

et()[source]#
Return type:

float

Returns:

the value of et

setEt(newVal)[source]#

setter of et

Parameters:

newVal (float) – a double to set et

mu()[source]#
Return type:

float

Returns:

the value of mu

muR()[source]#
Return type:

float

Returns:

the value of mu

setMu(newVal)[source]#

setter of mu

Parameters:

newVal (float) – a double to set mu

setMuR(newVal)[source]#

setter of muR

Parameters:

newVal (float) – a double to set muR

display()[source]#

print the data to the screen

class siconos.kernel.MixedComplementarityConditionNSL(newSize, equalitySize)[source]#

Bases: NonSmoothLaw

Complementarity NonSmoothLaw

basic constructor

Parameters:
  • newSize (int) – size of the non smooth law

  • equalitySize (int) – size of the equality relation

display()[source]#

print the data to the screen

equalitySize()[source]#

get the number of equality present in the MLCP

Return type:

int

Returns:

an unsigned int

class siconos.kernel.ComplementarityConditionNSL(size)[source]#

Bases: NonSmoothLaw

Complementarity NonSmoothLaw

basic constructor

Parameters:

size (int) – of the non smooth law

display()[source]#

print the data to the screen

class siconos.kernel.EqualityConditionNSL(size)[source]#

Bases: NonSmoothLaw

Equality NonSmoothLaw

basic constructor

Parameters:

size (int) – of the non smooth law

display()[source]#

display the data of the NonSmoothLaw on the standard output

class siconos.kernel.MultipleImpactNSL(*args)[source]#

Bases: NonSmoothLaw

basic constructor

Parameters:

size (int) – the nonsmooth law size

isVerified()[source]#
Return type:

boolean

Returns:

a boolean value which determines if the NS Law is verified. Not implemented for the moment.

display()[source]#

display the data of the NonSmoothLaw on the standard output

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:
  • size (int) – size of the NonSmoothLaw

  • lb (float, optional) – lower endpoint of the interval, default value is -1.0

  • ub (float, optional) – upper endpoint of the interval, default value is 1.0

isVerified()[source]#

check the ns law to see if it is verified

Return type:

boolean

Returns:

true if the NS Law is verified, false otherwise

lb()[source]#

to get lb

Return type:

float

Returns:

the value of lb

setLb(lb)[source]#

to set the lower bound

Parameters:

lb (float) – the new lower bound

ub()[source]#

to get ub

Return type:

float

Returns:

the value of ub

setUb(ub)[source]#

to set ub

Parameters:

ub (float) – the new upper bound

display()[source]#

print the data to the screen

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 P

  • K (SiconosVector) – vector in the (H-K)-representation of the polytope P

H()[source]#

get H

Return type:

SimpleMatrix

Returns:

a reference to the H matrix

K()[source]#

get K

Return type:

SiconosVector

Returns:

a reference to the K vector

isVerified()[source]#

check the ns law to see if it is verified

Return type:

boolean

Returns:

true if the NS Law is verified, false otherwise

display()[source]#

print the data to the screen

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

resetAllNonSmoothParts()[source]#

reset nonsmooth part of the rhs, for all ‘levels’

resetNonSmoothPart(level)[source]#

set nonsmooth part of the rhs to zero for a given level

Parameters:

level (int) –

number()[source]#

returns the id of the dynamical system

setNumber(new_number)[source]#

set the id of the DynamicalSystem

Return type:

int

Returns:

the previous value of number

n()[source]#

returns the size of the vector state x

dimension()[source]#

returns the dimension of the system (depends on system type, e.g. n for first order, ndof for Lagrangian).

x0()[source]#

returns a pointer to the initial state vector

getX0()[source]#

get a copy of the initial state vector

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

x()[source]#

returns a pointer to the state vector \(x\)

Return type:

SiconosVector

Returns:

SP::SiconosVector

getx()[source]#

get a copy of the current state vector \(x\)

Return type:

SiconosVector

Returns:

SiconosVector

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:

SiconosVector

Returns:

SP::SiconosVector

getR()[source]#

get a copy of r vector (input due to nonsmooth behavior)

Return type:

SiconosVector

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:

SiconosVector

Returns:

SP::SiconosVector

getRhs()[source]#

get a copy of the right-hand side vector, (i.e. \(\dot x\))

Return type:

SiconosVector

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:

SiconosMatrix

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:

SiconosVector

Returns:

SP::SiconosVector

getz()[source]#

get a copy of \(z\), the vector of algebraic parameters.

Return type:

SiconosVector

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:

int

Returns:

int

setStepsInMemory(steps)[source]#

set number of steps to be saved

Parameters:

steps (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

static resetCount(new_count=0)[source]#

reset the global DynamicSystem counter (for ids)

Return type:

int

Returns:

the previous value of count

resetToInitialState()[source]#

reset the state x() to the initial state x0

isLinear()[source]#
Return type:

boolean

Returns:

true if the system is linear

display(brief=True)[source]#

print the data of the dynamical system on the standard output

siconos.kernel.DynamicalSystem_resetCount(new_count=0)[source]#

reset the global DynamicSystem counter (for ids)

Return type:

int

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.

Parameters:
  • t0 (float) – initial time

  • T (float) – final time

currentTime()[source]#
Return type:

float

Returns:

the current time value

setCurrentTime(newValue)[source]#

set the current time

Parameters:

newValue (float) – the new time

t0()[source]#
Return type:

float

Returns:

initial time

sett0(newT0)[source]#

set initial time of the time discretisation

Parameters:

newT0 (float) –

finalT()[source]#
Return type:

float

Returns:

final time

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

setTitle(s)[source]#

set the title of the simulation

Parameters:

s (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

setDate(s)[source]#

set the date of the simulation

Parameters:

s (string) – std::string : the date

isBVP()[source]#

get problem type (true if BVP)

Return type:

boolean

Returns:

a bool

isIVP()[source]#

get problem type (true if IVP)

Return type:

boolean

Returns:

a bool

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.

getNumberOfDS()[source]#
Return type:

int

Returns:

the number of Dynamical Systems present in the 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:

DynamicalSystem

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:

int

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:

Interaction

Returns:

a pointer to an Interaction


Overload 2: get Interaction named name

Parameters:

name (string) – of the Interaction to get

Return type:

Interaction

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 an interaction to two dynamical systems

Parameters:
setName(*args)[source]#

Overload 1: set the name for this Dynamical System

Parameters:
  • ds (DynamicalSystem) – a pointer to the system

  • name (string) – the name of the DynamicalSystem


Overload 2: set the name for this Interaction

Parameters:
  • interaction (Interaction) – a pointer to the Interaction

  • name (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 Interaction

  • isControlInteraction (boolean) – true if the Interaction is used for control purposes

topology()[source]#

get the topology of the system

Return type:

Topology

Returns:

a pointer on Topology

display()[source]#

display the data of the Non Smooth Dynamical System

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

swapInMemory()[source]#

save DynamicalSystems and Interactions states in Memories

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

updateInput(time, level)[source]#

compute r thanks to lambda[level] for all Interactions

Parameters:
  • time (float) –

  • level (int) – lambda level

updateOutput(*args)[source]#

Overload 1: compute output for all the interactions for a given level

Parameters:
  • time (float) –

  • level (int, optional) – y order to be computed


Overload 2: compute output for all the interactions and for a level range

Parameters:
  • time (float) –

  • level_min (int) – y min order to be computed

  • level_max (int) – y max order to be computed

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

visitDynamicalSystems(visitor)[source]#

visit all dynamical systems in this system

Parameters:

visitor (SP::SiconosVisitor) – an SP::SiconosVisitor that can visit classes derived from DS

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

Parameters:
  • t0 (float) – initial time

  • T (float) – final time

interaction()[source]#

Overload 1: get Interaction number I

Parameters:

nb (int) – the identifier of the Interaction to get

Return type:

Interaction

Returns:

a pointer to an Interaction


Overload 2: get Interaction named name

Parameters:

name (string) – of the Interaction to get

Return type:

Interaction

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 system

  • name (string) – the name of the DynamicalSystem


Overload 2: set the name for an Interaction

Parameters:
  • inter (Interaction) – a pointer to the Interaction

  • name (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:

link two dynamical systems to a relation

Parameters:
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) – Interaction

  • isControlInteraction (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:

int

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:

int

Returns:

the number of Interactions Graphs

indexSetSize(level)[source]#

get the size of the InteractionGraphs at a given level

Parameters:

level (int) –

Return type:

int

Returns:

size of the InteractionGraphs at a given level

indexSetsResize(newSize)[source]#

resize Interactions Graphs

Parameters:

newSize (int) – the new size

setHasChanged(val)[source]#

set _hasChanged to val

Parameters:

val (boolean) – a bool

hasChanged()[source]#

check

Return type:

boolean

Returns:

a bool

numberOfConstraints()[source]#

get the total number of scalar constraints

Return type:

int

Returns:

an unsigned int

setSymmetric(val)[source]#

set symmetry in the blocks computation

Parameters:

val (boolean) – a bool

setProperties()[source]#

initialize graphs properties

displayDynamicalSystems()[source]#

list and display all dynamical systems

getDynamicalSystem(*args)[source]#

Overload 1: Get a dynamical system using its number Warning: O(n) complexity

Parameters:

requiredNumber (int) – the required number

Return type:

DynamicalSystem

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:

DynamicalSystem

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:

Interaction

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:

Interaction

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

numberOfInvolvedDS(inumber)[source]#

get the number of DynamicalSystem currently involved in an indexSet

Parameters:

inumber (int) – the indexSet number

Return type:

int

Returns:

the number of DynamicalSystem involved

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:

SiconosVector

Returns:

pointer on a SiconosVector

mass()[source]#

get mass matrix (pointer link)

Return type:

SiconosMatrix

Returns:

SP::SiconosMatrix

inverseMass()[source]#

get (pointer) inverse or LU-factorization of the mass, used for LU-forward-backward computation

Return type:

SimpleMatrix

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 q

  • velocity (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:

int

Returns:

an unsigned int.

q()[source]#

generalized coordinates of the system (vector of size dimension())

Return type:

SiconosVector

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) –

q0()[source]#

get initial state (pointer link)

Return type:

SiconosVector

Returns:

pointer on a 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:

SiconosVector

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:

SiconosVector

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:

SiconosVector

Returns:

pointer on a SiconosVector

forces()[source]#

get \(F(v,q,t,z)\) (pointer link)

Return type:

SiconosVector

Returns:

pointer on a SiconosVector

jacobianqForces()[source]#
Return type:

SiconosMatrix

Returns:

\(\nabla_qF(v,q,t,z)\) (pointer link)

jacobianvForces()[source]#

get \(\nabla_{\dot q}F(v,q,t,z)\) (pointer link)

Return type:

SiconosMatrix

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:

BoundaryCondition

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:

SiconosVector

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

update_inverse_mass()[source]#

Update the content of the lu factorization of the mass of the system, if required.

init_forces()[source]#

Allocate memory for forces and its jacobian.

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:

SiconosVector

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:

SiconosVector

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:

SiconosVector

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

resetToInitialState()[source]#

reset the state to the initial state

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

resetAllNonSmoothParts()[source]#

reset non-smooth part of the rhs (i.e. p), for all ‘levels’

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 q

  • velocity (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:

SiconosVector

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:

SiconosVector

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:

SiconosVector

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:

SiconosVector

Returns:

pointer on a SiconosVector

fInt()[source]#

get $F_{int}$ (pointer link)

Return type:

SiconosVector

Returns:

pointer on a plugged vector

setFIntPtr(newPtr)[source]#

set $F_{int}$ (pointer link)

Parameters:

newPtr (SiconosVector) – a SP to plugged vector

fExt()[source]#

get \(F_{ext}\) , (pointer link)

Return type:

SiconosVector

Returns:

pointer on a plugged vector

setFExtPtr(newPtr)[source]#

set \(F_{ext}\) , (pointer link)

Parameters:

newPtr (SiconosVector) – a SP to a Simple vector

fGyr()[source]#

get \(F_{gyr}\) , (pointer link)

Return type:

SiconosVector

Returns:

pointer on a plugged 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:

SiconosMatrix

Returns:

pointer on a SiconosMatrix

jacobianFIntqDot()[source]#

get \(\nabla_{\dot q}F_{int}\) , (pointer link)

Return type:

SiconosMatrix

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:

SiconosMatrix

Returns:

pointer on a SiconosMatrix

jacobianFGyrqDot()[source]#

get \(\nabla_{\dot q}F_{gyr}\) , (pointer link)

Return type:

SiconosMatrix

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:

SiconosVector

Returns:

pointer on a SiconosVector

jacobianqForces()[source]#

get \(\nabla_qF(v,q,t,z)\) (pointer link)

Return type:

SiconosMatrix

Returns:

pointer on a SiconosMatrix

jacobianvForces()[source]#

get \(\nabla_{\dot q}F(v,q,t,z)\) (pointer link)

Return type:

SiconosMatrix

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 forces

  • velocity (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 forces

  • velocity (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 jacobian

  • velocity (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 jacobian

  • velocity (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 jacobian

  • velocity (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 jacobian

  • velocity (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

computeKineticEnergy()[source]#

To compute the kinetic energy

display(brief=True)[source]#

print the data of the dynamical system on the standard output

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

update_inverse_mass()[source]#

Update the content of the lu factorization of the mass of the system, if required.

init_forces()[source]#

Allocate memory for forces and its jacobian.

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}\]

It