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,
IDA includes the Backward Differentiation Formulas (BDFs).
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:
algvarA list for defining which variables are differential and which are algebraic.atolDefines the absolute tolerance(s) that is to be used by the solver.backwardSpecifies if the simulation is done in reverse time.clock_stepSpecifies if the elapsed time of an integrator step should be timed or not.display_progressThis option actives output during the integration in terms of that the current integration is periodically printed to the stdout.dqrhomaxSpecifies the selection parameters used in deciding switching between a simultaneous or separate approximation of the two terms in the sensitivity residual.dqtypeSpecifies the difference quotient type in the sensitivity calculations.external_event_detectionA Boolean flag which indicates if Assimulos event finding algorithm or CVode’s is used to localize events.inithThis determines the initial step-size to be used in the integration.linear_solverSpecifies the linear solver to be used.lsoffBoolean value to turn OFF Sundials LineSearch when calculating initial conditions.maxcorSThis detmines the maximum number of nonlinear iterations for the sensitivity variables.maxhDefines the maximal step-size that is to be used by the solver.maxordThis determines the maximal order that is be used by the solver.maxstepsDetermines the maximum number of steps the solver is allowed to take to finish the simulation.num_threadsThis options specifies the number of threads to be used for those solvers that supports it.pbarSpecifies the order of magnitude for the parameters.report_continuouslyThis options specifies if the solver should report the solution continuously after steps.rtolDefines the relative tolerance that is to be used by the solver.sensmethodSpecifies the sensitivity solution method.store_event_pointsThis options specifies if the solver should save additional points at the events, \(t_e^-, t_e^+\).suppress_algA Boolean flag which indicates that the error-tests are suppressed on algebraic variables.suppress_sensA Boolean flag which indicates that the error-tests are suppressed on the sensitivity variables.time_limitThis option can be used to limit the time of an integration.tout1Sets the value used in the internal Sundials function for determine initial conditions.usejacThis sets the option to use the user defined jacobian.usesensThis options activates or deactivates the sensitivity calculations.verbosityThis determines the level of the output.
Methods:
IDA.interpolateIDA.interpolate_sensitivityIDA.make_consistent Directs IDA to try to calculate consistent initial conditions.Simulate the problem:
Information:
IDA.get_options() Returns the current solver options.IDA.get_supports() Returns the functionality which the solver supports.IDA.get_statistics() Returns the run-time statistics (if any).IDA.get_event_data() Returns the event information (if any).IDA.print_event_data() Prints the event information (if any).IDA.print_statistics() Prints the run-time statistics for the problem.