Neural-network surrogate models for rotating neutron star sequences.
Project description
nn_rns
nn_rns is a library of neural-network reconstruction for rotating neutron
stars. It evaluates reconstructed neutron-star observables from a user-provided
equation-of-state (EoS) table.
Install
You can install nn_rns in two common ways.
1. Install from PyPI
pip install nn-rns
2. Install from source
git clone git@github.com:zzhu-astro/NN_RNS.git
cd NN_RNS
pip install .
For local development, you can also use editable mode:
pip install -e .
Basic usage
The main workflow is:
- Load the neural networks.
- Load an EoS table.
- Evaluate reconstructed rotating-neutron-star observables.
from nn_rns import EoSTable, RNSNetworks
model = RNSNetworks() # load networks
eos = EoSTable("path/to/eos_table.rns") # load EoS
model.rns_eval(eos) # evaluate observables
After model.rns_eval(eos), the reconstructed results are stored in three main
members:
model.nn_rns_static: reconstructed observables for static stars.model.nn_rns_kepler: reconstructed observables for the Kepler sequence.model.nn_rns_rotate: reconstructed observables for rotating models.
These arrays store the reconstructed observables generated by the trained neural networks.
Main functions
compute_observables()
compute_observables() is used to compute interpolated observables for
user-specified rotation and central variables.
- Rotation input can be given as
Omegaorr_ratio. - Central input can be given as
e_c,p_c, ornb_c. - The function returns interpolated observables on the target grid.
Typical usage:
obs = model.compute_observables(
rot_input=[0.4, 0.5],
central_input=[1.0e15, 1.2e15],
rot_input_type="Omega",
central_input_type="e_c",
)
compute_m_max()
compute_m_max() is used to compute the maximum mass sequence for
user-specified rotation input.
- Rotation input can be given as
Omegaorr_ratio. - The function returns the interpolated maximum mass and the corresponding rotation quantity.
Typical usage:
mmax, rot = model.compute_m_max(
rot_input=[0.4, 0.5],
rot_input_type="Omega",
)
Warning
[!WARNING] Data after the maximum mass may not be trustworthy due to the lack of training data.
Users should treat post-maximum-mass predictions with caution.
Notes
- Users should provide their own EoS table when constructing
EoSTable. - The package ships with the trained model weights under
nn_rns/NN/, so users do not need to download them separately.
References
If you use nn_rns in research work or publications, please cite the
corresponding paper.
W. Liu, L. Wang and Z. Zhu, "Reconstruction of fast-rotating neutron star observables with the neural network", arXiv preprint arXiv:2604.05428, 2026.
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
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
File details
Details for the file nn_rns-0.1.0.tar.gz.
File metadata
- Download URL: nn_rns-0.1.0.tar.gz
- Upload date:
- Size: 2.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1001ece716c827db65c7fe4391cb5b0c2f413c7fe32d4240aa4e89c7b35ff5b
|
|
| MD5 |
03680b94a67e03a16bf3f0a07b920a1f
|
|
| BLAKE2b-256 |
20733b374afa4de8e61ab9c2bcc3fd0dfc7b1d8874bcf97399d145c686296be1
|
File details
Details for the file nn_rns-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nn_rns-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f2ded20c6bab475fd1178ecfbac79664acf2bb1943096cdb4ae5f3b55ce4ff4
|
|
| MD5 |
9ee0c6c1fb89424678288eec525db255
|
|
| BLAKE2b-256 |
de07080fbc4ea485a57e81d20d403f90a4b6703a04f39f82b802af863826626b
|