qnm

qnm: A Python package for calculating Kerr quasinormal modes, separation constants, and spherical-spheroidal mixing coefficients - Published in JOSS (2019)

https://github.com/duetosymmetry/qnm

Science Score: 100.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: arxiv.org, joss.theoj.org, zenodo.org
  • Committers with academic emails
    2 of 4 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

black-holes general-relativity numerical-methods physics python scientific-computing
Last synced: 4 months ago · JSON representation ·

Repository

Python package for computing Kerr quasinormal mode frequencies, separation constants, and spherical-spheroidal mixing coefficients

Basic Info
  • Host: GitHub
  • Owner: duetosymmetry
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage: https://qnm.readthedocs.io
  • Size: 7.97 MB
Statistics
  • Stars: 46
  • Watchers: 7
  • Forks: 23
  • Open Issues: 13
  • Releases: 6
Topics
black-holes general-relativity numerical-methods physics python scientific-computing
Created almost 7 years ago · Last pushed 4 months ago
Metadata Files
Readme License Code of conduct Citation Codemeta

README.md

github PyPI version Conda Version DOI JOSS status arXiv:1908.10377 ascl:1910.022 license pytest for not-slow tests pytest for slow tests Documentation Status

Welcome to qnm

qnm is an open-source Python package for computing the Kerr quasinormal mode frequencies, angular separation constants, and spherical-spheroidal mixing coefficients. The qnm package includes a Leaver solver with the Cook-Zalutskiy spectral approach to the angular sector, and a caching mechanism to avoid repeating calculations.

With this python package, you can compute the QNMs labeled by different (s,l,m,n), at a desired dimensionless spin parameter 0≤a<1. The angular sector is treated as a spectral decomposition of spin-weighted spheroidal harmonics into spin-weighted spherical harmonics. Therefore you get the spherical-spheroidal decomposition coefficients for free when solving for ω and A (see below for details).

We have precomputed a large cache of low-lying modes (s=-2 and s=-1, all l<8, all n<7). These can be automatically installed with a single function call, and interpolated for good initial guesses for root-finding at some value of a.

Installation

PyPI

qnm is available on PyPI:

shell pip install qnm

Conda

qnm is available on conda-forge:

shell conda install -c conda-forge qnm

From source

shell git clone https://github.com/duetosymmetry/qnm.git cd qnm python setup.py install

If you do not have root permissions, replace the last step with python setup.py install --user. Instead of using setup.py manually, you can also replace the last step with pip install . or pip install --user ..

Dependencies

All of these can be installed through pip or conda. * numpy * scipy * numba * tqdm (just for qnm.download_data() progress)

Documentation

Automatically-generated API documentation is available on Read the Docs: qnm.

