pathsim.solvers.euler module

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

Bases: ExplicitSolver

Explicit Forward Euler (FE) integration method.

This is the simplest explicit numerical integration method. It is first-order accurate (\(O(h)\)) and generally not suitable for stiff problems due to its limited stability region.

Method:

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

Characteristics

  • Order: 1

  • Stages: 1

  • Explicit

  • Fixed timestep only

  • Not A-stable

  • Low accuracy and stability, but computationally very cheap.

When to Use

  • Educational purposes: Ideal for teaching basic numerical integration concepts

  • Very smooth problems: When the function is extremely smooth and well-behaved

  • Rapid prototyping: Quick initial testing before applying more sophisticated methods

  • Resource-constrained scenarios: When computational cost must be minimized

Not recommended for production use, stiff problems, or when accuracy is important.

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 (BE) integration method.

This is the simplest implicit numerical integration method. It is first-order accurate (\(O(h)\)) and is A-stable and L-stable, making it suitable for very stiff problems where stability is paramount, although its low order limits accuracy for non-stiff problems or when high precision is required.

Method:

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

This implicit equation is solved iteratively using the internal optimizer.

Characteristics

  • Order: 1

  • Stages: 1 (Implicit)

  • Implicit

  • Fixed timestep only

  • A-stable, L-stable

  • Very stable, suitable for stiff problems, but low accuracy.

When to Use

  • Highly stiff problems: Excellent stability for very stiff ODEs

  • Robustness over accuracy: When stability is more critical than precision

  • Long-time integration: For simulations over very long time periods where stability matters

  • Initial testing of stiff systems: Simple method to verify problem setup

Trade-off: Sacrifices accuracy for exceptional stability. For higher accuracy on stiff problems, consider BDF or ESDIRK methods.

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