Python/SymPy-based code generation for numerical relativity... and beyond!
Project description
NRPy+ 2.0: Next-generation Python/SymPy-Based Code Generation for Numerical Relativity... and Beyond!
Quick start:
pip install nrpy- Choose a project to build, run the provided command, then follow the instructions for compiling & running the generated C code.
3. Wave equation solver
3. Cartesian coordinates:
python3 -m nrpy.examples.wave_equation_cartesian3. Curvilinear coordinates:python3 -m nrpy.examples.wave_equation_curvilinear4. General relativity 5. Two black holes collide:python3 -m nrpy.examples.two_blackholes_collide
Slow start, in case you want to develop NRPy+ directly:
- Clone this repository.
cd nrpy, then e.g., run an example code:python3 nrpy/examples/wave_equation_cartesian, then follow the instructions for compiling & running the generated C code.- Run
./wavetoy. It'll output at various times the solution from the point closest to r=0, as well as the relative error compared to the exact solution at that point to a fileout0d-conv_factor1.00.txt. - All BlackHoles@Home (BHaH) infrastructure codes now support parameter files, and each code generation automatically outputs a parfile named
[project name].par. So you'll find an editablewavetoy.par. - In addition, users can override certain parameter file parameters at the command line. E.g.,
wavetoyhas a parameterconvergence_factorthat increases the resolution (technicallyNx=Ny=Nz) by this factor. To output at twice the resolution, simply run./wavetoy 2.0, and a new file will be outputout0d-conv_factor2.00.txt, which contains data at 2x the resolution. - Analyze the output from
out0d-conv_factor1.00.txtandout0d-conv_factor2.00.txtin e.g.,gnuplot.
Key Improvements over NRPy+ 1.0:
Easy Installation
- NRPy+ has been transformed into a proper Python project and can now be installed via pip! Use the command
pip install nrpyto get started. - Visit our PyPI page for more information.
- With pip, it's easier than ever to build your own projects based on NRPy+.
- You can now generate a complete C project from start to finish without the need for running a Jupyter notebook.
- For instance, running
pip install nrpy && python3 -m nrpy.examples.two_blackholes_collidewill generate a C code project that evolves Brill-Lindquist forward in time using the BSSN formulation.
- For instance, running
- Check out GitHub README for instructions on generating other pre-baked example codes... or use them to generate your own codes!
Python 3.6+ Features
- NRPy+ now makes use of Python features introduced in version 3.6 and above, such as f-strings.
- The code is now more Pythonic and incorporates objects where useful. Global variables are now a thing of the past!
User-friendly
- It's much simpler to work with NRPy+ now; you no longer have to read the source code of each function you call.
- Facilitating this, you'll find:
- Docstrings for all functions, classes, and modules.
- Type hints across all modules;
mypy --strictpasses. - Numerous doctests.
- Code formatted with Black.
- Stricter linting.
- Facilitating this, you'll find:
Improved Continuous Integration
- GitHub Actions now checks all files within the repo and will fail if any of the following conditions are met:
- Doctest failure
- pylint score less than 9.5
- Black needs to reformat any
.pyfile mypy --strictfails on any.pyfile- Generating and compiling all examples from the pip-installed NRPy+ fresh from the latest git commit fails.
More Extensible
- The "SENR" infrastructure has been replaced with "BHaH" (BlackHoles@Home). All BHaH-specific functionality is located in
nrpy/infrastructures/BHaH/.- While BHaH currently only supports single grids, multi-patch support will be added soon.
- You'll notice the old paramstruct has been broken into commondata_struct (data shared by all grids) and griddata (contains data specific to a particular grid).
- Adding multi-patch support is a matter of setting commondata.NUMGRIDS > 1 and all the special algorithms.
- There is a common but slightly customizable
main.cfile used by all BHaH codes, seenrpy/infrastructures/BHaH/main_c.py. This should greatly minimize code duplication in BHaH codes. - Parameter files are now supported, as well as advanced command-line input.
- The
infrastructures/directory includes helper functions for specific infrastructures. It currently contains BHaH and CarpetX subdirectories, with more to come. Cparametershas been renamed toCodeParameters, allowing for future extensions of NRPy+ to output kernels in Python, Fortran, etc.- Rewritten expression validation infrastructure, to make it easier to validate newly added sympy expressions -- regardless of how complex they are.
Plans for Old nrpytutorial Code
- We'll migrate the Jupyter notebooks to a new nrpytutorial GitHub repo as they are updated to NRPy+ 2.0.
- All the core
.pyfiles from nrpytutorial have been modernized & ported to NRPy+ 2.0. - What
.pyfiles remain in nrpytutorial will be ported to NRPy+ 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nrpy-2.0.5.tar.gz
(205.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
nrpy-2.0.5-py3-none-any.whl
(247.1 kB
view details)
File details
Details for the file nrpy-2.0.5.tar.gz.
File metadata
- Download URL: nrpy-2.0.5.tar.gz
- Upload date:
- Size: 205.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7837263b23da2c2b6b554f6433068cde9bb4a05085f74f72914df6351706e380
|
|
| MD5 |
2580b8bf9c53eda4ffb5a4e3b191378b
|
|
| BLAKE2b-256 |
7031ee1511fd7c6be0a3a7cf5f230ad31a8e48c2aed811d14e4ac236f7b4393c
|
File details
Details for the file nrpy-2.0.5-py3-none-any.whl.
File metadata
- Download URL: nrpy-2.0.5-py3-none-any.whl
- Upload date:
- Size: 247.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a23d08a550d5da6f4d8b6833f97b39fe0a8a02f809f7ead900f082b982846982
|
|
| MD5 |
25b573128d234f40c8ce9b101efdbd2b
|
|
| BLAKE2b-256 |
481c68fa3fe525e8c5f0087ed8c86f1b293053681551073b607a2b8042ecf7bc
|