Solution Guide¶
canterax.Solution is the main user-facing API. It wraps a loaded mechanism and exposes a Cantera-like ideal-gas state surface.
Constructing a solution¶
from canterax import Solution
gas = Solution("gri30.yaml")
Construction loads the mechanism immediately and initializes a default state:
temperature
300 Kpressure
1 atmcomposition set to pure
N2when that species exists, otherwise the first species in the mechanism
Setting composition¶
Both mole and mass fractions are accepted. Strings use Cantera-style composition syntax.
gas.X = "CH4:1, O2:2, N2:7.52"
gas.Y = [0.055, 0.220, 0.725]
Canterax normalizes positive totals automatically. A non-positive total raises ValueError.
Setting thermodynamic state¶
The most direct state pair is TP.
gas.TP = 1200.0, 101325.0
gas.TPX = 1200.0, 101325.0, "CH4:1, O2:2, N2:7.52"
The following getter/setter pairs are implemented:
TP,TPX,TPYHP,HPX,HPYUV,UVX,UVYSP,SPX,SPYSV,SVX,SVYTD,TDX,TDYDP,DPX,DPY
Passing None in a tuple keeps the current value for that slot.
gas.TP = None, 2 * 101325.0
gas.TPX = 1500.0, None, None
Basis-aware aliases¶
The aliases below follow gas.basis, which can be either "mass" or "molar":
husgcpcvvdensity
If you need an explicit unit basis regardless of current state, use the dedicated properties:
enthalpy_mass,enthalpy_moleentropy_mass,entropy_molecp_mass,cp_moledensity_mass,density_molevolume_mass,volume_mole
Scalar properties¶
Common properties include:
cp_mass,cp_molecv_mass,cv_moleenthalpy_mass,enthalpy_moleint_energy_mass,int_energy_moleentropy_mass,entropy_molegibbs_mass,gibbs_moledensity_mass,density_molevolume_mass,volume_molemean_molecular_weightviscositythermal_conductivity
Species-level arrays¶
Canterax exposes the same kinds of standard-state and partial molar arrays users commonly inspect in Cantera:
standard_cp_Rstandard_enthalpies_RTstandard_entropies_Rstandard_int_energies_RTstandard_gibbs_RTpartial_molar_cppartial_molar_enthalpiespartial_molar_entropiespartial_molar_int_energieschemical_potentialsnet_production_rates
These are returned as NumPy arrays.
Metadata and helper methods¶
Useful helpers include:
species_names,element_namesn_species,n_reactions,n_elementsmolecular_weights,atomic_weightsspecies_name(k),species_index(name)element_name(m),element_index(name)n_atoms(species, element)mass_fraction_dict(threshold=0.0)mole_fraction_dict(threshold=0.0)
Practical notes¶
Solutionis intentionally stateful and mutating, like Cantera’s Python API.Composition setters accept strings, sequences, and arrays.
Many internal computations use JAX arrays, but user-facing property getters typically return Python scalars or NumPy arrays.
The current implementation targets ideal-gas mechanisms only.