A flexible and efficient solver for the 1D Nonlinear Schrödinger Equation (NLSE) using pseudo-spectral methods
This package provides a high-accuracy numerical framework for solving the 1D focusing NLSE:
where
The solver employs a Fourier pseudo-spectral method combined with high-order time integration:
Using the Fourier transform
where spatial derivatives are computed spectrally:
$\mathcal{F}[\partial^2_x \psi] = -k^2 \hat{\psi}$ - Wavenumbers:
$k_j = 2\pi j/L$ for$j \in [-N/2, N/2)$
To prevent aliasing from the nonlinear term, we apply an exponential filter (2/3 rule):
The filtered equation in Fourier space:
is solved using the 8th-order Dormand-Prince method (DOP853) with adaptive time-stepping, achieving relative tolerances down to
The solver monitors three conserved quantities to ensure numerical stability:
-
Mass (L² norm):
$M = \int_{-\infty}^{\infty} |\psi|^2 dx$ -
Momentum:
$P = \int_{-\infty}^{\infty} \text{Im}(\psi^* \partial_x \psi) dx$ -
Energy (Hamiltonian):
$E = \int_{-\infty}^{\infty} \left[\frac{1}{2}|\partial_x \psi|^2 - \frac{1}{2}|\psi|^4\right] dx$
- Spectral accuracy: Exponential convergence for smooth solutions
- Adaptive time-stepping: Automatic step size control based on error estimates
- JIT compilation: Optional Numba acceleration for performance-critical sections
- Stability monitoring: Real-time tracking of conservation laws
- Multiple initial conditions: Solitons, breathers, and modulation instability scenarios
pip install simple-idealized-1d-nlsegit clone https://github.com/samuderasains/simple-idealized-1d-nlse.git
cd simple-idealized-1d-nlse
pip install -e .# Run single scenario with YAML config
nlse-simulate single_soliton
# Run with TXT configuration file
nlse-simulate --config configs/txt/single_soliton.txt
# Run all predefined scenarios
nlse-simulate --all
# Run with verbose output
nlse-simulate single_soliton --verbosesimple_idealized_1d_nlse/
├── src/simple_idealized_1d_nlse/
│ ├── core/ # Core solver and numerical methods
│ ├── utils/ # Utility functions and helpers
│ ├── visualization/ # FiveThirtyEight-style plotting
│ └── io/ # Input/output handlers (YAML/TXT)
├── configs/
│ ├── yaml/ # YAML configuration files
│ └── txt/ # TXT configuration files
../outputs/ # Simulation results (outside package)
../logs/ # Simulation logs (outside package)
- Sandy H. S. Herho - sandy.herho@email.ucr.edu
- Iwan P. Anwar
- Faruq Khadami
- Rusmawan Suwarman
- Dasapta E. Irawan
This project is licensed under the WTFPL License - see the LICENSE file for details.
If you use this software in your research, please cite:
@software{nlse_solver_2025,
title = {Simple Idealized 1D NLSE Solver},
author = {Herho, Sandy H. S. and Anwar, Iwan P. and Khadami, Faruq and
Suwarman, Rusmawan and Irawan, Dasapta E.},
year = {2025},
version = {0.0.4},
url = {https://github.com/sandyherho/simple_idealized_1d_nlse}
}