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: siconos.kernel.SiconosMatrix

Matrix (embedded various types of Boost matrices of double)

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

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

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

Overload 1: Default constructor


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

Parameters
  • row (int) – number of rows.

  • col (int) – number of columns.

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

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

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


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

Parameters
  • row (int) – number of rows.

  • col (int) – number of columns.

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

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

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


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

Parameters
  • row (int) – number of rows.

  • col (int) – number of columns.

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

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

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


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

Parameters
  • row (int) – number of rows.

  • col (int) – number of columns.

  • typ – the type of matrix

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

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


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

Parameters
  • row (int) – number of rows.

  • col (int) – number of columns.

  • 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: siconos.kernel.MemoryContainer

Interface to stl container of SiconosVector.

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

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

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

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

Overload 1: creates an empty SiconosMemory.


Overload 2: creates a SiconosMemory

Parameters
  • 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: siconos.kernel.NonSmoothLaw

Newton impact Non Smooth Law

This class formalizes the Newton Impact law together with a complementarity condition. i.e.

\[\left\{\begin{array}{l} y \geq 0, \lambda \geq 0, y^{T} \lambda=0\ \ if y \leq 0 \quad \mbox{then} \quad \dot y(t^{+}) - e \dot y(t^{-}) \geq 0, \quad \lambda \geq 0, (\dot y(t^{+}) - e \dot y(t^{-}))^{T} \lambda=0 \end{array}\right.\]

nsLawSize is equal to 1.

Overload 1: default constructor


Overload 2: constructor with the value of the NewtonImpactNSL attributes

Parameters

e (float) – the value of the coefficient of restitution


Overload 3: Apply multiple-axis impact

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: siconos.kernel.NonSmoothLaw

Newton Impact-Friction Non Smooth Law

Overload 1: basic constructor

Parameters

size (int) – size of the ns law


Overload 2: constructor with the value of the NewtonImpactFrictionNSL attributes

Parameters
  • 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: siconos.kernel.NonSmoothLaw

Newton Impact-Friction Non Smooth Law

Overload 1:

basic constructor

type size

int

param size

size of the ns law


Overload 2:

constructor with the value of the NewtonImpactRollingFrictionNSL attributes :type en: float

Parameters

en

double : normal e coefficient

type et

float

param et

double tangent e coefficient

type mu

float

param mu

double : friction coefficient

type muR

float

param muR

double : rolling friction coefficient

type size

int

param size

unsigned int: size of the ns law

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: siconos.kernel.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: siconos.kernel.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: siconos.kernel.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: siconos.kernel.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: siconos.kernel.NonSmoothLaw

Relay NonSmoothLaw

This class formalizes the Relay nonsmooth law i.e.

\[-y \in \mathcal{N}_{[lb,ub]}(\lambda),\]

where \(lb\) is the lower bound and \(ub\) is the upper bound of the Relay law.

In this default case, the lower bound is set to \(lb=-1\) and the upper bound ub is set to \(ub=1\). We get the well-known form of the RelayNSL as the multivalued sign function, i.e.

\[y \in -\mathcal{N}_{[-1,1]}(\lambda) \Longleftrightarrow \lambda \in -\mbox{sgn} (y)\]

where the multi-valued sign function is defined as

\[\begin{split}\mbox{sgn} (y) = \left\{ \begin{array}{lcl} 1 && y >0 \\ [-1,1] && y =0 \\ -1 && y <0 \end{array}\right.\end{split}\]

TODO: Build the Sgn NonSmoothLaw as the default instance of Relay

constructor with the value of the RelayNSL attributes

Parameters
  • 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: siconos.kernel.NonSmoothLaw

NormalCone NonSmoothLaw

This class formalizes a nonsmooth law in the form of a normal cone inclusion i.e.

\[0 \in y + \mathcal{N}_{P}(\lambda),\]

where \(P\) is a polyhedral set. This is a generalization of the RelayNSL law, where the set \(P\) is a scaled box. Note that there exists an inverse of the previous relation in the form

\[\lambda \in \partial \sigma_{P} (-y),\]

with \(\sigma_{P}\) the support function of \(P\) and \(\partial \sigma_{P}\) the subdifferential of this support function.

Note that the polyhedral set \(P\) is described as \(\{\lambda\mid H \lambda \geq K\}\), where \(H\) is a matrix and \(K\) a vector.

Constructor with the polyhedral representation of P as Hx >= K

Parameters
  • size (int) – size of the NonSmoothLaw

  • H (SimpleMatrix) – matrix in the (H-K)-representation of the polytope 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

reset(*args)[source]

Overload 1: Set all DS non-smooth part to zero.


Overload 2: Set all DS non-smooth part to zero for a given level.

Parameters

level (int) – the level to will be zeroed

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: siconos.kernel.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: siconos.kernel.DynamicalSystem

Second Order non linear dynamical systems - \(M(q,z) \dot v = F(v, q, t, z) + p\)

This class defines and computes a generic ndof-dimensional second order Non Linear Dynamical System of the form :

\[\begin{split}M(q,z) \dot v = F(v, q, t, z) + p \\ \dot q = G(q,v)\end{split}\]

where

  • \(q \in R^{ndof}\) is the set of the coordinates,

  • \(\dot q =v \in R^{ndof}\) the velocity,

  • \(\ddot q = \dot v \in R^{ndof}\) the acceleration, i. e. the second

time derivative of the generalized coordinates. - \(p \in R^{ndof}\) the reaction forces due to the Non Smooth Interaction. - \(M(q) \in R^{ndof \times ndof}\) is the inertia term (access : mass() method). - \(F( \dot q , q , t) \in R^{ndof}\) are the forces (access forces() method). - \(z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discrete state.

q[i] is the derivative number i of q. Thus: q[0]= \(q\), global coordinates, q[1]= \(\dot q\), velocity, q[2]= \(\ddot q\), acceleration.

The following operators (and their jacobians) can be plugged, in the usual way (see User Guide, ‘User-defined plugins’)

  • \(M(q)\) (computeMass())

  • \(F(v , q , t, z)\) (computeF())

If required (e.g. for Event-Driven like simulation), formulation as a first-order system is also available, and writes:

  • \(n= 2 ndof\)

  • \(x = \left[\begin{array}{c}q \\ \dot q\end{array}\right]\)

  • rhs given by:

\[\begin{split}\dot x = \left[\begin{array}{c} \dot q\\ \ddot q = M^{-1}(q)\left[F(v, q , t, z) + p \right]\\ \end{array}\right]\end{split}\]
  • jacobian of the rhs, with respect to x

\[\begin{split}\nabla_{x}rhs(x,t) = \left[\begin{array}{cc} 0 & I \\ \nabla_{q}(M^{-1}(q)F(v, q , t, z)) & \nabla_{\dot q}(M^{-1}(q)F(v, q , t, z)) \\ \end{array}\right]\end{split}\]

with the input due to the non smooth law:

\[\begin{split}\left[\begin{array}{c} 0 \\ p \end{array}\right]\end{split}\]

In that case, use the following methods: - initRhs() to allocate/initialize memory for these new operators, - rhs() to get the rhs vector - computeRhs(), computeJacobianRhsx() …, to update the content of rhs, its jacobians …

Overload 1:

default constructor


Overload 2:
minimal constructor, from state dimension

result in \(\dot x = r\)

type dimension

int

param dimension

size of the system (n)


Overload 3:

Copy constructor

Parameters

ds (DynamicalSystem) – the DynamicalSystem to copy

p(level=2)[source]

get p

Parameters

level (int, optional) – unsigned int, required level for p, default = 2

Return type

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: siconos.kernel.SecondOrderDS

Lagrangian non linear dynamical systems - \(M(q,z) \dot v = F(v, q, t, z) + p\)

This class defines and computes a generic ndof-dimensional Lagrangian Non Linear Dynamical System of the form :

\[\begin{split}M(q,z) \dot v + F_{gyr}(v, q, z) + F_{int}(v , q , t, z) = F_{ext}(t, z) + p \\ \dot q = v\end{split}\]

where

  • \(q \in R^{ndof}\) is the set of the generalized coordinates,

  • \(\dot q =v \in R^{ndof}\) the velocity, i. e. the time

derivative of the generalized coordinates (Lagrangian systems). - \(\ddot q =\\dot v \in R^{ndof}\) the acceleration, i. e. the second time derivative of the generalized coordinates. - \(p \in R^{ndof}\) the reaction forces due to the Non Smooth Interaction. - \(M(q) \in R^{ndof \times ndof}\) is the inertia term (access : mass() method). - \(F_{gyr}(\dot q, q) \in R^{ndof}\) is the non linear inertia term (access fGyr() method). - \(F_{int}(\dot q , q , t) \in R^{ndof}\) are the internal forces (access fInt() method). - \(F_{ext}(t) \in R^{ndof}\) are the external forces (access fExt() method). - \(z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discrete state.

The equation of motion is also shortly denoted as \(M(q,z) \dot v = F(v, q, t, z) + p\)

where \(F(v, q, t, z) \in R^{ndof}\) collects the total forces acting on the system, that is \(F(v, q, t, z) = F_{ext}(t, z) - F_{gyr}(v, q, z) + F_{int}(v, q , t, z)\)

This vector is saved and may be accessed using forces() method.

q[i] is the derivative number i of q. Thus: q[0]=:math:q, global coordinates, q[1]= \(\dot q\) , velocity, q[2]= \(\ddot q\), acceleration.

The following operators (and their jacobians) can be plugged, in the usual way (see User Guide, ‘User-defined plugins’)

  • \(M(q)\) (computeMass())

  • \(F_{gyr}(v, q, z)\) (computeFGyr())

  • \(F_{int}(v , q , t, z)\) (computeFInt())

  • \(F_{ext}(t, z)\) (computeFExt())

If required (e.g. for Event-Driven like simulation), formulation as a first-order system is also available, and writes:

  • \(n= 2 ndof\)

  • \(x = \left[\begin{array}{c}q \\ \dot q\end{array}\right]\)

  • rhs given by:

\[\begin{split}\dot x = \left[\begin{array}{c} \dot q\\ \ddot q = M^{-1}(q)\left[F(v, q , t, z) + p \right]\\ \end{array}\right] ndverbatim\end{split}\]
  • jacobian of the rhs, with respect to x

\[\begin{split}\nabla_{x}rhs(x,t) = \left[\begin{array}{cc} 0 & I \\ \nabla_{q}(M^{-1}(q)F(v, q , t, z)) & \nabla_{\dot q}(M^{-1}(q)F(v, q , t, z)) \\ \end{array}\right]\end{split}\]

with the input due to the non smooth law:

\[\begin{split}\left[\begin{array}{c} 0 \\ p \end{array}\right]\end{split}\]

In that case, use the following methods: - initRhs() to allocate/initialize memory for these new operators, - rhs() to get the rhs vector - computeRhs(), computeJacobianRhsx() …, to update the content of rhs, its jacobians …

Overload 1:

Default constructor


Overload 2:

constructor from initial state only, \(dv = p\)

type position

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: siconos.kernel.LagrangianDS

Lagrangian Linear Systems with time invariant coefficients - \(M\dot v + Cv + Kq = F_{ext}(t,z) + p\)

The class LagrangianLinearTIDS allows to define and compute a generic ndof-dimensional Lagrangian Linear Time Invariant Dynamical System of the form:

\[M \ddot q + C \dot q + K q = F_{ext}(t,z) + p,\]

where - \(q \in R^{ndof}\) is the set of the generalized coordinates, - \(\dot q \in R^{ndof}\) the velocity, i. e. the time derivative of the generalized coordinates. - \(\ddot q \in R^{ndof}\) the acceleration, i. e. the second time derivative of the generalized coordinates. - \(p \in R^{ndof}\) the forces due to the Non Smooth Interaction. In particular case of Non Smooth evolution, the variable p contains the impulse and not the force. - \(M \in R^{ndof \times ndof}\) is the Mass matrix (access : mass() method). - \(K \in R^{ndof \times ndof}\) is the stiffness matrix (access : K() method). - \(C \in R^{ndof \times ndof}\) is the viscosity matrix (access : C() method). - \(z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discret state.

The equation of motion is also shortly denoted as:

\[M(q,z) \dot v = F(v, q, t, z) + p\]

where - \(F(v, q, t, z) \in R^{ndof}\) collects the total forces acting on the system, that is \(F(v, q, t, z) = F_{ext}(t, z) - Cv - Kq\).

This vector is saved and may be accessed using forces() method.

If required (e.g. for Event-Driven like simulation), reformulation as a first-order system is also available, and writes:

  • \(n= 2 ndof\)

  • \(x = \left[\begin{array}{c}q \\ \dot q\end{array}\right]\)

  • rhs given by:

\[\begin{split}rhs(x,t,z) = \left[\begin{array}{c} \dot q \\ \ddot q = M^{-1}\left[F_{ext}(t, z) - C \dot q - K q + p \right] \\ \end{array}\right]\end{split}\]

Its jacobian is:

\[\begin{split}\nabla_{x}rhs(x,t) = \left[\begin{array}{cc} 0 & I \\ -M^{-1}K & -M^{-1}C \\ \end{array}\right]\end{split}\]

with the input due to the non smooth law:

\[\begin{split}r = \left[\begin{array}{c}0 \\ p \end{array}\right]\end{split}\]

Overload 1: default constructor


Overload 2: constructor from initial state and all matrix operators.

Parameters

Overload 3: constructor from initial state and mass matrix only. Leads to \(M\dot v = F_{ext}(t,z) + p\) .

Parameters
initRhs(t)[source]

allocate (if needed) and compute rhs and its jacobian.

Parameters

t (float) – time of initialization

computeForces(time, q, velocity)[source]

Compute \(F(v,q,t,z)\)

Parameters
  • time (float) – the current time

  • q (SiconosVector) – SP::SiconosVector: pointers on q

  • velocity (SiconosVector) – SP::SiconosVector: pointers on velocity

getK()[source]

get a copy of the stiffness matrix

Return type

SimpleMatrix

Returns

SimpleMatrix

K()[source]

get stiffness matrix (pointer link)

Return type

SiconosMatrix

Returns

pointer on a SiconosMatrix

setK(K)[source]

set (copy) the value of the stiffness matrix

Parameters

K (SiconosMatrix) – new stiffness matrix

setKPtr(newPtr)[source]

set stiffness matrix (pointer link)

Parameters

newPtr (SiconosMatrix) – pointer to the new Stiffness matrix

getC()[source]

get a copy of the damping matrix

Return type

SimpleMatrix

Returns

SimpleMatrix

C()[source]

get damping matrix (pointer link)

Return type

SiconosMatrix

Returns

pointer on a SiconosMatrix

setC(C)[source]

set (copy) the value of the damping matrix

Parameters

C (SiconosMatrix) – new damping matrix

setCPtr(newPtr)[source]

set damping matrix (pointer link)

Parameters

newPtr (SiconosMatrix) – pointer to the new damping matrix

jacobianqForces()[source]

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

Return type

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

isLinear()[source]
Return type

boolean

Returns

true if the Dynamical system is linear.

display(brief=True)[source]

print the data onto the screen

class siconos.kernel.LagrangianLinearDiagonalDS(*args)[source]

Bases: siconos.kernel.LagrangianDS

Lagrangian Linear Systems with time invariant and diagonal coefficients - \(M\dot v + Cv + Kq = F_{ext}(t,z) + p\)

where

  • \(q \in R^{ndof}\) is the set of the generalized coordinates,

  • \(\dot q = v \in R^{ndof}\) the velocity, i. e. the time derivative of the generalized coordinates.

  • \(\ddot q \in R^{ndof}\) the acceleration, i. e. the second time derivative of the generalized coordinates.

  • \(p \in R^{ndof}\) the forces due to the nonsmooth interaction. In the particular case of a nonsmooth evolution,

the variable p contains the impulse and not the force. - \(M \in R^{ndof \times ndof}\) is the mass matrix (access : mass() method). - \(K \in R^{ndof \times ndof}\) is the stiffness matrix (access : stiffness() method). - \(C \in R^{ndof \times ndof}\) is the viscosity matrix (access : damping() method). - \(z \in R^{zSize}\) is a vector of arbitrary algebraic variables, some sort of discret state.

Remind that the specificity of this class is that all matrices are diagonal (and hence only diagonal coefficients are saved in memory).

For details about dynamical systems in Siconos, please read user’s guide.

Overload 1: default constructor


Overload 2: constructor from initial state and all operators.

Parameters

Overload 3: constructor for complete system with identity mass matrix

Parameters

Overload 4: constructor for undamped system and identity mass matrix

Parameters
get_stiffness()[source]

get a copy of the stiffness matrix (diagonal only)

Return type

SiconosVector

Returns

SiconosVector

stiffness()[source]

get stiffness matrix (diagonal only, pointer link)

Return type

SiconosVector

Returns

pointer on a SiconosVector

get_damping()[source]

get a copy of the damping matrix (diagonal only)

Return type

SiconosVector

Returns

SiconosVector

damping()[source]

get damping matrix (diagonal only, pointer link)

Return type

SiconosVector

Returns

pointer on a SiconosVector

initRhs(t)[source]

allocate (if needed) and compute rhs and its jacobian.

Parameters

t (float) – time of initialization

computeForces(time, q, velocity)[source]

Compute \(F(v,q,t,z)\)

Parameters
  • time (float) – the current time

  • q (SiconosVector) – generalized coordinates

  • velocity (SiconosVector) – time derivative of the generalized coordinates

isLinear()[source]
Return type

boolean

Returns

true if the Dynamical system is linear.

display(brief=True)[source]

print the data of the dynamical system on the standard output

siconos.kernel.computeExtForceAtPos(q, isMextExpressedInInertialFrame, force, forceAbsRef, pos, posAbsRef, fExt, mExt, accumulate)[source]

Compute the force and moment vectors applied to a body with state q from a force vector at a given position.

class siconos.kernel.NewtonEulerDS(*args)[source]

Bases: siconos.kernel.SecondOrderDS

NewtonEuler non linear dynamical systems

The equations of motion in the Newton-Euler formalism can be stated as

\[\begin{split}\left\{\begin{array}{rcl} M \dot v + F_{int}(q,v, \Omega, t)&=& F_{ext}(t), \\ I \dot \Omega + \Omega \wedge I\Omega + M_{int}(q,v, \Omega, t) &=& M_{ext}(t), \\ \dot q &=& T(q) [ v, \Omega] \\ \dot R &=& R \tilde \Omega,\quad R^{-1}=R^T,\quad \det(R)=1 . \end{array}\right.\end{split}\]

with

  • \(x_G,v_G\) position and velocity of the center of mass expressed in a

inertial frame of reference (world frame) - \(\Omega\) angular velocity vector expressed in the body-fixed frame (frame attached to the object) - \(R\) rotation matrix form the inertial frame to the body-fixed frame \(R^{-1}=R^T, \det(R)=1\), i.e \(R\in SO^+(3)\) - \(M=m\,I_{3\times 3}\) diagonal mass matrix with \(m \in \mathbb{R}\) the scalar mass - \(I\) constant inertia matrix - \(F_{ext}\) and \(M_{ext}\) are the external applied forces and moment

In the current implementation, \(R\) is parametrized by a unit quaternion.

Overload 1: Default constructor


Overload 2: constructor from a minimum set of data

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

forces()[source]

get forces

Return type

SiconosVector

Returns

pointer on a SiconosVector

jacobianqForces()[source]

get JacobianqForces

Return type

SiconosMatrix

Returns

pointer on a SiconosMatrix

jacobianvForces()[source]

get JacobianvForces

Return type

SiconosMatrix

Returns

pointer on a SiconosMatrix

getqDim()[source]

Returns dimension of vector q

q()[source]

get q (pointer link)

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

twist()[source]

get twist

Return type

SiconosVector

Returns

pointer on a SiconosVector

velocity()[source]

get twist

Return type

SiconosVector

Returns

pointer on a SiconosVector this accessor is left to get a uniform access to velocity. This should be removed with MechanicalDS class

velocity0()[source]

get initial velocity (pointer)

Return type

SiconosVector

Returns

pointer on a SiconosVector

setVelocity(newValue)[source]

set velocity (copy)

Parameters

newValue (SiconosVector) –

setVelocityPtr(newPtr)[source]

set velocity (pointer link)

Parameters

newPtr (SiconosVector) –

setVelocity0(newValue)[source]

set initial velocity (copy)

Parameters

newValue (SiconosVector) –

setVelocity0Ptr(newPtr)[source]

set initial velocity (pointer link)

Parameters

newPtr (SiconosVector) –

acceleration()[source]

get acceleration (pointer link)

Return type

SiconosVector

Returns

pointer on a SiconosVector

computeMass(*args)[source]

Overload 1: default function to compute the mass


Overload 2: function to compute the mass

Parameters

position (SiconosVector) – value used to evaluate the mass matrix

linearVelocity(*args)[source]

Overload 1: Get the linear velocity in the absolute (inertial) or relative (body) frame of reference.

Parameters

absoluteRef (boolean) – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.

Return type

SiconosVector

Returns

A SiconosVector of size 3 containing the linear velocity of this dynamical system.


Overload 2: Fill a SiconosVector with the linear velocity in the absolute (inertial) or relative (body) frame of reference.

Parameters
  • absoluteRef (boolean) – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.

  • v (SiconosVector) – A SiconosVector of size 3 to receive the linear velocity.

angularVelocity(*args)[source]

Overload 1: Get the angular velocity in the absolute (inertial) or relative (body) frame of reference.

Parameters

absoluteRef (boolean) – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.

Return type

SiconosVector

Returns

A SiconosVector of size 3 containing the angular velocity of this dynamical system.


Overload 2: Fill a SiconosVector with the angular velocity in the absolute (inertial) or relative (body) frame of reference.

Parameters
  • absoluteRef (boolean) – If true, velocity is returned in the inertial frame, otherwise velocity is returned in the body frame.

  • w (SiconosVector) – A SiconosVector of size 3 to receive the angular velocity.

scalarMass()[source]

get mass value

Return type

float

Returns

a double

setScalarMass(mass)[source]

Modify the scalar mass

inertia()[source]
Return type

SiconosMatrix

Returns

the inertia matrix

setInertia(*args)[source]

Overload 1:

Modify the inertia matrix (pointer link)

Parameters

newInertia (SiconosMatrix) – the new inertia matrix


Overload 2:

Modify the inertia matrix.

Parameters
  • ix (float) – x component

  • iy (float) – y component

  • iz (float) – z component

updateMassMatrix()[source]

to be called after scalar mass or inertia matrix have changed

fExt()[source]

get fExt

Return type

SiconosVector

Returns

pointer on a plugged vector

setFExtPtr(newPtr)[source]

set fExt to pointer newPtr

Parameters

newPtr (SiconosVector) – a SP to a Simple vector

setMExtPtr(newPtr)[source]

set mExt to pointer newPtr

Parameters

newPtr (SiconosVector) – a SP to a Simple vector

mGyr()[source]

get mGyr

Return type

SiconosVector

Returns

pointer on a plugged vector

qMemory()[source]

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

Return type

SiconosMemory

Returns

a memory

twistMemory()[source]

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

Return type

SiconosMemory

Returns

a memory

velocityMemory()[source]

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

Return type

SiconosMemory

Returns

a memory

initMemory(steps)[source]

initialize the SiconosMemory objects with a positive size.

Parameters

steps (int) – the size of the SiconosMemory (i)

swapInMemory()[source]

push the current values of x, q and r in the stored previous values xMemory, qMemory, rMemory, TODO: Modify the function swapIn Memory with the new Object Memory

forcesMemory()[source]

get forces in memory buff

Return type

SiconosMemory

Returns

pointer on a SiconosMemory

computeKineticEnergy()[source]

To compute the kinetic energy

display(brief=True)[source]

print the data to the screen

init_inverse_mass()[source]

Allocate memory for the lu factorization of the mass of the system. Useful for some integrators with system inversion involving the mass

update_inverse_mass()[source]

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

setComputeFExtFunction(*args)[source]

Overload 1: allow to set a specified function to compute _fExt

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the name of the function to use in this plugin


Overload 2: set a specified function to compute _fExt

Parameters

fct (void) – a pointer on the plugin function

setComputeMExtFunction(*args)[source]

Overload 1: allow to set a specified function to compute _mExt

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the name of the function to use in this plugin


Overload 2: set a specified function to compute _mExt

Parameters

fct (void) – a pointer on the plugin function

setComputeFIntFunction(*args)[source]

Overload 1: allow to set a specified function to compute _fInt

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the name of the function to use in this plugin


Overload 2: set a specified function to compute _fInt

Parameters

fct (void) – a pointer on the plugin function

setComputeMIntFunction(*args)[source]

Overload 1: allow to set a specified function to compute _mInt

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the name of the function to use in this plugin


Overload 2: set a specified function to compute _mInt

Parameters

fct (void) – a pointer on the plugin function

setComputeJacobianFIntqFunction(*args)[source]

Overload 1: allow to set a specified function to compute the jacobian w.r.t q of the internal forces

Parameters
  • pluginPath (string) – std::string : the complete path to the plugin

  • functionName (string) – std::string : the name of the function to use in this plugin


Overload 2: set a specified function to compute jacobian following q of the FInt

Parameters

fct (void) – a pointer on the plugin function

setComputeJacobianFIntvFunction(*args)[source]

Overload 1: allow to set a specified function to compute the jacobian following v of the internal forces w.r.t.

Parameters
  • pluginPath: – the complete path to the plugin

  • functionName: – the name of the function to use in this plugin


Overload 2: set a specified function to compute jacobian following v of the FInt

Parameters

fct (void) – a pointer on the plugin function

setComputeJacobianMIntqFunction(*args)[source]

Overload 1: allow to set a specified function to compute the jacobian w.r.t q of the internal forces

Parameters
  • pluginPath: – the complete path to the plugin

  • functionName: – the name of the function to use in this plugin


Overload 2: set a specified function to compute jacobian following q of the FInt

Parameters

fct (void) – a pointer on the plugin function

setComputeJacobianMIntvFunction(*args)[source]

Overload 1: allow to set a specified function to compute the jacobian following v of the internal forces w.r.t.

Parameters
  • pluginPath: – the complete path to the plugin

  • functionName: – the name of the function to use in this plugin


Overload 2: set a specified function to compute jacobian following v of the FInt

Parameters

fct (void) – a pointer on the plugin function

computeFExt(*args)[source]

Overload 1: function to compute the external forces

Parameters

time (float) – the current time


Overload 2: default function to compute the external forces

Parameters
  • time (float) – the current time

  • fExt (SiconosVector) – the computed external force (in-out param)

addExtForceAtPos(*args)[source]

Adds a force/torque impulse to a body’s FExt and MExt vectors in either absolute (inertial) or relative (body) frame. Modifies contents of _fExt and _mExt! Therefore these must have been set as constant vectors using setFExtPtr and setMExtPtr prior to calling this function. Adjustments to _mExt will take into account the value of _isMextExpressedInInertialFrame.

Parameters
  • force (SiconosVector) – A force vector to be added.

  • forceAbsRef (boolean) – If true, force is in inertial frame, otherwise it is in body frame.

  • pos (SiconosVector, optional) – A position at which force should be applied. If nullptr, the center of mass is assumed.

  • posAbsRef (boolean, optional) – If true, pos is in inertial frame, otherwise it is in body frame.

computeFInt(*args)[source]

Overload 1: default function to compute the internal forces

Parameters

Overload 2: default function to compute the internal forces

Parameters
computeMInt(*args)[source]

Overload 1: default function to compute the internal moments

Parameters

Overload 2: default function to compute the internal moments

Parameters
updatePlugins(time)[source]

default function to update the plugins functions using a new time:

Parameters

time (float) – the current time

init_forces()[source]

Allocate memory for forces and its jacobian.

computeForces(*args)[source]
Overload 1:

Default function to compute forces

type time

float

param time

double, the current time


Overload 2:

function to compute forces with some specific values for q and twist (ie not those of the current state). :type time: float

Parameters

time

double : the current time

type q

SiconosVector

param q

SP::SiconosVector: pointers on q

type twist

SiconosVector

param twist

SP::SiconosVector: pointers on twist

computeJacobianqForces(time)[source]

Default function to compute the jacobian w.r.t. q of forces

Parameters

time (float) – double, the current time

computeJacobianvForces(time)[source]

Default function to compute the jacobian w.r.t. v of forces

Parameters

time (float) – double, the current time

computeMGyr(*args)[source]

Overload 1: function to compute gyroscopic forces with some specific values for q and twist (ie not those of the current state).

Parameters

twist (SiconosVector) – SP::SiconosVector: pointers on twist vector


Overload 2: function to compute gyroscopic forces with some specific values for q and twist (ie not those of the current state).

Parameters
computeJacobianMGyrtwist(time)[source]

Default function to compute the jacobian following q of mGyr

Parameters

time (float) – the current time

computeJacobianMGyrtwistByFD(time, q, twist)[source]

Default function to compute the jacobian following q of mGyr by forward finite difference

Parameters
computeJacobianFIntq(*args)[source]

Overload 1: To compute the jacobian w.r.t q of the internal forces

Parameters

time (float) – double : the current time


Overload 2: To compute the jacobian w.r.t q of the internal forces

Parameters
computeJacobianFIntqByFD(time, position, twist)[source]

To compute the jacobian w.r.t q of the internal forces by forward finite difference

Parameters
computeJacobianFIntv(*args)[source]

Overload 1: To compute the jacobian w.r.t v of the internal forces

Parameters

time (float) – double : the current time


Overload 2: To compute the jacobian w.r.t. v of the internal forces

Parameters
computeJacobianFIntvByFD(time, position, twist)[source]

To compute the jacobian w.r.t v of the internal forces by forward finite difference

Parameters
computeJacobianMIntq(*args)[source]

Overload 1: To compute the jacobian w.r.t q of the internal forces

Parameters

time (float) – double : the current time


Overload 2: To compute the jacobian w.r.t q of the internal forces

Parameters
computeJacobianMIntqByFD(time, position, twist)[source]

To compute the jacobian w.r.t q of the internal moments by forward finite difference

Parameters
computeJacobianMIntv(*args)[source]

Overload 1: To compute the jacobian w.r.t v of the internal forces

Parameters

time (float) – double : the current time


Overload 2: To compute the jacobian w.r.t. v of the internal forces

Parameters
computeJacobianMIntvByFD(time, position, twist)[source]

To compute the jacobian w.r.t v of the internal moments by forward finite difference

Parameters
class siconos.kernel.FirstOrderNonLinearDS(*args)[source]

Bases: siconos.kernel.DynamicalSystem

General First Order Non Linear Dynamical Systems

This class defines and computes a generic n-dimensional dynamical system of the form :

\[M \dot x = f(x,t,z) + r, \quad x(t_0) = x_0\]

where

  • \(x \in R^{n}\) is the state.

  • \(M \in R^{n\times n}\) a “mass matrix”

  • \(r \in R^{n}\) the input due to the Non Smooth Interaction.

  • \(z \in R^{zSize}\) is a vector of arbitrary algebraic

variables, some sort of discret state. For example, z may be used to set some perturbation parameters, to control the system (z set by actuators) and so on.

  • \(f : R^{n} \times R \mapsto R^{n}\) the vector field.

By default, the DynamicalSystem is considered to be an Initial Value Problem (IVP) and the initial conditions are given by

\[x(t_0)=x_0\]

To define a Boundary Value Problem, a pointer on a BoundaryCondition must be set.

The right-hand side and its jacobian (from base class) are defined as

\[\begin{split}rhs &=& \dot x = M^{-1}(f(x,t,z)+ r) \\ jacobianRhsx &=& \nabla_x rhs(x,t,z) = M^{-1}\nabla_x f(x,t,z)\end{split}\]

The following operators can be plugged, in the usual way (see User Guide)

  • \(f(x,t,z)\)

  • \(\nabla_x f(x,t,z)\)

  • \(M(t)\)

Overload 1: default constructor


Overload 2: constructor from initial state, leads to \(\dot x = r\)

Parameters

newX0 (SiconosVector) – initial state

Warning: you need to set explicitely the plugin for f and its jacobian if needed (e.g. if used with an EventDriven scheme)


Overload 3: constructor from initial state and f (plugins), \(\dot x = f(x, t, z) + r\)

Parameters
  • newX0 (SiconosVector) – initial state

  • fPlugin (string) – name of the plugin function to be used for f(x,t,z)

  • jacobianfxPlugin (string) – name of the plugin to be used for the jacobian of f(x,t,z)


Overload 4: Copy constructor

Parameters

FONLDS (FirstOrderNonLinearDS) – the FirstOrderNonLinearDS to copy

initRhs(time)[source]

allocate (if needed) and compute rhs and its jacobian.

Parameters

time (float) – of initialization

initializeNonSmoothInput(level)[source]

set nonsmooth input to zero

Parameters

level (int) – input-level to be initialized.

resetToInitialState()[source]

reset the state to the initial state

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. r), for all ‘levels’

resetNonSmoothPart(level)[source]

set nonsmooth part of the rhs (i.e. r) to zero for a given level

Parameters

level (int) –

M()[source]

returns a pointer to M, matrix coeff. on left-hand side

setMPtr(newM)[source]

set M, matrix coeff of left-hand side (pointer link)

Parameters

newM (SiconosMatrix) – the new M matrix

getInvM()[source]

get a copy of the LU factorisation of M operator

Return type

SimpleMatrix

Returns

SimpleMatrix

invM()[source]

get the inverse of LU fact. of M operator (pointer link)

Return type

SiconosMatrix

Returns

pointer to a SiconosMatrix

f()[source]

returns f(x,t,z) (pointer link)

setFPtr(newPtr)[source]

set f(x,t,z) (pointer link)

Parameters

newPtr (SiconosVector) – a SP::SiconosVector

jacobianfx()[source]

get jacobian of f(x,t,z) with respect to x (pointer link)

Return type

SiconosMatrix

Returns

SP::SiconosMatrix

setJacobianfxPtr(newPtr)[source]

set jacobian of f(x,t,z) with respect to x (pointer link)

Parameters

newPtr (SiconosMatrix) – the new value

rMemory()[source]

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

Return type

SiconosMemory

Returns

a memory vector

fold()[source]

returns previous value of rhs –>OSI Related!!

initMemory(steps)[source]
initialize the SiconosMemory objects: reserve memory for i

vectors in memory and reset all to zero.

type steps

int

param steps

the size of the SiconosMemory (i)

swapInMemory()[source]

push the current values of x and r in memory (index 0 of memory is the last inserted vector) xMemory and rMemory,

updatePlugins(time)[source]

Call all plugged-function to initialize plugged-object values

Parameters

time (float) – value

setComputeMFunction(*args)[source]

Overload 1: to set a specified function to compute M

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – function name to use in this library


Overload 2: set a specified function to compute M

Parameters

fct (FPtr1) – a pointer on the plugin function

setComputeFFunction(*args)[source]

Overload 1: to set a specified function to compute f(x,t)

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this library


Overload 2: set a specified function to compute the vector f

Parameters

fct (FPtr1) – a pointer on the plugin function

setComputeJacobianfxFunction(*args)[source]

Overload 1: to set a specified function to compute jacobianfx

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – function name to use in this library


Overload 2: set a specified function to compute jacobianfx

Parameters

fct (FPtr1) – a pointer on the plugin function

computeM(time)[source]

Default function to compute \(M: (x,t)\)

Parameters

time (float) – time instant used in the computations

computef(time, state)[source]

Default function to compute \(f: (x,t)\)

Parameters
  • time (float) – time instant used in the computations function to compute \(f: (x,t)\)

  • time – time instant used in the computations

  • state (SiconosVector) – x value

computeJacobianfx(time, state)[source]

Default function to compute \(\nabla_x f: (x,t) \in R^{n} \times R \mapsto R^{n \times n}\) with x different from current saved state.

Parameters
  • time (float) – instant used in the computations

  • state (SiconosVector) – a SiconosVector to store the resuting value

getPluginF()[source]

Get _pluginf

Return type

SP::PluggedObject

Returns

a SP::PluggedObject

getPluginJacxf()[source]

Get _pluginJacxf

Return type

SP::PluggedObject

Returns

a SP::PluggedObject

getPluginM()[source]

Get _pluginM

Return type

SP::PluggedObject

Returns

a SP::PluggedObject

display(brief=True)[source]

print the data of the dynamical system on the standard output

class siconos.kernel.FirstOrderLinearDS(*args)[source]

Bases: siconos.kernel.FirstOrderNonLinearDS

First Order Linear Systems - \(M(t) \dot x = A(t)x(t)+ b(t) + r, \quad x(t_0)=x_0\).

This class represents first order linear systems of the form:

\[M(t) \dot x = A(t)x(t)+ b(t) + r, x(t_0)=x_0\]

where

  • \(x \in R^{n}\) is the state,

  • \(r \in R^{n}\) the input due to the Non Smooth Interaction.

  • \(M \in R^{n\times n}\) is an invertible matrix

  • \(A \in R^{n\times n}\)

  • \(b \in R^{n}\)

The following operators can be plugged, in the usual way (see User Guide)

  • \(A(t)\)

  • \(b(t)\)

  • \(M(t)\)

Overload 1: default constructor


Overload 2: constructor from initial state and plugins

Parameters
  • newX0 (SiconosVector) – the initial state of this DynamicalSystem

  • APlugin (string) – plugin for A

  • bPlugin (string) – plugin for b


Overload 3: constructor from initial state and plugin for A

Parameters

Overload 4: constructor from initial state

Parameters

newX0 (SiconosVector) – the initial state of this DynamicalSystem


Overload 5: constructor from a initial state and constant matrices

Parameters

Overload 6: Copy constructor

Parameters

FOLDS (FirstOrderLinearDS) – the original FirstOrderLinearDS we want to copy

initRhs(time)[source]

Initialization function for the rhs and its jacobian.

Parameters

time (float) – time of initialization.

computeRhs(time)[source]

update right-hand side for the current state

Parameters

time (float) – of interest

computeJacobianRhsx(time)[source]

update \(\nabla_x rhs\) for the current state

Parameters

time (float) – of interest

A()[source]

get the matrix \(A\)

Return type

SiconosMatrix

Returns

pointer (SP) on a matrix

jacobianfx()[source]

get jacobian of f(x,t,z) with respect to x (pointer link)

Return type

SiconosMatrix

Returns

SP::SiconosMatrix

setAPtr(newA)[source]

set A to pointer newPtr

Parameters

newA (SiconosMatrix) – the new A matrix

setA(newA)[source]

set A to a new matrix

Parameters

newA (SiconosMatrix) – the new A matrix

b()[source]

get b vector (pointer link)

Return type

SiconosVector

Returns

a SP::SiconosVector

setbPtr(b)[source]

set b vector (pointer link)

Parameters

b (SiconosVector) – a SiconosVector

setb(b)[source]

set b vector (copy)

Parameters

b (SiconosVector) – a SiconosVector

updatePlugins(time)[source]

Call all plugged-function to initialize plugged-object values

Parameters

time (float) – value

setComputeAFunction(*args)[source]

Overload 1: set a specified function to compute the matrix A => same action as setComputeJacobianfxFunction

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this plugin


Overload 2: set a specified function to compute the matrix A

Parameters

fct (void) – a pointer on a function

setComputebFunction(*args)[source]

Overload 1: set a specified function to compute the vector b

Parameters
  • pluginPath (string) – the complete path to the plugin file

  • functionName (string) – the function name to use in this plugin


Overload 2: set a specified function to compute the vector b

Parameters

fct (void) – a pointer on a function

computeA(time)[source]

default function to compute matrix A => same action as computeJacobianfx

Parameters

time (float) – time instant used to compute A

computeb(time)[source]

default function to compute vector b

Parameters

time (float) – time instant used to compute b

getPluginA()[source]

Get _pluginA

Return type

SP::PluggedObject

Returns

the plugin for A

getPluginB()[source]

Get _pluginb

Return type

SP::PluggedObject

Returns

the plugin for b

setPluginA(newPluginA)[source]

Set _pluginA

Parameters

newPluginA (SP::PluggedObject) – the new plugin

setPluginB(newPluginB)[source]

Set _pluginb

Parameters

newPluginB (SP::PluggedObject) – the new plugin

display(brief=True)[source]

data display on screen

isLinear()[source]

True if the system is linear.

Return type

boolean

Returns

a boolean

class siconos.kernel.FirstOrderLinearTIDS(*args)[source]

Bases: siconos.kernel.FirstOrderLinearDS

First order linear and time-invariant coeff systems - \(M \dot x = Ax(t)+ b + r, x(t_0)=x_0\) .

This class represents first order linear systems of the form:

\[M\dot x(t) = A x(t) + b + r, x(t_0)=x_0\]

where - \(x \in R^{n}\) is the state, - \(r \in R^{n}\) the input due to the Non Smooth Interaction. - \(M \in R^{n\times n}\) is a constant invertible matrix - \(A \in R^{n\times n}\) - \(b \in R^{n}\)

No plugged operators for this class.

Overload 1: initial state and constant A matrix

Parameters

Overload 2: initial state, constant A matrix, constant b vector

Parameters

Overload 3: Copy constructor

Parameters

FOLTIDS (FirstOrderLinearTIDS) – the FirstOrderLinearTIDS to copy

initRhs(time)[source]

Initialization function for the rhs and its jacobian.

Parameters

time (float) – of initialization.

computeRhs(time)[source]

Default function to the right-hand side term

Parameters

time (float) – current time

computeJacobianRhsx(time)[source]

Default function to jacobian of the right-hand side term according to x

Parameters

time (float) – current time

display(brief=True)[source]

data display on screen

updatePlugins(time)[source]

Dumb function, there is no plugin here

Parameters

time (float) – unused

class siconos.kernel.Relation(*args)[source]

Bases: object

General Non Linear Relation (Abstract Base class for Relations).

The present class is an interface to all relations and provides tools to define and describe them.

A relation is a link between global variables of the Dynamical Systems and some local ones, named y and lambda; belonging to one and only one Interaction.

All relations are specified by their type (First order or Lagrangian) accessed by getType() and their sub-type (linear, scleronomous …), returned by getSubType().

A relation provides functions to compute:

  • a function computeOutput() that updates y using dynamical systems global

variables, - a function computeInput() that updates non-smooth dynamical systems parts (e.g. r or p) using \(\lambda\) .

getType()[source]
Return type

int

Returns

the type of the Relation (FirstOrder or Lagrangian)

getSubType()[source]
Return type

int

Returns

the subType of the Relation

setComputehFunction(pluginPath, functionName)[source]

To set a plug-in function to compute output function h

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this plugin

setComputeJachxFunction(pluginPath, functionName)[source]

To set a plug-in function to compute \(\nabla_x h(..)\)

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this plugin

setComputeJachzFunction(pluginPath, functionName)[source]

To set a plug-in function to compute \(\nabla_z h(..)\)

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this plugin

setComputeJachlambdaFunction(pluginPath, functionName)[source]

To set a plug-in function to compute \(\nabla_{\lambda} h(..)\)

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this plugin

setComputegFunction(pluginPath, functionName)[source]

To set a plug-in function to compute input function g

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this plugin

setComputeFFunction(pluginPath, functionName)[source]

To set a plug-in function to compute input function F

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this plugin

setComputeEFunction(pluginPath, functionName)[source]

To set a plug-in function to compute input function E

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this plugin

setComputeJacgxFunction(pluginPath, functionName)[source]

To set a plug-in function to compute the jacobian of \(g\) w.r.t. x

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this plugin

setComputeJacglambdaFunction(pluginPath, functionName)[source]

To set a plug-in function to compute the jacobian of \(g\) w.r.t. \(\lambda\)

Parameters
  • pluginPath (string) – the complete path to the plugin

  • functionName (string) – the function name to use in this plugin

initialize(inter)[source]

initialize the relation (check sizes, memory allocation …)

Parameters

inter (Interaction) – the interaction using this relation

checkSize(inter)[source]

check sizes of the relation specific operators.

Parameters

inter (Interaction) – an Interaction using this relation

computeJach(time, inter)[source]

compute all the H Jacobian

Parameters
  • time (float) – the current time

  • inter (Interaction) – the interaction using this relation

computeJacg(time, inter)[source]

compute all the G Jacobian

Parameters
  • time (float) – the current time

  • inter (Interaction) – the interaction using this relation

  • interProp

computeOutput(time, inter, derivativeNumber=0)[source]

default function to compute y

Parameters
  • time (float) – the current time

  • inter (Interaction) – the interaction using this relation

  • derivativeNumber (int, optional) – number of the derivative to compute (optional, default = 0)

computeInput(time, inter, level=0)[source]

default function to compute r

Parameters
  • time (float) – the current time

  • inter (Interaction) – the interaction using this relation

  • level (int, optional) – the input “derivative” order of lambda used to compute input

isLinear()[source]

return true if the relation is linear.

Return type

boolean

Returns

bool

requireResidu()[source]

return true if the relation requires the computation of residu

Return type

boolean

Returns

true if residu are required, false otherwise

display()[source]

main relation members display

getPluginh()[source]

Get _pluginh

Return type

SP::PluggedObject

Returns

a shared pointer to the plugin

getPluginJachx()[source]

Get _pluginJachx

Return type

SP::PluggedObject

Returns

a shared pointer to the plugin

getPluginJachlambda()[source]

Get _pluginJachlambda

Return type

SP::PluggedObject

Returns

a shared pointer to the plugin

getPluging()[source]

Get _pluging

Return type

SP::PluggedObject

Returns

a shared pointer to the plugin

getPluginJacLg()[source]

Get _pluginJacglambda

Return type

SP::PluggedObject

Returns

a shared pointer to the plugin

getPluginf()[source]

Get _pluginf

Return type

SP::PluggedObject

Returns

a shared pointer to the plugin

getPlugine()[source]

Get _plugine

Return type

SP::PluggedObject

Returns

a shared pointer to the plugin

class siconos.kernel.LagrangianR(lagType)[source]

Bases: siconos.kernel.Relation

Lagrangian Non Linear Relation (generic interface)

This class is an interface for specific Lagrangian Relations used for Lagrangian dynamical systems.

  • \(y = h(t,q,\dot q,\ldots)\) describes the constraint (the relation)

  • The Jacobian of the constraints with respect to the coodinates \(q\)

i.e. \(\nabla^T_q h(t,q,\dot q,\ldots)\) , is accessed with jachq().

This Jacobian is mainly used for Newton linearization and to compute the time-derivative of the constraint,

\(y = h(q,\ldots)\) that is \(\dot y (t) = \nabla^T_q h(t,q,\dot q,\ldots) (q) \dot q +\ldots\)

This object can also store more general linearized part of the gap function. If \(y=h(q)\) models a gap function, then the time derivative can be generically written as

\(\dot y (t) = H(q,\ldots) \dot q +\ldots.\) The matrix \(H(q,\ldots)\) can also be accessed using jachq().

  • The Jacobian of the constraints with respect to the generalized velocities \(\dot q\)

i.e. \(\nabla^\top_{\dot q} h(t,q,\dot q,\ldots)\) is accessed using jachqDot().

  • The time-derivative of Jacobian of the constraints with respect to the generalized coordinates \(q\)

i.e. \(\frac{d}{dt} \nabla^\top_{q} h(t,q,\dot q,\ldots).\) , is accessed using dotJachq().

This value is useful to compute the second-order time–derivative of the constraints with respect to time.

All these operators can be defined with user-defined plugins.

basic constructor

Parameters

lagType (int) – the sub-type of the relation

initialize(inter)[source]

initialize the relation (check sizes, memory allocation …)

Parameters

inter (Interaction) – the interaction using this relation

jachq()[source]

get a pointer on matrix Jach[index]

Return type

SimpleMatrix

Returns

a pointer on a SimpleMatrix

setJachqPtr(newPtr)[source]

set Jach[index] to pointer newPtr (pointer link)

Parameters

newPtr (SimpleMatrix) – the new matrix

display()[source]

main relation members display

class siconos.kernel.LagrangianLinearTIR(*args)[source]

Bases: siconos.kernel.LagrangianR

Lagrangian Linear Relation.

Lagrangian Relation with:

\(y= Cq + e + Fz\)

\(p = C^t \lambda\)

C is the only required input to built a LagrangianLinearTIR.

Overload 1: Default constructor


Overload 2: create the Relation from a set of data

Parameters

C (SimpleMatrix) – the matrix C


Overload 3: create the Relation from a set of data

Parameters

Overload 4: create the Relation from a set of data

Parameters
checkSize(inter)[source]

check sizes of the relation specific operators.

Parameters

inter (Interaction) – an Interaction using this relation

computeOutput(time, inter, derivativeNumber=0)[source]

default function to compute y

Parameters
  • time (float) – not used

  • inter (Interaction) – the Interaction we want to update

  • derivativeNumber (int, optional) – the derivative of y we want to compute

computeInput(time, inter, level=0)[source]

default function to compute r

Parameters
  • time (float) – not used

  • inter (Interaction) – the Interaction we want to update

  • level (int, optional) – the derivative of lambda we want to compute

computeJach(time, inter)[source]

compute all the H Jacobian

Parameters
  • time (float) – not used

  • inter (Interaction) – the Interaction we want to update

  • interProp – interaction properties

computeJacg(time, inter)[source]

compute all the G Jacobian

Parameters
  • time (float) – not used

  • inter (Interaction) – the Interaction we want to update

  • interProp – interaction properties

C()[source]
Return type

SimpleMatrix

Returns

pointer on a plugged matrix

setCPtr(newPtr)[source]

set C to pointer newPtr

Parameters

newPtr (SimpleMatrix) – a SP to plugged matrix

D()[source]
Return type

SimpleMatrix

Returns

pointer on a plugged matrix

setDPtr(newPtr)[source]

set D to pointer newPtr

Parameters

newPtr (SimpleMatrix) – a SP to plugged matrix

F()[source]
Return type

SimpleMatrix

Returns

pointer on a plugged matrix

setFPtr(newPtr)[source]

set F to pointer newPtr

Parameters

newPtr (SimpleMatrix) – a SP to plugged matrix

e()[source]
Return type

SiconosVector

Returns

pointer on a plugged vector

setEPtr(newPtr)[source]

set e to pointer newPtr

Parameters

newPtr (SiconosVector) – a SP to plugged vector

display()[source]

print the data to the screen

isLinear()[source]
Return type

boolean

Returns

true if the relation is linear.

class siconos.kernel.LagrangianRheonomousR(*args)[source]

Bases: siconos.kernel.LagrangianR

Lagrangian (Non Linear) Rheonomous Relation

This class provides tools to describe non linear relation of the type:

\[\begin{split}y = h(q,t,z) \\ \dot y = \nabla^\top_q(q,t,z)\dot q + \frac{\partial }{\partial t}h(q,t,z) \\\end{split}\]

or more generally

\[\dot y = H(q,t,z)\dot q + \frac{\partial }{\partial t}h(q,t,z)\]

and by duality

\[p = H^\top(q,t,z)\lambda\]

The following operators (and their jacobians) can be plugged, in the usual way (see User Guide, ‘User-defined plugins’)

  • \(h(q,t,z)\)

  • \(\nabla_q h(q,t,z)\)

  • \(\dot h(q,t,z)\)

The plugin functions must fit with the following signature (FPtr4):

void func(unsigned int qsize, double* q, double time, unsigned int ysize, double* buffer , unsigned int sizez, double* z)

buffer being either \(y\) , \(\dot h\) or \(\nabla_qh\) .

Overload 1: default constructor


Overload 2: constructor from a set of data

Parameters
  • pluginh (string) – name of the plugin to compute h. Its signature must be “void userPluginH(unsigned int, double*, double, unsigned int, double*, unsigned int, double*)”

  • pluginJacobianhq (string) – name of the plugin to compute jacobian h according to q. Its signature must be “void userPluginG0(unsigned int, double*, double, unsigned int, double*, unsigned int, double*)”

  • pluginDoth (string) – name of the plugin to compute hDot. Its signature must be “void userPluginHDot(unsigned int, double*,double, unsigned int, double*, unsigned int, double*)

initialize(inter)[source]

initialize G matrices or components specific to derived classes.

Parameters

inter (Interaction) – the Interaction

checkSize(inter)[source]

check sizes of the relation specific operators.

Parameters

inter (Interaction) – an Interaction using this relation

hDot()[source]

get a pointer on vector hDot

Return type

SiconosVector

Returns

a smart pointer on a SiconosVector

setComputehDotFunction(pluginpath, name)[source]

to set a specified function to compute function hDot

Parameters
  • pluginpath (string) – the complete path to the plugin

  • name (string) – the name of the function to use in this plugin

computeh(time, q, z, y)[source]

to compute the output y = h(t,q,z) of the Relation

Parameters
  • time (float) – current time value

  • q (BlockVector) – coordinates of the dynamical systems involved in the relation

  • z (BlockVector) – user defined parameters (optional)

  • y (SiconosVector) – the resulting vector

computehDot(time, q, z)[source]

to compute the time-derivative of the output y = h(t,q,z), saved in attribute _hDot (access: hDot())

Parameters
  • time (float) – current time value

  • q (BlockVector) – coordinates of the dynamical systems involved in the relation

  • z (BlockVector) – user defined parameters (optional)

computeJachq(time, q, z)[source]

to compute the jacobian of h(…). Set attribute _jachq (access: jacqhq())

Parameters
  • time (float) – current time value

  • q (BlockVector) – coordinates of the dynamical systems involved in the relation

  • z (BlockVector) – user defined parameters (optional)

computeJach(time, inter)[source]

compute all the H Jacobian

computeJacg(time, inter)[source]

compute all the G Jacobian

computeOutput(time, inter, derivativeNumber=0)[source]

to compute output

Parameters
  • time (float) – current time

  • inter (Interaction) – the Interaction

  • derivativeNumber (int, optional) – number of the derivative to compute, optional, default = 0.

computeInput(time, inter, level=0)[source]

to compute p

Parameters
  • time (float) – current time

  • inter (Interaction) – the Interaction

  • level (int, optional) – “derivative” order of lambda used to compute input

class siconos.kernel.LagrangianScleronomousR(*args)[source]

Bases: siconos.kernel.LagrangianR

Scleronomic Lagrangian (Non Linear) Relations

\[y = h(q,z)\]
\[\dot y = \nabla^\top_q h(q,z) \dot q\]

or more generally

\[\dot y = H(q,z) \dot q\]

and by duality

\[p = \nabla_q h(q,z)\lambda\]

or more generally

\[p = H^\top(q,z)\lambda\]

with

\[H^\top(q,z) = \nabla_q h(q,z)\]

is the pure Lagrangian setting.

y (or its discrete approximation) is stored in y[0] \(\dot y\) (or its discrete approximation) is stored in y[1] higher level y[i] can be used for storing higher levels of derivatives.

Jacobians and h are connected to plug-in functions.

The plugin function to compute h(q,z) needs the following parameters:

–> sizeQ: size of q = sum of the sizes of all the DynamicalSystems involved in the interaction

–> q : pointer to the first element of q

–> sizeY : size of vector y (ie of the interaction)

–> [in,out] y : pointer to the first element of y

–> sizeZ : size of vector z

–> [in,out] z: pointer to z vector(s) from DS.

Its signature must be “void plugin(unsigned int, double*, unsigned int, double*, unsigned int, double*)”

The plugin function to compute G0(q,z), gradient of h according to q, needs the following parameters:

–> sizeQ: size of q = sum of the sizes of all the DynamicalSystems involved in the interaction

–> q : pointer to the first element of q

–> sizeY : size of vector y (ie of the intercation)

–> [in,out] H : pointer to the first element of H (sizeY X sizeDS matrix)

–> sizeZ : size of vector z

–>[in,out] z: pointer to z vector(s) from DS.

Its signature must be “void plugin(unsigned int, double*, unsigned int, double*, unsigned int, double*)”

Overload 1: basic constructor


Overload 2: constructor from a set of data

Parameters
  • pluginh (string) – the name of the plugin to compute h(q,z). The signature of the plugged function must be: “void pluginH(unsigned int, double*, unsigned int, double*, unsigned int, double*)”

  • pluginJacobianhq (string) – the name of the plugin to compute jacobian h according to q. The signature of the plugged function must be: “void pluginG0(unsigned int, double*, unsigned int, double*, unsigned int, double*)”


Overload 3: constructor from a set of data used for EventDriven Scheme

Parameters
  • pluginh (string) – the name of the plugin to compute h(q,z). The signature of the plugged function must be: “void pluginH(unsigned int, double*, unsigned int, double*, unsigned int, double*)”

  • pluginJacobianhq (string) – the name of the plugin to compute jacobian h according to q. The signature of the plugged function must be: “void pluginG0(unsigned int, double*, unsigned int, double*, unsigned int, double*)”

  • pluginDotJacobianhq (string) – the name of the plugin to compute the derivative of H Jacobian with respect to time The signature of the plugged function must be: “void pluginS0(unsigned int, double*,unsigned int, double*, unsigned int, double*, unsigned int, double*)”

initialize(inter)[source]

initialize the relation (check sizes, memory allocation …)

Parameters

inter (Interaction) – the interaction using this relation

checkSize(inter)[source]

check sizes of the relation specific operators.

Parameters

inter (Interaction) – an Interaction using this relation

dotjacqhXqdot()[source]
Return type

SiconosVector

Returns

the product of the time–derivative of Jacobian with the velocity qdot

computeh(q, z, y)[source]

to compute the output y = h(q,z) of the Relation

Parameters
  • q (BlockVector) – coordinates of the dynamical systems involved in the relation

  • z (BlockVector) – user defined parameters (optional)

  • y (SiconosVector) – the resulting vector

computeJachq(q, z)[source]

to compute the jacobian of h(…). Set attribute _jachq (access: jacqhq())

Parameters
  • q (BlockVector) – coordinates of the dynamical systems involved in the relation

  • z (BlockVector) – user defined parameters (optional)

computeDotJachq(q, z, qDot)[source]

to compute the time derivative of the Jacobian. Result in _dotjachq (access: dotjachq())

Parameters
  • q (BlockVector) – coordinates of the dynamical systems involved in the relation

  • z (BlockVector) – user defined parameters (optional)

  • time – derivatives of q

computedotjacqhXqdot(time, inter, DSlink)[source]

to compute the product of the time–derivative of Jacobian with the velocity qdot

Parameters
  • time (float) – double, current time

  • inter (Interaction) – interaction

  • DSlink (VectorOfBlockVectors) –

computeJach(time, inter)[source]

compute all the H Jacobian

Parameters
  • time (float) – double, current time

  • inter (Interaction) – interaction that owns the relation

  • interProp

computeJacg(time, inter)[source]

compute all the G Jacobian

Parameters
  • time (float) – double, current time

  • inter (Interaction) – interaction that owns the relation

  • interProp

computeOutput(time, inter, derivativeNumber=0)[source]

to compute output

Parameters
  • time (float) – the current time

  • inter (Interaction) – interaction that owns the relation

  • derivativeNumber (int, optional) – number of the derivative to compute, optional, default = 0.

computeInput(time, inter, level=0)[source]

to compute p

Parameters
  • time (float) – the current time

  • inter (Interaction) – interaction that owns the relation

  • level (int, optional) – “derivative” order of lambda used to compute input

class siconos.kernel.LagrangianCompliantR(*args)[source]

Bases: siconos.kernel.LagrangianR

Lagrangian Compliant Relation: Scleronomous, Non-Holonomic (function of lambda)

\(Y[0] = y = h(q,\lambda(t),z)\)

\(Y[1] = \dot y = G0(q,\lambda(t),z)\dot q + G1((q,\lambda(t),z)\dot\lambda(t)\)

\(p = G0^t(q,\lambda(t),z)\lambda(t)\)

with \(G0(q,\lambda(t),z) = \nabla_q h(q,\lambda(t),z)\)

\(G1(q,\lambda(t),z) = \nabla_{\lambda}h(q,\lambda(t),z)\)

h, G0 and G1 are connected to user-defined functions.

Overload 1: default constructor


Overload 2: constructor from a set of data

Parameters
  • pluginh (string) – the name of the plugin to compute h

  • pluginJacobianhq (string) – the name of the plugin to compute the gradient of h w.r.t q

  • pluginJacobianhlambda (string) – the name of the plugin to compute the gradient of h w.r.t \(\lambda\)

initialize(inter)[source]

initialize G matrices or components specific to derived classes

Parameters

inter (Interaction) – : the Interaction

checkSize(inter)[source]

check sizes of the relation specific operators.

Parameters

inter (Interaction) – an Interaction using this relation

computeh(time, q, lambda_, z, y)[source]

to compute the output y = h(q,z) of the Relation

Parameters
  • time (