Skip to main content

Python bindings for GRHayL (EOS-first preview)

Project description

pyghl

This directory contains Python bindings for GRHayL, including enough tabulated-EOS and con2prim functionality to reproduce the neural-network dataset/testing generators in Unit_Tests/data_gen.

What is included

  • pyghl.initialize_params(...)
  • pyghl.initialize_metric(...)
  • pyghl.compute_ADM_auxiliaries(...)
  • pyghl.initialize_primitives(...)
  • pyghl.initialize_diagnostics(...)
  • pyghl.compute_conservs(...)
  • pyghl.undensitize_conservatives(...)
  • pyghl.compute_SU_Bsq_Ssq_BdotS(...)
  • pyghl.limit_v_and_compute_u0(...)
  • pyghl.limit_utilde_and_compute_v(...)
  • pyghl.guess_primitives(...)
  • pyghl.tabulated_Palenzuela1D_energy(...)
  • pyghl.nn_c2p_guess(eos, ...)
  • pyghl.nn_c2p_guess_x(eos, ...)
  • Struct wrappers:
    • pyghl.Primitive
    • pyghl.Conservative
    • pyghl.Metric
    • pyghl.ADMAux
    • pyghl.Diagnostics
  • pyghl.eos.initialize_tabulated_eos_functions_and_params(...)
  • pyghl.nn helpers:
    • flat_metric()
    • guess(eos, ...)
    • guess_x(eos, ...)
    • nn_initial_guess(...)
    • iter_dataset_points(...)
    • read_training_dataset(...)
    • train_regressor(...)
    • train_on_dataset(...)
    • save_inference_bundle(...)
    • load_inference_bundle(...)
    • export_to_c_header(...)
  • TabulatedEOS methods:
    • tabulated_enforce_bounds_rho_Ye_T
    • tabulated_enforce_bounds_rho_Ye_eps
    • tabulated_compute_P_from_T
    • tabulated_compute_eps_from_T
    • tabulated_compute_cs2_from_T
    • tabulated_compute_P_eps_from_T
    • tabulated_compute_P_eps_S_from_T
    • tabulated_compute_T_from_eps
    • tabulated_compute_P_T_from_eps

Build requirements

  • The pinned GRHayL submodule initialized at extern/GRHayL, or GRHAYL_DIR set to a configured GRHayL checkout.
  • HDF5 enabled in GRHayL build.
  • Python build tooling (pip, setuptools, compiler toolchain).

Install (from repo root)

Initialize the pinned GRHayL source:

git submodule update --init --recursive

Install:

python3 -m pip install -e .

Offline or restricted-network environments:

python3 -m pip install --no-build-isolation -e .

The build step runs:

make -C extern/GRHayL grhayl

and then compiles the Python extension against extern/GRHayL/build/lib/libghl.so. Set GRHAYL_DIR=/path/to/GRHayL to build against a different local checkout.

If editable install is not available in your environment, you can work from the repository root with:

PYTHONPATH=src python3 ...

Example

import pyghl as ghl

params = ghl.initialize_params()
eos = ghl.eos.initialize_tabulated_eos_functions_and_params(
    params,
    "Unit_Tests/sample_table/Hempel_SFHoEOS_rho222_temp180_ye60_version_1.1_20120817_simple.h5",
)

rho = 1e-12
Y_e = 0.05
T = 1e2

rho, Y_e, T = eos.tabulated_enforce_bounds_rho_Ye_T(rho, Y_e, T)
P = eos.tabulated_compute_P_from_T(rho, Y_e, T)

You can also pass a short table name and set GRHAYL_EOS_TABLE_DIR.

Neural-network data generators

The following example scripts mirror the C generators in Unit_Tests/data_gen:

  • examples/nn_c2p_generate_dataset.py
  • examples/nn_c2p_test.py
  • examples/nn_c2p_train.py

The same tools are also importable/runnable as package modules:

  • pyghl train <eos-file> [dataset] ...

  • pyghl append-eos <eos-file> [nn-hdf5] ...

  • python -m pyghl.nn_c2p.nn_c2p_generate_dataset ...

  • python -m pyghl.nn_c2p.nn_c2p_train ...

  • python -m pyghl.nn_c2p.nn_c2p_test ...

  • python -m pyghl.nn_c2p.append_eos_file ...

  • python -m pyghl.nn_c2p.check_eos ...

  • python -m pyghl.nn_c2p.list_installed_models

  • python -m pyghl.nn_c2p.remove_eos_nn ...

Example:

PYTHONPATH=src python3 examples/nn_c2p_generate_dataset.py \
  Unit_Tests/sample_table/Hempel_SFHoEOS_rho222_temp180_ye60_version_1.1_20120817_simple.h5 \
  train --n-pts 2 --output /tmp/nn_training_dataset.bin

