jqnm 0.1.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.
- jqnm-0.1.0/LICENSE +25 -0
- jqnm-0.1.0/MANIFEST.in +6 -0
- jqnm-0.1.0/PKG-INFO +218 -0
- jqnm-0.1.0/README.md +173 -0
- jqnm-0.1.0/jqnm/LICENSE +25 -0
- jqnm-0.1.0/jqnm/__init__.py +113 -0
- jqnm-0.1.0/jqnm/_version.py +1 -0
- jqnm-0.1.0/jqnm/angular.py +432 -0
- jqnm-0.1.0/jqnm/cached.py +660 -0
- jqnm-0.1.0/jqnm/contfrac.py +166 -0
- jqnm-0.1.0/jqnm/nearby.py +329 -0
- jqnm-0.1.0/jqnm/radial.py +229 -0
- jqnm-0.1.0/jqnm/schwarzschild/__init__.py +13 -0
- jqnm-0.1.0/jqnm/schwarzschild/approx.py +151 -0
- jqnm-0.1.0/jqnm/schwarzschild/data/Schw_dict.npz +0 -0
- jqnm-0.1.0/jqnm/schwarzschild/overtonesequence.py +266 -0
- jqnm-0.1.0/jqnm/schwarzschild/tabulated.py +266 -0
- jqnm-0.1.0/jqnm/spinsequence.py +489 -0
- jqnm-0.1.0/jqnm.egg-info/PKG-INFO +218 -0
- jqnm-0.1.0/jqnm.egg-info/SOURCES.txt +27 -0
- jqnm-0.1.0/jqnm.egg-info/dependency_links.txt +1 -0
- jqnm-0.1.0/jqnm.egg-info/requires.txt +22 -0
- jqnm-0.1.0/jqnm.egg-info/top_level.txt +1 -0
- jqnm-0.1.0/pyproject.toml +82 -0
- jqnm-0.1.0/requirements.txt +14 -0
- jqnm-0.1.0/setup.cfg +4 -0
- jqnm-0.1.0/test/test_comparison_qnm.py +577 -0
- jqnm-0.1.0/test/test_jax.py +107 -0
- jqnm-0.1.0/test/test_qnm.py +256 -0
jqnm-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Cedric Ewen
|
|
4
|
+
Copyright (c) 2019 Leo C. Stein (original qnm package)
|
|
5
|
+
|
|
6
|
+
This package is derived from the qnm package (https://github.com/duetosymmetry/qnm)
|
|
7
|
+
by Leo C. Stein, which is also MIT licensed.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
jqnm-0.1.0/MANIFEST.in
ADDED
jqnm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jqnm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: JAX-accelerated package for computing Kerr quasinormal mode frequencies with automatic differentiation support
|
|
5
|
+
Author-email: Cedric Ewen <chessdric@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ewencedr/jqnm
|
|
8
|
+
Project-URL: Repository, https://github.com/ewencedr/jqnm
|
|
9
|
+
Project-URL: Issues, https://github.com/ewencedr/jqnm/issues
|
|
10
|
+
Project-URL: Original Package, https://github.com/duetosymmetry/qnm
|
|
11
|
+
Keywords: black holes,quasinormal modes,physics,scientific computing,numerical methods,jax,gpu,differentiable,gravitational waves
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Classifier: Development Status :: 4 - Beta
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: numpy
|
|
27
|
+
Requires-Dist: scipy
|
|
28
|
+
Requires-Dist: jax>=0.4.28
|
|
29
|
+
Requires-Dist: optimistix>=0.0.6
|
|
30
|
+
Requires-Dist: equinox>=0.11.0
|
|
31
|
+
Requires-Dist: tqdm
|
|
32
|
+
Provides-Extra: cuda12
|
|
33
|
+
Requires-Dist: jax[cuda12]; extra == "cuda12"
|
|
34
|
+
Provides-Extra: cuda11
|
|
35
|
+
Requires-Dist: jax[cuda11]; extra == "cuda11"
|
|
36
|
+
Provides-Extra: test
|
|
37
|
+
Requires-Dist: pytest; extra == "test"
|
|
38
|
+
Requires-Dist: qnm; extra == "test"
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: pytest; extra == "dev"
|
|
41
|
+
Requires-Dist: qnm; extra == "dev"
|
|
42
|
+
Requires-Dist: black; extra == "dev"
|
|
43
|
+
Requires-Dist: ruff; extra == "dev"
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
# jqnm - JAX-Accelerated Kerr Quasinormal Modes
|
|
47
|
+
|
|
48
|
+
[](https://badge.fury.io/py/jqnm)
|
|
49
|
+
[](LICENSE)
|
|
50
|
+
|
|
51
|
+
`jqnm` is a JAX-accelerated Python package for computing Kerr black hole
|
|
52
|
+
quasinormal mode frequencies, angular separation constants, and
|
|
53
|
+
spherical-spheroidal mixing coefficients.
|
|
54
|
+
|
|
55
|
+
This package is a **JAX-based rewrite** of the excellent [qnm](https://github.com/duetosymmetry/qnm)
|
|
56
|
+
package by [Leo C. Stein](https://duetosymmetry.com), providing:
|
|
57
|
+
|
|
58
|
+
- **GPU acceleration** via JAX
|
|
59
|
+
- **Automatic differentiation** - compute gradients of QNM frequencies with respect to spin
|
|
60
|
+
- **JIT compilation** for faster repeated computations
|
|
61
|
+
- **Automatic caching** - modes computed once and cached at `~/.jqnm/`
|
|
62
|
+
- Full compatibility with the original `qnm` package interface
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
### PyPI
|
|
67
|
+
|
|
68
|
+
```shell
|
|
69
|
+
pip install jqnm
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### From source
|
|
73
|
+
|
|
74
|
+
```shell
|
|
75
|
+
git clone https://github.com/ewencedr/jqnm.git
|
|
76
|
+
cd jqnm
|
|
77
|
+
pip install .
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### GPU Support
|
|
81
|
+
|
|
82
|
+
For GPU acceleration, install JAX with CUDA support:
|
|
83
|
+
|
|
84
|
+
```shell
|
|
85
|
+
# For CUDA 12
|
|
86
|
+
pip install jqnm[cuda12]
|
|
87
|
+
|
|
88
|
+
# For CUDA 11
|
|
89
|
+
pip install jqnm[cuda11]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Dependencies
|
|
93
|
+
|
|
94
|
+
- numpy
|
|
95
|
+
- scipy
|
|
96
|
+
- [JAX](https://github.com/google/jax) (>=0.4.28)
|
|
97
|
+
- [optimistix](https://github.com/patrick-kidger/optimistix) - differentiable root finding
|
|
98
|
+
- [equinox](https://github.com/patrick-kidger/equinox)
|
|
99
|
+
- tqdm (for download progress)
|
|
100
|
+
|
|
101
|
+
## Quick Start
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
import jqnm
|
|
105
|
+
|
|
106
|
+
# Get the (2,2,0) gravitational mode
|
|
107
|
+
# On first use, modes are computed and cached automatically
|
|
108
|
+
grav_220 = jqnm.modes_cache(s=-2, l=2, m=2, n=0)
|
|
109
|
+
|
|
110
|
+
# Compute QNM frequency at spin a=0.68
|
|
111
|
+
omega, A, C = grav_220(a=0.68)
|
|
112
|
+
print(omega)
|
|
113
|
+
# (0.5239751042900859-0.08151262363117728j)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Modes are automatically computed on first use and cached to `~/.jqnm/data/` for subsequent runs.
|
|
117
|
+
|
|
118
|
+
> **Note:** `import jqnm` enables 64-bit precision in JAX
|
|
119
|
+
> (`jax.config.update("jax_enable_x64", True)`), because the continued-fraction
|
|
120
|
+
> root finding needs double precision. The setting is global, so it applies to
|
|
121
|
+
> all JAX code in the same process.
|
|
122
|
+
|
|
123
|
+
## Automatic Differentiation
|
|
124
|
+
|
|
125
|
+
One of the key features of `jqnm` is the ability to compute gradients:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
import jax
|
|
129
|
+
import jax.numpy as jnp
|
|
130
|
+
import jqnm
|
|
131
|
+
|
|
132
|
+
# Get a mode
|
|
133
|
+
mode = jqnm.modes_cache(s=-2, l=2, m=2, n=0)
|
|
134
|
+
|
|
135
|
+
# Define a function that returns the real part of omega
|
|
136
|
+
def get_omega_real(a):
|
|
137
|
+
omega, A, C = mode(a=a)
|
|
138
|
+
return jnp.real(omega)
|
|
139
|
+
|
|
140
|
+
# Compute the derivative with respect to spin
|
|
141
|
+
d_omega_da = jax.grad(get_omega_real)
|
|
142
|
+
print(d_omega_da(0.5))
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Usage
|
|
146
|
+
|
|
147
|
+
The highest-level interface is via `jqnm.modes_cache`, which loads cached
|
|
148
|
+
*spin sequences* from disk or computes them on first use. A spin sequence is
|
|
149
|
+
a mode labeled by (s,l,m,n), with the spin `a` ranging from a=0 to some maximum
|
|
150
|
+
(e.g., 0.9995).
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
import jqnm
|
|
154
|
+
import numpy as np
|
|
155
|
+
import matplotlib.pyplot as plt
|
|
156
|
+
|
|
157
|
+
# Get multiple overtones
|
|
158
|
+
s, l, m = (-2, 2, 2)
|
|
159
|
+
mode_list = [(s, l, m, n) for n in np.arange(0, 7)]
|
|
160
|
+
modes = {ind: jqnm.modes_cache(*ind) for ind in mode_list}
|
|
161
|
+
|
|
162
|
+
# Plot omega trajectories
|
|
163
|
+
plt.figure(figsize=(10, 4))
|
|
164
|
+
plt.subplot(1, 2, 1)
|
|
165
|
+
for mode, seq in modes.items():
|
|
166
|
+
plt.plot(np.real(seq.omega), np.imag(seq.omega))
|
|
167
|
+
plt.xlabel('Re(ω)')
|
|
168
|
+
plt.ylabel('Im(ω)')
|
|
169
|
+
plt.title('QNM Frequencies')
|
|
170
|
+
|
|
171
|
+
plt.subplot(1, 2, 2)
|
|
172
|
+
for mode, seq in modes.items():
|
|
173
|
+
plt.plot(np.real(seq.A), np.imag(seq.A))
|
|
174
|
+
plt.xlabel('Re(A)')
|
|
175
|
+
plt.ylabel('Im(A)')
|
|
176
|
+
plt.title('Separation Constants')
|
|
177
|
+
plt.tight_layout()
|
|
178
|
+
plt.show()
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Spherical-Spheroidal Decomposition
|
|
182
|
+
|
|
183
|
+
The angular dependence of QNMs are spin-weighted *spheroidal* harmonics.
|
|
184
|
+
The package returns coefficients C for expressing spheroidals in terms of
|
|
185
|
+
sphericals:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
import jqnm
|
|
189
|
+
|
|
190
|
+
grav_220 = jqnm.modes_cache(s=-2, l=2, m=2, n=0)
|
|
191
|
+
omega, A, C = grav_220(a=0.68)
|
|
192
|
+
|
|
193
|
+
# Get the corresponding l values
|
|
194
|
+
ells = jqnm.angular.ells(s=-2, m=2, l_max=grav_220.l_max)
|
|
195
|
+
print(f"ell values: {ells}")
|
|
196
|
+
print(f"C coefficients: {C}")
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Credits and Acknowledgments
|
|
200
|
+
|
|
201
|
+
This package is a JAX-based rewrite of the [qnm](https://github.com/duetosymmetry/qnm)
|
|
202
|
+
package created by [Leo C. Stein](https://duetosymmetry.com). The original package
|
|
203
|
+
and its scientific foundations are described in:
|
|
204
|
+
|
|
205
|
+
> Stein, Leo C. (2019). *qnm: A Python package for calculating Kerr quasinormal
|
|
206
|
+
> modes, separation constants, and spherical-spheroidal mixing coefficients.*
|
|
207
|
+
> Journal of Open Source Software, 4(42), 1683.
|
|
208
|
+
> [doi:10.21105/joss.01683](https://doi.org/10.21105/joss.01683)
|
|
209
|
+
> [arXiv:1908.10377](https://arxiv.org/abs/1908.10377)
|
|
210
|
+
|
|
211
|
+
If you use this package in academic work, please cite the original `qnm` paper above.
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
216
|
+
|
|
217
|
+
This package is derived from [qnm](https://github.com/duetosymmetry/qnm)
|
|
218
|
+
(Copyright © 2019 Leo C. Stein), which is also MIT licensed.
|
jqnm-0.1.0/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# jqnm - JAX-Accelerated Kerr Quasinormal Modes
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/jqnm)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
`jqnm` is a JAX-accelerated Python package for computing Kerr black hole
|
|
7
|
+
quasinormal mode frequencies, angular separation constants, and
|
|
8
|
+
spherical-spheroidal mixing coefficients.
|
|
9
|
+
|
|
10
|
+
This package is a **JAX-based rewrite** of the excellent [qnm](https://github.com/duetosymmetry/qnm)
|
|
11
|
+
package by [Leo C. Stein](https://duetosymmetry.com), providing:
|
|
12
|
+
|
|
13
|
+
- **GPU acceleration** via JAX
|
|
14
|
+
- **Automatic differentiation** - compute gradients of QNM frequencies with respect to spin
|
|
15
|
+
- **JIT compilation** for faster repeated computations
|
|
16
|
+
- **Automatic caching** - modes computed once and cached at `~/.jqnm/`
|
|
17
|
+
- Full compatibility with the original `qnm` package interface
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
### PyPI
|
|
22
|
+
|
|
23
|
+
```shell
|
|
24
|
+
pip install jqnm
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### From source
|
|
28
|
+
|
|
29
|
+
```shell
|
|
30
|
+
git clone https://github.com/ewencedr/jqnm.git
|
|
31
|
+
cd jqnm
|
|
32
|
+
pip install .
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### GPU Support
|
|
36
|
+
|
|
37
|
+
For GPU acceleration, install JAX with CUDA support:
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
# For CUDA 12
|
|
41
|
+
pip install jqnm[cuda12]
|
|
42
|
+
|
|
43
|
+
# For CUDA 11
|
|
44
|
+
pip install jqnm[cuda11]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Dependencies
|
|
48
|
+
|
|
49
|
+
- numpy
|
|
50
|
+
- scipy
|
|
51
|
+
- [JAX](https://github.com/google/jax) (>=0.4.28)
|
|
52
|
+
- [optimistix](https://github.com/patrick-kidger/optimistix) - differentiable root finding
|
|
53
|
+
- [equinox](https://github.com/patrick-kidger/equinox)
|
|
54
|
+
- tqdm (for download progress)
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import jqnm
|
|
60
|
+
|
|
61
|
+
# Get the (2,2,0) gravitational mode
|
|
62
|
+
# On first use, modes are computed and cached automatically
|
|
63
|
+
grav_220 = jqnm.modes_cache(s=-2, l=2, m=2, n=0)
|
|
64
|
+
|
|
65
|
+
# Compute QNM frequency at spin a=0.68
|
|
66
|
+
omega, A, C = grav_220(a=0.68)
|
|
67
|
+
print(omega)
|
|
68
|
+
# (0.5239751042900859-0.08151262363117728j)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Modes are automatically computed on first use and cached to `~/.jqnm/data/` for subsequent runs.
|
|
72
|
+
|
|
73
|
+
> **Note:** `import jqnm` enables 64-bit precision in JAX
|
|
74
|
+
> (`jax.config.update("jax_enable_x64", True)`), because the continued-fraction
|
|
75
|
+
> root finding needs double precision. The setting is global, so it applies to
|
|
76
|
+
> all JAX code in the same process.
|
|
77
|
+
|
|
78
|
+
## Automatic Differentiation
|
|
79
|
+
|
|
80
|
+
One of the key features of `jqnm` is the ability to compute gradients:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
import jax
|
|
84
|
+
import jax.numpy as jnp
|
|
85
|
+
import jqnm
|
|
86
|
+
|
|
87
|
+
# Get a mode
|
|
88
|
+
mode = jqnm.modes_cache(s=-2, l=2, m=2, n=0)
|
|
89
|
+
|
|
90
|
+
# Define a function that returns the real part of omega
|
|
91
|
+
def get_omega_real(a):
|
|
92
|
+
omega, A, C = mode(a=a)
|
|
93
|
+
return jnp.real(omega)
|
|
94
|
+
|
|
95
|
+
# Compute the derivative with respect to spin
|
|
96
|
+
d_omega_da = jax.grad(get_omega_real)
|
|
97
|
+
print(d_omega_da(0.5))
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Usage
|
|
101
|
+
|
|
102
|
+
The highest-level interface is via `jqnm.modes_cache`, which loads cached
|
|
103
|
+
*spin sequences* from disk or computes them on first use. A spin sequence is
|
|
104
|
+
a mode labeled by (s,l,m,n), with the spin `a` ranging from a=0 to some maximum
|
|
105
|
+
(e.g., 0.9995).
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
import jqnm
|
|
109
|
+
import numpy as np
|
|
110
|
+
import matplotlib.pyplot as plt
|
|
111
|
+
|
|
112
|
+
# Get multiple overtones
|
|
113
|
+
s, l, m = (-2, 2, 2)
|
|
114
|
+
mode_list = [(s, l, m, n) for n in np.arange(0, 7)]
|
|
115
|
+
modes = {ind: jqnm.modes_cache(*ind) for ind in mode_list}
|
|
116
|
+
|
|
117
|
+
# Plot omega trajectories
|
|
118
|
+
plt.figure(figsize=(10, 4))
|
|
119
|
+
plt.subplot(1, 2, 1)
|
|
120
|
+
for mode, seq in modes.items():
|
|
121
|
+
plt.plot(np.real(seq.omega), np.imag(seq.omega))
|
|
122
|
+
plt.xlabel('Re(ω)')
|
|
123
|
+
plt.ylabel('Im(ω)')
|
|
124
|
+
plt.title('QNM Frequencies')
|
|
125
|
+
|
|
126
|
+
plt.subplot(1, 2, 2)
|
|
127
|
+
for mode, seq in modes.items():
|
|
128
|
+
plt.plot(np.real(seq.A), np.imag(seq.A))
|
|
129
|
+
plt.xlabel('Re(A)')
|
|
130
|
+
plt.ylabel('Im(A)')
|
|
131
|
+
plt.title('Separation Constants')
|
|
132
|
+
plt.tight_layout()
|
|
133
|
+
plt.show()
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Spherical-Spheroidal Decomposition
|
|
137
|
+
|
|
138
|
+
The angular dependence of QNMs are spin-weighted *spheroidal* harmonics.
|
|
139
|
+
The package returns coefficients C for expressing spheroidals in terms of
|
|
140
|
+
sphericals:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
import jqnm
|
|
144
|
+
|
|
145
|
+
grav_220 = jqnm.modes_cache(s=-2, l=2, m=2, n=0)
|
|
146
|
+
omega, A, C = grav_220(a=0.68)
|
|
147
|
+
|
|
148
|
+
# Get the corresponding l values
|
|
149
|
+
ells = jqnm.angular.ells(s=-2, m=2, l_max=grav_220.l_max)
|
|
150
|
+
print(f"ell values: {ells}")
|
|
151
|
+
print(f"C coefficients: {C}")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Credits and Acknowledgments
|
|
155
|
+
|
|
156
|
+
This package is a JAX-based rewrite of the [qnm](https://github.com/duetosymmetry/qnm)
|
|
157
|
+
package created by [Leo C. Stein](https://duetosymmetry.com). The original package
|
|
158
|
+
and its scientific foundations are described in:
|
|
159
|
+
|
|
160
|
+
> Stein, Leo C. (2019). *qnm: A Python package for calculating Kerr quasinormal
|
|
161
|
+
> modes, separation constants, and spherical-spheroidal mixing coefficients.*
|
|
162
|
+
> Journal of Open Source Software, 4(42), 1683.
|
|
163
|
+
> [doi:10.21105/joss.01683](https://doi.org/10.21105/joss.01683)
|
|
164
|
+
> [arXiv:1908.10377](https://arxiv.org/abs/1908.10377)
|
|
165
|
+
|
|
166
|
+
If you use this package in academic work, please cite the original `qnm` paper above.
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
171
|
+
|
|
172
|
+
This package is derived from [qnm](https://github.com/duetosymmetry/qnm)
|
|
173
|
+
(Copyright © 2019 Leo C. Stein), which is also MIT licensed.
|
jqnm-0.1.0/jqnm/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Cedric Ewen
|
|
4
|
+
Copyright (c) 2019 Leo C. Stein (original qnm package)
|
|
5
|
+
|
|
6
|
+
This package is derived from the qnm package (https://github.com/duetosymmetry/qnm)
|
|
7
|
+
by Leo C. Stein, which is also MIT licensed.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""jqnm - JAX-accelerated Kerr quasinormal modes.
|
|
2
|
+
|
|
3
|
+
A JAX-based rewrite of the qnm package for computing Kerr black hole
|
|
4
|
+
quasinormal mode frequencies, angular separation constants, and
|
|
5
|
+
spherical-spheroidal mixing coefficients.
|
|
6
|
+
|
|
7
|
+
This package provides GPU acceleration and automatic differentiation
|
|
8
|
+
capabilities via JAX.
|
|
9
|
+
|
|
10
|
+
The highest-level interface is via :class:`jqnm.cached.KerrSeqCache`,
|
|
11
|
+
which will fetch instances of :class:`jqnm.spinsequence.KerrSpinSeq`.
|
|
12
|
+
|
|
13
|
+
Examples
|
|
14
|
+
--------
|
|
15
|
+
|
|
16
|
+
>>> import jqnm
|
|
17
|
+
>>> # Modes are computed and cached automatically on first use
|
|
18
|
+
>>> grav_220 = jqnm.modes_cache(s=-2, l=2, m=2, n=0)
|
|
19
|
+
>>> omega, A, C = grav_220(a=0.68)
|
|
20
|
+
>>> print(omega)
|
|
21
|
+
(0.5239751042900845-0.08151262363119986j)
|
|
22
|
+
|
|
23
|
+
**Members**
|
|
24
|
+
|
|
25
|
+
.. autosummary::
|
|
26
|
+
|
|
27
|
+
jqnm.download_data
|
|
28
|
+
jqnm.modes_cache
|
|
29
|
+
|
|
30
|
+
.. autofunction:: download_data
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
from __future__ import print_function, division, absolute_import
|
|
35
|
+
|
|
36
|
+
# Enable 64-bit precision in JAX
|
|
37
|
+
import jax
|
|
38
|
+
jax.config.update("jax_enable_x64", True)
|
|
39
|
+
|
|
40
|
+
from ._version import __version__
|
|
41
|
+
|
|
42
|
+
__copyright__ = "Copyright (C) 2024 Cedric Ewen"
|
|
43
|
+
__email__ = "chessdric@gmail.com"
|
|
44
|
+
__status__ = "beta"
|
|
45
|
+
__author__ = "Cedric Ewen"
|
|
46
|
+
__license__ = """
|
|
47
|
+
MIT License
|
|
48
|
+
|
|
49
|
+
Copyright (c) 2024 Cedric Ewen
|
|
50
|
+
Copyright (c) 2019 Leo C. Stein (original qnm package)
|
|
51
|
+
|
|
52
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
53
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
54
|
+
in the Software without restriction, including without limitation the rights
|
|
55
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
56
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
57
|
+
furnished to do so, subject to the following conditions:
|
|
58
|
+
|
|
59
|
+
The above copyright notice and this permission notice shall be included in
|
|
60
|
+
all copies or substantial portions of the Software.
|
|
61
|
+
|
|
62
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
63
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
64
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
65
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
66
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
67
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
68
|
+
THE SOFTWARE.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
__credits__ = """
|
|
72
|
+
This package is a JAX-based rewrite of the qnm package by Leo C. Stein.
|
|
73
|
+
Original package: https://github.com/duetosymmetry/qnm
|
|
74
|
+
|
|
75
|
+
If you use this package in academic work, please cite:
|
|
76
|
+
Stein, Leo C. (2019). "qnm: A Python package for calculating Kerr
|
|
77
|
+
quasinormal modes, separation constants, and spherical-spheroidal
|
|
78
|
+
mixing coefficients." J. Open Source Softw., 4(42), 1683.
|
|
79
|
+
doi:10.21105/joss.01683, arXiv:1908.10377
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
from . import radial
|
|
83
|
+
from . import angular
|
|
84
|
+
from . import contfrac
|
|
85
|
+
from . import nearby
|
|
86
|
+
|
|
87
|
+
from . import spinsequence
|
|
88
|
+
|
|
89
|
+
from . import cached
|
|
90
|
+
from .cached import download_data
|
|
91
|
+
|
|
92
|
+
############################################################
|
|
93
|
+
## Package initialization
|
|
94
|
+
|
|
95
|
+
# Singleton for cache
|
|
96
|
+
modes_cache = cached.KerrSeqCache(init_schw=True)
|
|
97
|
+
"""Interface to the cache of QNMs. This is a singleton instance of
|
|
98
|
+
:class:`jqnm.cached.KerrSeqCache`. It can be called like a function
|
|
99
|
+
`jqnm.modes_cache(s,l,m,n)` to get a specific mode, the result being an
|
|
100
|
+
instance of :class:`jqnm.spinsequence.KerrSpinSeq`."""
|
|
101
|
+
|
|
102
|
+
# Ensure common versions of jitted functions are compiled
|
|
103
|
+
def _ensure_jitted():
|
|
104
|
+
finder = nearby.NearbyRootFinder(a=0.3, s=-2, m=2, A_closest_to=3.6+0.1j,
|
|
105
|
+
l_max=20, omega_guess=0.4-0.09j,
|
|
106
|
+
tol=1e-10, n_inv=0, Nr_max=4000)
|
|
107
|
+
finder.do_solve()
|
|
108
|
+
finder.set_params(Nr_max=float("inf"))
|
|
109
|
+
finder.do_solve()
|
|
110
|
+
|
|
111
|
+
return
|
|
112
|
+
|
|
113
|
+
_ensure_jitted()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|