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

From pypi:

pip install canterax

For local development:

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.1.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.1-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: canterax-0.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 0aa920a210fe052aff621fa135fdb87a455c0d8f81c3eea9c7fe229da00fa961
MD5 e1c7fd50159db81c3c55bcf8a16380c9
BLAKE2b-256 311fbb0ff1c58bd7ebb80df6fe2a12210307d7adc8b297edae80763dd5ec7bc0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: canterax-0.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f99de06a8663bd6c2f088da267278d89e3c8931809ef0caafde281e224d007e1
MD5 f346d8069bf8478c1e6b41be1a0218a4
BLAKE2b-256 68dc5895667b4b54707c7c345af406813e37fbec33afd52c0277aafe5288f44f

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