numgrids 0.4.0__tar.gz → 0.6.0__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.
Files changed (62) hide show
  1. {numgrids-0.4.0 → numgrids-0.6.0}/LICENSE +1 -1
  2. numgrids-0.6.0/PKG-INFO +114 -0
  3. numgrids-0.6.0/README.md +192 -0
  4. numgrids-0.6.0/docs/pypi_description.md +57 -0
  5. numgrids-0.6.0/numgrids/__init__.py +133 -0
  6. numgrids-0.6.0/numgrids/amr.py +389 -0
  7. numgrids-0.6.0/numgrids/api.py +420 -0
  8. numgrids-0.6.0/numgrids/axes.py +701 -0
  9. numgrids-0.6.0/numgrids/boundary.py +633 -0
  10. numgrids-0.6.0/numgrids/convergence.py +143 -0
  11. numgrids-0.6.0/numgrids/curvilinear.py +928 -0
  12. numgrids-0.6.0/numgrids/diff.py +479 -0
  13. numgrids-0.6.0/numgrids/evolution.py +195 -0
  14. numgrids-0.6.0/numgrids/grids.py +712 -0
  15. numgrids-0.6.0/numgrids/integration.py +90 -0
  16. numgrids-0.6.0/numgrids/interpol.py +318 -0
  17. numgrids-0.6.0/numgrids/io.py +352 -0
  18. numgrids-0.6.0/numgrids/operators.py +436 -0
  19. numgrids-0.6.0/numgrids/plots.py +219 -0
  20. numgrids-0.6.0/numgrids/py.typed +0 -0
  21. numgrids-0.6.0/numgrids/utils.py +92 -0
  22. numgrids-0.6.0/numgrids.egg-info/PKG-INFO +114 -0
  23. {numgrids-0.4.0 → numgrids-0.6.0}/numgrids.egg-info/SOURCES.txt +17 -1
  24. numgrids-0.6.0/numgrids.egg-info/requires.txt +32 -0
  25. numgrids-0.6.0/pyproject.toml +99 -0
  26. numgrids-0.6.0/tests/test_amr.py +308 -0
  27. {numgrids-0.4.0 → numgrids-0.6.0}/tests/test_api.py +33 -25
  28. {numgrids-0.4.0 → numgrids-0.6.0}/tests/test_axes.py +5 -5
  29. {numgrids-0.4.0 → numgrids-0.6.0}/tests/test_boundary.py +2 -3
  30. numgrids-0.6.0/tests/test_curvilinear.py +491 -0
  31. {numgrids-0.4.0 → numgrids-0.6.0}/tests/test_diff.py +74 -3
  32. numgrids-0.6.0/tests/test_features.py +476 -0
  33. numgrids-0.6.0/tests/test_grids.py +535 -0
  34. {numgrids-0.4.0 → numgrids-0.6.0}/tests/test_integration.py +1 -1
  35. {numgrids-0.4.0 → numgrids-0.6.0}/tests/test_interpol.py +1 -1
  36. numgrids-0.6.0/tests/test_io.py +220 -0
  37. numgrids-0.6.0/tests/test_operators.py +271 -0
  38. {numgrids-0.4.0 → numgrids-0.6.0}/tests/test_plots.py +1 -2
  39. numgrids-0.6.0/tests/test_poles.py +265 -0
  40. numgrids-0.6.0/tests/test_radial.py +266 -0
  41. numgrids-0.6.0/tests/test_regressions.py +145 -0
  42. numgrids-0.6.0/tests/test_usability.py +216 -0
  43. numgrids-0.4.0/PKG-INFO +0 -39
  44. numgrids-0.4.0/README.md +0 -246
  45. numgrids-0.4.0/docs/pypi_description.md +0 -21
  46. numgrids-0.4.0/numgrids/__init__.py +0 -10
  47. numgrids-0.4.0/numgrids/api.py +0 -748
  48. numgrids-0.4.0/numgrids/axes.py +0 -357
  49. numgrids-0.4.0/numgrids/boundary.py +0 -337
  50. numgrids-0.4.0/numgrids/diff.py +0 -264
  51. numgrids-0.4.0/numgrids/grids.py +0 -303
  52. numgrids-0.4.0/numgrids/integration.py +0 -71
  53. numgrids-0.4.0/numgrids/interpol.py +0 -75
  54. numgrids-0.4.0/numgrids/plots.py +0 -77
  55. numgrids-0.4.0/numgrids/utils.py +0 -33
  56. numgrids-0.4.0/numgrids.egg-info/PKG-INFO +0 -39
  57. numgrids-0.4.0/numgrids.egg-info/requires.txt +0 -4
  58. numgrids-0.4.0/pyproject.toml +0 -30
  59. numgrids-0.4.0/tests/test_grids.py +0 -236
  60. {numgrids-0.4.0 → numgrids-0.6.0}/numgrids.egg-info/dependency_links.txt +0 -0
  61. {numgrids-0.4.0 → numgrids-0.6.0}/numgrids.egg-info/top_level.txt +0 -0
  62. {numgrids-0.4.0 → numgrids-0.6.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) [year] [fullname]
