{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# I - An example to start with ..." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
This first tutorial's main objective is to help you get started with the Python interface of Cantera. The goal here is to get acquainted with the notion of objects and functions that we will encounter\n", "in all Python scripts.
\n", "We will start by defining a simple gaseous object directly in a script, before\n", "introducing the Python terminal and its possibilities. Next, we will see how to access and modify the\n", " state of this newly instantiated gas object through adequate functions; before concluding with a\n", "general discussion on the specificities of gaseous objects.
\n", " The second objective of this first tutorial is to introduce the data file format of Cantera, which\n", "will be the subject of the second tutorial.
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Importation of cantera" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import cantera as ct\n", "from cantera import cti2yaml" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. Create solution from yaml file" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
This will create an instance of the class Solution from cantera package.\n", "
\n", "The file gri30.yaml contains all the important informations about the chemistry, meaning :
\n", "\n", "- the properties of the different species\n", "- the reactions \n", "- the kinetics used\n", "- the type of transport used\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "gas = ct.Solution(\"gri30.yaml\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "NB : Cantera only supports yaml format mechanisms. Indeed, yaml format is more human readable and more flexible than cti format (used in the previous versions of Cantera). \n", "\n", "You will see some more information about the structure and the data present in this yaml file at the end of this tutorial, and how to convert a cti to a yaml file.\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. Choose and print the thermodynamic state of the gas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "To define the mixture of the gas correctly, it is necessary to define two thermodynamic parameters and the quantities of the different species ( molar fraction X or mass fraction Y ). \n", "These commands give all the interesting informations for the gas state, namely the temperature, the pressure and the density of the mixture. \n", " \n", "It also gives information about the species in the mixture as mass fractions Y or molar fractions X.\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "NB : If you are lost, you can still use the function **help** to see what are the functions available for a gaseous object." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on Solution in module cantera.composite object:\n", "\n", "class Solution(cantera.transport.Transport, cantera.kinetics.Kinetics, cantera.thermo.ThermoPhase)\n", " | A class for chemically-reacting solutions. Instances can be created to\n", " | represent any type of solution -- a mixture of gases, a liquid solution, or\n", " | a solid solution, for example.\n", " | \n", " | Class `Solution` derives from classes `ThermoPhase`, `Kinetics`, and\n", " | `Transport`. It defines no methods of its own, and is provided so that a\n", " | single object can be used to compute thermodynamic, kinetic, and transport\n", " | properties of a solution.\n", " | \n", " | To skip initialization of the Transport object, pass the keyword argument\n", " | ``transport_model=None`` to the `Solution` constructor.\n", " | \n", " | The most common way to instantiate `Solution` objects is by using a phase\n", " | definition, species and reactions defined in an input file::\n", " | \n", " | gas = ct.Solution('gri30.yaml')\n", " | \n", " | If an input file defines multiple phases, the corresponding key in the\n", " | ``phases`` map can be used to specify the desired phase via the ``name`` keyword\n", " | argument of the constructor::\n", " | \n", " | gas = ct.Solution('diamond.yaml', name='gas')\n", " | diamond = ct.Solution('diamond.yaml', name='diamond')\n", " | \n", " | The name of the `Solution` object defaults to the *phase* identifier\n", " | specified in the input file. Upon initialization of a `Solution` object,\n", " | a custom name can assigned via::\n", " | \n", " | gas.name = 'my_custom_name'\n", " | \n", " | `Solution` objects can also be constructed using `Species` and `Reaction`\n", " | objects which can themselves either be imported from input files or defined\n", " | directly in Python::\n", " | \n", " | spec = ct.Species.list_from_file(\"gri30.yaml\")\n", " | spec_gas = ct.Solution(thermo='ideal-gas', species=spec)\n", " | rxns = ct.Reaction.list_from_file(\"gri30.yaml\", spec_gas)\n", " | gas = ct.Solution(thermo='ideal-tas', kinetics='gas',\n", " | species=spec, reactions=rxns, name='my_custom_name')\n", " | \n", " | where the ``thermo`` and ``kinetics`` keyword arguments are strings\n", " | specifying the thermodynamic and kinetics model, respectively, and\n", " | ``species`` and ``reactions`` keyword arguments are lists of `Species` and\n", " | `Reaction` objects, respectively. Note that importing the reactions from a\n", " | YAML input file requires a `Kinetics` object containing the species, as\n", " | shown.\n", " | \n", " | Types of underlying models that form the composite `Solution` object are\n", " | queried using the ``thermo_model``, ``kinetics_model`` and\n", " | ``transport_model`` attributes; further, the ``composite`` attribute is a\n", " | shorthand returning a tuple containing the types of the three constitutive\n", " | models.\n", " | \n", " | For non-trivial uses cases of this functionality, see the examples\n", " | `extract_submechanism.py `_\n", " | and `mechanism_reduction.py `_.\n", " | \n", " | In addition, `Solution` objects can be constructed by passing the text of\n", " | the YAML phase definition in directly, using the ``yaml`` keyword\n", " | argument::\n", " | \n", " | yaml_def = '''\n", " | phases:\n", " | - name: gas\n", " | thermo: ideal-gas\n", " | kinetics: gas\n", " | elements: [O, H, Ar]\n", " | species:\n", " | - gri30.yaml/species: all\n", " | reactions:\n", " | - gri30.yaml/reactions: declared-species\n", " | skip-undeclared-elements: true\n", " | skip-undeclared-third-bodies: true\n", " | state: {T: 300, P: 1 atm}\n", " | '''\n", " | gas = ct.Solution(yaml=yaml_def)\n", " | \n", " | Method resolution order:\n", " | Solution\n", " | cantera.transport.Transport\n", " | cantera.kinetics.Kinetics\n", " | cantera.thermo.ThermoPhase\n", " | cantera.solutionbase._SolutionBase\n", " | builtins.object\n", " | \n", " | Methods inherited from cantera.transport.Transport:\n", " | \n", " | __init__(self, /, *args, **kwargs)\n", " | Initialize self. See help(type(self)) for accurate signature.\n", " | \n", " | __reduce_cython__(...)\n", " | \n", " | __setstate_cython__(...)\n", " | \n", " | get_binary_diff_coeffs_polynomial(self, i, j)\n", " | Get the polynomial fit to the logarithm of temperature for\n", " | the binary diffusion coefficient of species ``i`` and ``j``.\n", " | \n", " | get_collision_integral_polynomials(self, i, j)\n", " | Get the polynomial fit to the logarithm of temperature for\n", " | the collision integral of species ``i`` and ``j``.\n", " | \n", " | get_thermal_conductivity_polynomial(self, i)\n", " | Get the polynomial fit to the logarithm of temperature for\n", " | the thermal conductivity of species ``i``.\n", " | \n", " | get_viscosity_polynomial(self, i)\n", " | Get the polynomial fit to the logarithm of temperature for\n", " | the viscosity of species ``i``.\n", " | \n", " | set_binary_diff_coeffs_polynomial(self, i, j, values)\n", " | Set the polynomial fit to the logarithm of temperature for\n", " | the binary diffusion coefficient of species ``i`` and ``j``.\n", " | \n", " | set_collision_integral_polynomial(self, i, j, avalues, bvalues, cvalues, actualT)\n", " | Get the polynomial fit to the logarithm of temperature for\n", " | the collision integral of species ``i`` and ``j``.\n", " | \n", " | set_thermal_conductivity_polynomial(self, i, values)\n", " | Set the polynomial fit to the logarithm of temperature for\n", " | the thermal conductivity of species ``i``.\n", " | \n", " | set_viscosity_polynomial(self, i, values)\n", " | Set the polynomial fit to the logarithm of temperature for\n", " | the viscosity of species ``i``.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Static methods inherited from cantera.transport.Transport:\n", " | \n", " | __new__(*args, **kwargs) from builtins.type\n", " | Create and return a new object. See help(type) for accurate signature.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data descriptors inherited from cantera.transport.Transport:\n", " | \n", " | CK_mode\n", " | Boolean to indicate if the chemkin interpretation is used.\n", " | \n", " | binary_diff_coeffs\n", " | Binary diffusion coefficients [m^2/s].\n", " | \n", " | electrical_conductivity\n", " | Electrical conductivity. [S/m].\n", " | \n", " | mix_diff_coeffs\n", " | Mixture-averaged diffusion coefficients [m^2/s] relating the\n", " | mass-averaged diffusive fluxes (with respect to the mass averaged\n", " | velocity) to gradients in the species mole fractions.\n", " | \n", " | mix_diff_coeffs_mass\n", " | Mixture-averaged diffusion coefficients [m^2/s] relating the\n", " | diffusive mass fluxes to gradients in the species mass fractions.\n", " | \n", " | mix_diff_coeffs_mole\n", " | Mixture-averaged diffusion coefficients [m^2/s] relating the\n", " | molar diffusive fluxes to gradients in the species mole fractions.\n", " | \n", " | mobilities\n", " | Electrical mobilities of charged species [m^2/s-V]\n", " | \n", " | multi_diff_coeffs\n", " | Multicomponent diffusion coefficients, D[i,j], the diffusion\n", " | coefficient for species i due to concentration gradients in\n", " | species j [m**2/s].\n", " | \n", " | species_viscosities\n", " | Pure species viscosities [Pa-s]\n", " | \n", " | thermal_conductivity\n", " | Thermal conductivity. [W/m/K]\n", " | \n", " | thermal_diff_coeffs\n", " | Return a one-dimensional array of the species thermal diffusion\n", " | coefficients [kg/m/s].\n", " | \n", " | transport_model\n", " | Get/Set the transport model associated with this transport model.\n", " | \n", " | Setting a new transport model deletes the underlying C++ Transport\n", " | object and replaces it with a new one implementing the specified model.\n", " | \n", " | viscosity\n", " | Viscosity [Pa-s].\n", " | \n", " | ----------------------------------------------------------------------\n", " | Methods inherited from cantera.kinetics.Kinetics:\n", " | \n", " | add_reaction(self, rxn)\n", " | Add a new reaction to this phase.\n", " | \n", " | kinetics_species_index(self, species, phase)\n", " | The index of species ``species`` of phase ``phase`` within arrays returned\n", " | by methods of class `Kinetics`. If ``species`` is a string, the ``phase``\n", " | argument is unused.\n", " | \n", " | kinetics_species_name(self, k)\n", " | Name of the species with index ``k`` in the arrays returned by methods\n", " | of class `Kinetics`.\n", " | \n", " | modify_reaction(self, irxn, rxn)\n", " | Modify the `Reaction` with index ``irxn`` to have the same rate\n", " | parameters as ``rxn``. ``rxn`` must have the same reactants and products\n", " | and be of the same type (for example, `ElementaryReaction`, `FalloffReaction`,\n", " | `PlogReaction`, etc.) as the existing reaction. This method does not\n", " | modify the third-body efficiencies, reaction orders, or reversibility of\n", " | the reaction.\n", " | \n", " | multiplier(self, i_reaction)\n", " | A scaling factor applied to the rate coefficient for reaction\n", " | ``i_reaction``. Can be used to carry out sensitivity analysis or to\n", " | selectively disable a particular reaction. See `set_multiplier`.\n", " | \n", " | product_stoich_coeff(self, k_spec, i_reaction)\n", " | The stoichiometric coefficient of species ``k_spec`` as a product in\n", " | reaction ``i_reaction``.\n", " | \n", " | reactant_stoich_coeff(self, k_spec, i_reaction)\n", " | The stoichiometric coefficient of species ``k_spec`` as a reactant in\n", " | reaction ``i_reaction``.\n", " | \n", " | reaction(self, i_reaction)\n", " | Return a `Reaction` object representing the reaction with index\n", " | ``i_reaction``. Changes to this object do not affect the `Kinetics` or\n", " | `Solution` object until the `modify_reaction` function is called.\n", " | \n", " | reaction_equations(self, indices)\n", " | Returns a list containing the reaction equation for all reactions in the\n", " | mechanism if ``indices`` is unspecified, or the equations for each\n", " | reaction in the sequence ``indices``. For example::\n", " | \n", " | >>> gas.reaction_equations()\n", " | ['2 O + M <=> O2 + M', 'O + H + M <=> OH + M', 'O + H2 <=> H + OH', ...]\n", " | >>> gas.reaction_equations([2,3])\n", " | ['O + H + M <=> OH + M', 'O + H2 <=> H + OH']\n", " | \n", " | See also `reaction_equation`.\n", " | \n", " | reactions(self)\n", " | Return a list of all `Reaction` objects. Changes to these objects do not\n", " | affect the `Kinetics` or `Solution` object until the `modify_reaction`\n", " | function is called.\n", " | \n", " | reset_custom(self)\n", " | Function calling the dlclose in CustomKinetics\n", " | in order to close the dynamic library (handle)\n", " | \n", " | set_multiplier(self, value, i_reaction)\n", " | Set the multiplier for for reaction ``i_reaction`` to ``value``.\n", " | If ``i_reaction`` is not specified, then the multiplier for all reactions\n", " | is set to ``value``. See `multiplier`.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data descriptors inherited from cantera.kinetics.Kinetics:\n", " | \n", " | creation_rates\n", " | Creation rates for each species. [kmol/m^3/s] for bulk phases or\n", " | [kmol/m^2/s] for surface phases.\n", " | \n", " | creation_rates_ddC\n", " | Calculate derivatives of species creation rates with respect to molar\n", " | concentration at constant temperature, pressure and mole fractions.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | creation_rates_ddCi\n", " | Calculate derivatives for species creation rates with respect to species\n", " | concentration at constant temperature, pressure, and concentration of all other\n", " | species. For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | The method returns a matrix with `n_total_species` rows and `n_total_species`\n", " | columns.\n", " | \n", " | For a derivative with respect to :math: `c_i`, all other :math: `c_i` are\n", " | held constant.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | .. versionadded:: 3.0\n", " | \n", " | creation_rates_ddP\n", " | Calculate derivatives of species creation rates with respect to pressure\n", " | at constant temperature, molar concentration and mole fractions.\n", " | \n", " | creation_rates_ddT\n", " | Calculate derivatives of species creation rates with respect to temperature\n", " | at constant pressure, molar concentration and mole fractions.\n", " | \n", " | creation_rates_ddX\n", " | Calculate derivatives for species creation rates with respect to species\n", " | concentrations at constant temperature, pressure and molar concentration.\n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | Note that for derivatives with respect to :math:`X_i`, all other :math:`X_j`\n", " | are held constant, rather than enforcing :math:`\\sum X_j = 1`.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | delta_enthalpy\n", " | Change in enthalpy for each reaction [J/kmol].\n", " | \n", " | delta_entropy\n", " | Change in entropy for each reaction [J/kmol/K].\n", " | \n", " | delta_gibbs\n", " | Change in Gibbs free energy for each reaction [J/kmol].\n", " | \n", " | delta_standard_enthalpy\n", " | Change in standard-state enthalpy (independent of composition) for\n", " | each reaction [J/kmol].\n", " | \n", " | delta_standard_entropy\n", " | Change in standard-state entropy (independent of composition) for\n", " | each reaction [J/kmol/K].\n", " | \n", " | delta_standard_gibbs\n", " | Change in standard-state Gibbs free energy (independent of composition)\n", " | for each reaction [J/kmol].\n", " | \n", " | derivative_settings\n", " | Property setting behavior of derivative evaluation.\n", " | \n", " | For ``GasKinetics``, the following keyword/value pairs are supported:\n", " | \n", " | - ``skip-third-bodies`` (boolean) ... if `False` (default), third body\n", " | concentrations are considered for the evaluation of derivatives\n", " | \n", " | - ``skip-falloff`` (boolean) ... if `True` (default), third-body effects\n", " | on reaction rates are not considered.\n", " | \n", " | - ``rtol-delta`` (double) ... relative tolerance used to perturb properties\n", " | when calculating numerical derivatives. The default value is 1e-8.\n", " | \n", " | Derivative settings are updated using a dictionary::\n", " | \n", " | >>> gas.derivative_settings = {\"skip-falloff\": True}\n", " | \n", " | Passing an empty dictionary will reset all values to their defaults.\n", " | \n", " | destruction_rates\n", " | Destruction rates for each species. [kmol/m^3/s] for bulk phases or\n", " | [kmol/m^2/s] for surface phases.\n", " | \n", " | destruction_rates_ddC\n", " | Calculate derivatives of species destruction rates with respect to molar\n", " | concentration at constant temperature, pressure and mole fractions.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | destruction_rates_ddCi\n", " | Calculate derivatives for species destruction rates with respect to species\n", " | concentration at constant temperature, pressure, and concentration of all other\n", " | species. For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | The method returns a matrix with `n_total_species` rows and `n_total_species` columns.\n", " | For a derivative with respect to :math: `c_i`, all other :math: `c_i` are\n", " | held constant.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | .. versionadded:: 3.0\n", " | \n", " | destruction_rates_ddP\n", " | Calculate derivatives of species destruction rates with respect to pressure\n", " | at constant temperature, molar concentration and mole fractions.\n", " | \n", " | destruction_rates_ddT\n", " | Calculate derivatives of species destruction rates with respect to temperature\n", " | at constant pressure, molar concentration and mole fractions.\n", " | \n", " | destruction_rates_ddX\n", " | Calculate derivatives for species destruction rates with respect to species\n", " | concentrations at constant temperature, pressure and molar concentration.\n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | Note that for derivatives with respect to :math:`X_i`, all other :math:`X_j`\n", " | are held constant, rather than enforcing :math:`\\sum X_j = 1`.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | equilibrium_constants\n", " | Equilibrium constants in concentration units for all reactions.\n", " | \n", " | forward_rate_constants\n", " | Forward rate constants for all reactions.\n", " | \n", " | The computed values include all temperature-dependent and pressure-dependent\n", " | contributions. By default, third-body concentrations are only considered if\n", " | they are part of the reaction rate definition; for a legacy implementation that\n", " | includes third-body concentrations, see `use_legacy_rate_constants`.\n", " | \n", " | forward_rate_constants_ddC\n", " | Calculate derivatives for forward rate constants with respect to molar\n", " | concentration at constant temperature, pressure and mole fractions.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | forward_rate_constants_ddP\n", " | Calculate derivatives for forward rate constants with respect to pressure\n", " | at constant temperature, molar concentration and mole fractions.\n", " | \n", " | forward_rate_constants_ddT\n", " | Calculate derivatives for forward rate constants with respect to temperature\n", " | at constant pressure, molar concentration and mole fractions.\n", " | \n", " | forward_rates_of_progress\n", " | Forward rates of progress for the reactions. [kmol/m^3/s] for bulk\n", " | phases or [kmol/m^2/s] for surface phases.\n", " | \n", " | forward_rates_of_progress_ddC\n", " | Calculate derivatives for forward rates-of-progress with respect to molar\n", " | concentration at constant temperature, pressure and mole fractions.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | forward_rates_of_progress_ddCi\n", " | Calculate derivatives for forward rates-of-progress with respect to species\n", " | concentrations at constant temperature, pressure and remaining species\n", " | concentrations.\n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | Note that for derivatives with respect to :math:`c_i`, all other :math:`c_j`\n", " | are held constant.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | .. versionadded:: 3.0\n", " | \n", " | forward_rates_of_progress_ddP\n", " | Calculate derivatives for forward rates-of-progress with respect to pressure\n", " | at constant temperature, molar concentration and mole fractions.\n", " | \n", " | forward_rates_of_progress_ddT\n", " | Calculate derivatives for forward rates-of-progress with respect to temperature\n", " | at constant pressure, molar concentration and mole fractions.\n", " | \n", " | forward_rates_of_progress_ddX\n", " | Calculate derivatives for forward rates-of-progress with respect to species\n", " | concentrations at constant temperature, pressure and molar concentration.\n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | Note that for derivatives with respect to :math:`X_i`, all other :math:`X_j`\n", " | are held constant, rather than enforcing :math:`\\sum X_j = 1`.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | heat_production_rates\n", " | Get the volumetric heat production rates [W/m^3] on a per-reaction\n", " | basis. The sum over all reactions results in the total volumetric heat\n", " | release rate.\n", " | Example: C. K. Law: Combustion Physics (2006), Fig. 7.8.6\n", " | \n", " | >>> gas.heat_production_rates[1] # heat production rate of the 2nd reaction\n", " | \n", " | heat_release_rate\n", " | Get the total volumetric heat release rate [W/m^3].\n", " | \n", " | kinetics_model\n", " | Return type of kinetics.\n", " | \n", " | kinetics_species_names\n", " | A list of all species names, corresponding to the arrays returned by\n", " | methods of class `Kinetics`.\n", " | \n", " | n_phases\n", " | Number of phases in the reaction mechanism.\n", " | \n", " | n_reactions\n", " | Number of reactions in the reaction mechanism.\n", " | \n", " | n_total_species\n", " | Total number of species in all phases participating in the kinetics\n", " | mechanism.\n", " | \n", " | net_production_rates\n", " | Net production rates for each species. [kmol/m^3/s] for bulk phases or\n", " | [kmol/m^2/s] for surface phases.\n", " | \n", " | net_production_rates_ddC\n", " | Calculate derivatives of species net production rates with respect to molar\n", " | density at constant temperature, pressure and mole fractions.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | net_production_rates_ddCi\n", " | Calculate derivatives for species net production rates with respect to species\n", " | concentration at constant temperature, pressure, and concentration of all other\n", " | species. For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | The method returns a matrix with `n_total_species` rows and `n_total_species` columns.\n", " | For a derivative with respect to :math: `c_i`, all other :math: `c_i` are\n", " | held constant.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | .. versionadded:: 3.0\n", " | \n", " | net_production_rates_ddP\n", " | Calculate derivatives of species net production rates with respect to pressure\n", " | at constant temperature, molar concentration and mole fractions.\n", " | \n", " | net_production_rates_ddT\n", " | Calculate derivatives of species net production rates with respect to\n", " | temperature at constant pressure, molar concentration and mole fractions.\n", " | \n", " | net_production_rates_ddX\n", " | Calculate derivatives for species net production rates with respect to species\n", " | concentrations at constant temperature, pressure and molar concentration.\n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | Note that for derivatives with respect to :math:`X_i`, all other :math:`X_j`\n", " | are held constant, rather than enforcing :math:`\\sum X_j = 1`.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | net_rates_of_progress\n", " | Net rates of progress for the reactions. [kmol/m^3/s] for bulk phases\n", " | or [kmol/m^2/s] for surface phases.\n", " | \n", " | net_rates_of_progress_ddC\n", " | Calculate derivatives for net rates-of-progress with respect to molar\n", " | concentration at constant temperature, pressure and mole fractions.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | net_rates_of_progress_ddCi\n", " | Calculate derivatives for net rates-of-progress with respect to species\n", " | concentrations at constant temperature, pressure and remaining species\n", " | concentrations. For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | Note that for derivatives with respect to :math:`c_i`, all other :math:`c_j`\n", " | are held constant.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | .. versionadded:: 3.0\n", " | \n", " | net_rates_of_progress_ddP\n", " | Calculate derivatives for net rates-of-progress with respect to pressure\n", " | at constant temperature, molar concentration and mole fractions.\n", " | \n", " | net_rates_of_progress_ddT\n", " | Calculate derivatives for net rates-of-progress with respect to temperature\n", " | at constant pressure, molar concentration and mole fractions.\n", " | \n", " | net_rates_of_progress_ddX\n", " | Calculate derivatives for net rates-of-progress with respect to species\n", " | concentrations at constant temperature, pressure and molar concentration.\n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | Note that for derivatives with respect to :math:`X_i`, all other :math:`X_j`\n", " | are held constant, rather than enforcing :math:`\\sum X_j = 1`.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | product_stoich_coeffs\n", " | The array of product stoichiometric coefficients. Element ``[k,i]`` of\n", " | this array is the product stoichiometric coefficient of species ``k`` in\n", " | reaction ``i``.\n", " | \n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | .. versionchanged:: 3.0\n", " | \n", " | Method was changed to a property in Cantera 3.0.\n", " | \n", " | product_stoich_coeffs3\n", " | The array of product stoichiometric coefficients. Element ``[k,i]`` of\n", " | this array is the product stoichiometric coefficient of species ``k`` in\n", " | reaction ``i``.\n", " | \n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | .. deprecated:: 3.0\n", " | \n", " | Method to be removed after Cantera 3.0. Replaceable by\n", " | `Kinetics.product_stoich_coeffs`\n", " | \n", " | product_stoich_coeffs_reversible\n", " | The array of product stoichiometric coefficients of reversible reactions.\n", " | Element ``[k,i]`` of this array is the product stoichiometric coefficient\n", " | of species ``k`` in reaction ``i``.\n", " | \n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | reactant_stoich_coeffs\n", " | The array of reactant stoichiometric coefficients. Element ``[k,i]`` of\n", " | this array is the reactant stoichiometric coefficient of species ``k`` in\n", " | reaction ``i``.\n", " | \n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | .. versionchanged:: 3.0\n", " | \n", " | Method was changed to a property in Cantera 3.0.\n", " | \n", " | reactant_stoich_coeffs3\n", " | The array of reactant stoichiometric coefficients. Element ``[k,i]`` of\n", " | this array is the reactant stoichiometric coefficient of species ``k`` in\n", " | reaction ``i``.\n", " | \n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | .. deprecated:: 3.0\n", " | \n", " | Method to be removed after Cantera 3.0. Replaceable by\n", " | `Kinetics.reactant_stoich_coeffs`\n", " | \n", " | reaction_phase_index\n", " | The index of the phase where the reactions occur.\n", " | \n", " | .. deprecated:: 3.0\n", " | \n", " | After Cantera 3.0, the reacting phase is always the first phase associated\n", " | with the Kinetics object. This method will be removed after Cantera 3.1.\n", " | \n", " | reverse_rate_constants\n", " | Reverse rate constants for all reactions.\n", " | \n", " | The computed values include all temperature-dependent and pressure-dependent\n", " | contributions. By default, third-body concentrations are only considered if\n", " | they are part of the reaction rate definition; for a legacy implementation that\n", " | includes third-body concentrations, see `use_legacy_rate_constants`.\n", " | \n", " | reverse_rates_of_progress\n", " | Reverse rates of progress for the reactions. [kmol/m^3/s] for bulk\n", " | phases or [kmol/m^2/s] for surface phases.\n", " | \n", " | reverse_rates_of_progress_ddC\n", " | Calculate derivatives for reverse rates-of-progress with respect to molar\n", " | concentration at constant temperature, pressure and mole fractions.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | reverse_rates_of_progress_ddCi\n", " | Calculate derivatives for reverse rates-of-progress with respect to species\n", " | concentrations at constant temperature, pressure and remaining species\n", " | concentrations.\n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | Note that for derivatives with respect to :math:`c_i`, all other :math:`c_j`\n", " | are held constant.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | .. versionadded:: 3.0\n", " | \n", " | reverse_rates_of_progress_ddP\n", " | Calculate derivatives for reverse rates-of-progress with respect to pressure\n", " | at constant temperature, molar concentration and mole fractions.\n", " | \n", " | reverse_rates_of_progress_ddT\n", " | Calculate derivatives for reverse rates-of-progress with respect to temperature\n", " | at constant pressure, molar concentration and mole fractions.\n", " | \n", " | reverse_rates_of_progress_ddX\n", " | Calculate derivatives for reverse rates-of-progress with respect to species\n", " | concentrations at constant temperature, pressure and molar concentration.\n", " | For sparse output, set ``ct.use_sparse(True)``.\n", " | \n", " | Note that for derivatives with respect to :math:`X_i`, all other :math:`X_j`\n", " | are held constant, rather than enforcing :math:`\\sum X_j = 1`.\n", " | \n", " | .. warning::\n", " | \n", " | This property is an experimental part of the Cantera API and\n", " | may be changed or removed without notice.\n", " | \n", " | third_body_concentrations\n", " | Effective third-body concentrations used by individual reactions; values\n", " | are only defined for reactions involving third-bodies and are set to\n", " | not-a-number otherwise.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Methods inherited from cantera.thermo.ThermoPhase:\n", " | \n", " | __call__(self, /, *args, **kwargs)\n", " | Call self as a function.\n", " | \n", " | add_species(self, species)\n", " | Add a new species to this phase. Missing elements will be added\n", " | automatically.\n", " | \n", " | add_species_alias(self, name, alias)\n", " | Add the alternate species name ``alias`` for an original species ``name``.\n", " | \n", " | atomic_weight(self, m)\n", " | Atomic weight [kg/kmol] of element ``m``\n", " | \n", " | element_index(self, element)\n", " | The index of element ``element``, which may be specified as a string or\n", " | an integer. In the latter case, the index is checked for validity and\n", " | returned. If no such element is present, an exception is thrown.\n", " | \n", " | element_name(self, m)\n", " | Name of the element with index ``m``.\n", " | \n", " | elemental_mass_fraction(self, m)\n", " | Get the elemental mass fraction :math:`Z_{\\mathrm{mass},m}` of element\n", " | :math:`m` as defined by:\n", " | \n", " | .. math:: Z_{\\mathrm{mass},m} = \\sum_k \\frac{a_{m,k} M_m}{M_k} Y_k\n", " | \n", " | with :math:`a_{m,k}` being the number of atoms of element :math:`m` in\n", " | species :math:`k`, :math:`M_m` the atomic weight of element :math:`m`,\n", " | :math:`M_k` the molecular weight of species :math:`k`, and :math:`Y_k`\n", " | the mass fraction of species :math:`k`::\n", " | \n", " | >>> phase.elemental_mass_fraction('H')\n", " | 1.0\n", " | \n", " | :param m:\n", " | Base element, may be specified by name or by index.\n", " | \n", " | elemental_mole_fraction(self, m)\n", " | Get the elemental mole fraction :math:`Z_{\\mathrm{mole},m}` of element\n", " | :math:`m` (the number of atoms of element m divided by the total number\n", " | of atoms) as defined by:\n", " | \n", " | .. math:: Z_{\\mathrm{mole},m} = \\frac{\\sum_k a_{m,k} X_k}\n", " | {\\sum_k \\sum_j a_{j,k} X_k}\n", " | \n", " | with :math:`a_{m,k}` being the number of atoms of element :math:`m` in\n", " | species :math:`k`, :math:`\\sum_j` being a sum over all elements, and\n", " | :math:`X_k` being the mole fraction of species :math:`k`::\n", " | \n", " | >>> phase.elemental_mole_fraction('H')\n", " | 1.0\n", " | \n", " | :param m:\n", " | Base element, may be specified by name or by index.\n", " | \n", " | equilibrate(self, XY, solver, rtol, max_steps, max_iter, estimate_equil, log_level)\n", " | Set to a state of chemical equilibrium holding property pair\n", " | ``XY`` constant.\n", " | \n", " | :param XY:\n", " | A two-letter string, which must be one of the set::\n", " | \n", " | ['TP','TV','HP','SP','SV','UV']\n", " | \n", " | :param solver:\n", " | Specifies the equilibrium solver to use. May be one of the following:\n", " | \n", " | * ``'element_potential'`` - a fast solver using the element potential\n", " | method\n", " | * ``'gibbs'`` - a slower but more robust Gibbs minimization solver\n", " | * ``'vcs'`` - the VCS non-ideal equilibrium solver\n", " | * ``'auto'`` - The element potential solver will be tried first, then\n", " | if it fails the Gibbs solver will be tried.\n", " | :param rtol:\n", " | The relative error tolerance.\n", " | :param max_steps:\n", " | The maximum number of steps in composition to take to find a converged\n", " | solution.\n", " | :param max_iter:\n", " | For the Gibbs minimization solver, this specifies the number of\n", " | outer iterations on T or P when some property pair other\n", " | than TP is specified.\n", " | :param estimate_equil:\n", " | Integer indicating whether the solver should estimate its own\n", " | initial condition. If 0, the initial mole fraction vector in the\n", " | `ThermoPhase` object is used as the initial condition. If 1, the\n", " | initial mole fraction vector is used if the element abundances are\n", " | satisfied. If -1, the initial mole fraction vector is thrown out,\n", " | and an estimate is formulated.\n", " | :param log_level:\n", " | Set to a value greater than 0 to write diagnostic output.\n", " | \n", " | equivalence_ratio(self, fuel, oxidizer, basis, include_species)\n", " | Get the equivalence ratio :math:`\\phi` of the current mixture, which is a\n", " | conserved quantity. Considers the oxidation of C to CO2, H to H2O\n", " | and S to SO2. Other elements are assumed not to participate in oxidation\n", " | (that is, N ends up as N2). If fuel and oxidizer are not specified, the\n", " | equivalence ratio is computed from the available oxygen and the\n", " | required oxygen for complete oxidation:\n", " | \n", " | .. math:: \\phi = \\frac{Z_{\\mathrm{mole},C} + Z_{\\mathrm{mole},S}\n", " | + \\frac{1}{4}Z_{\\mathrm{mole},H}} {\\frac{1}{2}Z_{\\mathrm{mole},O}}\n", " | \n", " | where :math:`Z_{\\mathrm{mole},e}` is the elemental mole fraction of element\n", " | :math:`e`. If the fuel and oxidizer compositions are specified, :math:`\\phi` is\n", " | computed from:\n", " | \n", " | .. math:: \\phi = \\frac{Z}{1-Z}\\frac{1-Z_{\\mathrm{st}}}{Z_{\\mathrm{st}}}\n", " | \n", " | where :math:`Z` is the Bilger mixture fraction and :math:`Z_{\\mathrm{st}}`\n", " | the Bilger mixture fraction at stoichiometric conditions.\n", " | The ``basis`` determines the composition of fuel and oxidizer:\n", " | ``basis='mole'`` (default) means mole fractions, ``basis='mass'`` means\n", " | mass fractions. Note that this definition takes all species into account.\n", " | In case certain species like inert diluents should be ignored, a\n", " | list of species can be provided with ``include_species``. This means that\n", " | only these species are considered for the computation of the equivalence\n", " | ratio. For more information, see `Python example\n", " | `_ ::\n", " | \n", " | >>> gas.set_equivalence_ratio(0.5, fuel='CH3:0.5, CH3OH:.5, N2:0.125', oxidizer='O2:0.21, N2:0.79, NO:0.01')\n", " | >>> gas.equivalence_ratio(fuel='CH3:0.5, CH3OH:.5, N2:0.125', oxidizer='O2:0.21, N2:0.79, NO:0.01')\n", " | 0.5\n", " | \n", " | :param fuel:\n", " | Fuel species name or mole/mass fractions as string, array, or dict.\n", " | :param oxidizer:\n", " | Oxidizer species name or mole/mass fractions as a string, array, or dict.\n", " | :param basis:\n", " | Determines if ``fuel`` and ``oxidizer`` are given in mole fractions\n", " | (``basis=\"mole\"``) or mass fractions (``basis=\"mass\"``)\n", " | :param include_species:\n", " | List of species names (optional). Only these species are considered for the\n", " | computation of the equivalence ratio. By default, all species are considered\n", " | \n", " | find_isomers(self, comp)\n", " | Find species/isomers matching a composition specified by ``comp``.\n", " | \n", " | mass_fraction_dict(self, threshold)\n", " | Return a dictionary giving the mass fraction for each species by name where the\n", " | mass fraction is greater than ``threshold``.\n", " | \n", " | mixture_fraction(self, fuel, oxidizer, basis, element)\n", " | Get the mixture fraction of the current mixture in\n", " | (kg fuel / (kg oxidizer + kg fuel)). This is a quantity that is conserved after\n", " | oxidation. Considers the oxidation of C to CO2, H to H2O and S to SO2. Other\n", " | elements are assumed not to participate in oxidation (that is, N ends up as N2).\n", " | The ``basis`` determines the composition of fuel and oxidizer:\n", " | ``basis=\"mole\"`` (default) means mole fractions, ``basis=\"mass\"`` means mass\n", " | fractions. The mixture fraction can be computed from a single element (for\n", " | example, carbon with ``element=\"C\"``)\n", " | \n", " | .. math:: Z_m = \\frac{Z_{\\mathrm{mass},m}-Z_{\\mathrm{mass},m,\\mathrm{ox}}}\n", " | {Z_{\\mathrm{mass},\\mathrm{fuel}}-Z_{\\mathrm{mass},m,\\mathrm{ox}}}\n", " | \n", " | where :math:`Z_{\\mathrm{mass},m}` is the elemental mass fraction of\n", " | element :math:`m` in the mixture, and :math:`Z_{\\mathrm{mass},m,\\mathrm{ox}}`\n", " | and :math:`Z_{\\mathrm{mass},\\mathrm{fuel}}` are the elemental mass fractions of\n", " | the oxidizer and fuel, or from the Bilger mixture fraction\n", " | (``element=\"Bilger\"``), which considers the elements C, S, H and O\n", " | (R. W. Bilger, \"Turbulent jet diffusion flames,\" Prog. Energy Combust. Sci.,\n", " | 109-131 (1979)). The Bilger mixture fraction is computed by default:\n", " | \n", " | .. math:: Z_m = Z_{\\mathrm{Bilger}} = \\frac{\\beta-\\beta_{\\mathrm{ox}}}\n", " | {\\beta_{\\mathrm{fuel}}-\\beta_{\\mathrm{ox}}}\n", " | \n", " | with\n", " | \n", " | .. math:: \\beta = 2\\frac{Z_C}{M_C}+2\\frac{Z_S}{M_S}+\\frac{1}{2}\\frac{Z_H}{M_H}\n", " | - \\frac{Z_O}{M_O}\n", " | \n", " | and :math:`M_m` the atomic weight of element :math:`m`.\n", " | For more information, see `Python example\n", " | `_.::\n", " | \n", " | >>> gas.set_mixture_fraction(0.5, 'CH3:0.5, CH3OH:0.5, N2:0.125', 'O2:0.21, N2:0.79, NO:0.01')\n", " | >>> gas.mixture_fraction('CH3:0.5, CH3OH:0.5, N2:0.125', 'O2:0.21, N2:0.79, NO:.01')\n", " | 0.5\n", " | \n", " | :param fuel:\n", " | Fuel species name or mole/mass fractions as string, array, or dict.\n", " | :param oxidizer:\n", " | Oxidizer species name or mole/mass fractions as a string, array, or\n", " | dict.\n", " | :param basis:\n", " | Determines if ``fuel`` and ``oxidizer`` are given in mole\n", " | fractions (``basis='mole'``) or mass fractions (``basis='mass'``)\n", " | :param element:\n", " | Computes the mixture fraction from the specified elemental\n", " | mass fraction (given by element name or element index) or as\n", " | the Bilger mixture fraction (default)\n", " | \n", " | modify_species(self, k, species)\n", " | Modify the thermodynamic data associated with a species. The species name,\n", " | elemental composition, and type of thermo parameterization must be unchanged.\n", " | \n", " | mole_fraction_dict(self, threshold)\n", " | Return a dictionary giving the mole fraction for each species by name where the\n", " | mole fraction is greater than ``threshold``.\n", " | \n", " | n_atoms(self, species, element)\n", " | Number of atoms of element ``element`` in species ``species``. The element\n", " | and species may be specified by name or by index.\n", " | \n", " | >>> phase.n_atoms('CH4','H')\n", " | 4\n", " | \n", " | report(self, show_thermo, threshold)\n", " | Generate a report describing the thermodynamic state of this phase. To\n", " | print the report to the terminal, simply call the phase object. The\n", " | following two statements are equivalent::\n", " | \n", " | >>> phase()\n", " | >>> print(phase.report())\n", " | \n", " | set_discretized_electron_energy_distribution(self, levels, distribution)\n", " | Set electron energy distribution. When this method is used, electron\n", " | temperature is calculated from the distribution.\n", " | \n", " | :param levels:\n", " | vector of electron energy levels [eV]\n", " | :param distribution:\n", " | vector of distribution\n", " | \n", " | set_equivalence_ratio(self, phi, fuel, oxidizer, basis, *, diluent, fraction)\n", " | Set the composition to a mixture of ``fuel`` and ``oxidizer`` at the\n", " | specified equivalence ratio ``phi``, holding temperature and pressure\n", " | constant. Considers the oxidation of C to CO2, H to H2O and S to SO2.\n", " | Other elements are assumed not to participate in oxidation (that is,\n", " | N ends up as N2). The ``basis`` determines the fuel and oxidizer\n", " | compositions: ``basis='mole'`` means mole fractions (default),\n", " | ``basis='mass'`` means mass fractions. The fuel/oxidizer mixture can be\n", " | be diluted by a ``diluent`` based on a mixing ``fraction``. The amount of\n", " | diluent is quantified as a fraction of fuel, oxidizer or the fuel/oxidizer\n", " | mixture. For more information, see `Python example\n", " | `_ ::\n", " | \n", " | >>> gas.set_equivalence_ratio(0.5, 'CH4', 'O2:1.0, N2:3.76', basis='mole')\n", " | >>> gas.mass_fraction_dict()\n", " | {'CH4': 0.02837633052851, 'N2': 0.7452356312613, 'O2': 0.22638803821018}\n", " | >>> gas.set_equivalence_ratio(1.2, 'NH3:0.8,CO:0.2', 'O2:1', basis='mole')\n", " | >>> gas.mass_fraction_dict()\n", " | {'CO': 0.14784006249290, 'NH3': 0.35956645545401, 'O2': 0.49259348205308}\n", " | \n", " | :param phi:\n", " | Equivalence ratio\n", " | :param fuel:\n", " | Fuel species name or mole/mass fractions as string, array, or dict.\n", " | :param oxidizer:\n", " | Oxidizer species name or mole/mass fractions as a string, array, or dict.\n", " | :param basis:\n", " | Determines if ``fuel`` and ``oxidizer`` are given in mole\n", " | fractions (``basis='mole'``) or mass fractions (``basis='mass'``).\n", " | :param diluent:\n", " | Optional parameter. Required if dilution is used. Specifies the composition\n", " | of the diluent in mole/mass fractions as a string, array or dict.\n", " | :param fraction:\n", " | Optional parameter. Dilutes the fuel/oxidizer mixture with the diluent\n", " | according to ``fraction``. Fraction can refer to the fraction of diluent in\n", " | the mixture (for example ``fraction=\"diluent:0.7\"`` will create a mixture\n", " | with 30 % fuel/oxidizer and 70 % diluent), the fraction of fuel in the\n", " | mixture (for example ``fraction=\"fuel:0.1\"`` means that the mixture contains\n", " | 10 % fuel. The amount of oxidizer is determined from the equivalence ratio\n", " | and the remaining mixture is the diluent) or fraction of oxidizer in the\n", " | mixture (for example ``fraction=\"oxidizer:0.1\"``). The fraction itself is\n", " | interpreted as mole or mass fraction based on ``basis``. The diluent is not\n", " | considered in the computation of the equivalence ratio. Default is no\n", " | dilution or ``fraction=None``. May be given as string or dictionary (for\n", " | example ``fraction={\"fuel\":0.7}``).\n", " | \n", " | set_mixture_fraction(self, mixture_fraction, fuel, oxidizer, basis)\n", " | Set the composition to a mixture of ``fuel`` and ``oxidizer`` at the\n", " | specified mixture fraction ``mixture_fraction`` (kg fuel / kg mixture), holding\n", " | temperature and pressure constant. Considers the oxidation of C to CO2,\n", " | H to H2O and S to SO2. Other elements are assumed not to participate in\n", " | oxidation (that is, N ends up as N2). The ``basis`` determines the composition\n", " | of fuel and oxidizer: ``basis='mole'`` (default) means mole fractions,\n", " | ``basis='mass'`` means mass fractions. For more information, see `Python\n", " | example\n", " | `_ ::\n", " | \n", " | >>> gas.set_mixture_fraction(0.5, 'CH4', 'O2:1.0, N2:3.76')\n", " | >>> gas.mass_fraction_dict()\n", " | {'CH4': 0.5, 'N2': 0.38350014242997776, 'O2': 0.11649985757002226}\n", " | >>> gas.set_mixture_fraction(0.5, {'NH3':0.8, 'CO':0.2}, 'O2:1.0')\n", " | >>> gas.mass_fraction_dict()\n", " | {'CO': 0.145682068778996, 'NH3': 0.354317931221004, 'O2': 0.5}\n", " | \n", " | :param mixture_fraction:\n", " | Mixture fraction (kg fuel / kg mixture)\n", " | :param fuel:\n", " | Fuel species name or mole/mass fractions as string, array, or dict.\n", " | :param oxidizer:\n", " | Oxidizer species name or mole/mass fractions as a string, array, or\n", " | dict.\n", " | :param basis: determines if ``fuel`` and ``oxidizer`` are given in mole\n", " | fractions (``basis='mole'``) or mass fractions (``basis='mass'``)\n", " | \n", " | set_unnormalized_mass_fractions(self, Y)\n", " | Set the mass fractions without normalizing to force ``sum(Y) == 1.0``.\n", " | Useful primarily when calculating derivatives with respect to ``Y[k]`` by\n", " | finite difference.\n", " | \n", " | set_unnormalized_mole_fractions(self, X)\n", " | Set the mole fractions without normalizing to force ``sum(X) == 1.0``.\n", " | Useful primarily when calculating derivatives with respect to ``X[k]``\n", " | by finite difference.\n", " | \n", " | species(self, k)\n", " | Return the `Species` object for species ``k``, where ``k`` is either the\n", " | species index or the species name. If ``k`` is not specified, a list of\n", " | all species objects is returned. Changes to this object do not affect\n", " | the `ThermoPhase` or `Solution` object until the `modify_species`\n", " | function is called.\n", " | \n", " | species_index(self, species)\n", " | The index of species ``species``, which may be specified as a string or\n", " | an integer. In the latter case, the index is checked for validity and\n", " | returned. If no such species is present, an exception is thrown.\n", " | \n", " | species_name(self, k)\n", " | Name of the species with index ``k``.\n", " | \n", " | stoich_air_fuel_ratio(self, fuel, oxidizer, basis)\n", " | Get the stoichiometric air to fuel ratio (kg oxidizer / kg fuel). Considers the\n", " | oxidation of C to CO2, H to H2O and S to SO2. Other elements are assumed\n", " | not to participate in oxidation (that is, N ends up as N2).\n", " | The ``basis`` determines the composition of fuel and oxidizer: ``basis='mole'`` (default)\n", " | means mole fractions, ``basis='mass'`` means mass fractions::\n", " | \n", " | >>> gas.set_mixture_fraction(0.5, 'CH3:0.5, CH3OH:.5, N2:0.125', 'O2:0.21, N2:0.79, NO:0.01')\n", " | >>> gas.stoich_air_fuel_ratio('CH3:0.5, CH3OH:.5, N2:0.125', 'O2:0.21, N2:0.79, NO:0.01')\n", " | 8.148040722239438\n", " | \n", " | :param fuel:\n", " | Fuel species name or mole/mass fractions as string, array, or dict.\n", " | :param oxidizer:\n", " | Oxidizer species name or mole/mass fractions as a string, array, or\n", " | dict.\n", " | :param basis:\n", " | Determines if ``fuel`` and ``oxidizer`` are given in mole\n", " | fractions (``basis='mole'``) or mass fractions (``basis='mass'``)\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data descriptors inherited from cantera.thermo.ThermoPhase:\n", " | \n", " | DP\n", " | Get/Set density [kg/m^3] and pressure [Pa].\n", " | \n", " | DPX\n", " | Get/Set density [kg/m^3], pressure [Pa], and mole fractions.\n", " | \n", " | DPY\n", " | Get/Set density [kg/m^3], pressure [Pa], and mass fractions.\n", " | \n", " | HP\n", " | Get/Set enthalpy [J/kg or J/kmol] and pressure [Pa].\n", " | \n", " | HPX\n", " | Get/Set enthalpy [J/kg or J/kmol], pressure [Pa] and mole fractions.\n", " | \n", " | HPY\n", " | Get/Set enthalpy [J/kg or J/kmol], pressure [Pa] and mass fractions.\n", " | \n", " | P\n", " | Pressure [Pa].\n", " | \n", " | P_sat\n", " | Saturation pressure [Pa] at the current temperature.\n", " | \n", " | Pe\n", " | Get electron Pressure [Pa].\n", " | \n", " | SP\n", " | Get/Set entropy [J/kg/K or J/kmol/K] and pressure [Pa].\n", " | \n", " | SPX\n", " | Get/Set entropy [J/kg/K or J/kmol/K], pressure [Pa], and mole fractions.\n", " | \n", " | SPY\n", " | Get/Set entropy [J/kg/K or J/kmol/K], pressure [Pa], and mass fractions.\n", " | \n", " | SV\n", " | Get/Set entropy [J/kg/K or J/kmol/K] and specific volume [m^3/kg or\n", " | m^3/kmol].\n", " | \n", " | SVX\n", " | Get/Set entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or\n", " | m^3/kmol], and mole fractions.\n", " | \n", " | SVY\n", " | Get/Set entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or\n", " | m^3/kmol], and mass fractions.\n", " | \n", " | T\n", " | Temperature [K].\n", " | \n", " | TD\n", " | Get/Set temperature [K] and density [kg/m^3 or kmol/m^3].\n", " | \n", " | TDX\n", " | Get/Set temperature [K], density [kg/m^3 or kmol/m^3], and mole\n", " | fractions.\n", " | \n", " | TDY\n", " | Get/Set temperature [K] and density [kg/m^3 or kmol/m^3], and mass\n", " | fractions.\n", " | \n", " | TP\n", " | Get/Set temperature [K] and pressure [Pa].\n", " | \n", " | TPX\n", " | Get/Set temperature [K], pressure [Pa], and mole fractions.\n", " | \n", " | TPY\n", " | Get/Set temperature [K], pressure [Pa], and mass fractions.\n", " | \n", " | T_sat\n", " | Saturation temperature [K] at the current pressure.\n", " | \n", " | Te\n", " | Get/Set electron Temperature [K].\n", " | \n", " | UV\n", " | Get/Set internal energy [J/kg or J/kmol] and specific volume\n", " | [m^3/kg or m^3/kmol].\n", " | \n", " | UVX\n", " | Get/Set internal energy [J/kg or J/kmol], specific volume\n", " | [m^3/kg or m^3/kmol], and mole fractions.\n", " | \n", " | UVY\n", " | Get/Set internal energy [J/kg or J/kmol], specific volume\n", " | [m^3/kg or m^3/kmol], and mass fractions.\n", " | \n", " | X\n", " | Get/Set the species mole fractions. Can be set as an array, as a dictionary,\n", " | or as a string. Always returns an array::\n", " | \n", " | >>> phase.X = [0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5]\n", " | >>> phase.X = {'H2':0.1, 'O2':0.4, 'AR':0.5}\n", " | >>> phase.X = 'H2:0.1, O2:0.4, AR:0.5'\n", " | >>> phase.X\n", " | array([0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5])\n", " | \n", " | Y\n", " | Get/Set the species mass fractions. Can be set as an array, as a dictionary,\n", " | or as a string. Always returns an array::\n", " | \n", " | >>> phase.Y = [0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5]\n", " | >>> phase.Y = {'H2':0.1, 'O2':0.4, 'AR':0.5}\n", " | >>> phase.Y = 'H2:0.1, O2:0.4, AR:0.5'\n", " | >>> phase.Y\n", " | array([0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5])\n", " | \n", " | activities\n", " | Array of nondimensional activities. Returns either molar or molal\n", " | activities depending on the convention of the thermodynamic model.\n", " | \n", " | activity_coefficients\n", " | Array of nondimensional, molar activity coefficients.\n", " | \n", " | atomic_weights\n", " | Array of atomic weight [kg/kmol] for each element in the mixture.\n", " | \n", " | basis\n", " | Determines whether intensive thermodynamic properties are treated on a\n", " | ``mass`` (per kg) or ``molar`` (per kmol) basis. This affects the values\n", " | returned by the properties `h`, `u`, `s`, `g`, `v`, `density`, `cv`,\n", " | and `cp`, as well as the values used with the state-setting properties\n", " | such as `HPX` and `UV`.\n", " | \n", " | case_sensitive_species_names\n", " | Enforce case-sensitivity for look up of species names\n", " | \n", " | charges\n", " | Array of species charges [elem. charge].\n", " | \n", " | chemical_potentials\n", " | Array of species chemical potentials [J/kmol].\n", " | \n", " | concentrations\n", " | Get/Set the species concentrations. Units are kmol/m^3 for bulk phases, kmol/m^2\n", " | for surface phases, and kmol/m for edge phases.\n", " | \n", " | cp\n", " | Heat capacity at constant pressure [J/kg/K or J/kmol/K] depending\n", " | on `basis`.\n", " | \n", " | cp_mass\n", " | Specific heat capacity at constant pressure [J/kg/K].\n", " | \n", " | cp_mole\n", " | Molar heat capacity at constant pressure [J/kmol/K].\n", " | \n", " | critical_density\n", " | Critical density [kg/m^3 or kmol/m^3] depending on `basis`.\n", " | \n", " | critical_pressure\n", " | Critical pressure [Pa].\n", " | \n", " | critical_temperature\n", " | Critical temperature [K].\n", " | \n", " | cv\n", " | Heat capacity at constant volume [J/kg/K or J/kmol/K] depending on\n", " | `basis`.\n", " | \n", " | cv_mass\n", " | Specific heat capacity at constant volume [J/kg/K].\n", " | \n", " | cv_mole\n", " | Molar heat capacity at constant volume [J/kmol/K].\n", " | \n", " | density\n", " | Density [kg/m^3 or kmol/m^3] depending on `basis`.\n", " | \n", " | density_mass\n", " | (Mass) density [kg/m^3].\n", " | \n", " | density_mole\n", " | Molar density [kmol/m^3].\n", " | \n", " | electric_potential\n", " | Get/Set the electric potential [V] for this phase.\n", " | \n", " | electrochemical_potentials\n", " | Array of species electrochemical potentials [J/kmol].\n", " | \n", " | electron_energy_distribution\n", " | Electron energy distribution\n", " | \n", " | electron_energy_distribution_type\n", " | Electron energy distribution type\n", " | \n", " | electron_energy_levels\n", " | Electron energy levels [eV]\n", " | \n", " | element_names\n", " | A list of all the element names.\n", " | \n", " | enthalpy_mass\n", " | Specific enthalpy [J/kg].\n", " | \n", " | enthalpy_mole\n", " | Molar enthalpy [J/kmol].\n", " | \n", " | entropy_mass\n", " | Specific entropy [J/kg/K].\n", " | \n", " | entropy_mole\n", " | Molar entropy [J/kmol/K].\n", " | \n", " | g\n", " | Gibbs free energy [J/kg or J/kmol] depending on `basis`.\n", " | \n", " | gibbs_mass\n", " | Specific Gibbs free energy [J/kg].\n", " | \n", " | gibbs_mole\n", " | Molar Gibbs free energy [J/kmol].\n", " | \n", " | h\n", " | Enthalpy [J/kg or J/kmol] depending on `basis`.\n", " | \n", " | has_phase_transition\n", " | Returns true if the phase represents a substance with phase transitions\n", " | \n", " | int_energy_mass\n", " | Specific internal energy [J/kg].\n", " | \n", " | int_energy_mole\n", " | Molar internal energy [J/kmol].\n", " | \n", " | is_compressible\n", " | Returns true if the density of the phase is an independent variable defining\n", " | the thermodynamic state of a substance\n", " | \n", " | is_pure\n", " | Returns true if the phase represents a pure (fixed composition) substance\n", " | \n", " | isothermal_compressibility\n", " | Isothermal compressibility [1/Pa].\n", " | \n", " | isotropic_shape_factor\n", " | Shape factor of isotropic-velocity distribution for electron energy\n", " | \n", " | max_temp\n", " | Maximum temperature for which the thermodynamic data for the phase are\n", " | valid.\n", " | \n", " | mean_electron_energy\n", " | Mean electron energy [eV]\n", " | \n", " | mean_molecular_weight\n", " | The mean molecular weight (molar mass) [kg/kmol].\n", " | \n", " | min_temp\n", " | Minimum temperature for which the thermodynamic data for the phase are\n", " | valid.\n", " | \n", " | molecular_weights\n", " | Array of species molecular weights (molar masses) [kg/kmol].\n", " | \n", " | n_electron_energy_levels\n", " | Number of electron energy levels\n", " | \n", " | n_elements\n", " | Number of elements.\n", " | \n", " | n_selected_species\n", " | Number of species selected for output (by slicing of Solution object)\n", " | \n", " | n_species\n", " | Number of species.\n", " | \n", " | normalize_electron_energy_distribution_enabled\n", " | Automatically normalize electron energy distribution\n", " | \n", " | partial_molar_cp\n", " | Array of species partial molar specific heat capacities at constant\n", " | pressure [J/kmol/K].\n", " | \n", " | partial_molar_enthalpies\n", " | Array of species partial molar enthalpies [J/kmol].\n", " | \n", " | partial_molar_entropies\n", " | Array of species partial molar entropies [J/kmol/K].\n", " | \n", " | partial_molar_int_energies\n", " | Array of species partial molar internal energies [J/kmol].\n", " | \n", " | partial_molar_volumes\n", " | Array of species partial molar volumes [m^3/kmol].\n", " | \n", " | phase_of_matter\n", " | Get the thermodynamic phase (gas, liquid, etc.) at the current conditions.\n", " | \n", " | quadrature_method\n", " | Quadrature method\n", " | \n", " | reference_pressure\n", " | Reference state pressure [Pa].\n", " | \n", " | s\n", " | Entropy [J/kg/K or J/kmol/K] depending on `basis`.\n", " | \n", " | sound_speed\n", " | Speed of sound [m/s].\n", " | \n", " | species_names\n", " | A list of all the species names.\n", " | \n", " | standard_concentration_units\n", " | Get standard concentration units for this phase.\n", " | \n", " | standard_cp_R\n", " | Array of nondimensional species standard-state specific heat capacities\n", " | at constant pressure at the current temperature and pressure.\n", " | \n", " | standard_enthalpies_RT\n", " | Array of nondimensional species standard-state enthalpies at the\n", " | current temperature and pressure.\n", " | \n", " | standard_entropies_R\n", " | Array of nondimensional species standard-state entropies at the\n", " | current temperature and pressure.\n", " | \n", " | standard_gibbs_RT\n", " | Array of nondimensional species standard-state Gibbs free energies at\n", " | the current temperature and pressure.\n", " | \n", " | standard_int_energies_RT\n", " | Array of nondimensional species standard-state internal energies at the\n", " | current temperature and pressure.\n", " | \n", " | state\n", " | Get/Set the full thermodynamic state as a single array, arranged as\n", " | [temperature, density, mass fractions] for most phases. Useful mainly\n", " | in cases where it is desired to store many states in a multidimensional\n", " | array.\n", " | \n", " | state_size\n", " | Return size of vector defining internal state of the phase.\n", " | \n", " | thermal_expansion_coeff\n", " | Thermal expansion coefficient [1/K].\n", " | \n", " | thermo_model\n", " | Return thermodynamic model describing phase.\n", " | \n", " | u\n", " | Internal energy in [J/kg or J/kmol].\n", " | \n", " | v\n", " | Specific volume [m^3/kg or m^3/kmol] depending on `basis`.\n", " | \n", " | volume_mass\n", " | Specific volume [m^3/kg].\n", " | \n", " | volume_mole\n", " | Molar volume [m^3/kmol].\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data and other attributes inherited from cantera.thermo.ThermoPhase:\n", " | \n", " | __pyx_vtable__ = \n", " | \n", " | ----------------------------------------------------------------------\n", " | Methods inherited from cantera.solutionbase._SolutionBase:\n", " | \n", " | __copy__(self)\n", " | \n", " | __del__(self)\n", " | \n", " | __getitem__(self, key, /)\n", " | Return self[key].\n", " | \n", " | __getstate__(self)\n", " | Save complete information of the current phase for pickling.\n", " | \n", " | __setstate__(self, pkl)\n", " | Restore Solution from pickled information.\n", " | \n", " | clear_user_data(self)\n", " | Clear all saved input data, so that the data given by `input_data` or\n", " | `write_yaml` will only include values generated by Cantera based on the\n", " | current object state.\n", " | \n", " | clear_user_header(self)\n", " | Clear all saved header data, so that the data given by `input_header` or\n", " | `write_yaml` will only include values generated by Cantera based on the\n", " | current object state.\n", " | \n", " | update_user_data(self, data)\n", " | Add the contents of the provided `dict` as additional fields when generating\n", " | YAML phase definition files with `write_yaml` or in the data returned by\n", " | `input_data`. Existing keys with matching names are overwritten.\n", " | \n", " | update_user_header(self, data)\n", " | Add the contents of the provided `dict` as additional top-level YAML fields\n", " | when generating files with `write_yaml` or in the data returned by\n", " | `input_header`. Existing keys with matching names are overwritten.\n", " | \n", " | write_chemkin(self, mechanism_path, thermo_path, transport_path, sort_species, sort_elements, overwrite)\n", " | Write this `~cantera.Solution` instance to one or more Chemkin-format files.\n", " | See the documentation for `cantera.yaml2ck.convert` for information about the\n", " | arguments to this function.\n", " | \n", " | write_yaml(self, filename, phases, units, precision, skip_user_defined, header)\n", " | Write the definition for this phase, any additional phases specified,\n", " | and their species and reactions to the specified file.\n", " | \n", " | :param filename:\n", " | The name of the output file; if ``None``, a YAML string is returned\n", " | :param phases:\n", " | Additional ThermoPhase / Solution objects to be included in the\n", " | output file\n", " | :param units:\n", " | A `UnitSystem` object or dictionary of the units to be used for\n", " | each dimension.\n", " | See `YamlWriter.output_units `.\n", " | :param precision:\n", " | For output floating point values, the maximum number of digits to\n", " | the right of the decimal point. The default is 15 digits.\n", " | :param skip_user_defined:\n", " | If `True`, user-defined fields which are not used by Cantera will\n", " | be stripped from the output. These additional contents can also be\n", " | controlled using the `update_user_data` and `clear_user_data` functions.\n", " | :param header:\n", " | If `True`, fields of the `input_header` will be added to the YAML header;\n", " | note that fields name ``generator``, ``cantera-version``, ``git-commit``\n", " | and ``date`` are reserved, which means that any existing data are\n", " | replaced by automatically generated content when the file is written.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data descriptors inherited from cantera.solutionbase._SolutionBase:\n", " | \n", " | composite\n", " | Returns tuple of thermo/kinetics/transport models associated with\n", " | this SolutionBase object.\n", " | \n", " | input_data\n", " | Get input data corresponding to the current state of this Solution,\n", " | along with any user-specified data provided with its input (YAML)\n", " | definition.\n", " | \n", " | input_header\n", " | Retrieve input header data not associated with the current state of this\n", " | Solution, which corresponds to fields at the root level of the YAML input\n", " | that are not required for the instantiation of Cantera objects.\n", " | \n", " | name\n", " | The name assigned to this object. The default value corresponds\n", " | to the YAML input file phase entry.\n", " | \n", " | selected_species\n", " | Get/set the set of species that are included when returning results that have\n", " | a value for each species, such as `species_names `,\n", " | `partial_molar_enthalpies `, or\n", " | `net_production_rates `. The list of\n", " | selected species can be set by name or index. This property returns the\n", " | species by index.::\n", " | \n", " | >>> gas.selected_species = [\"H2\", \"O2\"]\n", " | >>> print(gas.molecular_weights)\n", " | [ 2.016 31.998]\n", " | \n", " | This method is often used implicitly by using an indexing expression on a\n", " | `Solution` object::\n", " | \n", " | >>> print(gas[\"H2\", \"O2\"].molecular_weights)\n", " | [ 2.016 31.998]\n", " | \n", " | source\n", " | The source of this object (such as a file name).\n", "\n" ] } ], "source": [ "help(gas)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can use several functions to define the state of your gas, that is to say :\n", "- gas.**TP** (Temperature Pressure)\n", "- gas.**TD** (Temperature Density)\n", "- gas.**HP** (Enthalpy Pressure)\n", "- gas.**UV** (Specific Internal Energy, Specific Volume)\n", "- gas.**SP** (Entropy Pressure)\n", "- gas.**SV** (Entropy Specific Volume)." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "gas.TP = 500, 101325" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Wrong method" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here, we chose to define the molar fraction of the gas directly by the following :" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "gas.X = {'CH4':1, 'O2':2, 'N2':7.52}" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " gri30:\n", "\n", " temperature 300 K\n", " pressure 7392.2 Pa\n", " density 0.081894 kg/m^3\n", " mean mol. weight 27.633 kg/kmol\n", " phase of matter gas\n", "\n", " 1 kg 1 kmol \n", " --------------- ---------------\n", " enthalpy -2.5459e+05 -7.0351e+06 J\n", " internal energy -3.4485e+05 -9.5295e+06 J\n", " entropy 8035.4 2.2205e+05 J/K\n", " Gibbs function -2.6652e+06 -7.3649e+07 J\n", " heat capacity c_p 1077.3 29770 J/K\n", " heat capacity c_v 776.45 21456 J/K\n", "\n", " mass frac. Y mole frac. X chem. pot. / RT\n", " --------------- --------------- ---------------\n", " O2 0.22014 0.19011 -28.952\n", " CH4 0.055187 0.095057 -57.294\n", " N2 0.72467 0.71483 -25.987\n", " [ +50 minor] 0 0 \n", "\n", "None\n" ] } ], "source": [ "print(gas())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What do you notice here ? Look at the pressure : it is not the same than what has been defined above. You should never define pressure and temperature and call the command \"gas.X\" afterwards. Below are explained correct methods to set the case correctly." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### First method" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "gas.TPX = 500, 101325, {'CH4':1, 'O2':2, 'N2':7.52}" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " gri30:\n", "\n", " temperature 500 K\n", " pressure 1.0132e+05 Pa\n", " density 0.67352 kg/m^3\n", " mean mol. weight 27.633 kg/kmol\n", " phase of matter gas\n", "\n", " 1 kg 1 kmol \n", " --------------- ---------------\n", " enthalpy -33317 -9.2066e+05 J\n", " internal energy -1.8376e+05 -5.0779e+06 J\n", " entropy 7811.5 2.1586e+05 J/K\n", " Gibbs function -3.9391e+06 -1.0885e+08 J\n", " heat capacity c_p 1140.4 31514 J/K\n", " heat capacity c_v 839.53 23199 J/K\n", "\n", " mass frac. Y mole frac. X chem. pot. / RT\n", " --------------- --------------- ---------------\n", " O2 0.22014 0.19011 -26.74\n", " CH4 0.055187 0.095057 -43.238\n", " N2 0.72467 0.71483 -23.767\n", " [ +50 minor] 0 0 \n", "\n", "None\n" ] } ], "source": [ "print(gas())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Second method" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here, we will set an equivalence ratio equal to unity with a mix of fuel (CH4) and oxidizer (air), which is doing the same as above." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "gas.TP = 500, 101325" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "gas.set_equivalence_ratio(1, 'CH4: 1', 'O2:1.0, N2:3.76')" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " gri30:\n", "\n", " temperature 500 K\n", " pressure 1.0132e+05 Pa\n", " density 0.67352 kg/m^3\n", " mean mol. weight 27.633 kg/kmol\n", " phase of matter gas\n", "\n", " 1 kg 1 kmol \n", " --------------- ---------------\n", " enthalpy -33317 -9.2066e+05 J\n", " internal energy -1.8376e+05 -5.0779e+06 J\n", " entropy 7811.5 2.1586e+05 J/K\n", " Gibbs function -3.9391e+06 -1.0885e+08 J\n", " heat capacity c_p 1140.4 31514 J/K\n", " heat capacity c_v 839.53 23199 J/K\n", "\n", " mass frac. Y mole frac. X chem. pot. / RT\n", " --------------- --------------- ---------------\n", " O2 0.22014 0.19011 -26.74\n", " CH4 0.055187 0.095057 -43.238\n", " N2 0.72467 0.71483 -23.767\n", " [ +50 minor] 0 0 \n", "\n", "None\n" ] } ], "source": [ "print(gas())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Additional informations" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['H2', 'H', 'O', 'O2', 'OH', 'H2O', 'HO2', 'H2O2', 'C', 'CH', 'CH2', 'CH2(S)', 'CH3', 'CH4', 'CO', 'CO2', 'HCO', 'CH2O', 'CH2OH', 'CH3O', 'CH3OH', 'C2H', 'C2H2', 'C2H3', 'C2H4', 'C2H5', 'C2H6', 'HCCO', 'CH2CO', 'HCCOH', 'N', 'NH', 'NH2', 'NH3', 'NNH', 'NO', 'NO2', 'N2O', 'HNO', 'CN', 'HCN', 'H2CN', 'HCNN', 'HCNO', 'HOCN', 'HNCO', 'NCO', 'N2', 'AR', 'C3H7', 'C3H8', 'CH2CHO', 'CH3CHO']\n" ] } ], "source": [ "print(gas.species_names)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "15\n" ] } ], "source": [ "print(gas.species_index('CO2'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Other informations concerning functions associated to the thermodynamic properties of the gas object can be found on the help function or on the following link :\n", "
\n", "https://cantera.org/documentation/docs-3.0/sphinx/html/matlab/thermodynamics.html#thermodynamic-properties" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4. Kinetic state of the gas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As well as for the thermodynamic state of the gas, the kinetic state can be found at the following link :\n", "
\n", "https://cantera.org/documentation/docs-3.0/sphinx/html/matlab/kinetics.html#chemical-kinetics" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ 0.00000000e+00 3.47828405e-33 9.56903426e-36 -1.90362726e-19\n", " 0.00000000e+00 0.00000000e+00 1.90362726e-19 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 1.90362726e-19 -1.90362726e-19 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 9.36554007e-42 0.00000000e+00\n", " 0.00000000e+00 9.56903407e-36 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 -9.56904343e-36\n", " 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00\n", " 0.00000000e+00]\n" ] } ], "source": [ "print(gas.net_production_rates)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here, this is nearly zero as no reaction has occured in the mix." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 5. Transport properties" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For the transport, the functions can be found here :\n", "
\n", "https://cantera.org/documentation/docs-3.0/sphinx/html/matlab/transport.html#transport-properties" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[3.42125932e-04 5.16149564e-04 2.56085897e-04 ... 1.13601915e-04\n", " 1.41676148e-04 1.41603612e-04]\n", " [5.16149564e-04 7.60016231e-04 4.32829554e-04 ... 1.70066300e-04\n", " 2.14491230e-04 2.14435073e-04]\n", " [2.56085897e-04 4.32829554e-04 1.20461676e-04 ... 4.41954859e-05\n", " 5.49580609e-05 5.47874219e-05]\n", " ...\n", " [1.13601915e-04 1.70066300e-04 4.41954859e-05 ... 1.62051724e-05\n", " 1.83687401e-05 1.82620858e-05]\n", " [1.41676148e-04 2.14491230e-04 5.49580609e-05 ... 1.83687401e-05\n", " 2.10821066e-05 2.09611620e-05]\n", " [1.41603612e-04 2.14435073e-04 5.47874219e-05 ... 1.82620858e-05\n", " 2.09611620e-05 2.08395155e-05]]\n" ] } ], "source": [ "print(gas.binary_diff_coeffs)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Default value uses the default transport specified in the phase definition. gas.binary_diff_coeffs works because the transport model is specified and defined as \"mixture-averaged\"." ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "mixture-averaged\n" ] } ], "source": [ "print(gas.transport_model)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here, with the version we used at CERFACS, four types of transport are available. The four differs in the following way :\n", "- **multicomponent** is the most complicated and detailed version, it uses each diffusion coefficient $D_{kj}$ to represent the interaction between each species (k being a species and j another one).\n", "- **mixture-averaged** is the most used version in Cantera as it allows the user to approximate results without losing too much precision. The approximation made is that every species has one interaction with the whole mix following the rule :\n", "$D_{km} = \\frac{1-Y_k}{\\sum_{j\\ne k}^{K} \\frac{X_j}{Djk}}$.\n", "- **AVBP** which is the transport used to compare results with AVBP solver used at cerfacs (this transport is not included in the normal version). This supposes a constant Schmidt number ( $Sc = \\frac{\\rho}{\\mu D_{km}}$, $\\rho$ being the density and $\\mu$ the viscosity ) for all the species and $D_{km}$ is guessed from this relation.\n", "- **unity-Lewis-number** which implements the unity Lewis number approximation for the mixture-averaged species diffusion coefficients." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This types of transport are used in the yaml file, as you will see in a minute." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Conclusion" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The purpose of this part was to explain :\n", "- how one can set up the thermodynamic state of a gas for a computation\n", "- how one will be able to print interesting data from the gaseous object\n", "
\n", "In the next part, we will focus on the object used to created the cantera gas object : the yaml file." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Things to retain from the first tutorial :\n", "- you should always import Cantera at the beginning of your file.\n", "- the solution is imported from a yaml file.\n", "- you should set the thermodynamic state and the amount of species of your gas before starting any computation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Appendix : The data files" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### a. Creation of the data file from CHEMKIN files" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The information required to compute the previous quantities were specified in the **.yaml** file, also\n", "labeled **mechanism file** or **data file**. In fact, Cantera no longer supports a data file format with the extension '.cti' or '.xml'.
\n", "For the following part, you can open a yaml script in the *Mechanisms* folder (for instance the **gri30** mechanism) to have a visual idea of what is a yaml file." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Cantera simulations will always involve one or more phases of matter. Depending on the calculation being performed, it may be necessary to evaluate **thermodynamic properties**, but also **transport properties**, and/or **homogeneous reaction rates** for the phase(s) present. In problems with multiple phases, the properties of the interfaces between phases, and the heterogeneous reaction rates at these interfaces, may also be required.

\n", "\n", "https://cantera.org/science/phase-thermo.html\n", "\n", "Before the properties can be evaluated, each phase must be defined, meaning that the models\n", "used to compute its properties and reaction rates must be specified, along with any parameters the\n", "models require. For example, a solid phase might be defined as being incompressible, with a specified\n", "density and composition. A gaseous phase for a combustion simulation might be defined as an ideal\n", "gas consisting of a mixture of many species that react with one another via a specified set of reactions.
\n", "If phases contain multiple species and reactions, as it is often the case in combustion application,\n", "a large amount of data is required to define it, since the contribution of each species to the thermodynamic and transport properties must be specified, and rate information must be given for each\n", "reaction. **Rather than defining this information via an application program, the Cantera approach\n", "is to put the phase and interface definitions in a text file that can be called from and read by an\n", "application program - or a script**.

\n", "\n", "In this tutorial, we will review what must be included in such 'data files', or 'mechanism files', and\n", "provide guidelines on how to write them to define phases and interfaces to use them in Cantera simulations.\n", "We will start by a review of some basic writing rules, followed by a discussion on how they are processed,\n", "and of how errors are handled. We will work with examples in the last sections." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To be able to translate the files from Chemkin (mechanism file, thermo database and transport database) to yaml format, it is necessary to use the command ck2yaml.
The following command should be executed on a terminal:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "ck2yaml --input=./CK2YAML/mech.inp --thermo=./CK2YAML/therm.dat --transport=./CK2YAML/tran.dat
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, if you look into the folder CK2YAML, the data file mechanism should be created." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also convert the files from cti to cantera (data file), using the command cti2yaml:
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " cti2yaml ./CTI2YAML/gri30.cti
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### b. The **.yaml** file" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "The typical shape of a **yaml** file will be the following :\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "UNITS DIRECTIVE\n", "\n", "\n", "### Phase & Interface data\n", "\n", "\n", "PHASE ENTRIES(name, thermo, elements, species, kinetics, reactions, transport, state*, options)
\n", "INTERFACE ENTRIES(name, elements, species, reactions, phases, site_density, state*)\n", "
\n", "\n", "### Species & Elements data\n", "\n", "\n", "ELEMENT ENTRIES(symbol, atomic_mass)\n", "SPECIES ENTRIES(name, composition, thermo ,transport, note, size, charge)\n", "\n", "\n", "### Reaction data\n", "\n", "REACTION ENTRIES(equation, type, rate-constant, efficiencies, options)
\n", "
\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "A data file consists of entries and directives, both of which have a syntax much like functions.\n", "

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A **directive** will tell the code how the entry parameters are to be interpreted, such as what is the\n", "default unit system, or how certain errors should be handled. For example :" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " units: {length: cm, quantity: mol, activation-energy: cal/mol}\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "An **entry** defines an object, for example, a reaction or a species. Entries have fields, that can be assigned\n", "values. Take the definition of the argon species :" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "- name: AR\n", " composition: {Ar: 1}\n", " thermo:\n", " model: NASA7\n", " temperature-ranges: [300.0, 1000.0, 5000.0]\n", " data:\n", " - [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366]\n", " - [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366]\n", " transport:\n", " model: gas\n", " geometry: atom\n", " diameter: 3.33\n", " well-depth: 136.5\n", " note: '120186'\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Its fields are its **name**, **compositions**, **thermodynamic**, **transport** and **notes** properties.
\n", "The syntax is < field name > : < value > , and the fields can be specified on one line or extended across several to be read more easily, as it was the case in the previous example. Some fields are required, otherwise processing the file will abort and an error message will be printed.
\n", "As can be seen on this example, the transport field for instance has several subfields (*model*, *geometry*, *diameter*, *well-depth*). A field can specify a model or a large group of parameters." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A cti file can support four different types of reactions :\n", "- classic reactions (classic Arrhenius defined like equations) which does not need a specified type.\n", "- three-body reactions **three-body** (reactions involving another species which can be a probability of being one species or another)\n", "- falloff reaction **falloff** (three-body reactions whose rates k are depending on the concentration of the three-body)\n", "- pressure dependent reaction **pressure-dependent-Arrhenius** (set of several Arrhenius parameters for specific pressures with a logarithmic interpolation inbetween)\n", "\n", "If you want more documentation about the reactions in cantera, please follow the link below :
\n", "https://cantera.org/documentation/docs-3.0/sphinx/html/yaml/reactions.html" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "NB : The following link will provide you other information about the species data if you are interested in knowing more about it :
\n", "https://cantera.org/science/species-thermo.html" ] } ], "metadata": { "kernelspec": { "display_name": "cantera-avbp3.0-py39", "language": "python", "name": "cantera-avbp3.0-py39" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.5" } }, "nbformat": 4, "nbformat_minor": 2 }