# Usage¶

To use ode:

import ode


## Examples¶

Double Pendulum Example

## Classes and functions¶

ode.Euler(dfun, xzero, timerange, timestep)[source]

Euler method integration. This class implements a generator.

Parameters
• dfun – derivative function of the system. The differential system arranged as a series of first-order equations: $$\dot{X} = \mathrm{dfun}(t, x)$$. Returns $$\dot{X}$$ should be a single dimensional array or list.

• xzero – the initial condition of the system

• timerange – the start and end times as (starttime, endtime) tuple/list/array.

• timestep – the timestep

Returns

t, x for each iteration. t is a number. x is an array.

ode.euler(dfun, xzero, timerange, timestep)[source]

Euler method integration. This function wraps the Euler class.

Parameters

All – All parameters are identical to the Euler class above.

Returns

t, x as arrays.

ode.BackwardEuler(dfun, xzero, timerange, timestep, convergencethreshold=1e-10, maxiterations=1000)[source]

Backward Euler method integration. This class implements a generator.

Parameters
• dfun – Derivative function of the system. The differential system arranged as a series of first-order equations: $$\dot{X} = \mathrm{dfun}(t, x)$$

• xzero – The initial condition of the system.

• vzero – The initial condition of first derivative of the system.

• timerange – The start and end times as (starttime, endtime).

• timestep – The timestep.

• convergencethreshold – Each step requires an iterative solution of an implicit equation. This is the threshold of convergence.

• maxiterations – Maximum iterations of the implicit equation before raising an exception.

Returns

t, x for each iteration.

ode.backwardeuler(dfun, xzero, timerange, timestep)[source]

Backward Euler method integration. This function wraps BackwardEuler.

Parameters

All – All parameters are identical to the BackwardEuler class above.

Returns

t, x as arrays.

ode.Verlet(ddfun, xzero, vzero, timerange, timestep)[source]

Verlet method integration. This class implements a generator.

Parameters
• ddfun – second derivative function of the system. The differential system arranged as a series of second-order equations: $$\ddot{X} = \mathrm{dfun}(t, x)$$

• xzero – the initial condition of the system

• vzero – the initial condition of first derivative of the system

• timerange – the start and end times as (starttime, endtime)

• timestep – the timestep

Returns

t, x, v for each iteration.

ode.verlet(ddfun, xzero, vzero, timerange, timestep)[source]

Verlet method integration. This function wraps the Verlet class.

Parameters

All – All parameters are identical to the Verlet class above.

Returns

t, x, v as arrays.