For a didactic introduction, you can watch my talk at the Spring 2020 BHPToolkit Workshop (starting around 4:11:02 in the stream. You can also follow along with the qnm presentation notebook.

Usage

The highest-level interface is via qnm.cached.KerrSeqCache, which loads cached spin sequences from disk. A spin sequence is just a mode labeled by (s,l,m,n), with the spin a ranging from a=0 to some maximum, e.g. 0.9995. A large number of low-lying spin sequences have been precomputed and are available online. The first time you use the package, download the precomputed sequences:

```python import qnm

qnm.download_data() # Only need to do this once

Trying to fetch https://duetosymmetry.com/files/qnm/data.tar.bz2

Trying to decompress file //qnm/data.tar.bz2

Data directory //qnm/data contains 860 pickle files

```

Then, use qnm.modes_cache to load a qnm.spinsequence.KerrSpinSeq of interest. If the mode is not available, it will try to compute it (see detailed documentation for how to control that calculation).

```python grav220 = qnm.modescache(s=-2,l=2,m=2,n=0) omega, A, C = grav_220(a=0.68) print(omega)

(0.5239751042900845-0.08151262363119974j)

```

Calling a spin sequence seq with seq(a) will return the complex quasinormal mode frequency omega, the complex angular separation constant A, and a vector C of coefficients for decomposing the associated spin-weighted spheroidal harmonics as a sum of spin-weighted spherical harmonics (see below for details).

Visual inspections of modes are very useful to check if the solver is behaving well. This is easily accomplished with matplotlib. Here are some partial examples (for the full examples, see the file notebooks/examples.ipynb in the source repo):

```python import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt

s, l, m = (-2, 2, 2) modelist = [(s, l, m, n) for n in np.arange(0,7)] modes = { ind : qnm.modescache(*ind) for ind in mode_list }

plt.subplot(1, 2, 1) for mode, seq in modes.items(): plt.plot(np.real(seq.omega),np.imag(seq.omega))

plt.subplot(1, 2, 2) for mode, seq in modes.items(): plt.plot(np.real(seq.A),np.imag(seq.A)) ```

Which results in the following figure (modulo formatting):

example_22n plot

```python s, l, n = (-2, 2, 0) modelist = [(s, l, m, n) for m in np.arange(-l,l+1)] modes = { ind : qnm.modescache(*ind) for ind in mode_list }

plt.subplot(1, 2, 1) for mode, seq in modes.items(): plt.plot(np.real(seq.omega),np.imag(seq.omega))

plt.subplot(1, 2, 2) for mode, seq in modes.items(): plt.plot(np.real(seq.A),np.imag(seq.A)) ```

Which results in the following figure (modulo formatting):

example_2m0 plot

Precision and validation

The default tolerances for continued fractions, cf_tol, is 1e-10, and for complex root-polishing, tol, is DBL_EPSILON≅1.5e-8. These can be changed at runtime so you can re-polish the cached values to higher precision.

Greg Cook's precomputed data tables (which were computed with arbitrary-precision arithmetic) can be used for validating the results of this code. See the comparison notebook notebooks/Comparison-against-Cook-data.ipynb to see such a comparison, which can be modified to compare any of the available modes.

Spherical-spheroidal decomposition

The angular dependence of QNMs are naturally spin-weighted spheroidal harmonics. The spheroidals are not actually a complete orthogonal basis set. Meanwhile spin-weighted spherical harmonics are complete and orthonormal, and are used much more commonly. Therefore you typically want to express a spheroidal (on the left hand side) in terms of sphericals (on the right hand side),

equation `$${}_s Y_{\\ell m}(\\theta, \\phi; a\\omega) = {\\sum_{\\ell'=\\ell_{\\min} (s,m)}^{\\ell_\\max}} C_{\\ell' \\ell m}(a\\omega)\\ {}_s Y_{\\ell' m}(\\theta, \\phi) \\,.$$`

Here ℓmin=max(|m|,|s|) and ℓmax can be chosen at run time. The C coefficients are returned as a complex ndarray, with the zeroth element corresponding to ℓmin. To avoid indexing errors, you can get the ndarray of ℓ values by calling qnm.angular.ells, e.g.

ells = qnm.angular.ells(s=-2, m=2, l_max=grav_220.l_max)

Contributing

Contributions are welcome! There are at least two ways to contribute to this codebase:

  1. If you find a bug or want to suggest an enhancement, use the issue tracker on GitHub. It's a good idea to look through past issues, too, to see if anybody has run into the same problem or made the same suggestion before.
  2. If you will write or edit the python code, we use the fork and pull request model.

You are also allowed to make use of this code for other purposes, as detailed in the MIT license. For any type of contribution, please follow the code of conduct.

How to cite

If this package contributes to a project that leads to a publication, please acknowledge this by citing the qnm article in JOSS. The following BibTeX entry is available in the qnm.__bibtex__ string: @article{Stein:2019mop, author = "Stein, Leo C.", title = "{qnm: A Python package for calculating Kerr quasinormal modes, separation constants, and spherical-spheroidal mixing coefficients}", journal = "J. Open Source Softw.", volume = "4", year = "2019", number = "42", pages = "1683", doi = "10.21105/joss.01683", eprint = "1908.10377", archivePrefix = "arXiv", primaryClass = "gr-qc", SLACcitation = "%%CITATION = ARXIV:1908.10377;%%" }

Credits

The code is developed and maintained by Leo C. Stein.

Owner

  • Name: Leo C. Stein
  • Login: duetosymmetry
  • Kind: user

Assistant Professor of Physics and Astronomy at U of MS. Gravitational waves, general relativity and beyond. Formerly at @caltech, @mit, Cornell

JOSS Publication

qnm: A Python package for calculating Kerr quasinormal modes, separation constants, and spherical-spheroidal mixing coefficients
Published
October 01, 2019
Volume 4, Issue 42, Page 1683
Authors
Leo C. Stein ORCID
Department of Physics and Astronomy, The University of Mississippi, University, MS 38677, USA
Editor
Juanjo Bazán ORCID
Tags
physics general relativity black holes

Citation (CITATION.bib)

@article{Stein:2019mop,
      author         = "Stein, Leo C.",
      title          = "{qnm: A Python package for calculating Kerr quasinormal
                        modes, separation constants, and spherical-spheroidal
                        mixing coefficients}",
      journal        = "J. Open Source Softw.",
      volume         = "4",
      year           = "2019",
      number         = "42",
      pages          = "1683",
      doi            = "10.21105/joss.01683",
      eprint         = "1908.10377",
      archivePrefix  = "arXiv",
      primaryClass   = "gr-qc",
      SLACcitation   = "%%CITATION = ARXIV:1908.10377;%%"
}

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "name": "qnm: Kerr quasinormal modes, separation constants, and spherical-spheroidal mixing coefficients calculator",
  "description": "qnm computes the Kerr quasinormal mode frequencies, angular separation constants, and spherical-spheroidal mixing coefficients. The qnm package includes a Leaver solver with the Cook-Zalutskiy spectral approach to the angular sector, and a caching mechanism to avoid repeating calculations. A large cache of low ℓ, m, n modes is available for download and can be installed with a single function call and interpolated to provide good initial guess for root-polishing at new values of spin.",
  "identifier": "ascl:1910.022",
  "author": [
    {
      "@type": "Person",
      "givenName": "Leo C.",
      "familyName": "Stein",
      "id": "https://orcid.org/0000-0001-7559-9597"
    }
  ],
  "citation": "https://inspirehep.net/record/1751578",
  "relatedLink": [
    "https://pypi.org/project/qnm/",
    "https://qnm.readthedocs.io/",
    "https://doi.org/10.5281/zenodo.2593978",
    "https://arxiv.org/abs/1908.10377"
  ],
  "codeRepository": "https://github.com/duetosymmetry/qnm",
  "programmingLanguage": "python",
  "referencePublication": [
    {
      "@type": "ScholarlyArticle",
      "url": "https://inspirehep.net/record/1751578",
      "id": "https://doi.org/10.21105/joss.01683"
    }
  ],
  "version": "0.4.0",
  "license": "https://spdx.org/licenses/MIT.html"
}

