Shock tube models¶
Contents
This class of model uses a Cantera cantera.Reactor
, by default a constant volume reactor, as a surrogate for a shock tube. The StateDefinition
is used as the initial state of the reactor.
Base shock tube class¶
-
class
shock_tube_base.
ShockTube
(T, Patm, composition, reactor_model, chemistry_model, loglevel=None, **kwargs)¶ A class for defining shock tube simulations.
This is a class that will create a simulation of a shock tube. The shock tube simulations are subclasses of this class. It is a subclass of
cantera_chemistry_model()
, which is in turn a subclass ofmodel()
. You cannot instantiate a member of this class because it does not have anevaluate()
method.This class implements the
initialize_reactor()
method required bycantera_chemistry_model()
. It also redefinesreset_model()
.Parameters: - T (float) – The unburned gas temperature in Kelvins
- Patm (float) – The pressure in atmospheres (will be converted internally to Pa)
- composition (array-like or str) – The composition of the unburned gas. Can be a float array or a Cantera composition string
- reactor_model (Cantera reactor model) – The Cantera reactor model used to simulate the shock tube. Typically IdealGasReactor
- chemistry_model (str) – The chemistry model for the shock tube. Must be a filename that contains a Cantera chemistry model that can be used to make a Cantera phase object
- loglevel – The level of external logging that the model should do. If None, does not produce any logging in the ignition delay solver. Otherwise, produces detailed output
-
initialize_reactor
()¶ Initialize the shock tube. It consists of a Cantera
cantera.IdealGasReactor
object defined in self.reactor_model and a Cantera reactor network containing only that reactor.
-
reactor_model
= None¶ The Cantera
cantera.IdealGasReactor
class that will be instantiated byinitalize_reactor()
-
reset_model
()¶ Reset all model parameters to their original values
This version works by erasing the chemistry and re-initializing it from the CTI file.
Shock tube delay¶
-
class
shock_tube_utils.
ShockTubeDelay
(T, Patm, composition, reactor_model, chemistry_model, critical_function, crit_ID=None, critical_value=None, critical_rise=None, initial_timestep=1e-05, loglevel=None, **kwargs)¶ A model for determining the delay time in shock tube ignition
This class provides a model for calculating a shock tube ignition delay time in Cantera. It is based off of the tutorial.
This class implements the
evaluate()
method required bymumpce.model()
. Theevaluate()
method of this class will find the delay time based on one of three possible conditions. The critical_function argument will determine which of these three conditions is being tracked.critical_species_production()
- Time at which the critical species production rate is maximizedtarget_concentration()
- Time at which the critical species concentration reaches a certain valuepressure rise()
- Time at which the rate of pressure rise is maximized
This class takes all the arguments of the shock_tube class and the following arguments:
Parameters: - critical_function (function) – The function that will determine whether the ignition event has occured. Several options are provided
- crit_ID (str) – The name of the species being tracked. If critical_function is pressure_rise, this does not need to be specified.
- critical_value (float) – The value of the critical species mole fraction at which integration will stop, if the ignition event is defined as the critical species reaching a certain concentration. Not used otherwise.
- critical_rise (str) – Whether the delay event is defined by the critical species rising above or falling below critical_value
- initial_timestep (float) – The initial timestep for integrating the reactor. Default 10 microseconds
-
evaluate
()¶ Finds the ignition delay time
Computes the ignition delay time with an iterative procedure. First, the delay time is found to within a precision of self.initial_timestep. Then, the reactor moves back two timesteps, halves the size of the timestep, and repeats until the ignition delay time is found to within one part in \(10^-5\) of the initial timestep. If the default timestep is \(10^-5\) s, then the final precision is \(10^-10\) s
If you know that the initial timestep was not set wisely, you can automatically compute one using self.optimal_timestep().
Returns: Ignition delay time in microseconds Return type: float
-
optimal_timestep
()¶ Compute an optimal initial timestep for this measurement, as the default may be too large or too small. Saves the result in self.inital_timestep
-
initial_timestep
= None¶ The initial timestep used to find the ignition delay. See
optimal_timestep()
Generic critical evaluation function¶
-
shock_tube_utils.
generic_critical_function
(measurement, critical_last)¶ A generic function to define whether the ignition delay criterion has been satisfied for use with the
shock_tube_delay()
classThis is a function used by
ShockTubeDelay
to determine if the ignition delay criterion has been satisfied. If it has been satisified, the integration will stop.ShockTubeDelay
stores this The function is called in the following way:keep_going,crit = self.critical(self,critical_last)
If keep_going is True,
ShockTubeDelay
continues integrating. If False, it will stop.When crit is calculated, it can be compared with critical_last. critical_last is output from the critical_function at the last timestep.
Parameters: - measurement – The shock tube object
- critical_last – The crit output from the previous timestep.
Returns: keep_going: Whether the integration should continue
Return type: keep_going bool
Returns: crit
Return type: crit float
Shock tube concentration¶
-
class
shock_tube_utils.
ShockTubeConcentration
(T, Patm, composition, reactor_model, chemistry_model, crit_ID, integration_time=0.0001, loglevel=None, **kwargs)¶ A model for determining the concentration of a particular species after a certain integration time.
This class provides a model for calculating the concentration in the shock tube at a specified time.
This class implements the
evaluate()
method required bymumpce.model()
. This class takes all the arguments of the shock_tube class and the following additional arguments:Parameters: - crit_ID (str) – The name of the species being tracked.
- integration_time (float) – The time over which the reactor will be integrated. Default 100 microseconds
-
evaluate
()¶ Calculates the concentration of the critical species at the specified integration time
Returns: Critical species mole fraction Return type: float
-
integration_time
= None¶ The time for which the reactor will be integrated
Shock tube ratio¶
-
class
shock_tube_utils.
ShockTubeRatio
(T, Patm, composition, reactor_model, chemistry_model, crit_numerator=None, crit_denom=None, integration_time=0.0001, loglevel=None, **kwargs)¶ A model for determining the mole fration ratios of two particular species after a certain integration time.
This class provides a model for calculating the ratio of the concentrations of two particular species in the shock tube at a specified time. The ratio is defined as \(y = C_n/C_d\) where \(C_n\) and \(C_d\) are the concentrations of the numerator and denominator species respectively.
This class implements the
evaluate()
method required bymumpce.model()
. It class takes all the arguments of the shock_tube class and the following additional arguments:Parameters: - crit_numerator (str) – The name of the numerator species
- crit_denom (str) – The name of the denominator species
- integration_time (float) – The time over which the reactor will be integrated. Default 100 microseconds
-
evaluate
()¶ Compute the concentration of the critical species
Returns: Critical species mole fraction Return type: float
-
integration_time
= None¶ The time for which the reactor will be integrated