Skip to main content

A differentiable, GPU-resident chemical kinetics library using JAX

Project description

Canterax

Differentiable, JAX-based chemical kinetics with a Cantera-like ideal-gas Solution API. https://canterax.readthedocs.io/en/latest/

Features

  • Ideal-gas ThermoPhase-style Solution wrapper
  • Cantera YAML mechanism loading
  • NASA-7 thermodynamics and Arrhenius kinetics
  • Cantera-like state setters including TP, HP, UV, SP, SV, TD, and DP
  • Basis-aware aliases matching Cantera (basis = "mass" or "molar")
  • Mixture viscosity and thermal_conductivity
  • TP and HP equilibrium modes
  • Differentiable reactor integration with JAX and Diffrax

Installation

git clone https://github.com/BenjiG03/canterax.git
cd canterax
pip install -e .

Quickstart

from canterax import Solution

gas = Solution("gri30.yaml")
gas.TPX = 1500.0, 101325.0, "CH4:1, O2:2, N2:7.52"

print(gas.cp_mass)
print(gas.cv_mass)
print(gas.enthalpy_mole)
print(gas.viscosity)
print(gas.thermal_conductivity)

Basis-aware aliases

gas = Solution("gri30.yaml")
gas.TPX = 1200.0, 101325.0, "H2:2, O2:1, N2:3.76"

gas.basis = "mass"
print(gas.h, gas.cp, gas.v)

gas.basis = "molar"
print(gas.h, gas.cp, gas.v)

State setters

gas = Solution("gri30.yaml")
gas.TPX = 1200.0, 2 * 101325.0, "CH4:1, O2:2, N2:7.52"

h, p, y = gas.HPY
gas.HPY = h, p, y

u, v, x = gas.UVX
gas.UVX = u, v, x

s, p = gas.SP
gas.SP = s, p

Equilibrium

gas = Solution("gri30.yaml")
gas.TPX = 2000.0, 101325.0, "CH4:1, O2:2, N2:7.52"
gas.equilibrate("TP")

gas = Solution("gri30.yaml")
gas.TPX = 1500.0, 101325.0, "CH4:1, O2:2, N2:7.52"
gas.equilibrate("HP")

Species-level thermodynamic arrays

The Solution object exposes the standard and partial molar properties commonly used from Cantera:

  • standard_cp_R
  • standard_enthalpies_RT
  • standard_entropies_R
  • standard_int_energies_RT
  • standard_gibbs_RT
  • partial_molar_cp
  • partial_molar_enthalpies
  • partial_molar_entropies
  • partial_molar_int_energies
  • chemical_potentials

Supported Solution surface

Implemented ideal-gas thermodynamic/state API:

  • State setters/getters: TP, TPX, TPY, HP, HPX, HPY, UV, UVX, UVY, SP, SPX, SPY, SV, SVX, SVY, TD, TDX, TDY, DP, DPX, DPY
  • Scalar properties: cp_mole, cp_mass, cv_mole, cv_mass, enthalpy_mole, enthalpy_mass, int_energy_mole, int_energy_mass, entropy_mole, entropy_mass, gibbs_mole, gibbs_mass, density_mole, density_mass, volume_mole, volume_mass, mean_molecular_weight, viscosity, thermal_conductivity
  • Basis-aware aliases: h, u, s, g, cp, cv, v, density
  • Metadata/helpers: thermo_model, phase_of_matter, reference_pressure, min_temp, max_temp, state_size, species_name, species_index, element_name, element_index, n_atoms, mass_fraction_dict, mole_fraction_dict

Not Currently Implemented:

  • non-ideal activity-based thermo
  • pure-fluid / saturation properties
  • plasma/electron properties
  • diffusion-coefficient transport APIs

Validation

The test suite validates the Canterax Solution object directly against Cantera:

  • scalar thermodynamic properties
  • species-level standard and partial molar arrays
  • basis-aware aliases
  • all implemented state setters
  • TP and HP equilibrium
  • mixture viscosity and thermal_conductivity

Run the suite with:

python -m pytest canterax/tests -q

License

MIT License.

Project details


Download files

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

Source Distribution

canterax-0.3.0.tar.gz (46.3 kB view details)

Uploaded Source

Built Distribution

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

canterax-0.3.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file canterax-0.3.0.tar.gz.

File metadata

  • Download URL: canterax-0.3.0.tar.gz
  • Upload date:
  • Size: 46.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for canterax-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d63d6bc13fd3aad541a2111c87d603d1231eadcda8471f9ba682d11a648c79cc
MD5 a8d18a7edf45249048172da7b4aad2cf
BLAKE2b-256 e4b1a78bf41c4d116e477c0890e6d3a29aa31ca7f7575625af6b0c6c6fef1cea

See more details on using hashes here.

File details

Details for the file canterax-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: canterax-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for canterax-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 49229339d49c41750257578e365f1e66321aff77e869eb571534a905027b365b
MD5 7500ec4744379a29c2383b092ef70e81
BLAKE2b-256 b6c0a3f3b029350a1a59f0faa91e1284167ebaba8b7dd14d6fff4f6eebb40b60

See more details on using hashes here.

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