GitHub Events

Total
  • Issues event: 1
  • Watch event: 7
  • Issue comment event: 10
  • Push event: 9
  • Pull request review event: 4
  • Pull request review comment event: 2
  • Pull request event: 7
  • Fork event: 6
  • Create event: 2
Last Year
  • Issues event: 1
  • Watch event: 7
  • Issue comment event: 10
  • Push event: 9
  • Pull request review event: 4
  • Pull request review comment event: 2
  • Pull request event: 7
  • Fork event: 6
  • Create event: 2

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 215
  • Total Committers: 4
  • Avg Commits per committer: 53.75
  • Development Distribution Score (DDS): 0.028
Past Year
  • Commits: 8
  • Committers: 3
  • Avg Commits per committer: 2.667
  • Development Distribution Score (DDS): 0.625
Top Committers
Name Email Commits
Leo C. Stein l****n@g****m 209
Duncan Macleod m****m@c****k 3
Raffi Enficiaud r****d@m****g 2
Lorena Magana zertuche l****z@g****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 29
  • Total pull requests: 11
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 29 days
  • Total issue authors: 5
  • Total pull request authors: 6
  • Average comments per issue: 0.83
  • Average comments per pull request: 1.09
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 2
  • Pull requests: 8
  • Average time to close issues: 3 months
  • Average time to close pull requests: 6 days
  • Issue authors: 1
  • Pull request authors: 3
  • Average comments per issue: 2.5
  • Average comments per pull request: 1.13
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • duetosymmetry (22)
  • duncanmmacleod (3)
  • IanHawke (2)
  • raffienficiaud (1)
  • Editst (1)
Pull Request Authors
  • duncanmmacleod (5)
  • raffienficiaud (2)
  • AlexKurek (2)
  • lmagana3 (1)
  • dependabot[bot] (1)
  • TrellixVulnTeam (1)
Top Labels
Issue Labels
enhancement (12) good first issue (2) wontfix (1)
Pull Request Labels
dependencies (1) github_actions (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 1,012 last-month
  • Total dependent packages: 3
    (may contain duplicates)
  • Total dependent repositories: 9
    (may contain duplicates)
  • Total versions: 20
  • Total maintainers: 1
pypi.org: qnm

Package for computing Kerr quasinormal mode frequencies, separation constants, and spherical-spheroidal mixing coefficients

  • Versions: 18
  • Dependent Packages: 3
  • Dependent Repositories: 5
  • Downloads: 1,012 Last month
  • Docker Downloads: 0
Rankings
Dependent packages count: 2.4%
Docker downloads count: 4.3%
Dependent repos count: 6.6%
Average: 7.0%
Downloads: 7.8%
Forks count: 9.6%
Stargazers count: 11.2%
Maintainers (1)
Last synced: 4 months ago
conda-forge.org: qnm

qnm is an open-source Python package for computing the Kerr quasinormal mode frequencies, angular separation constants, and spherical-spheroidal mixing coefficients. The qnm package includes a Leaver solver with the Cook-Zalutskiy spectral approach to the angular sector, and a caching mechanism to avoid repeating calculations.

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 4
Rankings
Dependent repos count: 16.2%
Average: 39.1%
Forks count: 41.9%
Stargazers count: 46.8%
Dependent packages count: 51.6%
Last synced: 4 months ago

Dependencies

docs/requirements.txt pypi
  • numba >=0.49.1
  • numpydoc *
  • recommonmark ==0.6.0
  • sphinx ==1.8.4
requirements.txt pypi
  • numba *
  • numpy *
  • pathlib2 *
  • scipy *
  • tqdm *
setup.py pypi
  • numba *
  • numpy *
  • pathlib2 *
  • scipy *
  • tqdm *
.github/workflows/pytest-not-slow.yml actions
  • actions/checkout v1 composite
  • actions/setup-python v1 composite
.github/workflows/pytest-slow.yml actions
  • actions/checkout v1 composite
  • actions/setup-python v1 composite