3
+ Copyright (c) 2023 Matthias Baer
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: numgrids
3
+ Version: 0.6.0
4
+ Summary: Working with numerical grids made easy.
5
+ Author-email: Matthias Baer <matthias.r.baer@googlemail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/maroba/numgrids
8
+ Project-URL: Documentation, https://maroba.github.io/numgrids/
9
+ Project-URL: Repository, https://github.com/maroba/numgrids
10
+ Project-URL: Issues, https://github.com/maroba/numgrids/issues
11
+ Project-URL: Changelog, https://maroba.github.io/numgrids/dev/changelog.html
12
+ Keywords: numerical grids,spectral methods,finite differences,chebyshev,pde,differential equations,curvilinear coordinates,scientific computing
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Intended Audience :: Education
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
25
+ Classifier: Topic :: Scientific/Engineering :: Physics
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.10
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: numpy>=1.22
31
+ Requires-Dist: scipy>=1.11
32
+ Requires-Dist: findiff>=0.10
33
+ Provides-Extra: plot
34
+ Requires-Dist: matplotlib>=3.5; extra == "plot"
35
+ Provides-Extra: xarray
36
+ Requires-Dist: xarray>=2023.1; extra == "xarray"
37
+ Provides-Extra: all
38
+ Requires-Dist: numgrids[plot,xarray]; extra == "all"
39
+ Provides-Extra: test
40
+ Requires-Dist: numgrids[all]; extra == "test"
41
+ Requires-Dist: pytest>=7; extra == "test"
42
+ Requires-Dist: pytest-cov; extra == "test"
43
+ Requires-Dist: netCDF4; extra == "test"
44
+ Provides-Extra: docs
45
+ Requires-Dist: numgrids[all]; extra == "docs"
46
+ Requires-Dist: sphinx; extra == "docs"
47
+ Requires-Dist: furo; extra == "docs"
48
+ Requires-Dist: sphinx-design; extra == "docs"
49
+ Requires-Dist: myst-parser; extra == "docs"
50
+ Requires-Dist: nbsphinx; extra == "docs"
51
+ Requires-Dist: ipython; extra == "docs"
52
+ Requires-Dist: ipykernel; extra == "docs"
53
+ Provides-Extra: dev
54
+ Requires-Dist: numgrids[docs,test]; extra == "dev"
55
+ Requires-Dist: ruff; extra == "dev"
56
+ Dynamic: license-file
57
+
58
+ <h1 align="center">numgrids</h1>
59
+ <p align="center"> Working with numerical grids made easy.</p>
60
+
61
+ Setting up numerical grids, differentiation matrices, and coordinate
62
+ transformations by hand is tedious and error-prone.
63
+ *numgrids* gives you a high-level, NumPy-friendly API that handles all of
64
+ this — so you can focus on the physics or mathematics of your problem instead
65
+ of bookkeeping grid indices and scale factors.
66
+
67
+ **Main Features**
68
+
69
+ - Numerical grids in any dimension from **equidistant**, **Chebyshev**, **logarithmic**, and **periodic** axes
70
+ - High-precision **spectral methods** (FFT + Chebyshev) selected automatically where possible
71
+ - Differentiation, integration (Clenshaw–Curtis, trapezoidal), and interpolation (spline or spectral)
72
+ - **Curvilinear coordinates**: spherical (volume and surface), cylindrical, polar, elliptic cylindrical, prolate and oblate spheroidal — or your own via scale factors
73
+ - **Full disks, cylinders, spheres and balls**: axes through the origin and the poles handle these points without coordinate singularities
74
+ - **Vector calculus**: gradient, divergence, curl, and Laplacian; volume and surface integrals
75
+ - **Operator algebra** with built-in `solve()` for boundary value problems and `eig()` for eigenvalue problems
76
+ - **Boundary conditions**: Dirichlet, Neumann, and Robin, specified per face in one line
77
+ - **Time evolution** (method of lines) for heat, wave, and Schrödinger-type equations
78
+ - **Adaptive mesh refinement**, convergence studies, multigrid hierarchies
79
+ - **Plotting**, **save / load** to `.npz`, and **xarray / NetCDF** interoperability
80
+ - Fully compatible with *NumPy* and *SciPy*
81
+
82
+ ## Installation
83
+
84
+ ```shell
85
+ pip install --upgrade numgrids
86
+ ```
87
+
88
+ Optional extras: `numgrids[plot]` (matplotlib), `numgrids[xarray]` (xarray), or `numgrids[all]`.
89
+
90
+ ## Quick Start
91
+
92
+ ```python
93
+ from numgrids import *
94
+ import numpy as np
95
+
96
+ # A 2D grid: Chebyshev points in x, periodic in y
97
+ grid = Grid(x=chebyshev(30, 0, 1), y=periodic(40))
98
+ f = grid.evaluate(lambda x, y: x**2 * np.sin(y))
99
+
100
+ df_dx = grid.diff(f, axis="x") # spectral derivative
101
+ total = grid.integrate(f**2) # integral over the domain
102
+
103
+ # Solve the Poisson equation with u = 0 on the boundary
104
+ grid = Grid(x=chebyshev(30, 0, 1), y=chebyshev(30, 0, 1))
105
+ u = grid.laplacian_operator().solve(1.0, bcs=0)
106
+
107
+ # Quantum harmonic oscillator: lowest energies 0.5, 1.5, 2.5, ...
108
+ grid = Grid(x=chebyshev(80, -10, 10))
109
+ H = -0.5 * grid.diff_operator(2) + 0.5 * grid.coords**2
110
+ energies, states = H.eig(k=4, bcs=0)
111
+ ```
112
+
113
+ Full documentation including API reference and example notebooks is available at
114
+ **[maroba.github.io/numgrids](https://maroba.github.io/numgrids/)**.
@@ -0,0 +1,192 @@
1
+ <h1 align="center">numgrids</h1>
2
+ <p align="center"> Working with numerical grids made easy. </p>
3
+
4
+ <p align="center"><a href="https://badge.fury.io/py/numgrids"> <img src="https://badge.fury.io/py/numgrids.svg?branch=main&kill_cache=1" alt="PyPI version"></a> <a href="https://github.com/maroba/numgrids/actions/workflows/checks.yml"> <img src="https://github.com/maroba/numgrids/actions/workflows/checks.yml/badge.svg" alt="build"></a><a href="https://codecov.io/gh/maroba/numgrids"> <img src="https://codecov.io/gh/maroba/numgrids/branch/main/graph/badge.svg?token=JNH9SP7BRG" alt=""></a> <a href="https://maroba.github.io/numgrids/"><img src="https://img.shields.io/badge/docs-GitHub%20Pages-blue" alt="Documentation"></a></p>
5
+
6
+ <div align="center"><img src="docs/assets/torus.png" width="25%"> <img src="docs/assets/disk320.png" width="25%"> <img src="docs/assets/cubic.png" width="25%"></div>
7
+
8
+ Setting up numerical grids, differentiation matrices, and coordinate
9
+ transformations by hand is tedious and error-prone.
10
+ *numgrids* gives you a high-level, NumPy-friendly API that handles all of
11
+ this — so you can focus on the physics or mathematics of your problem instead
12
+ of bookkeeping grid indices and scale factors.
13
+
14
+ **Main Features**
15
+
16
+ - Numerical grids in any dimension from **equidistant**, **Chebyshev**, **logarithmic**, and **periodic** axes
17
+ - High-precision **spectral methods** (FFT + Chebyshev) selected automatically where possible
18
+ - Differentiation, integration (Clenshaw–Curtis, trapezoidal), and interpolation (spline or spectral)
19
+ - **Curvilinear coordinates**: spherical (volume and surface), cylindrical, polar, elliptic cylindrical, prolate and oblate spheroidal — or your own via scale factors
20
+ - **Full disks, cylinders, spheres and balls**: axes through the origin and the poles handle these points without coordinate singularities
21
+ - **Vector calculus**: gradient, divergence, curl, and Laplacian on Cartesian and curvilinear grids; volume and surface integrals
22
+ - **Operator algebra** — write `-0.5 * D2 + V` — with built-in `solve()` for boundary value problems and `eig()` for eigenvalue problems
23
+ - **Boundary conditions**: Dirichlet, Neumann, and Robin, specified as compactly as `bcs={"x_low": 0, "x_high": Neumann(1)}`
24
+ - **Time evolution** (method of lines) for heat, wave, and Schrödinger-type equations
25
+ - **Adaptive mesh refinement**, convergence studies, multigrid hierarchies
26
+ - **Plotting**, **save / load** to `.npz`, and **xarray / NetCDF** interoperability
27
+ - Fully compatible with *NumPy* and *SciPy* (all operators export sparse matrices)
28
+
29
+ ## Installation
30
+
31
+ ```shell
32
+ pip install --upgrade numgrids
33
+ ```
34
+
35
+ Optional extras: `numgrids[plot]` (matplotlib), `numgrids[xarray]` (xarray), or `numgrids[all]`.
36
+
37
+ ## Documentation
38
+
39
+ Full documentation including user guide, API reference and example notebooks is available at
40
+ **[maroba.github.io/numgrids](https://maroba.github.io/numgrids/)**.
41
+
42
+ ## Quick Start
43
+
44
+ ### Grids, derivatives, integrals
45
+
46
+ ```python
47
+ from numgrids import *
48
+ import numpy as np
49
+
50
+ # A 2D grid: Chebyshev points in x, periodic in y. Keyword arguments name the axes.
51
+ grid = Grid(x=chebyshev(30, 0, 1), y=periodic(40, 0, 2 * np.pi))
52
+
53
+ f = grid.evaluate(lambda x, y: x**2 * np.sin(y)) # sample a function
54
+
55
+ df_dx = grid.diff(f, axis="x") # partial derivatives (spectrally accurate)
56
+ d2f_dy2 = grid.diff(f, order=2, axis="y")
57
+ lap = grid.laplacian(f)
58
+ total = grid.integrate(f**2) # integral over the whole domain
59
+ value = grid.interpolate(f, (0.3, 1.2), method="spectral")
60
+ ```
61
+
62
+ Axis types: `chebyshev(n, low, high)`, `equidistant(...)`, `periodic(...)`, `logarithmic(...)`.
63
+ The differentiation method (FFT, Chebyshev, finite differences) is chosen automatically
64
+ according to the axis type.
65
+
66
+ ### Solving PDEs
67
+
68
+ Combine operators like formulas, then solve:
69
+
70
+ ```python
71
+ # Poisson equation ∇²u = -2π² sin(πx) sin(πy) with u = 0 on the boundary
72
+ grid = Grid(x=chebyshev(30, 0, 1), y=chebyshev(30, 0, 1))
73
+ L = grid.laplacian_operator()
74
+ u = L.solve(lambda x, y: -2 * np.pi**2 * np.sin(np.pi * x) * np.sin(np.pi * y), bcs=0)
75
+
76
+ # Mixed boundary conditions per face
77
+ u = L.solve(1.0, bcs={"x_low": 0, "x_high": Neumann(0), "y_low": 0, "y_high": Robin(1, 1, 0)})
78
+ ```
79
+
80
+ Eigenvalue problems — here the quantum harmonic oscillator — come without spurious modes:
81
+
82
+ ```python
83
+ grid = Grid(x=chebyshev(80, -10, 10))
84
+ x = grid.coords
85
+ H = -0.5 * grid.diff_operator(2) + 0.5 * x**2
86
+
87
+ energies, states = H.eig(k=4, bcs=0) # [0.5, 1.5, 2.5, 3.5]
88
+ ```
89
+
90
+ Time-dependent problems are integrated with the method of lines:
91
+
92
+ ```python
93
+ grid = Grid(x=chebyshev(40, 0, 1))
94
+ result = evolve(grid, 0.1 * grid.laplacian_operator(), # heat equation u_t = 0.1 u_xx
95
+ np.sin(np.pi * grid.coords), t_span=(0, 1), bcs=0, method="BDF")
96
+ grid.plot(result.final)
97
+ ```
98
+
99
+ ### Curvilinear grids & vector calculus
100
+
101
+ ```python
102
+ grid = SphericalGrid(
103
+ chebyshev(25, 0.1, 5), # r
104
+ chebyshev(20, 0.1, np.pi - 0.1), # theta
105
+ periodic(30), # phi
106
+ )
107
+ R, Theta, Phi = grid.meshed_coords
108
+ f = R**2
109
+
110
+ grid.laplacian(f) # = 6
111
+ gr, gt, gp = grid.gradient(f) # (2r, 0, 0)
112
+ grid.divergence(gr, gt, gp) # div(grad f) = laplacian f
113
+ grid.curl(gr, gt, gp) # curl(grad f) = 0
114
+ grid.integrate(np.ones(grid.shape)) # volume of the shell (volume element included)
115
+ grid.faces["r_high"].integrate(f) # surface integral over the outer sphere
116
+ ```
117
+
118
+ `PolarGrid`, `CylindricalGrid`, `EllipticCylindricalGrid`, `ProlateSpheroidalGrid` and
119
+ `OblateSpheroidalGrid` work the same way. Any other orthogonal coordinate system can be
120
+ defined by its scale factors:
121
+
122
+ ```python
123
+ grid = CurvilinearGrid(
124
+ axis_q1, axis_q2, axis_q3,
125
+ scale_factors=(
126
+ lambda c: np.ones_like(c[0]), # h_1(q)
127
+ lambda c: c[0], # h_2(q) = q_1
128
+ lambda c: c[0] * np.sin(c[1]), # h_3(q) = q_1 sin(q_2)
129
+ ),
130
+ )
131
+ ```
132
+
133
+ ## Example Notebooks
134
+
135
+ - [Operators and solvers: Poisson, eigenmodes, time evolution](examples/operators-and-solvers.ipynb)
136
+ - [Heat equation in a rod](examples/heat-equation-rod.ipynb)
137
+ - [Poisson equation in 2D](examples/poisson-equation-2d.ipynb)
138
+ - [Quantum harmonic oscillator](examples/quantum-harmonic-oscillator.ipynb)
139
+ - [Vibrations of a drum](examples/wave-equation-drum.ipynb)
140
+ - [Spherical harmonics](examples/spherical-harmonics.ipynb)
141
+ - [Convergence study](examples/convergence-study.ipynb)
142
+ - [Adaptive mesh refinement](examples/adaptive-refinement-demo.ipynb)
143
+
144
+ ## How to Cite
145
+
146
+ If you use *numgrids* in a publication, please cite it as:
147
+
148
+ > M. Baer. *numgrids* software package. URL: https://github.com/maroba/numgrids. 2023
149
+
150
+ BibTeX entry:
151
+
152
+ ```bibtex
153
+ @misc{numgrids,
154
+ title = {{numgrids} Software Package},
155
+ author = {M. Baer},
156
+ url = {https://github.com/maroba/numgrids},
157
+ key = {numgrids},
158
+ note = {\url{https://github.com/maroba/numgrids}},
159
+ year = {2023}
160
+ }
161
+ ```
162
+
163
+ ## Development
164
+
165
+ Clone the repository and install it in development mode with all extras:
166
+
167
+ ```shell
168
+ git clone https://github.com/maroba/numgrids.git
169
+ cd numgrids
170
+ pip install -e ".[dev]"
171
+ ```
172
+
173
+ Run the tests (including the doctests in the docstrings) and the linter:
174
+
175
+ ```shell
176
+ python -m pytest
177
+ ruff check numgrids tests
178
+ ```
179
+
180
+ Build the documentation:
181
+
182
+ ```shell
183
+ sphinx-build -b html docs docs/_build/html
184
+ ```
185
+
186
+ ### Contributing
187
+
188
+ 1. Fork the repository
189
+ 2. Develop
190
+ 3. Write tests!
191
+ 4. Create an [issue](https://github.com/maroba/numgrids/issues)
192
+ 5. Create a pull request, when done
@@ -0,0 +1,57 @@
1
+ <h1 align="center">numgrids</h1>
2
+ <p align="center"> Working with numerical grids made easy.</p>
3
+
4
+ Setting up numerical grids, differentiation matrices, and coordinate
5
+ transformations by hand is tedious and error-prone.
6
+ *numgrids* gives you a high-level, NumPy-friendly API that handles all of
7
+ this — so you can focus on the physics or mathematics of your problem instead
8
+ of bookkeeping grid indices and scale factors.
9
+
10
+ **Main Features**
11
+
12
+ - Numerical grids in any dimension from **equidistant**, **Chebyshev**, **logarithmic**, and **periodic** axes
13
+ - High-precision **spectral methods** (FFT + Chebyshev) selected automatically where possible
14
+ - Differentiation, integration (Clenshaw–Curtis, trapezoidal), and interpolation (spline or spectral)
15
+ - **Curvilinear coordinates**: spherical (volume and surface), cylindrical, polar, elliptic cylindrical, prolate and oblate spheroidal — or your own via scale factors
16
+ - **Full disks, cylinders, spheres and balls**: axes through the origin and the poles handle these points without coordinate singularities
17
+ - **Vector calculus**: gradient, divergence, curl, and Laplacian; volume and surface integrals
18
+ - **Operator algebra** with built-in `solve()` for boundary value problems and `eig()` for eigenvalue problems
19
+ - **Boundary conditions**: Dirichlet, Neumann, and Robin, specified per face in one line
20
+ - **Time evolution** (method of lines) for heat, wave, and Schrödinger-type equations
21
+ - **Adaptive mesh refinement**, convergence studies, multigrid hierarchies
22
+ - **Plotting**, **save / load** to `.npz`, and **xarray / NetCDF** interoperability
23
+ - Fully compatible with *NumPy* and *SciPy*
24
+
25
+ ## Installation
26
+
27
+ ```shell
28
+ pip install --upgrade numgrids
29
+ ```
30
+
31
+ Optional extras: `numgrids[plot]` (matplotlib), `numgrids[xarray]` (xarray), or `numgrids[all]`.
32
+
33
+ ## Quick Start
34
+
35
+ ```python
36
+ from numgrids import *
37
+ import numpy as np
38
+
39
+ # A 2D grid: Chebyshev points in x, periodic in y
40
+ grid = Grid(x=chebyshev(30, 0, 1), y=periodic(40))
41
+ f = grid.evaluate(lambda x, y: x**2 * np.sin(y))
42
+
43
+ df_dx = grid.diff(f, axis="x") # spectral derivative
44
+ total = grid.integrate(f**2) # integral over the domain
45
+
46
+ # Solve the Poisson equation with u = 0 on the boundary
47
+ grid = Grid(x=chebyshev(30, 0, 1), y=chebyshev(30, 0, 1))
48
+ u = grid.laplacian_operator().solve(1.0, bcs=0)
49
+
50
+ # Quantum harmonic oscillator: lowest energies 0.5, 1.5, 2.5, ...
51
+ grid = Grid(x=chebyshev(80, -10, 10))
52
+ H = -0.5 * grid.diff_operator(2) + 0.5 * grid.coords**2
53
+ energies, states = H.eig(k=4, bcs=0)
54
+ ```
55
+
56
+ Full documentation including API reference and example notebooks is available at
57
+ **[maroba.github.io/numgrids](https://maroba.github.io/numgrids/)**.
@@ -0,0 +1,133 @@
1
+ """numgrids -- working with numerical grids made easy."""
2
+
3
+ from importlib.metadata import PackageNotFoundError as _PackageNotFoundError
4
+ from importlib.metadata import version as _version
5
+
6
+ try:
7
+ __version__ = _version("numgrids")
8
+ except _PackageNotFoundError: # pragma: no cover - running from a source tree
9
+ __version__ = "0.0.0+unknown"
10
+
11
+ # Import the ``numgrids.diff`` submodule eagerly: importing it lazily later
12
+ # would rebind the package attribute ``numgrids.diff`` from the function
13
+ # (imported below) to the module.
14
+ from . import diff as _diff_module # noqa: F401, I001
15
+ from .amr import AdaptationResult, ErrorEstimator, adapt, estimate_error
16
+ from .api import (
17
+ AxisType,
18
+ Diff,
19
+ chebyshev,
20
+ colatitude,
21
+ create_axis,
22
+ diff,
23
+ equidistant,
24
+ integrate,
25
+ interpolate,
26
+ logarithmic,
27
+ periodic,
28
+ radial,
29
+ )
30
+ from .axes import ChebyshevAxis, ColatitudeAxis, EquidistantAxis, LogAxis, RadialAxis
31
+ from .boundary import (
32
+ BoundaryFace,
33
+ Dirichlet,
34
+ DirichletBC,
35
+ Neumann,
36
+ NeumannBC,
37
+ Robin,
38
+ RobinBC,
39
+ apply_bcs,
40
+ resolve_bcs,
41
+ )
42
+ from .convergence import ConvergenceResult, convergence_study
43
+ from .curvilinear import (
44
+ CurvilinearGrid,
45
+ CylindricalGrid,
46
+ EllipticCylindricalGrid,
47
+ OblateSpheroidalGrid,
48
+ PolarGrid,
49
+ ProlateSpheroidalGrid,
50
+ SphericalGrid,
51
+ SphericalSurfaceGrid,
52
+ )
53
+ from .evolution import EvolutionResult, evolve
54
+ from .grids import Grid, MultiGrid
55
+ from .integration import Integral
56
+ from .interpol import Interpolator
57
+ from .io import from_xarray, load_grid, save_grid, to_xarray
58
+ from .operators import Operator
59
+
60
+
61
+ def Axis(*args, **kwargs):
62
+ """Deprecated alias of :func:`create_axis`.
63
+
64
+ .. deprecated:: 0.5.0
65
+ Use :func:`create_axis` or the short-hand factories
66
+ :func:`chebyshev`, :func:`equidistant`, :func:`periodic` and
67
+ :func:`logarithmic` instead. The axis base class lives in
68
+ :mod:`numgrids.axes`.
69
+ """
70
+ import warnings
71
+ warnings.warn(
72
+ "numgrids.Axis is deprecated; use numgrids.create_axis (or chebyshev, "
73
+ "equidistant, periodic, logarithmic) instead.",
74
+ DeprecationWarning,
75
+ stacklevel=2,
76
+ )
77
+ return create_axis(*args, **kwargs)
78
+
79
+
80
+ __all__ = [
81
+ "AdaptationResult",
82
+ "Axis",
83
+ "AxisType",
84
+ "BoundaryFace",
85
+ "ChebyshevAxis",
86
+ "ColatitudeAxis",
87
+ "ConvergenceResult",
88
+ "CurvilinearGrid",
89
+ "CylindricalGrid",
90
+ "Diff",
91
+ "Dirichlet",
92
+ "DirichletBC",
93
+ "EllipticCylindricalGrid",
94
+ "EquidistantAxis",
95
+ "ErrorEstimator",
96
+ "EvolutionResult",
97
+ "Grid",
98
+ "Integral",
99
+ "Interpolator",
100
+ "LogAxis",
101
+ "MultiGrid",
102
+ "Neumann",
103
+ "NeumannBC",
104
+ "OblateSpheroidalGrid",
105
+ "Operator",
106
+ "PolarGrid",
107
+ "ProlateSpheroidalGrid",
108
+ "RadialAxis",
109
+ "Robin",
110
+ "RobinBC",
111
+ "SphericalGrid",
112
+ "SphericalSurfaceGrid",
113
+ "adapt",
114
+ "apply_bcs",
115
+ "chebyshev",
116
+ "colatitude",
117
+ "convergence_study",
118
+ "create_axis",
119
+ "diff",
120
+ "equidistant",
121
+ "estimate_error",
122
+ "evolve",
123
+ "from_xarray",
124
+ "integrate",
125
+ "interpolate",
126
+ "load_grid",
127
+ "logarithmic",
128
+ "periodic",
129
+ "radial",
130
+ "resolve_bcs",
131
+ "save_grid",
132
+ "to_xarray",
133
+ ]