# JSim ODE Solver Tuning Guide

*This page is for the current JSim version 2.0. Click here for the earlier JSim 1.6 version.*

The default set of parameters associated with the ODE solvers are usually sufficient for most ODE problems, but occassionally need to be "tweaked". When a solver fails or gives a poor result, it is usually caused by (1) too large a step size, (2) too large relative and absolute tolerances in the solutions, (3) too few steps for calculation, or (4) problem being too stiff. Many of these problems can be fixed by changing the ODE solver parameters, or by using a more complex solver, or by doing both. The ODE solvers are listed in order of increasing complexity.

## Euler: forward one-step

Decrease model step (t.delta) where t stands for the independent variable (e.g. t.delta, x.delta, etc.) and/or increase nstep. The actual step size is (t.delta/nstep) for the solver. Error is first order (proportional to actual step size).

## RK2: 2nd order Runge-Kutta, also known as modified trapezoidal method

Decrease model step (t.delta) where t stands for the independent variable (e.g. t.delta, x.delta, etc.) and/or increase nstep. The actual step size is (t.delta/nstep) for the solver. Error is second order (proportional to actual step size squared).

## RK4: 4th order Runge-Kutta

Decrease model step (t.delta) where t stands for the independent variable (e.g. t.delta, x.delta, etc.) and/or increase nstep. The actual step size is (t.delta/nstep) for the solver.

## KM: Runge-Kutta Merson with adaptive stepsize

Decrease minstep (must be smaller than t.delta) and/or decrease tol.

## Fehlberg: Runge-Kutta-Fehlberg (RKF45)

Decrease minstep (must be smaller than t.delta) and/or decrease tol.

## CVode

Decrease reltol and/or abstol; increase maxsteps; checking the box marked "stiff" invokes a BDF (backward differentiation formula, otherwise Adams-Moulton methods are used.)

## Dopri5: Dorman Prince 5th order with variable stepsize (explicit Runge-Kutta Method)

Decrease reltol and abstol. Most of the other parameters are already set to reasonable values and changing them will probably not improve the solution.

## Radau: Implicit Runge-Kutta method with variable order (5,9,13) with step size control

Decrease reltol and abstol. Most of the other parameters are already set to reasonable values and changing them will probably not improve the solution.

Comments or Questions?[This page was last modified 06Jul12, 3:18 pm.]

**Model development and archiving support at
physiome.org provided by the following grants:** NIH U01HL122199 Analyzing the Cardiac Power Grid, 09/15/2015 - 05/31/2020, NIH/NIBIB BE08407 Software Integration,
JSim and SBW 6/1/09-5/31/13; NIH/NHLBI T15 HL88516-01 Modeling for Heart, Lung and Blood: From Cell to Organ,
4/1/07-3/31/11; NSF BES-0506477 Adaptive Multi-Scale Model Simulation,
8/15/05-7/31/08; NIH/NHLBI R01 HL073598 Core 3: 3D Imaging and Computer
Modeling of the Respiratory Tract, 9/1/04-8/31/09; as well as prior
support from NIH/NCRR P41 RR01243 Simulation Resource in Circulatory Mass
Transport and Exchange, 12/1/1980-11/30/01 and NIH/NIBIB R01 EB001973
JSim: A Simulation Analysis Platform, 3/1/02-2/28/07.