Dynamical System

class pathsim.blocks.dynsys.DynamicalSystem(func_dyn=<function DynamicalSystem.<lambda>>, func_alg=<function DynamicalSystem.<lambda>>, initial_value=0.0, jac_dyn=None)[source]

Bases: Block

This block implements a nonlinear dynamical system / nonlinear state space model.

Its basically the same as the ODE block with the addition of an output equation that takes the state, input and time as arguments:

\[\begin{split}\begin{eqnarray} \dot{x}(t) =& \mathrm{func}_\mathrm{dyn}(x(t), u(t), t) \\ y(t) =& \mathrm{func}_\mathrm{alg}(x(t), u(t), t) \end{eqnarray}\end{split}\]
Parameters:
  • func_dyn (callable) – right hand side function of ode-part of the system

  • func_alg (callable) – output function of the system

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

  • jac_dyn (callable | None) – optional jacobian of func_dyn to improve convergence for implicit ode solvers

op_dyn

internal dynamic operator for func_dyn

Type:

DynamicOperator

op_alg

internal dynamic operator for func_alg

Type:

DynamicOperator

set_solver(Solver, parent, **solver_args)[source]

set the internal numerical integrator

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

  • parent (None | Solver) – solver instance to use as parent

  • solver_args (dict) – parameters for solver initialization

update(t)[source]

update system equation for fixed point loop, by evaluating the output function of the system

Parameters:

t (float) – evaluation time

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