IDA

This class provides a connection to the Sundials (https://computation.llnl.gov/casc/sundials/main.html) solver IDA.

IDA is a variable-order, variable-step multi-step algorithm for solving differential algebraic equations of the form,

F(t,y,\dot{y})=0, \quad y(t_0) = y_0, \quad \dot{y}(t_0) = \dot{y}_0.

IDA includes the Backward Differentiation Formulas (BDFs).

Support

  • State events (root funtions) : True
  • Step events (completed step) : True
  • Time events : True

Usage

Import the solver together with the correct problem:

from assimulo.solvers import IDA
from assimulo.problem import Implicit_Problem

Define the problem, such as:

def res(t, y, yd): #Note that y and yd are 1-D numpy arrays.
    res = yd[0]-1.0
    return N.array([res]) #Note that the return must be numpy array, NOT a scalar.

y0  = [1.0]
yd0 = [1.0]
t0  = 1.0

Create a problem instance:

mod = Implicit_Problem(res, y0, yd0, t0)

Note

For complex problems, it is recommended to check the available examples and the documentation in the problem class, Implicit_Problem. It is also recommended to define your problem as a subclass of Implicit_Problem.

Warning

When subclassing from a problem class, the function for calculating the right-hand-side (for ODEs) must be named rhs and in the case with a residual function (for DAEs) it must be named res.

Create a solver instance:

sim = IDA(mod)

Modify (optionally) the solver parameters.

Parameters:

  • algvar A list for defining which variables are differential and which are algebraic.
  • atol Defines the absolute tolerance(s) that is to be used by the solver.
  • backward Specifies if the simulation is done in reverse time.
  • clock_step Specifies if the elapsed time of an integrator step should be timed or not.
  • display_progress This option actives output during the integration in terms of that the current integration is periodically printed to the stdout.
  • dqrhomax Specifies the selection parameters used in deciding switching between a simultaneous or separate approximation of the two terms in the sensitivity residual.
  • dqtype Specifies the difference quotient type in the sensitivity calculations.
  • external_event_detection A Boolean flag which indicates if Assimulos event finding algorithm or CVode’s is used to localize events.
  • inith This determines the initial step-size to be used in the integration.
  • linear_solver Specifies the linear solver to be used.
  • lsoff Boolean value to turn OFF Sundials LineSearch when calculating initial conditions.
  • maxcorS This detmines the maximum number of nonlinear iterations for the sensitivity variables.
  • maxh Defines the maximal step-size that is to be used by the solver.
  • maxord This determines the maximal order that is be used by the solver.
  • maxsteps Determines the maximum number of steps the solver is allowed to take to finish the simulation.
  • num_threads This options specifies the number of threads to be used for those solvers that supports it.
  • pbar Specifies the order of magnitude for the parameters.
  • report_continuously This options specifies if the solver should report the solution continuously after steps.
  • rtol Defines the relative tolerance that is to be used by the solver.
  • sensmethod Specifies the sensitivity solution method.
  • store_event_points This options specifies if the solver should save additional points at the events, t_e^-, t_e^+.
  • suppress_alg A Boolean flag which indicates that the error-tests are suppressed on algebraic variables.
  • suppress_sens A Boolean flag which indicates that the error-tests are suppressed on the sensitivity variables.
  • time_limit This option can be used to limit the time of an integration.
  • tout1 Sets the value used in the internal Sundials function for determine initial conditions.
  • usejac This sets the option to use the user defined jacobian.
  • usesens This options activates or deactivates the sensitivity calculations.
  • verbosity This determines the level of the output.

Methods:

Simulate the problem:

Information: