spectral.RK4#

class spectral.RK4[source]#

Bases: TimeIntegrator

Classical 4th-order Runge-Kutta method (ERK4).

The classical explicit four-stage fourth-order Runge-Kutta method. This is one of the most widely used explicit time integrators, offering a good balance between accuracy and computational cost.

Notes

The method evaluates the right-hand side four times per step at intermediate stages. It is 4th-order accurate and suitable for a wide range of initial value problems, though it lacks special stability properties like SSP methods.

References

Engsig-Karup, “Lecture 5: Initial Value Problems”, p. 58

Methods

__init__

Initialize time integrator.

step

Take one time step.

Examples using spectral.RK4#

Generate KdV Soliton Samples (RK4, RK3)

Generate KdV Soliton Samples (RK4, RK3)

Spatial and Temporal Convergence for Fourier KdV Solver

Spatial and Temporal Convergence for Fourier KdV Solver

Single Soliton Error and Conservation Analysis

Single Soliton Error and Conservation Analysis

Two-Soliton KdV Collision Dataset Generation

Two-Soliton KdV Collision Dataset Generation

Profiling Script: Single Soliton KdV Solver

Profiling Script: Single Soliton KdV Solver

Scalability Analysis: Time per Step vs Grid Size

Scalability Analysis: Time per Step vs Grid Size

Work-Precision Analysis: RK3 vs RK4 with Varying Grid Resolution

Work-Precision Analysis: RK3 vs RK4 with Varying Grid Resolution
step(rhs: Callable, u: ndarray, t: float, dt: float) ndarray[source]#

Take one time step.

Parameters:
rhsCallable

Right-hand side function f(u, t)

unp.ndarray

Current solution

tfloat

Current time

dtfloat

Time step

Returns:
np.ndarray

Solution at next time step