Simple Idealized 1D NLSE Solver
A flexible and efficient solver for the 1D Nonlinear Schrödinger Equation (NLSE) using pseudo-spectral methods
Overview
This package provides a high-accuracy numerical framework for solving the 1D focusing NLSE:
$$i \frac{\partial \psi}{\partial t} + \frac{1}{2} \frac{\partial^2 \psi}{\partial x^2 } + |\psi|^2 \psi = 0,$$
where $\psi(x,t)$ is the complex wave function. This equation models various physical phenomena including Bose-Einstein condensates, nonlinear optics, and water waves.
Numerical Method
The solver employs a Fourier pseudo-spectral method combined with high-order time integration:
Spatial Discretization
Using the Fourier transform $\hat{\psi}(k,t) = \mathcal{F}[\psi(x,t)]$, the NLSE becomes:
$$\frac{\partial \hat{\psi}}{\partial t} = -\frac{i}{2}k^2\hat{\psi} + i\mathcal{F}[|\psi|^2\psi],$$
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)$
Anti-Aliasing Filter
To prevent aliasing from the nonlinear term, we apply an exponential filter (2/3 rule):
$$\sigma(k) = \exp\left[-36\left(\frac{|k|}{k_{max}}\right)^{36}\right], \quad k_{max} = \frac{2\pi N}{3L}$$
Time Integration
The filtered equation in Fourier space:
$$\frac{d\hat{\psi}_f}{dt} = -\frac{i}{2}k^2\hat{\psi}_f + i\sigma(k)\mathcal{F}[|\mathcal{F}^{-1}[\hat{\psi}_f]|^2 \mathcal{F}^{-1}[\hat{\psi}_f]]$$
is solved using the 8th-order Dormand-Prince method (DOP853) with adaptive time-stepping, achieving relative tolerances down to $10^{-9}$.
Conservation Laws
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$
Key Features
- 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
Installation
From PyPI
pip install simple-idealized-1d-nlse
From source
git clone https://github.com/sandyherho/simple-idealized-1d-nlse.git
cd simple-idealized-1d-nlse
pip install -e .
Quick Start
# 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 --verbose
Project Structure
simple_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)
Authors
- Sandy H. S. Herho - sandyherho@itb.ac.id
- Iwan P. Anwar
- Faruq Khadami
- Rusmawan Suwarman
- Dasapta E. Irawan
License
This project is licensed under the WTFPL License - see the LICENSE file for details.
Citation
If you use this software in your research, please cite:
@article{HerhoEtAl_NLSE_2026,
title={{Simple-idealized-1d-nlse: Pseudo-spectral solver for the 1D nonlinear Schrödinger equation}},
volume={23},
number={2},
journal={Revista Mexicana de Física E},
author={Herho, Sandy and Anwar, Iwan and Khadami, Faruq and Suwarman, Rusmawan and Irawan, Dasapta},
year={2026},
pages={1–18},
note={\url{https://doi.org/10.31349/RevMexFisE.23.020206}}
}
Metadata
Release files for simple-idealized-1d-nlse 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simple_idealized_1d_nlse-0.0.5.tar.gz | 17.5 kB | Without provenance | Details for simple_idealized_1d_nlse-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_idealized_1d_nlse-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for simple_idealized_1d_nlse-0.0.5-py3-none-any.whl |
Total release size: 38.9 kB
Release files / simple_idealized_1d_nlse-0.0.5.tar.gz
| Download URL | simple_idealized_1d_nlse-0.0.5.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2262c21cad38ac54a5fa4b906bbd3394ce8abb4ba89f2cb18872dfaecb0a7e6f
|
|
BLAKE2b-256 checksum How to use checksums |
42c5733aa0d4da334414758a3db577ed809d8abbd97d3ba12fda5e6244b850ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.11.7 Linux/5.15.0-185-generic
|
Release files / simple_idealized_1d_nlse-0.0.5-py3-none-any.whl
| Download URL | simple_idealized_1d_nlse-0.0.5-py3-none-any.whl |
|---|---|
| Size | 21.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
101e3fa5242cf4a9e8a4fa1560c2fae281a15ba2180fe239ef655a5d50d6464e
|
|
BLAKE2b-256 checksum How to use checksums |
6020b2e755ab9c5423e70c2b9fd5b1ea8a50d41dbe1fa9350701bc255c1112fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.11.7 Linux/5.15.0-185-generic
|
Security for simple-idealized-1d-nlse 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.