PYTHONPATH=src python3 examples/nn_c2p_test.py \
  Unit_Tests/sample_table/Hempel_SFHoEOS_rho222_temp180_ye60_version_1.1_20120817_simple.h5 \
  /tmp/nn_training_dataset.bin --limit 8

python3 -m pyghl.nn_c2p.nn_c2p_generate_dataset \
  Unit_Tests/sample_table/Hempel_SFHoEOS_rho222_temp180_ye60_version_1.1_20120817_simple.h5 \
  train

pyghl train \
  Unit_Tests/sample_table/Hempel_SFHoEOS_rho222_temp180_ye60_version_1.1_20120817_simple.h5

pyghl train \
  Unit_Tests/sample_table/Hempel_SFHoEOS_rho222_temp180_ye60_version_1.1_20120817_simple.h5 \
  /tmp/nn_training_dataset.bin

pyghl append-eos \
  Unit_Tests/sample_table/Hempel_SFHoEOS_rho222_temp180_ye60_version_1.1_20120817_simple.h5 \
  /tmp/tiny_mlp_model.h5

pyghl append-eos \
  Unit_Tests/sample_table/Hempel_SFHoEOS_rho222_temp180_ye60_version_1.1_20120817_simple.h5

python3 -m pyghl.nn_c2p.list_installed_models

python3 -m pyghl.nn_c2p.check_eos \
  Unit_Tests/sample_table/Hempel_SFHoEOS_rho222_temp180_ye60_version_1.1_20120817_simple.h5

python3 -m pyghl.nn_c2p.remove_eos_nn \
  Unit_Tests/sample_table/Hempel_SFHoEOS_rho222_temp180_ye60_version_1.1_20120817_simple.h5

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyghl-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

pyghl-0.2.0-cp313-cp313-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyghl-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

pyghl-0.2.0-cp312-cp312-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyghl-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

pyghl-0.2.0-cp311-cp311-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyghl-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

pyghl-0.2.0-cp310-cp310-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file pyghl-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyghl-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52a151ee80622ba5a9894915f5c15969b6bcaab0f21ce93f0f341aea1dc38c2f
MD5 baa3da71809e1112f3ad806caa78891d
BLAKE2b-256 0d9f4ba366126300adc5db6ccc994a7b717f91e9df965578e61ab08346284996

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on GRHayL/pyghl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyghl-0.2.0-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyghl-0.2.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 908ede11750e06681dfd29dfaf63c7a338dcbce151a1108a7b9c8224354543e2
MD5 158c838bfa0dc6cb823ae27480794399
BLAKE2b-256 c5c948a44d7c805fb9d89767aa8d75f8ad249d23264dbf11bb2c9637ffc846ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.2.0-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: publish.yml on GRHayL/pyghl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyghl-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyghl-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0eeeaa1cd9cb472f6d5956db0a31ba7c97e72d82747972156a6f56da16cec65b
MD5 03031ef96ffe6422d639a1be13bcdca1
BLAKE2b-256 28aa42641931174d5609477fa5b05d1cc6820c1aa79a38b6fe4b67ea73003e9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on GRHayL/pyghl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyghl-0.2.0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyghl-0.2.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c1fad8db023b5523763cad0ce01209bc9c9556264e50b390e0f7f2edccf2fda3
MD5 1cd9befa995ac7926badf161827a37bf
BLAKE2b-256 09ad130c104dff55dddaf1e9a785e4aad70dcaade0879e1adcc44617b55ae44a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.2.0-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: publish.yml on GRHayL/pyghl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyghl-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyghl-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 04f3d8a059a42a21a6f5241c82c62e92a2438938314d2c8c6c61ad0c8b6804fb
MD5 98d9cf91f89c804286ed6d7d5f336a61
BLAKE2b-256 db8eeaf62bad2a05d7eccc9bc97fb0f56730924f3b06ce14fb165cbe896f84a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on GRHayL/pyghl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyghl-0.2.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyghl-0.2.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 28b460d0427816282504d324ba58b03e79f40d83df7c1ec04046584e036ae5fd
MD5 60cd8d1ea47f2ff33c0b3dc25cd46ba0
BLAKE2b-256 37811db076c9df425c01e18032447928db395fbd469746729e5109a680d56167

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.2.0-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: publish.yml on GRHayL/pyghl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyghl-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyghl-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 631eb6656e6c35255169dec8699aaaa1e85374cc8341a5de5617437688502797
MD5 9f3c955ce0562cced36a3c08db3d0c58
BLAKE2b-256 bfe1b1e4ed2b66503aebb598d7426fb151b3c517457445400f469d041074382a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on GRHayL/pyghl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyghl-0.2.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyghl-0.2.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 39ca72c17a3bc9827c211e243302bf41d88a716b427065b17709ff88b798b02f
MD5 ced051bd351f0352dfa39a7ae40c231e
BLAKE2b-256 1419aeb6b938f89a984cb230dfc65ced1e4d15268204097c6a900e81a281ee0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.2.0-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: publish.yml on GRHayL/pyghl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page