Euler

class pathsim.solvers.euler.EUF(*solver_args, **solver_kwargs)[source]

Bases: ExplicitSolver

Explicit forward Euler method. First-order, single-stage.

\[x_{n+1} = x_n + h \, f(x_n, t_n)\]

Characteristics

  • Order: 1

  • Stages: 1

  • Explicit, fixed timestep

  • Not A-stable

Note

The cheapest solver per step but also the least accurate. Its small stability region requires very small timesteps for moderately dynamic block diagrams, which usually makes higher-order methods more efficient overall. Prefer RK4 for fixed-step or RKDP54 for adaptive integration of non-stiff systems. Only practical when computational cost per step must be absolute minimum and accuracy is secondary.

References

step(f, dt)[source]

performs the explicit forward timestep for (t+dt) based on the state and input at (t)

Parameters:
  • f (array_like) – evaluation of function

  • dt (float) – integration timestep

Returns:

  • success (bool) – timestep was successful

  • err (float) – truncation error estimate

  • scale (float) – timestep rescale from error controller

class pathsim.solvers.euler.EUB(*solver_args, **solver_kwargs)[source]

Bases: ImplicitSolver

Implicit backward Euler method. First-order, A-stable and L-stable.

\[x_{n+1} = x_n + h \, f(x_{n+1}, t_{n+1})\]

The implicit equation is solved iteratively by the internal optimizer.

Characteristics

  • Order: 1

  • Stages: 1 (implicit)

  • Fixed timestep

  • A-stable, L-stable

Note

Maximum stability at the cost of accuracy. L-stability fully damps parasitic high-frequency modes, making this a safe fallback for very stiff block diagrams (e.g. high-gain PID loops or fast electrical dynamics coupled to slow mechanical plant). Because each step requires solving a nonlinear equation, the cost per step is higher than explicit methods. For better accuracy on stiff systems, use BDF2 (fixed-step) or ESDIRK43 (adaptive).

References

solve(f, J, dt)[source]

Solves the implicit update equation using the internal optimizer.

Parameters:
  • f (array_like) – evaluation of function

  • J (array_like) – evaluation of jacobian of function

  • dt (float) – integration timestep

Returns:

err – residual error of the fixed point update equation

Return type:

float