pyro

pyro: a framework for hydrodynamics explorations and prototyping - Published in JOSS (2019)

https://github.com/python-hydro/pyro2

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 1 DOI reference(s) in JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
    5 of 18 committers (27.8%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

advection astrophysical-simulation finite-volume finite-volume-methods hydrodynamics multigrid pde pyro python simulation solver

Keywords from Contributors

amrex adaptive-mesh-refinement amr astrophysics castro cfd gravity radiation reactions hpsf

Scientific Fields

Economics Social Sciences - 40% confidence
Last synced: 4 months ago · JSON representation ·

Repository

A framework for hydrodynamics explorations and prototyping

Basic Info
Statistics
  • Stars: 324
  • Watchers: 13
  • Forks: 128
  • Open Issues: 37
  • Releases: 10
Topics
advection astrophysical-simulation finite-volume finite-volume-methods hydrodynamics multigrid pde pyro python simulation solver
Created over 11 years ago · Last pushed 5 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Zenodo

README.md

License PyPI Version pylint flake8 pytest-all github pages

Binder

JOSS status DOI

pyro logo

A simple python-based tutorial on computational methods for hydrodynamics

pyro is a computational hydrodynamics code that presents two-dimensional solvers for advection, compressible hydrodynamics, diffusion, incompressible hydrodynamics, and multigrid, all in a finite-volume framework. The code is mainly written in python and is designed with simplicity in mind. The algorithms are written to encourage experimentation and allow for self-learning of these code methods.

The latest version of pyro is always available at:

https://github.com/python-hydro/pyro2

The project webpage, where you'll find documentation, plots, notes, etc. is here:

https://python-hydro.github.io/pyro2

(Note: there is an outdated page at readthedocs.org that is no longer updated)

Table of Contents

Getting started

  • By default, we assume python 3.9 or later.

  • We require numpy, numba, matplotlib, and h5py for running pyro and setuptools_scm for the install.

  • There are several ways to install pyro. The simplest way is via PyPI/pip:

    pip install pyro-hydro

    Alternately, you can install directly from source, via

    pip install .

    you can optionally add the -e argument to install if you are planning on developing pyro solvers directly.

  • Not all matplotlib backends allow for the interactive plotting as pyro is run. One that does is the TkAgg backend. This can be made the default by creating a file ~/.matplotlib/matplotlibrc with the content:

    backend: TkAgg

    You can check what backend is your current default in python via:

    python import matplotlib.pyplot print matplotlib.pyplot.get_backend()

    • If you want to run the unit tests, you need to have pytest installed.
    • Finally, you can run a quick test of the advection solver:

pyro_sim.py advection smooth inputs.smooth

you should see a graphing window pop up with a smooth pulse advecting diagonally through the periodic domain.

Core Data Structures

The main data structures that describe the grid and the data the lives on the grid are described in a jupyter notebook:

https://github.com/python-hydro/pyro2/blob/main/pyro/mesh/mesh-examples.ipynb

Many of the methods here rely on multigrid. The basic multigrid solver is demonstrated in the juputer notebook:

https://github.com/python-hydro/pyro2/blob/main/pyro/multigrid/multigrid-constant-coefficients.ipynb

Solvers

pyro provides the following solvers (all in 2-d):

  • advection: a second-order unsplit linear advection solver. This uses characteristic tracing and corner coupling for the prediction of the interface states. This is the basic method to understand hydrodynamics.

  • advection_fv4: a fourth-order accurate finite-volume advection solver that uses RK4 time integration.

  • advection_nonuniform: a solver for advection with a non-uniform velocity field.

  • advection_rk: a second-order unsplit solver for linear advection that uses Runge-Kutta integration instead of characteristic tracing.

  • advection_weno: a method-of-lines WENO solver for linear advection.

  • burgers: a second-order unsplit solver for invsicid Burgers' equation.

  • burgers_viscous: a second-order unsplit solver for viscous Burgers' equation with constant-coefficient diffusion. It uses Crank-Nicolson time-discretized solver for solving diffusion.

  • compressible: a second-order unsplit solver for the Euler equations of compressible hydrodynamics. This uses characteristic tracing and corner coupling for the prediction of the interface states and a 2-shock or HLLC approximate Riemann solver.

  • compressible_fv4: a fourth-order accurate finite-volume compressible hydro solver that uses RK4 time integration. This is built from the method of McCourquodale and Colella (2011).

  • compressible_rk: a second-order unsplit solver for Euler equations that uses Runge-Kutta integration instead of characteristic tracing.

  • compressible_sdc: a fourth-order compressible solver, using spectral-deferred correction (SDC) for the time integration.

  • diffusion: a Crank-Nicolson time-discretized solver for the constant-coefficient diffusion equation.

  • incompressible: a second-order cell-centered approximate projection method for the incompressible equations of hydrodynamics.

  • incompressible_viscous: an extension of the incompressible solver including a diffusion term for viscosity.

  • lm_atm: a solver for the equations of low Mach number hydrodynamics for atmospheric flows.

  • lm_combustion: (in development) a solver for the equations of low Mach number hydrodynamics for smallscale combustion.

  • multigrid: a cell-centered multigrid solver for a constant-coefficient Helmholtz equation, as well as a variable-coefficient Poisson equation (which inherits from the constant-coefficient solver).

  • particles: a solver for Lagrangian tracer particles.

  • swe: a solver for the shallow water equations.

Working with data

In addition to the main pyro program, there are many analysis tools that we describe here. Note: some problems write a report at the end of the simulation specifying the analysis routines that can be used with their data.

  • pyro/util/compare.py: this takes two simulation output files as input and compares zone-by-zone for exact agreement. This is used as part of the regression testing.

    usage: ./compare.py file1 file2

  • pyro/plot.py: this takes the an output file as input and plots the data using the solver's dovis method.

    usage: ./plot.py file

  • pyro/analysis/

    • dam_compare.py: this takes an output file from the shallow water dam break problem and plots a slice through the domain together with the analytic solution (calculated in the script).

      usage: ./dam_compare.py file

    • gauss_diffusion_compare.py: this is for the diffusion solver's Gaussian diffusion problem. It takes a sequence of output files as arguments, computes the angle-average, and the plots the resulting points over the analytic solution for comparison with the exact result.

      usage: ./gauss_diffusion_compare.py file*

    • incomp_converge_error.py: this is for the incompressible solver's converge problem. This takes a single output file as input and compares the velocity field to the analytic solution, reporting the L2 norm of the error.

      usage: ./incomp_converge_error.py file

    • plotvar.py: this takes a single output file and a variable name and plots the data for that variable.

      usage: ./plotvar.py file variable

    • sedov_compare.py: this takes an output file from the compressible Sedov problem, computes the angle-average profile of the solution and plots it together with the analytic data (read in from cylindrical-sedov.out).

      usage: ./sedov_compare.py file

    • smooth_error.py: this takes an output file from the advection solver's smooth problem and compares to the analytic solution, outputting the L2 norm of the error.

      usage: ./smooth_error.py file

    • sod_compare.py: this takes an output file from the compressible Sod problem and plots a slice through the domain over the analytic solution (read in from sod-exact.out).

      usage: ./sod_compare.py file

Understanding the algorithms

There is a set of notes that describe the background and details of the algorithms that pyro implements:

http://open-astrophysics-bookshelf.github.io/numerical_exercises/

The source for these notes is also available on github:

https://github.com/Open-Astrophysics-Bookshelf/numerical_exercises

Regression and unit testing

The pyro/test.py script will run several of the problems (as well as some stand-alone multigrid tests) and compare the solution to stored benchmarks (in each solver's tests/ subdirectory). The return value of the script is the number of tests that failed.

Unit tests are controlled by pytest and can be run simply via

pytest

Acknowledgements

If you use pyro in a class or workshop, please e-mail us to let us know (we'd like to start listing these on the website).

If pyro was used for a publication, please cite the article found in the CITATION file.

Getting help

We use github discussions as a way to ask about the code:

https://github.com/python-hydro/pyro2/discussions

Owner

  • Name: python-hydro
  • Login: python-hydro
  • Kind: organization

JOSS Publication

pyro: a framework for hydrodynamics explorations and prototyping
Published
February 22, 2019
Volume 4, Issue 34, Page 1265
Authors
Alice Harpole ORCID
Department of Physics and Astronomy, Stony Brook University
Michael Zingale ORCID
Department of Physics and Astronomy, Stony Brook University
Ian Hawke ORCID
University of Southampton
Taher Chegini ORCID
University of Houston
Editor
Lorena A Barba ORCID
Tags
hydrodynamics astrophysics physics partial differential equations

Citation (CITATION.md)

If you use pyro, please cite the pyro JOSS paper *and* the latest Zenodo DOI.

## JOSS

The pyro JOSS paper is at: https://joss.theoj.org/papers/10.21105/joss.01265

You can cite it as:

```bibtex
@article{pyro_joss,
         doi = {10.21105/joss.01265},
         url = {https://doi.org/10.21105/joss.01265},
         year = {2019},
         publisher = {The Open Journal},
         volume = {4},
         number = {34},
         pages = {1265},
         author = {Alice Harpole and Michael Zingale and Ian Hawke and Taher Chegini},
         title = {pyro: a framework for hydrodynamics explorations and prototyping},
         journal = {Journal of Open Source Software}
}
```

## Astronomy and Computing

You can also additionally cite the paper from *Astronomy and Computing*:

```bibtex
@article{pyro_ac,
         author = {{Zingale}, M.},
         title = "{pyro: A teaching code for computational astrophysical hydrodynamics}",
         journal = {Astronomy and Computing},
         year = 2014,
         month = {oct},
         volume = 6,
         pages = {52-62},
         doi = {10.1016/j.ascom.2014.07.003}
}
```

## Zenodo

The latest pyro Zenodo record is at https://doi.org/10.5281/zenodo.2575564



GitHub Events

Total
  • Create event: 3
  • Release event: 1
  • Issues event: 10
  • Watch event: 14
  • Delete event: 2
  • Issue comment event: 25
  • Push event: 91
  • Pull request review comment event: 6
  • Pull request review event: 14
  • Pull request event: 98
  • Fork event: 7
Last Year
  • Create event: 3
  • Release event: 1
  • Issues event: 10
  • Watch event: 14
  • Delete event: 2
  • Issue comment event: 25
  • Push event: 91
  • Pull request review comment event: 6
  • Pull request review event: 14
  • Pull request event: 98
  • Fork event: 7

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 1,647
  • Total Committers: 18
  • Avg Commits per committer: 91.5
  • Development Distribution Score (DDS): 0.128
Past Year
  • Commits: 128
  • Committers: 3
  • Avg Commits per committer: 42.667
  • Development Distribution Score (DDS): 0.086
Top Committers
Name Email Commits
Michael Zingale m****e@s****u 1,437
Alice Harpole a****e@g****m 115
Eric T. Johnson y****3 22
Zhi Chen 6****3 20
Taher Chegini t****i@g****m 13
Ian Hawke I****e@s****k 9
Ying-Tai Chen y****8@g****m 9
Nathan Goldbaum n****u@i****u 5
Alice Harpole a****4@s****k 5
Alexander Smith 7****1 2
Simon Guichandut 4****t 2
dependabot[bot] 4****] 2
Arfon Smith a****n 1
Chris DeGrendele 3****e 1
sebastiano s****o@t****t 1
jmuzsik j****k@i****m 1
dwillcox e****x@g****m 1
mojiastonybrook m****a@s****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 37
  • Total pull requests: 261
  • Average time to close issues: 12 months
  • Average time to close pull requests: 19 days
  • Total issue authors: 8
  • Total pull request authors: 12
  • Average comments per issue: 1.46
  • Average comments per pull request: 0.57
  • Merged pull requests: 232
  • Bot issues: 0
  • Bot pull requests: 9
Past Year
  • Issues: 15
  • Pull requests: 141
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 3 days
  • Issue authors: 1
  • Pull request authors: 4
  • Average comments per issue: 1.2
  • Average comments per pull request: 0.33
  • Merged pull requests: 126
  • Bot issues: 0
  • Bot pull requests: 5
Top Authors
Issue Authors
  • zingale (30)
  • yut23 (3)
  • zhichen3 (2)
  • harpolea (2)
  • ngoldbaum (1)
  • bcaddy (1)
  • jmuzsik (1)
  • brownbaerchen (1)
Pull Request Authors
  • zingale (272)
  • zhichen3 (32)
  • yut23 (27)
  • dependabot[bot] (12)
  • harpolea (5)
  • aisclark91 (5)
  • simonguichandut (2)
  • ssagynbayeva (1)
  • SebastianoF (1)
  • zooechiu (1)
  • jmuzsik (1)
  • ChrisDeGrendele (1)
Top Labels
Issue Labels
enhancement (3) hackday (2) infrastructure (1) new solver (1)
Pull Request Labels
dependencies (12) github_actions (8) python (4) documentation (4) bug (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 71 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 6
  • Total maintainers: 1
pypi.org: pyro-hydro

A python hydrodynamics code for teaching and prototyping

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 71 Last month
Rankings
Stargazers count: 3.8%
Forks count: 4.3%
Dependent packages count: 6.6%
Average: 15.5%
Dependent repos count: 30.6%
Downloads: 32.0%
Maintainers (1)
Last synced: 4 months ago

Dependencies

.github/workflows/docs-test.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/flake8.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/gh-pages.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/isort.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/pylint.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/pytest.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/regtest.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
pyproject.toml pypi
.github/workflows/codespell.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
requirements.txt pypi
  • codespell *
  • flake8 >=3.5.0
  • h5py >=2.7
  • importlib-metadata *
  • matplotlib >=2.0.0
  • nbsphinx >=0.3.1
  • nbval >=0.9.0
  • numba >=0.40.0
  • numpy >=1.13.3
  • numpydoc *
  • prettytable *
  • pytest >=3.6
  • pytest-cov >=2.6.0
  • scipy >=0.16
  • sphinx-copybutton *
  • sphinx-math-dollar *
  • sphinx-prompt *
  • sphinx_book_theme *
  • sphinxcontrib-bibtex *