pathsim.blocks.ode module

class pathsim.blocks.ode.ODE(func=<function ODE.<lambda>>, initial_value=0.0, jac=None)[source]

Bases: Block

This block implements an ordinary differential equation (ODE) defined by its right hand side

d/dt x = func(x, u, t)

with inhomogenity (input) ‘u’ and state vector ‘x’. The function can be nonlinear and the ODE can be of arbitrary order. The block utilizes the integration engine to solve the ODE by integrating the ‘func’, which is the right hand side function.

Parameters:
  • func (callable) – right hand side function of ODE

  • initial_value (array[float]) – initial state / initial condition

  • jac (callable, None) – jacobian of ‘func’ or ‘None’

set_solver(Solver, **solver_args)[source]

set the internal numerical integrator

Parameters:
  • Solver (Solver) – numerical integration solver class

  • solver_args (dict) – parameters for solver initialization

update(t)[source]

update system equation for fixed point loop, here just setting the outputs

Parameters:

t (float) – evaluation time

Returns:

error – deviation to previous iteration for convergence control

Return type:

float

solve(t, dt)[source]

advance solution of implicit update equation of the solver

Parameters:
  • t (float) – evaluation time

  • dt (float) – integration timestep

Returns:

error – solver residual norm

Return type:

float

step(t, dt)[source]

compute timestep update with integration engine

Parameters:
  • t (float) – evaluation time

  • dt (float) – integration timestep

Returns:

  • success (bool) – step was successful

  • error (float) – local truncation error from adaptive integrators

  • scale (float) – timestep rescale from adaptive integrators