simple-idealized-1d-nlse


Namesimple-idealized-1d-nlse JSON
Version 0.0.4 PyPI version JSON
download
home_pageNone
SummaryA flexible and efficient solver for the 1D Nonlinear Schrödinger Equation
upload_time2025-09-07 05:39:38
maintainerNone
docs_urlNone
authorSandy H. S. Herho
requires_python<4.0,>=3.8
licenseWTFPL
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Simple Idealized 1D NLSE Solver

[![DOI](https://zenodo.org/badge/1038236999.svg)](https://doi.org/10.5281/zenodo.16895284)
[![Python](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
[![License: WTFPL](https://img.shields.io/badge/License-WTFPL-brightgreen.svg)](http://www.wtfpl.net/about/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![PyPI version](https://img.shields.io/pypi/v/simple-idealized-1d-nlse.svg)](https://pypi.org/project/simple-idealized-1d-nlse/)

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

```bash
pip install simple-idealized-1d-nlse
```


### From source

```bash
git clone https://github.com/samuderasains/simple-idealized-1d-nlse.git
cd simple-idealized-1d-nlse
pip install -e .
```

## Quick Start

```bash
# 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** - sandy.herho@email.ucr.edu
- **Iwan P. Anwar** 
- **Faruq Khadami** 
- **Rusmawan Suwarman** 
- **Dasapta E. Irawan** 

## License

This project is licensed under the WTFPL License - see the [LICENSE](LICENSE) file for details.

## Citation

If you use this software in your research, please cite:

```bibtex
@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}
}

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "simple-idealized-1d-nlse",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Sandy H. S. Herho",
    "author_email": "sandy.herho@email.ucr.edu",
    "download_url": "https://files.pythonhosted.org/packages/54/81/3312bffbe4a35d1a630895eeefc3a44a4055536412b5a443ad445f7d69d2/simple_idealized_1d_nlse-0.0.4.tar.gz",
    "platform": null,
    "description": "# Simple Idealized 1D NLSE Solver\n\n[![DOI](https://zenodo.org/badge/1038236999.svg)](https://doi.org/10.5281/zenodo.16895284)\n[![Python](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)\n[![License: WTFPL](https://img.shields.io/badge/License-WTFPL-brightgreen.svg)](http://www.wtfpl.net/about/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![PyPI version](https://img.shields.io/pypi/v/simple-idealized-1d-nlse.svg)](https://pypi.org/project/simple-idealized-1d-nlse/)\n\nA flexible and efficient solver for the 1D Nonlinear Schr\u00f6dinger Equation (NLSE) using pseudo-spectral methods\n\n## Overview\n\nThis package provides a high-accuracy numerical framework for solving the 1D focusing NLSE:\n\n$$i \\frac{\\partial \\psi}{\\partial t} + \\frac{1}{2} \\frac{\\partial^2 \\psi}{\\partial x^2 } + |\\psi|^2 \\psi = 0,$$\n\nwhere $\\psi(x,t)$ is the complex wave function. This equation models various physical phenomena including Bose-Einstein condensates, nonlinear optics, and water waves.\n\n### Numerical Method\n\nThe solver employs a **Fourier pseudo-spectral method** combined with high-order time integration:\n\n#### Spatial Discretization\nUsing the Fourier transform $\\hat{\\psi}(k,t) = \\mathcal{F}[\\psi(x,t)]$, the NLSE becomes:\n\n$$\\frac{\\partial \\hat{\\psi}}{\\partial t} = -\\frac{i}{2}k^2\\hat{\\psi} + i\\mathcal{F}[|\\psi|^2\\psi],$$\n\nwhere spatial derivatives are computed spectrally:\n- $\\mathcal{F}[\\partial^2_x \\psi] = -k^2 \\hat{\\psi}$\n- Wavenumbers: $k_j = 2\\pi j/L$ for $j \\in [-N/2, N/2)$\n\n#### Anti-Aliasing Filter\nTo prevent aliasing from the nonlinear term, we apply an exponential filter (2/3 rule):\n\n$$\\sigma(k) = \\exp\\left[-36\\left(\\frac{|k|}{k_{max}}\\right)^{36}\\right], \\quad k_{max} = \\frac{2\\pi N}{3L}$$\n\n#### Time Integration\nThe filtered equation in Fourier space:\n\n$$\\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]]$$\n\nis solved using the **8th-order Dormand-Prince method (DOP853)** with adaptive time-stepping, achieving relative tolerances down to $10^{-9}$.\n\n### Conservation Laws\n\nThe solver monitors three conserved quantities to ensure numerical stability:\n\n- **Mass (L\u00b2 norm)**: $M = \\int_{-\\infty}^{\\infty} |\\psi|^2 dx$\n\n- **Momentum**: $P = \\int_{-\\infty}^{\\infty} \\text{Im}(\\psi^* \\partial_x \\psi) dx$\n\n- **Energy (Hamiltonian)**: $E = \\int_{-\\infty}^{\\infty} \\left[\\frac{1}{2}|\\partial_x \\psi|^2 - \\frac{1}{2}|\\psi|^4\\right] dx$\n\n### Key Features\n\n- **Spectral accuracy**: Exponential convergence for smooth solutions\n- **Adaptive time-stepping**: Automatic step size control based on error estimates\n- **JIT compilation**: Optional Numba acceleration for performance-critical sections\n- **Stability monitoring**: Real-time tracking of conservation laws\n- **Multiple initial conditions**: Solitons, breathers, and modulation instability scenarios\n\n## Installation\n\n### From PyPI\n\n```bash\npip install simple-idealized-1d-nlse\n```\n\n\n### From source\n\n```bash\ngit clone https://github.com/samuderasains/simple-idealized-1d-nlse.git\ncd simple-idealized-1d-nlse\npip install -e .\n```\n\n## Quick Start\n\n```bash\n# Run single scenario with YAML config\nnlse-simulate single_soliton\n\n# Run with TXT configuration file\nnlse-simulate --config configs/txt/single_soliton.txt\n\n# Run all predefined scenarios\nnlse-simulate --all\n\n# Run with verbose output\nnlse-simulate single_soliton --verbose\n```\n\n## Project Structure\n\n```\nsimple_idealized_1d_nlse/\n\u251c\u2500\u2500 src/simple_idealized_1d_nlse/\n\u2502   \u251c\u2500\u2500 core/           # Core solver and numerical methods\n\u2502   \u251c\u2500\u2500 utils/          # Utility functions and helpers\n\u2502   \u251c\u2500\u2500 visualization/  # FiveThirtyEight-style plotting\n\u2502   \u2514\u2500\u2500 io/            # Input/output handlers (YAML/TXT)\n\u251c\u2500\u2500 configs/           \n\u2502   \u251c\u2500\u2500 yaml/          # YAML configuration files\n\u2502   \u2514\u2500\u2500 txt/           # TXT configuration files\n\n../outputs/            # Simulation results (outside package)\n../logs/              # Simulation logs (outside package)\n```\n\n\n## Authors\n\n- **Sandy H. S. Herho** - sandy.herho@email.ucr.edu\n- **Iwan P. Anwar** \n- **Faruq Khadami** \n- **Rusmawan Suwarman** \n- **Dasapta E. Irawan** \n\n## License\n\nThis project is licensed under the WTFPL License - see the [LICENSE](LICENSE) file for details.\n\n## Citation\n\nIf you use this software in your research, please cite:\n\n```bibtex\n@software{nlse_solver_2025,\n  title = {Simple Idealized 1D NLSE Solver},\n  author = {Herho, Sandy H. S. and Anwar, Iwan P. and Khadami, Faruq and \n           Suwarman, Rusmawan and Irawan, Dasapta E.},\n  year = {2025},\n  version = {0.0.4},\n  url = {https://github.com/sandyherho/simple_idealized_1d_nlse}\n}\n",
    "bugtrack_url": null,
    "license": "WTFPL",
    "summary": "A flexible and efficient solver for the 1D Nonlinear Schr\u00f6dinger Equation",
    "version": "0.0.4",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f739cbda4fadae398ff8c78d4310f509e7fd96cec81deee3f7f5e9be9eba6f61",
                "md5": "8a8a44e77bef4928c4d084b7ee0fea29",
                "sha256": "8606f73f72acebc8ca8deb26c48d72800c5a9505a39c7e6f4df6597e1db38b29"
            },
            "downloads": -1,
            "filename": "simple_idealized_1d_nlse-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8a8a44e77bef4928c4d084b7ee0fea29",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 21296,
            "upload_time": "2025-09-07T05:39:36",
            "upload_time_iso_8601": "2025-09-07T05:39:36.595446Z",
            "url": "https://files.pythonhosted.org/packages/f7/39/cbda4fadae398ff8c78d4310f509e7fd96cec81deee3f7f5e9be9eba6f61/simple_idealized_1d_nlse-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54813312bffbe4a35d1a630895eeefc3a44a4055536412b5a443ad445f7d69d2",
                "md5": "f9382c14a101c5ff09b22d03606f97c8",
                "sha256": "6e3ff7f8b846a919f60fe924551b781f733fa44ec9ba28274e93557337e73a47"
            },
            "downloads": -1,
            "filename": "simple_idealized_1d_nlse-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "f9382c14a101c5ff09b22d03606f97c8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 17277,
            "upload_time": "2025-09-07T05:39:38",
            "upload_time_iso_8601": "2025-09-07T05:39:38.241837Z",
            "url": "https://files.pythonhosted.org/packages/54/81/3312bffbe4a35d1a630895eeefc3a44a4055536412b5a443ad445f7d69d2/simple_idealized_1d_nlse-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-07 05:39:38",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "simple-idealized-1d-nlse"
}
        
Elapsed time: 1.64579s