Skip to main content

JAXprop

JAX-compatible Python package for real-fluid thermodynamic properties, phase equilibria and metastable states, with automatic differentiation.

🔗 Docs: turbo-sim.github.io/jaxprop
📦 PyPI: pypi.org/project/jaxprop

Note: This project is based on the CoolProp library but is not affiliated with or endorsed by the CoolProp project.

Key features

  • Compute and plot phase envelopes and spinodal lines for pure fluids.
  • Evaluate thermodynamic properties from Helmholtz energy–based equations of state, including metastable states inside the two-phase region.
  • Perform flash calculations for any input pair with a custom solver and user-defined initial guesses.
  • Work with structured property dictionaries and immutable FluidState objects.
  • Evaluate properties over arrays of input conditions for efficient parametric studies and plotting.
  • Use JAX-enabled evaluators with jit, grad and vmap, according to each model's declared capabilities.

Installation

pip install jaxprop

Uniform fluid constructor (0.6.0)

Version 0.6.0 is published on PyPI. The release passed hosted Linux and Windows HEOS tests and downstream Barotropy verification. See the 0.6.0 release notes and migration guide before upgrading.

import jaxprop as jxp

fluid = jxp.Fluid("CO2", method="coolprop", backend="HEOS")
state = fluid.get_state(jxp.PT_INPUTS, 10e6, 400.0)
print(state.density)

callback = jxp.Fluid("CO2", method="coolprop_jax", backend="HEOS")
gas = jxp.Fluid("Air", method="perfect_gas")
table = jxp.Fluid(
    "CO2",
    method="bicubic",
    backend="HEOS",
    table_options={
        "h_min": 600e3, "h_max": 850e3,
        "p_min": 5e6, "p_max": 12e6,
        "N_h": 16, "N_p": 16,
    },
)

method selects the evaluator or approximate physical model. backend selects the CoolProp source used for evaluation, table generation, calibration and reference data; it defaults to HEOS. Inspect fluid.capabilities before using phase operations, diagnostics or JAX transformations.

CoolProp and its callback accept errors="raise" (default) or errors="mask". Mask mode preserves successful batch elements and exposes failed elements as NaNs with integer state.status codes. Transformed callback calls require it:

import jax

temperature = jax.jit(
    lambda h: callback.get_state(jxp.HmassP_INPUTS, h, 8e6, errors="mask").T
)

The callback supports first-order finite-difference derivatives. Perfect gas and bicubic tables support raise, mask and clip; their transformed calls require explicit mask or clip mode. For example:

adjusted = gas.get_state(jxp.PT_INPUTS, -1.0, 300.0, errors="clip")
print(adjusted.p, adjusted.clipped, adjusted.status)

Clipping returns a consistent adjusted state with a clipping flag. Nonfinite inputs remain failed elements. Perfect gas now preserves calibrated source enthalpy/entropy and heat capacity with consistent ideal-gas equations, enabling 22 properties. Gradient helpers return PropertyDerivatives with SI units and a separate .primal state. Bicubic clipping projects onto the configured enthalpy/pressure rectangle. Fixed-coordinate inverses can also project a target when the table proves a monotone response; unsuccessful or ambiguous inverses remain failed elements. Inverse budgets are configured once with the inverse_max_steps and inverse_tolerance table options. Inspect capabilities and the public contract or implementation checklist for current support.

Binary mixtures

Configure fixed mass fractions once, then use the same three-argument state call:

nitrogen = jxp.Fluid("Nitrogen", method="perfect_gas")
oxygen = jxp.Fluid("Oxygen", method="perfect_gas")
mixture = jxp.Fluid(
    "working_mix",
    method="binary_mixture",
    model_options={
        "components": (nitrogen, oxygen),
        "mass_fractions": (0.4, 0.6),
    },
)
state = mixture.get_state(jxp.PT_INPUTS, 1e6, 500.0)

The model supports PT, HmassP and PSmass, returning 27 fields. It represents constituent parcels at common pressure and temperature without mass exchange or molecular mixing entropy. Heat capacities and compressibilities follow that model's thermodynamic identities. speed_of_sound and speed_of_sound_pT are the pressure/temperature equilibrium speed; speed_of_sound_p is the distinct thermally frozen Wood speed. Composition is not vapor quality; composite quality and saturation requests are explicitly unsupported.

Active perfect-gas/bicubic components use native JAX with explicit mask/clip inside transformations. All-active FluidJAX components use one whole-mixture callback with mask mode and first-order state-input derivatives. Direct-source and source/native/callback hybrids use eager raise/mask; compiled hybrid support remains deferred. Host configurations are fixed component snapshots; native component numerical parameters remain dynamic. Inspect mixture.capabilities.

FluidMix translates the legacy name/mass-ratio constructor once and returns the same FluidBinaryMixture class; FluidTwoComponent is an alias of that class. Optional inverse controls belong in model_options. See the binary contract and the water/nitrogen example. See the verified Phase 9 checklist and full-state timing report.

For application-owned JAX settings, complete compiled consumers, worker serialization, source-EOS plotting and physical/formal metastable tables, see the fluid lifecycle guide. Configuration snapshots are inspection records; verified evaluator snapshots preserve the full model.

For interface changes and reproducible example commands, see the migration guide and example workflows.

Development and citation

Roberto Agromayor is the main developer, with contributions from Srinivas Prakash Diwanji, Alberto Bergamin and Andrea Cioffi.

Citation metadata is provided in CITATION.cff. For version-specific reproducibility, also record the release or commit used.

Metadata

Release files for jaxprop 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jaxprop 0.6.3
File Size Uploaded Provenance Actions
jaxprop-0.6.3.tar.gz 185.7 kB Without provenance Details for jaxprop-0.6.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jaxprop 0.6.3
File Interpreter ABI Platform Actions
jaxprop-0.6.3-py3-none-any.whl Python 3 none any Details for jaxprop-0.6.3-py3-none-any.whl

Total release size: 383.6 kB

Release files / jaxprop-0.6.3.tar.gz

Download URL jaxprop-0.6.3.tar.gz
Size 185.7 kB
Tags Source
SHA-256 checksum
How to use checksums
618aa4e9c1d69d762121f83101ce3d4cabc8e57bbf45516ffcd95ac218ad3e52
BLAKE2b-256 checksum
How to use checksums
8bb319a4d5fe3f49a1063b149d9854ba880be30672d5fd8e7b7d7f8bde141de0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.2 CPython/3.12.16 Linux/7.0.0-1020-azure

Release files / jaxprop-0.6.3-py3-none-any.whl

Download URL jaxprop-0.6.3-py3-none-any.whl
Size 197.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dedf64e855798b3b23c9ae5e9950a7d259926ecf850f6356cd28f3eeff8b1358
BLAKE2b-256 checksum
How to use checksums
efd86155327f20f9f45e252a58d0f3e14b88800d5ef112bc941efc51bc2aa5b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.5.2 CPython/3.12.16 Linux/7.0.0-1020-azure

Security for jaxprop 0.6.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page