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

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.11macOS 14.0+ ARM64

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

File metadata

File hashes

Hashes for pyghl-0.1.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 84a090678498aadd72726bdfa29b10c2d23f3b81abf9c85292c76a14759d92c7
MD5 1cc36841eb6887204d4cd973df8c9238
BLAKE2b-256 f9f619640ca8e9d8d830e17d7fd18a3e152e6d90ca2c0ded5e81bae58cbe74ef

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyghl-0.1.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 24c4075632cea1c14523cda16cb8a4bf223f3782432350dd6acba979b3b90885
MD5 10496c2c1fbba51b990e49e69dc900b1
BLAKE2b-256 4a51a58c443bc71dd260813018b499046fc11a281aacd66cc6e049eba031024e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyghl-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f91a042f1786e540b87f563eab97b71fe7850213fd9a4043079a64eb05d4eb91
MD5 2f204d3f6032f3c9ee7806cd5a6fbd94
BLAKE2b-256 a51d08f80d4cf0702224656071e491d1736f262fd5442210bc875ccabe282763

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyghl-0.1.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e98c03744d3c29467df9cc7dc80b4238a75c1b7e03a14f9ea8a2114f7261cf4a
MD5 b1655ce6c0c46807c3a5943b41efb2b5
BLAKE2b-256 fc9319604e697ab4a5a85566734671bd0e149101b45b932bfc02919abee6a2b8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyghl-0.1.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3207b27414072e3dd8e7485f56df8c4f39730e75f3d2c7b39c1f72113414f9c4
MD5 c67eace8fefcbaab13193fd4e36fc8f1
BLAKE2b-256 b059804caac41f92639ccc0827fe0801b626895d55e80c2b0b2bf8b3b85007d3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyghl-0.1.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 80ce881b6b40aeae370750df25495cd27b715266256fbeca6005db503fc07b28
MD5 1c06abe40ebd70fcbbfae7b85038607b
BLAKE2b-256 2c3cbf68c5a181c4a43d5db2c590c75600800f18afdaa9fcc34814d1c63eb9de

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyghl-0.1.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e14371448d0a6bbc386d577d101b21c86c3dfa3679cb460eba3bb8862099e3d8
MD5 8dc0c25f5d518f7e654e38c6389b9125
BLAKE2b-256 58a0e7246c01ac6043686e724749766f062a8a202ec726800aed606013bfa124

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyghl-0.1.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7efc2407436861dd49017100c748ea652b2e970c949dd44a19a67132daea52d2
MD5 3513e8de0fdea3f4ed8c3fca34c1d730
BLAKE2b-256 72b33ce6ba84bb2dc9e8c9076cd4fa4c4bab5faff8bc765d68c4c076bc8191f2

See more details on using hashes here.

Provenance

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