File kernel/src/simulationTools/LsodarOSI.hpp

Contents

File kernel/src/simulationTools/LsodarOSI.hpp#

Go to the source code of this file

LsodarOSI solver (from odepack)

Defines

ATOL_DEFAULT#
RTOL_DEFAULT#
class LsodarOSI : public OneStepIntegrator
#include <LsodarOSI.hpp>

LsodarOSI solver (odepack)

Many parameters are required as input/output for LSODAR. See the documentation of this function in externals/odepack/opkdmain.f to have a full description of these parameters. Most of them are read-only parameters (ie can not be set by user).

Except:

  • jt: Jacobian type indicator (1 means a user-supplied full Jacobian, 2 means an internally generated full Jacobian). Default = 2.

  • itol, rtol and atol

ITOL = an indicator for the type of error control.

RTOL = a relative error tolerance parameter, either a scalar or array of length NEQ.

ATOL = an absolute error tolerance parameter, either a scalar or an array of length NEQ. Input only.

Public Types

enum LsodarOSI_ds_workVector_id#

Values:

enumerator FREE#
enumerator WORK_LENGTH#
enum LsodarOSI_interaction_workVector_id#

Values:

enumerator OSNSP_RHS#
enumerator WORK_INTERACTION_LENGTH#
enum LsodarOSI_interaction_workBlockVector_id#

Values:

enumerator xfree#
enumerator BLOCK_WORK_LENGTH#

Public Functions

LsodarOSI()

Default constructor.

inline ~LsodarOSI()

destructor

inline const std::vector<integer> intData() const

get vector of integer parameters for lsodar

Returns:

a vector<integer>

inline integer intData(unsigned int i) const

get _intData[i]

Parameters:

i – index number (starting from 0)

Returns:

an integer

inline void setIntData(unsigned int i, int newValue)

set _intData[i]

Parameters:
  • i – index number (starting from 0)

  • newValue – the new value

inline const SA::doublereal getRtol() const

get relative tolerance parameter for lsodar

Returns:

a doublereal*

inline const SA::doublereal getAtol() const

get absolute tolerance parameter for lsodar

Returns:

a doublereal*

inline int getMaxNstep() const

get the maximum number of steps for one call

Returns:

an interger

inline const SA::doublereal getRwork() const

get real work vector parameter for lsodar

Returns:

a doublereal*

inline SA::integer getIwork() const

get iwork

Returns:

a pointer to integer

inline SA::integer getJroot() const

get output of root information

Returns:

a pointer to integer

inline void setJT(integer newJT)

set Jt value, Jacobian type indicator.

Excerpts from the lsodar documentation. 1 means a user-supplied full (neq by neq) jacobian. 2 means an internally generated (difference quotient) full jacobian (using neq extra calls to f per df/dy value). 4 means a user-supplied banded jacobian. 5 means an internally generated banded jacobian (using ml+mu+1 extra calls to f per df/dy evaluation). if jt = 1 or 4, the user must supply a subroutine jac (the name is arbitrary) as described above under jac. if jt = 2 or 5, a dummy argument can be used.

Parameters:

newJT – new value for the jt parameter.

void setTol(integer newItol, SA::doublereal newRtol, SA::doublereal newAtol)

set itol, rtol and atol (tolerance parameters for lsodar)

Parameters:
  • newItol – itol value

  • newRtol – rtol value

  • newAtol – atol value

void setTol(integer newItol, doublereal newRtol, doublereal newAtol)

set itol, rtol and atol (scalar tolerance parameters for lsodar)

Parameters:
  • newItol – itol value

  • newRtol – rtol value

  • newAtol – atol value

void setMaxNstep(integer maxNumberSteps)

set the maximum number of steps for one call of Lsodar

Parameters:

maxNumberSteps – the maximum number of steps

void setMinMaxStepSizes(doublereal minStep, doublereal maxStep)

set the minimum and maximum step sizes

Parameters:
  • minStep – minimum step size

  • maxStep – maximum step size

void setMaxOrder(integer maxorderNonStiff, integer maxorderStiff)

set maximum method order

Parameters:
  • maxorderNonStiff – maximum order for nonstiff methods

  • maxorderStiff – maximum order for stiff methods

void updateData()

update doubleData and iwork memory size, when changes occur in _intData.

void fillXWork(integer *size, doublereal *array)

fill xWork with a doublereal

Parameters:
  • size – size of x array

  • array – x array of double

void computeRhs(double t)

compute rhs(t) for all dynamical systems in the set

Parameters:

t – current time of simulation

void computeJacobianRhs(double t, DynamicalSystemsGraph &DSG0)

compute jacobian of the rhs at time t for all dynamical systems in the set

Parameters:
void f(integer *sizeOfX, doublereal *time, doublereal *x, doublereal *xdot)#
void g(integer *nEq, doublereal *time, doublereal *x, integer *ng, doublereal *gOut)#
void jacobianfx(integer*, doublereal*, doublereal*, integer*, integer*, doublereal*, integer*)#
virtual void initialize() override

initialization of the integrator

virtual void initializeWorkVectorsForDS(double t, SP::DynamicalSystem ds) override

initialization of the work vectors and matrices (properties) related to one dynamical system on the graph and needed by the osi

Parameters:
  • t – time of initialization

  • ds – the dynamical system

virtual void initializeWorkVectorsForInteraction(Interaction &inter, InteractionProperties &interProp, DynamicalSystemsGraph &DSG) override

initialization of the work vectors and matrices (properties) related to one interaction on the graph and needed by the osi

Parameters:
  • inter – the interaction

  • interProp – the properties on the graph

  • DSG – the dynamical systems graph

inline virtual unsigned int numberOfIndexSets() const override

get the number of index sets required for the simulation

Returns:

unsigned int

virtual void integrate(double &tinit, double &tend, double &tout, int &ioparam) override

integrate the system, between tinit and tend (->iout=true), with possible stop at tout (->iout=false)

Parameters:
  • tinit – initial time

  • tend – end time

  • tout – real end time

  • ioparam – in-out parameter, input: 1 for first call, else 2. Output: 2 if no root was found, else 3.

virtual void updateState(const unsigned int level) override

update the state of the DynamicalSystems attached to this Integrator

Parameters:

level – level of interest for the dynamics

inline virtual void prepareNewtonIteration(double time) override#
virtual void computeFreeOutput(InteractionsGraph::VDescriptor &vertex_descr, OneStepNSProblem *osnsp) override

integrates the Interaction linked to this integrator, without taking non-smooth effects into account

Parameters:
  • vertex_descr – descriptor vertex of the interaction graph

  • osnsp – pointer to OneStepNSProblem

inline virtual SiconosVector &osnsp_rhs(InteractionsGraph::VDescriptor &vertex_inter, InteractionsGraph &indexSet) override

return the workVector corresponding to the right hand side of the OneStepNonsmooth problem

virtual void display() override

print the data to the screen

ACCEPT_STD_VISITORS()#

Public Static Functions

static inline int count_rhs_call()

Return current number of rhs call (for all lsodar-like OSIs!)

Returns:

int

static inline int count_steps()

Return the number of lsodar steps already done (for all lsodar-like OSIs!)

Returns:

int

Public Static Attributes

static int count_NST

Lsodar counter : Number of steps taken for the problem so far.

static int count_NFE

Number of RHS evaluations for the problem so far.

Private Functions

ACCEPT_SERIALIZATION(LsodarOSI)#

Private Members

std::vector<integer> _intData#

neq, ng, itol, itask, istate, iopt, lrw, liw, jt See opkdmain.f and lsodar routine for details on those variables.

unsigned int _sizeTol#

_sizeTol size of the vector ot tolerances

unsigned int _itol#

Type of tolerances.

SA::doublereal rtol#

relative tolerance

SA::doublereal atol#

absolute tolerance

SA::doublereal rwork#

real work array

SA::integer iwork#

integer work array

SA::integer jroot#

integer array used for output of root information

SP::BlockVector _xWork#

temporary vector to save x values

SP::SiconosVector _xtmp#

Friends

friend struct _NSLEffectOnFreeOutput