bloc.mechanism_converter#

Mechanism conversion utilities focused on composition transformation.

This module provides functions to convert compositions between different mechanisms without creating unnecessary Solution objects, improving performance in iterative algorithms like Forward-Backward Sweep.

Functions#

convert_composition_between_mechanisms(...[, htol, ...])

Convert composition from source mechanism to target mechanism.

create_gas_from_composition(mechanism, composition, ...)

Create a Solution object from composition data.

Module Contents#

bloc.mechanism_converter.convert_composition_between_mechanisms(source_composition, source_T, source_P, source_mechanism, target_mechanism, htol=0.0001, Xtol=0.0001, verbose=False)#

Convert composition from source mechanism to target mechanism.

This function performs mechanism switching by returning composition data rather than Solution objects, avoiding unnecessary object creation in iterative algorithms.

Parameters:
  • source_composition (Dict[str, float]) – Mole fractions in source mechanism

  • source_T (float) – Temperature in K

  • source_P (float) – Pressure in Pa

  • source_mechanism (str) – Source mechanism path

  • target_mechanism (str) – Target mechanism path

  • htol (float) – Tolerance for enthalpy variation

  • Xtol (float) – Tolerance for mole fraction variation

  • verbose (bool) – Print conversion details

Returns:

  • target_composition (Dict[str, float]) – Mole fractions in target mechanism

  • target_T (float) – Temperature in K (adjusted for enthalpy conservation)

  • target_P (float) – Pressure in Pa (unchanged)

Raises:

ValueError – If enthalpy or composition variations exceed tolerances

bloc.mechanism_converter.create_gas_from_composition(mechanism, composition, temperature, pressure, use_cached=True)#

Create a Solution object from composition data.

This function provides a clean interface for creating Solution objects from composition data, with the option to use cached solutions for performance optimization.

Parameters:
  • mechanism (str) – Mechanism path

  • composition (Dict[str, float]) – Mole fractions

  • temperature (float) – Temperature in K

  • pressure (float) – Pressure in Pa

  • use_cached (bool) – Whether to use cached Solution (default True) Set to False for iterative property calculations

Returns:

gas – Solution object at specified state

Return type:

ct.Solution