cvode_with_jac_sparse.py

assimulo.examples.cvode_with_jac_sparse.run_example(with_plots=True)[source]

Example for demonstrating the use of a user supplied Jacobian (sparse). Note that this will only work if Assimulo has been configured with Sundials + SuperLU. Based on the SUNDIALS example cvRoberts_sps.c

ODE:

\[\begin{split}\dot y_1 &= -0.04y_1 + 1e4 y_2 y_3 \\ \dot y_2 &= - \dot y_1 - \dot y_3 \\ \dot y_3 &= 3e7 y_2^2\end{split}\]

on return:

  • exp_mod problem instance
  • exp_sim solver instance

Final Run Statistics: Example using analytic (sparse) Jacobian 

 Number of steps                                 : 57
 Number of function evaluations                  : 88
 Number of Jacobian evaluations                  : 2
 Number of function eval. due to Jacobian eval.  : 0
 Number of error test failures                   : 3
 Number of nonlinear iterations                  : 84
 Number of nonlinear convergence failures        : 0

Solver options:

 Solver                   : CVode
 Linear multistep method  : BDF
 Nonlinear solver         : Newton
 Linear solver type       : SPARSE
 Maximal order            : 5
 Tolerances (absolute)    : [  1.00000000e-08   1.00000000e-14   1.00000000e-06]
 Tolerances (relative)    : 0.0001

Simulation interval    : 0.0 - 0.4 seconds.
Elapsed simulation time: 0.027547121048 seconds.
_images/cvode_with_jac_sparse.png

Note

Press [source] (to the top right) to view the example.