This class provides a connection to the Sundials (https://computation.llnl.gov/casc/sundials/main.html) solver CVode.
CVode is a variable-order, variable-step multi-step algorithm for solving ordinary differential equations of the form,
CVode includes the Backward Differentiation Formulas (BDFs) which are suitable for stiff problems and also the Adams-Moulton formulas for non-stiff systems.
Import the solver together with the correct problem:
from assimulo.solvers import CVode
from assimulo.problem import Explicit_Problem
Define the problem, such as:
def rhs(t, y): #Note that y are a 1-D numpy array.
yd = -1.0
return N.array([yd]) #Note that the return must be numpy array, NOT a scalar.
y0 = [1.0]
t0 = 1.0
Create a problem instance:
mod = Explicit_Problem(rhs, y0, t0)
Note
For complex problems, it is recommended to check the available examples and the documentation in the problem class, Explicit_Problem. It is also recommended to define your problem as a subclass of Explicit_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 = CVode(mod)
Modify (optionally) the solver parameters.
Parameters:
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.discrThis determines the discretization method.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.iterThis determines the iteration method that is be used by the solver.linear_solverSpecifies the linear solver to be used.maxcorThis detmines the maximum number of nonlinear iterations.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.maxkrylovSpecifies the maximum number of dimensions for the krylov subspace to be used.maxncfThis determines the maximum number of convergence failures allowed by the solver (in each step).maxnefThis determines the maximum number of error test failures allowed by the solver (in each step).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.minhDefines the minimal step-size that is to be used by the solver.normThis determines the norm that is used by the solver when determining errors.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.precondSpecifies the preconditioning type.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.stablimitSpecifies if the internal stability limit detection for BDF should be used or not.store_event_pointsThis options specifies if the solver should save additional points at the events, \(t_e^-, t_e^+\).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.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:
Simulate the problem:
Information:
CVode.get_options() Returns the current solver options.CVode.get_supports() Returns the functionality which the solver supports.CVode.get_statistics() Returns the run-time statistics (if any).CVode.get_event_data() Returns the event information (if any).CVode.print_event_data() Prints the event information (if any).CVode.print_statistics() Prints the run-time statistics for the problem.