sangkuriang: A pseudo-spectral Python library for Korteweg-de Vries soliton simulation
Sandy H. S. Herho, Faruq Khadami, Iwan P. Anwar, Dasapta E. Irawan
TL;DR
This work presents sangkuriang, an open-source Python library for solving the Korteweg-de Vries (KdV) equation using Fourier pseudo-spectral spatial discretization and adaptive high-order time integration, accelerated by Numba JIT. The approach enforces accurate soliton dynamics through spectral derivatives and a DOP853 time-stepping scheme, with NetCDF CF-conformant outputs and diagnostic tools for conservation, soliton tracking, and phase-space structure. Validation across four test cases demonstrates conservation of the invariants $M$, $P$, and $E$ to $10^{-7}$–$10^{-4}$ relative error and soliton velocities consistent with the theoretical relation $v = εA/3$, while information-theoretic measures and RQA corroborate integrable-like behavior. The tool balances numerical fidelity with accessibility on modest hardware, making it suitable for classroom demonstrations and preliminary soliton-dynamics research, and it lays groundwork for future extensions to exact initial data, topography variation, and higher-dimensional generalizations such as the KP equation.
Abstract
The Korteweg-de Vries (KdV) equation serves as a foundational model in nonlinear wave physics, describing the balance between dispersive spreading and nonlinear steepening that gives rise to solitons. This article introduces sangkuriang, an open-source Python library for solving this equation using Fourier pseudo-spectral spatial discretization coupled with adaptive high-order time integration. The implementation leverages just-in-time (JIT) compilation for computational efficiency while maintaining accessibility for instructional purposes. Validation encompasses progressively complex scenarios including isolated soliton propagation, symmetric two-wave configurations, overtaking collisions between waves of differing amplitudes, and three-body interactions. Conservation of the classical invariants is monitored throughout, with deviations remaining small across all test cases. Measured soliton velocities conform closely to theoretical predictions based on the amplitude-velocity relationship characteristic of integrable systems. Complementary diagnostics drawn from information theory and recurrence analysis confirm that computed solutions preserve the regular phase-space structure expected for completely integrable dynamics. The solver outputs data in standard scientific formats compatible with common analysis tools and generates visualizations of spatiotemporal wave evolution. By combining numerical accuracy with practical accessibility on modest computational resources, sangkuriang offers a platform suitable for both classroom demonstrations of nonlinear wave phenomena and exploratory research into soliton dynamics.
