RK4

class pathsim.solvers.rk4.RK4(*solver_args, **solver_kwargs)[source]

Bases: ExplicitRungeKutta

Classical four-stage, 4th order explicit Runge-Kutta method.

The most well-known Runge-Kutta method. It provides a good balance between accuracy and computational cost for non-stiff problems. This is the standard textbook Runge-Kutta method, often simply called “RK4” or “the Runge-Kutta method.”

Characteristics

  • Order: 4

  • Stages: 4

  • Explicit

  • Fixed timestep only

  • Not SSP

  • Widely used, good general-purpose explicit solver

When to Use

  • General-purpose integration: Excellent default choice for smooth, non-stiff problems

  • Fixed timestep applications: When adaptive stepping is not required

  • Moderate accuracy needs: Good balance of accuracy and computational cost

  • Educational/reference: Standard method for comparison and teaching

Note

Not suitable for stiff problems. For adaptive timestepping, consider RKDP54 or RKF45. For problems requiring TVD/SSP properties, use SSPRK methods.

References

interpolate(r, dt)[source]

Interpolate solution after successful timestep as a ratio in the interval [t, t+dt].

This is especially relevant for Runge-Kutta solvers that have a higher order interpolant. Otherwise this is just linear interpolation using the buffered state.

Parameters:
  • r (float) – ration for interpolation within timestep

  • dt (float) – integration timestep

Returns:

x – interpolated state

Return type:

numeric, array[numeric]