simulation¶
Simulation classes and helpers for evaluating kinetic models against data.
- members:
- class pyteck.simulation.BaseSimulation(kind, apparatus, meta, properties)[source]¶
Abstract base class for a single simulation case of a kinetic model.
Subclasses implement a specific simulation type, e.g. a homogeneous reactor for autoignition delay or a one-dimensional flame for laminar burning velocity.
- Parameters:
kind (str) – Kind of experiment (e.g., ‘ignition delay’)
apparatus (str) – Type of apparatus (e.g., ‘shock tube’)
meta (dict) – Metadata for this case
properties (pyked.chemked.DataPoint) – Set of properties for this case
- abstractmethod run_case(restart=False)[source]¶
Run the simulation case set up by
setup_case.- Parameters:
restart (bool, optional) – If
True, skip the case when its results file already exists (default:False).
- abstractmethod setup_case(model_file, species_key, path='')[source]¶
Set up the simulation case to be run.
- Parameters:
model_file (str or pathlib.Path) – Filename for Cantera-format model
species_key (dict) – Dictionary with species names for
model_filepath (str or pathlib.Path, optional) – Directory in which to save any results data file. The default (
"") uses the current working directory.
- class pyteck.simulation.FlameSimulation(kind, apparatus, meta, properties)[source]¶
One-dimensional freely propagating laminar flame simulation.
Placeholder for laminar burning velocity measurements. The corresponding PyKED schema is still in development (see PyKED PR #141), so this simulation type is not yet implemented.
- run_case(restart=False)[source]¶
Run the simulation case set up by
setup_case.- Parameters:
restart (bool, optional) – If
True, skip the case when its results file already exists (default:False).
- setup_case(model_file, species_key, path='')[source]¶
Set up the simulation case to be run.
- Parameters:
model_file (str or pathlib.Path) – Filename for Cantera-format model
species_key (dict) – Dictionary with species names for
model_filepath (str or pathlib.Path, optional) – Directory in which to save any results data file. The default (
"") uses the current working directory.
- class pyteck.simulation.HomogeneousReactorSimulation(kind, apparatus, meta, properties)[source]¶
Homogeneous (0-D) reactor simulation for autoignition delay.
Models shock tube and rapid compression machine ignition-delay experiments using a Cantera
IdealGasReactor.- static create_volume_history(mech, temp, pres, reactants, pres_rise, time_end)[source]¶
Construct a volume profile based on initial conditions and pressure rise.
- Parameters:
mech (str or pathlib.Path) – Cantera-format mechanism file (
*.yaml)temp (float) – Initial temperature, in K
pres (float) – Initial pressure, in Pa
reactants (str) – Reactants composition in mole fraction
pres_rise (float) – Pressure rise rate, in s^-1
time_end (float) – End time of simulation, in s
- Returns:
Times and computed volumes
- Return type:
- static get_ignition_delay(time, target, target_name, ignition_type)[source]¶
Identify ignition delay based on time, target, and type of detection.
- Parameters:
time (numpy.ndarray) – Times in s
target (numpy.ndarray) – Values of target quantity of interest (e.g., temperature, pressure, species amount)
target_name (str) – Name of target quantity of interest (e.g., ‘temperature’, ‘OH’)
ignition_type (str) – ‘max’, ‘d/dt max’, ‘1/2 max’, or ‘d/dt max extrapolated’
- Returns:
One or more calculated ignition delay times, in s
- Return type:
- run_case(restart=False)[source]¶
Run simulation case set up by
setup_case.- Parameters:
restart (bool, optional) – If
True, skip the case when its results file already exists (default:False).
- static sample_rising_pressure(time_end, init_pres, freq, pressure_rise_rate)[source]¶
Samples pressure for particular frequency assuming linear rise.
- setup_case(model_file, species_key, path='')[source]¶
Sets up the simulation case to be run.
- Parameters:
model_file (str or pathlib.Path) – Filename for Cantera-format model
species_key (dict) – Dictionary with species names for
model_filepath (str or pathlib.Path, optional) – Directory in which to save the results data file. The default (
"") writes to the current working directory.
- class pyteck.simulation.PressureRiseProfile(mech_filename, initial_temp, initial_pres, reactants, pressure_rise, time_end)[source]¶
Set the velocity of reactor moving wall via specified pressure rise.
The initialization and calling of this class are handled by the Func1 interface of Cantera.
The approach used here is based on that discussed by Chaos and Dryer, “Chemical-kinetic modeling of ignition delay: Considerations in interpreting shock tube data”, Int J Chem Kinet 2010 42:143-150, doi:10.1002/kin.20471 <http://dx.doi.org/10.1002/kin.20471. A time-dependent polytropic state change is emulated by determining volume as a function of time, via a constant linear pressure rise \(A\) (given as a percentage of the initial pressure):
\[ \begin{align}\begin{aligned}\begin{split}\frac{dv}{dt} &= -\frac{1}{\gamma} \frac{v(t)}{P(t)} \frac{dP}{dt} \\ v(t) &= \frac{1}{\rho} \left[ \frac{P(t)}{P_0} \right]^{-1 / \gamma}\end{split}\\\begin{split}\frac{dP}{dt} &= A P_0 \\ \therefore P(t) &= P_0 (A t + 1)\end{split}\\\frac{dv}{dt} = -A \frac{1}{\rho \gamma} (A t + 1)^{-1 / \gamma}\end{aligned}\end{align} \]The expression for \(\frac{dv}{dt}\) can then be used directly for the
Wallvelocity.
- class pyteck.simulation.VolumeProfile(volume_history)[source]¶
Set the velocity of reactor moving wall via specified volume profile.
The initialization and calling of this class are handled by the Func1 interface of Cantera.
Based on
VolumeProfileimplemented in Bryan W. Weber’s CanSen <http://bryanwweber.github.io/CanSen/>
- pyteck.simulation.create_simulation(kind, apparatus, meta, properties)[source]¶
Construct the appropriate
BaseSimulationsubclass for a case.- Parameters:
kind (str) – Experiment/measurement type (e.g., ‘ignition delay’)
apparatus (str) – Apparatus kind (e.g., ‘shock tube’)
meta (dict) – Metadata for this case
properties (pyked.chemked.DataPoint) – Object with full set of experimental properties for this case
- Returns:
Simulation case of the appropriate subclass
- Return type: