Generic chemistry interface for Cantera¶
The generic chemistry interface for Cantera defines a number of common methods that are used for all Cantera-based simulations. These methods create and modify Cantera phase objects for sensitivity analysis.
Initialization function summary¶
-
cantera_utils.
measurement_initialize
(filename, chemistry_model)¶ Read a text file to initialize a batch of measurements
-
cantera_utils.
measurement_initialize_pd
(source, chemistry_model=None, **kwargs)¶ Read a database file in Excel into a Pandas dataframe, then process the dataframe into a batch of measurements
Parameters: source – The file that contains the experimental database. Key chemistry_model: The Cantera chemistry model. It must be a chemistry model that can be used to make a Cantera phase object
Generic chemistry model method summary¶
CanteraChemistryModel (T, Patm, composition, …) |
A class for Cantera chemistry models. |
CanteraChemistryModel.sensitivity (…[, tq]) |
Evaluates the sensitivity of the model value with respect to the model parameters |
CanteraChemistryModel.get_parameter (parameter_id) |
Retrieves a model parameter’s value. |
CanteraChemistryModel.perturb_parameter (…) |
Replaces a model parameter’s value by a new value. |
CanteraChemistryModel.reset_model () |
Reset all model parameters to their original values |
CanteraChemistryModel.get_model_parameter_info ([…]) |
Gets the list of available parameters for this model |
CanteraChemistryModel.prepare_chemistry ([…]) |
Instantiate the Cantera chemistry model and get information about the reaction model. |
CanteraChemistryModel.initialize_chemistry () |
Create the Cantera phase object and set its initial state |
CanteraChemistryModel.blank_chemistry () |
Erase the Cantera phase object, Cantera reactor object, and Cantera simulation object. |
Generic Cantera chemistry model class¶
-
class
cantera_chemistry_model.
CanteraChemistryModel
(T, Patm, composition, chemistry_model, **kwargs)¶ A class for Cantera chemistry models.
Parameters: - T (float) – The unburned gas temperature in Kelvins
- Patm (float) – The pressure in atmospheres (will be converted internally to Pa)
- composition (str,ndarray(float)) – The composition of the unburned gas. Can be a float array or a Cantera composition string
- chemistry_model (str) – The chemistry model for the flame. Must be a chemistry model that can be used to make a Cantera phase object
Key no_falloff: If False, the falloff parameters for reactions will be available as active parameters (default True)
Key no_energies: if False, the activation energies will be available as active parameters. (default True)
This is a class that implements certain common methods for the Cantera-based simulations in this package. It is a subclass of
Model
. It implements the following methods required byModel
:You cannot instantiate a member of this class because it does not have an
evaluate()
method.It also includes the following methods that permit easier access to the Cantera objects that the model contains:
In addition, the method
initialize_reactor()
is provided as an abstract method. Subclasses of this class must define this method or else they cannot be instantiated.-
sensitivity
(perturbation, parameter_list, logfile, tq=True)¶ Evaluates the sensitivity of the model value with respect to the model parameters
Parameters: - perturbation (float) – The amount to perturb each parameter during the sensitivity analysis
- parameter_list (array_like) – The list of parameters to perturb. This will be a list of parameter identifiers, which are usually ints or strs.
- logfile (str) – The logging file that will contain the sensitivity calculation output.
Returns: model_value,sensitivity_vector
Return type: float,ndarray
-
get_parameter
(parameter_id)¶ Retrieves a model parameter’s value.
This will retrive the parameter specified by parameter_id, which will be either a reaction pre-exponential factor or an activation energy.
Parameters: parameter_id (int) – The parameter identifier. Returns: parameter_value Return type: float
-
perturb_parameter
(parameter_id, new_value)¶ Replaces a model parameter’s value by a new value.
This will replace a reaction’s pre-exponential factor or activation energy with a new value
Parameters: - parameter_id (int) – The parameter identifier.
- new_value (float) – The amount to change the parameters value.
-
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.
-
get_model_parameter_info
(no_efficiencies=False, no_energy=False, no_falloff=False)¶ Gets the list of available parameters for this model
Parameters: - no_efficiencies – If True, then do not consider the third-body efficiencies as active parameters
- no_energies – If True, then do not consider activation energies as active parameters
- no_falloff – If True, then do not consider high- and low-pressure limits as active parameters
Returns: model_parameter_info
Return type: list of dicts
-
prepare_chemistry
(no_efficiencies=True, no_energy=True, no_falloff=True, **kwargs)¶ Instantiate the Cantera chemistry model and get information about the reaction model. This is called during instantiation of the model and normally would not be called at any other time.
-
initialize_chemistry
()¶ Create the Cantera phase object and set its initial state
This method does the following:
- Checks to see if a Cantera Solution object exists that defined the thermodynamic state of the Cantera reactor, and creates that object if it does not exist
- Sets the state of the Cantera Solution object to the state specified in self.initial
-
blank_chemistry
()¶ Erase the Cantera phase object, Cantera reactor object, and Cantera simulation object.