optixde 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- optixde-0.2.2/CHANGELOG.md +83 -0
- optixde-0.2.2/CITATION.cff +21 -0
- optixde-0.2.2/LICENSE +21 -0
- optixde-0.2.2/MANIFEST.in +4 -0
- optixde-0.2.2/PKG-INFO +451 -0
- optixde-0.2.2/README.md +417 -0
- optixde-0.2.2/optixde/__init__.py +10 -0
- optixde-0.2.2/optixde/bc/__init__.py +25 -0
- optixde-0.2.2/optixde/bc/rasterize.py +100 -0
- optixde-0.2.2/optixde/bc/robin.py +149 -0
- optixde-0.2.2/optixde/bc/segmented.py +228 -0
- optixde-0.2.2/optixde/fft_backend/__init__.py +98 -0
- optixde-0.2.2/optixde/fft_backend/base.py +336 -0
- optixde-0.2.2/optixde/fft_backend/cupy_backend.py +285 -0
- optixde-0.2.2/optixde/fft_backend/numpy_backend.py +195 -0
- optixde-0.2.2/optixde/fft_backend/propagator_cache.py +227 -0
- optixde-0.2.2/optixde/fft_backend/torch_backend.py +286 -0
- optixde-0.2.2/optixde/geometry/__init__.py +11 -0
- optixde-0.2.2/optixde/geometry/boolean.py +241 -0
- optixde-0.2.2/optixde/geometry/primitives.py +995 -0
- optixde-0.2.2/optixde/operators/__init__.py +15 -0
- optixde-0.2.2/optixde/operators/spectral.py +129 -0
- optixde-0.2.2/optixde/operators/transforms.py +355 -0
- optixde-0.2.2/optixde/post/__init__.py +35 -0
- optixde-0.2.2/optixde/post/plotting.py +802 -0
- optixde-0.2.2/optixde/solvers/__init__.py +214 -0
- optixde-0.2.2/optixde/solvers/_diagnostics.py +187 -0
- optixde-0.2.2/optixde/solvers/allen_cahn.py +24 -0
- optixde-0.2.2/optixde/solvers/base/__init__.py +126 -0
- optixde-0.2.2/optixde/solvers/base/allen_cahn.py +466 -0
- optixde-0.2.2/optixde/solvers/base/burgers.py +427 -0
- optixde-0.2.2/optixde/solvers/base/cylinder_flow.py +339 -0
- optixde-0.2.2/optixde/solvers/base/diffusion.py +813 -0
- optixde-0.2.2/optixde/solvers/base/etd.py +359 -0
- optixde-0.2.2/optixde/solvers/base/helmholtz.py +420 -0
- optixde-0.2.2/optixde/solvers/base/navier_stokes.py +429 -0
- optixde-0.2.2/optixde/solvers/base/ode.py +154 -0
- optixde-0.2.2/optixde/solvers/base/poisson.py +716 -0
- optixde-0.2.2/optixde/solvers/base/poisson_inhom.py +289 -0
- optixde-0.2.2/optixde/solvers/base/schrodinger.py +443 -0
- optixde-0.2.2/optixde/solvers/base/wave.py +388 -0
- optixde-0.2.2/optixde/solvers/burgers.py +26 -0
- optixde-0.2.2/optixde/solvers/cylinder_flow.py +22 -0
- optixde-0.2.2/optixde/solvers/diffusion.py +22 -0
- optixde-0.2.2/optixde/solvers/helmholtz.py +18 -0
- optixde-0.2.2/optixde/solvers/navier_stokes.py +20 -0
- optixde-0.2.2/optixde/solvers/poisson.py +20 -0
- optixde-0.2.2/optixde/solvers/schrodinger.py +22 -0
- optixde-0.2.2/optixde/solvers/segmented/__init__.py +21 -0
- optixde-0.2.2/optixde/solvers/segmented/poisson.py +40 -0
- optixde-0.2.2/optixde/solvers/segmented/polygonal.py +384 -0
- optixde-0.2.2/optixde/solvers/segmented/transient.py +180 -0
- optixde-0.2.2/optixde/solvers/solid/__init__.py +19 -0
- optixde-0.2.2/optixde/solvers/solid/elasticity_dynamic.py +70 -0
- optixde-0.2.2/optixde/solvers/solid/elasticity_static.py +205 -0
- optixde-0.2.2/optixde/solvers/solid/postprocess.py +153 -0
- optixde-0.2.2/optixde/solvers/splitting.py +83 -0
- optixde-0.2.2/optixde/solvers/wave.py +18 -0
- optixde-0.2.2/optixde/version.py +4 -0
- optixde-0.2.2/optixde.egg-info/PKG-INFO +451 -0
- optixde-0.2.2/optixde.egg-info/SOURCES.txt +82 -0
- optixde-0.2.2/optixde.egg-info/dependency_links.txt +1 -0
- optixde-0.2.2/optixde.egg-info/requires.txt +25 -0
- optixde-0.2.2/optixde.egg-info/top_level.txt +1 -0
- optixde-0.2.2/pyproject.toml +80 -0
- optixde-0.2.2/setup.cfg +4 -0
- optixde-0.2.2/tests/test_allen_cahn.py +130 -0
- optixde-0.2.2/tests/test_backend_cache.py +75 -0
- optixde-0.2.2/tests/test_burgers.py +145 -0
- optixde-0.2.2/tests/test_core_solvers.py +114 -0
- optixde-0.2.2/tests/test_cylinder_flow.py +79 -0
- optixde-0.2.2/tests/test_cylinder_flow_example.py +54 -0
- optixde-0.2.2/tests/test_import.py +6 -0
- optixde-0.2.2/tests/test_navier_stokes.py +137 -0
- optixde-0.2.2/tests/test_public_api.py +81 -0
- optixde-0.2.2/tests/test_robin.py +96 -0
- optixde-0.2.2/tests/test_schrodinger.py +149 -0
- optixde-0.2.2/tests/test_solver_convergence.py +168 -0
- optixde-0.2.2/tests/test_solver_diagnostics.py +312 -0
- optixde-0.2.2/tests/test_splitting.py +48 -0
- optixde-0.2.2/tests/test_torch_backend.py +129 -0
- optixde-0.2.2/tests/test_transforms.py +36 -0
- optixde-0.2.2/tests/test_validation.py +56 -0
- optixde-0.2.2/tests/test_wave.py +109 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to OptiXDE are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format follows the spirit of [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and OptiXDE uses semantic versioning for public releases.
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.2.2] - 2026-07-27
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- File-level SPDX copyright and MIT license identifiers across Python sources.
|
|
15
|
+
- Explicit author, contact, license, project URL, and benchmark reference
|
|
16
|
+
metadata for open-source and research citation workflows.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Modernized Python package license metadata and prepared automated
|
|
21
|
+
TestPyPI/PyPI publishing.
|
|
22
|
+
- Removed repository-tracked personal editor settings.
|
|
23
|
+
|
|
24
|
+
## [0.2.1] - 2026-06-30
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Citation metadata through `CITATION.cff` so GitHub can expose a repository
|
|
29
|
+
citation entry.
|
|
30
|
+
- Project changelog and README links for release notes and citation guidance.
|
|
31
|
+
|
|
32
|
+
## [0.2.0] - 2026-06-30
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Public release artifacts for OptiXDE v0.2.0, including wheel and source
|
|
37
|
+
distribution on GitHub Releases.
|
|
38
|
+
- Matrix-free solver coverage for Poisson, Helmholtz, diffusion, and wave
|
|
39
|
+
equations on rectangular uniform grids.
|
|
40
|
+
- Wave-equation examples, including periodic single-mode phase validation,
|
|
41
|
+
Gaussian packet propagation, and a paper-style Section 6.3 reproduction
|
|
42
|
+
script.
|
|
43
|
+
- Operator-splitting examples for nonlinear PDE workflows, including
|
|
44
|
+
Allen--Cahn and 1D periodic viscous Burgers.
|
|
45
|
+
- Burgers reproduction tooling with high-resolution reference comparison,
|
|
46
|
+
space-time visualization, parameter scans, and Torch backend support.
|
|
47
|
+
- Periodic vorticity-streamfunction Navier--Stokes examples, including a
|
|
48
|
+
Taylor--Green vortex and a cylinder-flow Brinkman prototype with force,
|
|
49
|
+
wake, spectrum, history, and scan diagnostics.
|
|
50
|
+
- Schrödinger/paraxial Gaussian propagation example with periodic FFT backend
|
|
51
|
+
support.
|
|
52
|
+
- PyTorch backend workflows for periodic FFT solvers on CPU and CUDA-capable
|
|
53
|
+
devices, plus Colab-oriented GPU smoke scripts.
|
|
54
|
+
- Backend diagnostics via `return_info=True`, capability flags, backend name,
|
|
55
|
+
device, boundary condition, transform path, and shape/dtype metadata.
|
|
56
|
+
- Unified solver reference validation benchmark covering representative wave,
|
|
57
|
+
Burgers, Navier--Stokes, and Schrödinger paths.
|
|
58
|
+
- Organized examples under `examples/base`, `examples/benchmarks`, and
|
|
59
|
+
`examples/solid`, with opt-in artifact generation.
|
|
60
|
+
- Release checklist and CI validation for tests, compile checks, and compact
|
|
61
|
+
solver-reference smoke runs.
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
|
|
65
|
+
- Standardized public solver entry points under `optixde.solvers`.
|
|
66
|
+
- Modernized legacy benchmark and example CLIs with explicit output paths.
|
|
67
|
+
- Moved generated figures and benchmark artifacts toward `examples/artifacts`
|
|
68
|
+
and kept repository outputs opt-in.
|
|
69
|
+
- Improved README coverage for solver conventions, boundary conditions,
|
|
70
|
+
diagnostics, examples, GPU usage, and release validation.
|
|
71
|
+
|
|
72
|
+
### Notes
|
|
73
|
+
|
|
74
|
+
- The Torch backend currently targets periodic FFT paths. Dirichlet and Neumann
|
|
75
|
+
DCT/DST paths remain NumPy/SciPy-oriented.
|
|
76
|
+
- Embedded-domain, segmented-boundary, cylinder-flow, and solid-mechanics
|
|
77
|
+
modules are still experimental and should be validated for each research use
|
|
78
|
+
case.
|
|
79
|
+
|
|
80
|
+
[Unreleased]: https://github.com/yangyLab/OptiXDE/compare/v0.2.2...main
|
|
81
|
+
[0.2.2]: https://github.com/yangyLab/OptiXDE/releases/tag/v0.2.2
|
|
82
|
+
[0.2.1]: https://github.com/yangyLab/OptiXDE/releases/tag/v0.2.1
|
|
83
|
+
[0.2.0]: https://github.com/yangyLab/OptiXDE/releases/tag/v0.2.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use OptiXDE in academic work, please cite this software and the related paper or preprint when available."
|
|
3
|
+
title: "OptiXDE: optical-inspired PDE solvers"
|
|
4
|
+
version: "0.2.2"
|
|
5
|
+
date-released: "2026-07-27"
|
|
6
|
+
type: software
|
|
7
|
+
license: MIT
|
|
8
|
+
authors:
|
|
9
|
+
- family-names: "Yang"
|
|
10
|
+
given-names: "Yang"
|
|
11
|
+
email: "yangyhhu@foxmail.com"
|
|
12
|
+
repository-code: "https://github.com/yangyLab/OptiXDE"
|
|
13
|
+
url: "https://github.com/yangyLab/OptiXDE/releases/tag/v0.2.2"
|
|
14
|
+
abstract: "OptiXDE is a lightweight Python package for optical-inspired, matrix-free spectral solvers for differential equations on uniform grids, with examples for linear PDEs, nonlinear splitting, flow, wave propagation, and GPU-oriented periodic FFT workflows."
|
|
15
|
+
keywords:
|
|
16
|
+
- PDE
|
|
17
|
+
- spectral methods
|
|
18
|
+
- FFT
|
|
19
|
+
- optical-inspired computing
|
|
20
|
+
- scientific computing
|
|
21
|
+
- GPU
|
optixde-0.2.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Yang Yang <yangyhhu@foxmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
optixde-0.2.2/PKG-INFO
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: optixde
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: OptiXDE: optical-inspired PDE solver
|
|
5
|
+
Author-email: Yang Yang <yangyhhu@foxmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yangyLab/OptiXDE
|
|
8
|
+
Project-URL: Repository, https://github.com/yangyLab/OptiXDE
|
|
9
|
+
Project-URL: Issues, https://github.com/yangyLab/OptiXDE/issues
|
|
10
|
+
Keywords: PDE,spectral methods,FFT,scientific computing,GPU
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy>=1.20
|
|
15
|
+
Provides-Extra: plot
|
|
16
|
+
Requires-Dist: matplotlib>=3.6; extra == "plot"
|
|
17
|
+
Provides-Extra: sparse
|
|
18
|
+
Requires-Dist: scipy>=1.9; extra == "sparse"
|
|
19
|
+
Provides-Extra: torch
|
|
20
|
+
Requires-Dist: torch; extra == "torch"
|
|
21
|
+
Provides-Extra: gpu
|
|
22
|
+
Requires-Dist: torch; extra == "gpu"
|
|
23
|
+
Provides-Extra: cupy
|
|
24
|
+
Requires-Dist: cupy; extra == "cupy"
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
27
|
+
Requires-Dist: coverage>=7.5; extra == "dev"
|
|
28
|
+
Requires-Dist: matplotlib>=3.6; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff>=0.5; extra == "dev"
|
|
31
|
+
Requires-Dist: scipy>=1.9; extra == "dev"
|
|
32
|
+
Requires-Dist: twine>=5; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<img src="optixde_logo_horizontal.svg" alt="OptiXDE logo" width="620">
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
# OptiXDE
|
|
40
|
+
|
|
41
|
+
[](pyproject.toml)
|
|
42
|
+
[](https://github.com/yangyLab/OptiXDE/releases/tag/v0.2.2)
|
|
43
|
+
[](#development)
|
|
44
|
+
[](docs/colab_torch_gpu.md)
|
|
45
|
+
|
|
46
|
+
OptiXDE is a lightweight Python package for optical-inspired PDE solvers on
|
|
47
|
+
uniform grids. It focuses on fast, matrix-free spectral methods for rectangular
|
|
48
|
+
domains, with experimental embedded-domain and solid-mechanics modules growing
|
|
49
|
+
alongside the core solver stack.
|
|
50
|
+
|
|
51
|
+
The core convention is consistent across the package:
|
|
52
|
+
|
|
53
|
+
- Poisson: `-Δu = f`
|
|
54
|
+
- Helmholtz: `(-Δ + k0^2)u = f`
|
|
55
|
+
- Diffusion: `u_t = D Δu`
|
|
56
|
+
- Wave: `u_tt = c^2 Δu`
|
|
57
|
+
|
|
58
|
+
## Highlights
|
|
59
|
+
|
|
60
|
+
- **Matrix-free solvers** for Poisson, Helmholtz, diffusion, and wave equations.
|
|
61
|
+
- **Operator splitting** utilities for nonlinear PDEs such as Allen--Cahn.
|
|
62
|
+
- **Nonlinear examples** for Allen--Cahn and 1D periodic viscous Burgers.
|
|
63
|
+
- **Periodic incompressible flow** via 2D vorticity-streamfunction Navier--Stokes.
|
|
64
|
+
- **Schrödinger/paraxial propagation** for optical-style complex wave fields.
|
|
65
|
+
- **FFT/DCT/DST transforms** for periodic, Dirichlet, and Neumann boundary
|
|
66
|
+
conditions.
|
|
67
|
+
- **Robin boundary support** through specialized fallbacks and finite-difference
|
|
68
|
+
projection helpers.
|
|
69
|
+
- **PyTorch backend** for periodic FFT solvers on CPU or CUDA GPUs.
|
|
70
|
+
- **Backend diagnostics** with `return_info=True` and capability flags.
|
|
71
|
+
- **Geometry helpers** for signed-distance primitives and Boolean operations.
|
|
72
|
+
- **Experimental modules** for segmented domains and periodic solid mechanics.
|
|
73
|
+
|
|
74
|
+
## Install
|
|
75
|
+
|
|
76
|
+
Install the current release from PyPI:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install optixde
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Install optional features from PyPI as needed:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install "optixde[plot]" # Matplotlib plotting helpers
|
|
86
|
+
pip install "optixde[sparse]" # SciPy-based polygonal embedded solvers
|
|
87
|
+
pip install "optixde[gpu]" # PyTorch backend for periodic GPU FFT solvers
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
For local development:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
git clone https://github.com/yangyLab/OptiXDE.git
|
|
94
|
+
cd OptiXDE
|
|
95
|
+
pip install -e .
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
For development, optional feature groups can be installed from the checkout:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install -e ".[plot]" # Matplotlib plotting helpers and examples
|
|
102
|
+
pip install -e ".[sparse]" # SciPy-based polygonal embedded solvers
|
|
103
|
+
pip install -e ".[torch]" # PyTorch backend alias
|
|
104
|
+
pip install -e ".[gpu]" # PyTorch backend for periodic GPU FFT solvers
|
|
105
|
+
pip install -e ".[cupy]" # CuPy backend, if your CUDA/CuPy stack is ready
|
|
106
|
+
pip install -e ".[dev]" # tests, lint, plotting, sparse extras
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Quick Start
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
import numpy as np
|
|
113
|
+
from optixde.solvers import (
|
|
114
|
+
diffusion2d_solve,
|
|
115
|
+
helmholtz2d_solve,
|
|
116
|
+
poisson2d_solve,
|
|
117
|
+
wave2d_solve,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
Lx = Ly = 2.0 * np.pi
|
|
121
|
+
N = 64
|
|
122
|
+
x = np.linspace(0.0, Lx, N, endpoint=False)
|
|
123
|
+
y = np.linspace(0.0, Ly, N, endpoint=False)
|
|
124
|
+
X, Y = np.meshgrid(x, y, indexing="xy")
|
|
125
|
+
|
|
126
|
+
u_exact = np.sin(2 * X) * np.cos(3 * Y)
|
|
127
|
+
f = 13.0 * u_exact
|
|
128
|
+
|
|
129
|
+
u = poisson2d_solve(f, Lx, Ly, bc="periodic")
|
|
130
|
+
w = helmholtz2d_solve(f, Lx, Ly, k0=1.0, bc="periodic")
|
|
131
|
+
next_u = diffusion2d_solve(
|
|
132
|
+
u_exact,
|
|
133
|
+
D=0.1,
|
|
134
|
+
Lx=Lx,
|
|
135
|
+
Ly=Ly,
|
|
136
|
+
dt=0.01,
|
|
137
|
+
bc="periodic",
|
|
138
|
+
)
|
|
139
|
+
next_wave_u, next_wave_v = wave2d_solve(
|
|
140
|
+
u_exact,
|
|
141
|
+
np.zeros_like(u_exact),
|
|
142
|
+
c=1.0,
|
|
143
|
+
Lx=Lx,
|
|
144
|
+
Ly=Ly,
|
|
145
|
+
dt=0.01,
|
|
146
|
+
bc="periodic",
|
|
147
|
+
)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Solver Map
|
|
151
|
+
|
|
152
|
+
### Poisson
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
u = poisson2d_solve(f, Lx, Ly, bc="periodic")
|
|
156
|
+
u = poisson2d_solve(f, Lx, Ly, bc="dirichlet")
|
|
157
|
+
u = poisson2d_solve(f, Lx, Ly, bc="neumann")
|
|
158
|
+
u = poisson2d_solve(f, Lx, Ly, bc="robin", robin=(alpha, beta, g))
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Periodic and Neumann Poisson problems require `mean(f) = 0`; OptiXDE enforces
|
|
162
|
+
this by default and fixes the additive constant with a zero-mean gauge.
|
|
163
|
+
|
|
164
|
+
### Helmholtz
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
u = helmholtz2d_solve(f, Lx, Ly, k0=1.0, bc="periodic")
|
|
168
|
+
u = helmholtz2d_solve(f, Lx, Ly, k0=1.0, bc="dirichlet")
|
|
169
|
+
u = helmholtz2d_solve(f, Lx, Ly, k0=1.0, bc="neumann")
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`k0 > 0` makes the operator strictly elliptic, so no zero-mean constraint is
|
|
173
|
+
needed.
|
|
174
|
+
|
|
175
|
+
### Diffusion
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
u = diffusion2d_solve(u0, D, Lx, Ly, dt, bc="periodic")
|
|
179
|
+
u = diffusion2d_solve(u0, D, Lx, Ly, dt, bc="dirichlet")
|
|
180
|
+
u = diffusion2d_solve(u0, D, Lx, Ly, dt, bc="neumann")
|
|
181
|
+
u = diffusion2d_solve(u0, D, Lx, Ly, dt, bc="robin", robin=(alpha, beta, g))
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Periodic diffusion also supports an ETD1 source term through `source=`.
|
|
185
|
+
|
|
186
|
+
### Wave
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
u, v = wave2d_solve(u0, v0, c, Lx, Ly, dt, bc="periodic")
|
|
190
|
+
u, v = wave2d_solve(u0, v0, c, Lx, Ly, dt, bc="dirichlet")
|
|
191
|
+
u, v = wave2d_solve(u0, v0, c, Lx, Ly, dt, bc="neumann")
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The wave solver advances the first-order state `(u, v)` for `u_tt = c^2 Δu`
|
|
195
|
+
with an exact spectral update for each mode. With `return_info=True`, it returns
|
|
196
|
+
`u_next, v_next, info`.
|
|
197
|
+
|
|
198
|
+
## Boundary Conditions
|
|
199
|
+
|
|
200
|
+
| Boundary condition | Poisson | Helmholtz | Diffusion | Wave | Notes |
|
|
201
|
+
| --- | --- | --- | --- | --- | --- |
|
|
202
|
+
| `periodic` | Yes | Yes | Yes | Yes | FFT-based; supports NumPy, Torch, and CuPy backends. |
|
|
203
|
+
| `dirichlet` | Yes | Yes | Yes | Yes | DST-based rectangular-domain solver. |
|
|
204
|
+
| `neumann` | Yes | Yes | Yes | Yes | DCT-based rectangular-domain solver; Poisson uses a zero-mean gauge. |
|
|
205
|
+
| `robin` | Yes | No | Yes | No | Uses exact Dirichlet/Neumann fallbacks where possible and penalty/projection helpers otherwise. |
|
|
206
|
+
|
|
207
|
+
The older `mode=` keyword remains accepted as a compatibility alias for `bc=`.
|
|
208
|
+
|
|
209
|
+
## Backends And GPU
|
|
210
|
+
|
|
211
|
+
The default backend is NumPy:
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
u = poisson2d_solve(f, Lx, Ly, bc="periodic", backend_name="numpy")
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
For GPU work, PyTorch is the recommended path:
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
u = poisson2d_solve(
|
|
221
|
+
f,
|
|
222
|
+
Lx,
|
|
223
|
+
Ly,
|
|
224
|
+
bc="periodic",
|
|
225
|
+
backend_name="torch",
|
|
226
|
+
device="cuda",
|
|
227
|
+
)
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Current PyTorch scope:
|
|
231
|
+
|
|
232
|
+
- Supported: periodic Poisson, Helmholtz, diffusion, wave, Burgers,
|
|
233
|
+
vorticity-streamfunction Navier--Stokes, and Schrödinger FFT paths.
|
|
234
|
+
- Supported: CPU tensors and CUDA tensors, depending on your PyTorch install.
|
|
235
|
+
- Not yet supported: Torch DCT/DST paths for Dirichlet and Neumann solvers.
|
|
236
|
+
|
|
237
|
+
For Colab GPU validation, see `docs/colab_torch_gpu.md`.
|
|
238
|
+
|
|
239
|
+
## Diagnostics
|
|
240
|
+
|
|
241
|
+
Backends expose lightweight capability flags:
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
from optixde.fft_backend import get_backend
|
|
245
|
+
|
|
246
|
+
backend = get_backend("torch", device="cuda")
|
|
247
|
+
print(backend.capabilities)
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Solver entry points can return metadata with `return_info=True`:
|
|
251
|
+
|
|
252
|
+
```python
|
|
253
|
+
u, info = poisson2d_solve(
|
|
254
|
+
f,
|
|
255
|
+
Lx,
|
|
256
|
+
Ly,
|
|
257
|
+
bc="periodic",
|
|
258
|
+
backend_name="torch",
|
|
259
|
+
device="cuda",
|
|
260
|
+
return_info=True,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
print(info["backend"], info["device"], info["bc"], info["transform"])
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Common `info` fields are stable across solvers:
|
|
267
|
+
|
|
268
|
+
- `solver`, `equation`, `bc`, `transform`: which equation and numerical path ran.
|
|
269
|
+
- `backend`, `device`, `capabilities`: NumPy/Torch/CuPy backend and feature flags.
|
|
270
|
+
- `input_shape`, `output_shape`, `input_dtype`, `output_dtype`: array metadata.
|
|
271
|
+
- PDE extras such as `dt`, `viscosity`, `epsilon`, `wave_speed`, or `coefficient`.
|
|
272
|
+
|
|
273
|
+
This is useful for tests, benchmarks, Colab runs, and checking whether a solve
|
|
274
|
+
used FFT, DCT, DST, operator splitting, or a fallback path.
|
|
275
|
+
|
|
276
|
+
## Examples
|
|
277
|
+
|
|
278
|
+
Example scripts live under `examples/`:
|
|
279
|
+
|
|
280
|
+
- `examples/base/`: core PDE demos and rectangular-domain experiments.
|
|
281
|
+
- `examples/benchmarks/`: CPU/GPU backend timing scripts and benchmark cases.
|
|
282
|
+
- `examples/solid/`: periodic solid-mechanics demos.
|
|
283
|
+
- `examples/demo_post.py`: plotting helper demo.
|
|
284
|
+
|
|
285
|
+
See `examples/README.md` for a command index.
|
|
286
|
+
|
|
287
|
+
Run a small backend benchmark:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
python examples/benchmarks/torch_fft_backend_benchmark.py --device cpu --sizes 64 128
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
On a CUDA machine or Colab runtime:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
python examples/benchmarks/colab_torch_gpu_smoke.py --device cuda --n 256
|
|
297
|
+
python examples/benchmarks/torch_fft_backend_benchmark.py --device cuda --sizes 512 1024
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Run the paper-style wave examples:
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
python examples/base/wave_single_mode_phase.py --sizes 128 256 512
|
|
304
|
+
python examples/base/wave_gaussian_packet.py --n 256
|
|
305
|
+
python examples/base/wave_gaussian_packet.py --n 192 --sigma 0.28 --center-x 3.141592653589793 --center-y 3.141592653589793 --T 6 --animation-output output/animations/wave/gaussian_packet.gif
|
|
306
|
+
python examples/base/wave_section_6_3_reproduction.py --output-dir examples/artifacts/section_6_3_wave
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Run the nonlinear Allen--Cahn splitting example:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
python examples/base/allen_cahn_splitting.py --n 128 --T 0.1
|
|
313
|
+
python examples/base/burgers_1d_periodic.py --n 256 --T 1.0
|
|
314
|
+
python examples/base/burgers_1d_periodic.py --backend torch --device cuda --n 1024 --T 1.0
|
|
315
|
+
python examples/base/burgers_section_reproduction.py --n 256 --ref-n 2048 --output-dir examples/artifacts/burgers_section --scan
|
|
316
|
+
python examples/base/navier_stokes_taylor_green.py --n 128 --T 1.0
|
|
317
|
+
python examples/base/navier_stokes_cylinder_brinkman.py --nx 128 --ny 64 --steps 1000 --plot --output examples/artifacts/navier_stokes_cylinder_brinkman.png --history-output examples/artifacts/navier_stokes_cylinder_brinkman_history.csv --history-figure examples/artifacts/navier_stokes_cylinder_brinkman_history.png --summary-output examples/artifacts/navier_stokes_cylinder_summary.csv --wake-figure examples/artifacts/navier_stokes_cylinder_wake.png --spectrum-figure examples/artifacts/navier_stokes_cylinder_spectrum.png
|
|
318
|
+
python examples/base/navier_stokes_cylinder_brinkman.py --nx 160 --ny 80 --steps 16000 --dt 0.001 --viscosity 0.005 --forcing 0.05 --perturbation 0.08 --penalty-eta 0.002 --animation-output output/animations/navier_stokes/cylinder_wake_vorticity.gif --animation-stride 200 --animation-vmax 8 --quiet
|
|
319
|
+
python examples/base/navier_stokes_cylinder_brinkman.py --nx 128 --ny 64 --steps 5000 --report-every 10 --quiet
|
|
320
|
+
python examples/base/navier_stokes_cylinder_brinkman.py --nx 96 --ny 48 --steps 400 --scan --scan-viscosity 0.002 0.0036 --scan-forcing 0.1 0.15 --scan-output examples/artifacts/navier_stokes_cylinder_scan.csv --quiet
|
|
321
|
+
python examples/base/schrodinger_gaussian_packet.py --n 128 --T 1.0
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Run the unified reference-validation table:
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
python examples/benchmarks/solver_reference_validation.py --sizes 64 128 --output examples/artifacts/solver_reference_validation.csv
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Package Layout
|
|
331
|
+
|
|
332
|
+
```text
|
|
333
|
+
optixde/
|
|
334
|
+
bc/ Robin, rasterization, and segmented-boundary helpers
|
|
335
|
+
fft_backend/ NumPy, PyTorch, CuPy, and propagator-cache utilities
|
|
336
|
+
geometry/ Signed-distance primitives and Boolean geometry
|
|
337
|
+
operators/ Spectral operators and transform helpers
|
|
338
|
+
post/ Optional Matplotlib plotting utilities
|
|
339
|
+
solvers/ Core, segmented-domain, and solid-mechanics solvers
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Primary public imports:
|
|
343
|
+
|
|
344
|
+
- `from optixde.solvers import poisson2d_solve, diffusion2d_solve, wave2d_solve`
|
|
345
|
+
- `from optixde.solvers import burgers1d_solve, navier_stokes2d_vorticity_solve`
|
|
346
|
+
- `from optixde.solvers import schrodinger2d_solve, allen_cahn2d_solve`
|
|
347
|
+
|
|
348
|
+
PDE-specific modules are also kept as stable compatibility namespaces:
|
|
349
|
+
|
|
350
|
+
- `optixde.solvers.poisson`
|
|
351
|
+
- `optixde.solvers.helmholtz`
|
|
352
|
+
- `optixde.solvers.diffusion`
|
|
353
|
+
- `optixde.solvers.wave`
|
|
354
|
+
- `optixde.solvers.splitting`
|
|
355
|
+
- `optixde.solvers.allen_cahn`
|
|
356
|
+
- `optixde.solvers.burgers`
|
|
357
|
+
- `optixde.solvers.navier_stokes`
|
|
358
|
+
- `optixde.solvers.schrodinger`
|
|
359
|
+
- `optixde.fft_backend`
|
|
360
|
+
- `optixde.geometry`
|
|
361
|
+
- `optixde.bc`
|
|
362
|
+
|
|
363
|
+
## Development
|
|
364
|
+
|
|
365
|
+
Install development extras:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
pip install -e ".[dev]"
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Run tests:
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
python -m unittest discover -s tests -p "test*.py"
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Optional checks:
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
python -m compileall -q optixde tests examples/benchmarks
|
|
381
|
+
python examples/benchmarks/solver_reference_validation.py --sizes 16 32 --burgers-ref-n 64 --burgers-dt 0.005 --burgers-ref-dt 0.0025 --burgers-T 0.02 --ns-dt 0.01 --ns-T 0.02 --wave-T 0.02
|
|
382
|
+
ruff check optixde tests
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
The test suite includes public import checks, transform checks, solver
|
|
386
|
+
diagnostics, Robin smoke tests, analytic convergence tests for the core
|
|
387
|
+
solvers, and a lightweight reference-validation benchmark used by CI. Torch GPU
|
|
388
|
+
tests are skipped automatically when PyTorch or CUDA is not available.
|
|
389
|
+
|
|
390
|
+
## Citation
|
|
391
|
+
|
|
392
|
+
If you use OptiXDE in academic work, please cite the software release and the
|
|
393
|
+
related paper or preprint when available. GitHub can read the citation metadata
|
|
394
|
+
from `CITATION.cff`.
|
|
395
|
+
|
|
396
|
+
```bibtex
|
|
397
|
+
@software{optixde2026,
|
|
398
|
+
title = {OptiXDE: optical-inspired PDE solvers},
|
|
399
|
+
author = {Yang, Yang},
|
|
400
|
+
year = {2026},
|
|
401
|
+
url = {https://github.com/yangyLab/OptiXDE},
|
|
402
|
+
version = {0.2.2},
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Release notes are tracked in `CHANGELOG.md`.
|
|
407
|
+
|
|
408
|
+
### Benchmark References
|
|
409
|
+
|
|
410
|
+
Several examples reuse published benchmark problem definitions for independent
|
|
411
|
+
OptiXDE implementations and comparisons:
|
|
412
|
+
|
|
413
|
+
- M. Raissi, P. Perdikaris, and G. E. Karniadakis, “Physics-informed neural
|
|
414
|
+
networks: A deep learning framework for solving forward and inverse problems
|
|
415
|
+
involving nonlinear partial differential equations,” *Journal of
|
|
416
|
+
Computational Physics*, 378, 686–707 (2019),
|
|
417
|
+
[doi:10.1016/j.jcp.2018.10.045](https://doi.org/10.1016/j.jcp.2018.10.045).
|
|
418
|
+
- L. Lu, X. Meng, Z. Mao, and G. E. Karniadakis, “DeepXDE: A deep learning
|
|
419
|
+
library for solving differential equations,” *SIAM Review*, 63(1), 208–228
|
|
420
|
+
(2021),
|
|
421
|
+
[doi:10.1137/19M1274067](https://doi.org/10.1137/19M1274067).
|
|
422
|
+
|
|
423
|
+
## Copyright, License, and Disclaimer
|
|
424
|
+
|
|
425
|
+
Copyright (c) 2025-2026 Yang Yang
|
|
426
|
+
<yangyhhu@foxmail.com>.
|
|
427
|
+
|
|
428
|
+
OptiXDE is open-source software distributed under the
|
|
429
|
+
[MIT License](LICENSE). You may use, copy, modify, and redistribute the
|
|
430
|
+
software subject to the terms of that license. Third-party libraries,
|
|
431
|
+
datasets, papers, and other referenced materials remain subject to their
|
|
432
|
+
respective licenses and copyrights.
|
|
433
|
+
|
|
434
|
+
OptiXDE is research software provided "as is", without warranty of any kind.
|
|
435
|
+
Numerical results should be independently verified before the software is used
|
|
436
|
+
for engineering, safety-critical, clinical, financial, or other consequential
|
|
437
|
+
decisions. The authors and contributors are not liable for losses or damages
|
|
438
|
+
arising from use of the software, to the extent permitted by applicable law.
|
|
439
|
+
|
|
440
|
+
Project information, source code, issue reporting, and release history are
|
|
441
|
+
available at [github.com/yangyLab/OptiXDE](https://github.com/yangyLab/OptiXDE).
|
|
442
|
+
|
|
443
|
+
## Project Status
|
|
444
|
+
|
|
445
|
+
OptiXDE is currently an early-stage research/development package. The stable
|
|
446
|
+
center is the rectangular-domain spectral solver stack; segmented-domain,
|
|
447
|
+
Robin, CuPy, and solid-mechanics pieces are still evolving.
|
|
448
|
+
|
|
449
|
+
When adding new solvers, keep the `-Δ` operator convention consistent across
|
|
450
|
+
the package and prefer backend-aware, matrix-free implementations where
|
|
451
|
+
possible.
|