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.1.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.1.0-cp313-cp313-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyghl-0.1.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.1.0-cp312-cp312-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyghl-0.1.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.1.0-cp311-cp311-macosx_14_0_arm64.whl (1.7 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

pyghl-0.1.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.1.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.1.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyghl-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 263f5b89eb724b0339c9501ca409d0c4ee6da0b4fd94ea96cbb3d54a8ba12162
MD5 67c25433edfe0302e76c7feb5880c96f
BLAKE2b-256 e011e7872ad696f5c846c38a7e47453190c4ea1dfc4cedff24296d27733c6e06

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.1.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.1.0-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyghl-0.1.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 447487d71b960d1cad1aab924cb9acb1329e37b32b2bf0998b3e92f609e3804c
MD5 8e2ab7c3a15866fd88094340722ce934
BLAKE2b-256 895d4f6cf31ca895cee136bebdf787cd1f1d2c8ca679f08b299f6489548b54b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.1.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.1.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyghl-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 41df1d29979155f4582c70f75873d0afb8f8a307b10187e3e138e480b838e0dc
MD5 1162459037d1d3905265c4a5d6ee22f7
BLAKE2b-256 e24fef7879b302de85cab8689641a486cb72cd7d5b101169e000cc94fd03a638

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.1.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.1.0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyghl-0.1.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 02ea4d273ca4a4c7534ba261aa326ca737cc175781a056b94a41411bb7bc7e72
MD5 7bd06683d0002af9e6eb8feda683c00e
BLAKE2b-256 0777b51097ae9c976e5c5cfa455c4b770083d694ad1c79765b3738699c850dba

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.1.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.1.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyghl-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0370eabfc6ec2393dfc50fab6e0d447eef8ab2510aca13c121475f288a2ed9f2
MD5 783356c687e5679976b2dc00decc857f
BLAKE2b-256 d6a1492b20852f31d71d15813313dc167b5c993cbf561ab5e1095c568c4311f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.1.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.1.0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyghl-0.1.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 cb18473e1fed844c5cbbce502a258943e9ae67e9ba2e3fd585787765b7b84468
MD5 7d881d77632d85c915da3c37d1a43809
BLAKE2b-256 b938a0b26aa2a227e2ae9a3173a4b1f4d7cf0b0c98176c8c95a6e4d970eb20cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.1.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.1.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyghl-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aa0ce5d661770c8509f4a91493cf4ef03c8af00e113b125801673e572c652889
MD5 2c7e3b8d915d1a01da61b1f0097a58f5
BLAKE2b-256 86edd4b6d67812d3eb94776b3b697a385fa66141c034772c12dbac34a93867a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.1.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.1.0-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyghl-0.1.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c012970c85c6fd844a713374467b2dc608889aeddde7c23948d1c5d483a57562
MD5 c943f9989cb880bd95055f9b6407f5fa
BLAKE2b-256 670284263eef82919eb948a8d634ad89452e4b3afef9379a0631a21ab4c2a158

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyghl-0.1.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