Warning
This documentation is for an old version of Cantera. You can find docs for newer versions here.
These classes are used to describe the thermodynamic state of a system.
Bases: cantera._cantera._SolutionBase
A phase with an equation of state.
Class ThermoPhase may be used to represent the intensive thermodynamic state of a phase of matter, which might be a gas, liquid, or solid.
Class ThermoPhase is not usually instantiated directly. It is used as a base class for classes Solution and Interface.
Get/Set enthalpy [J/kg or J/kmol] and pressure [Pa].
Get/Set enthalpy [J/kg or J/kmol], pressure [Pa] and mole fractions.
Get/Set enthalpy [J/kg or J/kmol], pressure [Pa] and mass fractions.
The ID of the phase. The default is taken from the CTI/XML input file.
Pressure [Pa].
Saturation pressure [Pa] at the current temperature.
Get/Set entropy [J/kg/K or J/kmol/K] and pressure [Pa].
Get/Set entropy [J/kg/K or J/kmol/K], pressure [Pa], and mole fractions.
Get/Set entropy [J/kg/K or J/kmol/K], pressure [Pa], and mass fractions.
Get/Set entropy [J/kg/K or J/kmol/K] and specific volume [m^3/kg or m^3/kmol].
Get/Set entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or m^3/kmol], and mole fractions.
Get/Set entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or m^3/kmol], and mass fractions.
Temperature [K].
Get/Set temperature [K] and density [kg/m^3 or kmol/m^3].
Get/Set temperature [K], density [kg/m^3 or kmol/m^3], and mole fractions.
Get/Set temperature [K] and density [kg/m^3 or kmol/m^3], and mass fractions.
Get/Set temperature [K] and pressure [Pa].
Get/Set temperature [K], pressure [Pa], and mole fractions.
Get/Set temperature [K], pressure [Pa], and mass fractions.
Saturation temperature [K] at the current pressure.
Get/Set internal energy [J/kg or J/kmol] and specific volume [m^3/kg or m^3/kmol].
Get/Set internal energy [J/kg or J/kmol], specific volume [m^3/kg or m^3/kmol], and mole fractions.
Get/Set internal energy [J/kg or J/kmol], specific volume [m^3/kg or m^3/kmol], and mass fractions.
Get/Set the species mole fractions. Can be set as an array, as a dictionary, or as a string. Always returns an array:
>>> phase.X = [0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5]
>>> phase.X = {'H2':0.1, 'O2':0.4, 'AR':0.5}
>>> phase.X = 'H2:0.1, O2:0.4, AR:0.5'
>>> phase.X
array([0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5])
Get/Set the species mass fractions. Can be set as an array, as a dictionary, or as a string. Always returns an array:
>>> phase.Y = [0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5]
>>> phase.Y = {'H2':0.1, 'O2':0.4, 'AR':0.5}
>>> phase.Y = 'H2:0.1, O2:0.4, AR:0.5'
>>> phase.Y
array([0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5])
Atomic weight [kg/kmol] of element m
Array of atomic weight [kg/kmol] for each element in the mixture.
Determines whether intensive thermodynamic properties are treated on a mass (per kg) or molar (per kmol) basis. This affects the values returned by the properties h, u, s, g, v, density, cv, and cp, as well as the values used with the state-setting properties such as HPX and UV.
Array of species chemical potentials [J/kmol].
Get/Set the species concentrations [kmol/m^3].
Specific heat capacity at constant pressure [J/kg/K].
Molar heat capacity at constant pressure [J/kmol/K].
Critical pressure [Pa].
Critical temperature [K].
Specific heat capacity at constant volume [J/kg/K].
Molar heat capacity at constant volume [J/kmol/K].
(Mass) density [kg/m^3].
Molar density [kmol/m^3].
Get/Set the electric potential [V] for this phase.
Array of species electrochemical potentials [J/kmol].
The index of element element, which may be specified as a string or an integer. In the latter case, the index is checked for validity and returned. If no such element is present, an exception is thrown.
Name of the element with index m.
A list of all the element names.
Get the array of element potentials. The element potentials are only defined for equilibrium states. This method first sets the composition to a state of equilibrium at constant T and P, then computes the element potentials for this equilibrium state.
Get the elemental mass fraction \(Z_{\mathrm{mass},m}\) of element \(m\) as defined by:
with \(a_{m,k}\) being the number of atoms of element \(m\) in species \(k\), \(M_m\) the atomic weight of element \(m\), \(M_k\) the molecular weight of species \(k\), and \(Y_k\) the mass fraction of species \(k\).
Parameters: | m – Base element, may be specified by name or by index. |
---|
>>> phase.elemental_mass_fraction('H')
1.0
Get the elemental mole fraction \(Z_{\mathrm{mole},m}\) of element \(m\) (the number of atoms of element m divided by the total number of atoms) as defined by:
with \(a_{m,k}\) being the number of atoms of element \(m\) in species \(k\), \(\sum_j\) being a sum over all elements, and \(X_k\) being the mole fraction of species \(k\).
Parameters: | m – Base element, may be specified by name or by index. |
---|
>>> phase.elemental_mole_fraction('H')
1.0
Specific enthalpy [J/kg].
Molar enthalpy [J/kmol].
Specific entropy [J/kg].
Molar entropy [J/kmol/K].
Set to a state of chemical equilibrium holding property pair XY constant.
Parameters: |
|
---|
Specific Gibbs free energy [J/kg].
Molar Gibbs free energy [J/kmol].
Specific internal energy [J/kg].
Molar internal energy [J/kmol].
Isothermal compressibility [1/Pa].
Maximum temperature for which the thermodynamic data for the phase are valid.
The mean molecular weight (molar mass) [kg/kmol].
Minimum temperature for which the thermodynamic data for the phase are valid.
Array of species molecular weights (molar masses) [kg/kmol].
Number of atoms of element element in species species. The element and species may be specified by name or by index.
>>> phase.n_atoms('CH4','H')
4
Number of elements.
Number of species.
The name assigned to this phase. The default is taken from the CTI/XML input file.
Array of species partial molar specific heat capacities at constant pressure [J/kmol/K].
Array of species partial molar enthalpies [J/kmol].
Array of species partial molar entropies [J/kmol/K].
Array of species partial molar internal energies [J/kmol].
Array of species partial molar volumes [m^3/kmol].
Reference state pressure [Pa].
Generate a report describing the thermodynamic state of this phase. To print the report to the terminal, simply call the phase object. The following two statements are equivalent:
>>> phase()
>>> print(phase.report())
Set the mass fractions without normalizing to force sum(Y) == 1.0. Useful primarily when calculating derivatives with respect to Y[k] by finite difference.
Set the mole fractions without normalizing to force sum(X) == 1.0. Useful primarily when calculating derivatives with respect to X[k] by finite difference.
Return the Species object for species k, where k is either the species index or the species name. If k is not specified, a list of all species objects is returned.
The index of species species, which may be specified as a string or an integer. In the latter case, the index is checked for validity and returned. If no such species is present, an exception is thrown.
Name of the species with index k.
A list of all the species names.
Array of nondimensional species standard-state specific heat capacities at constant pressure at the current temperature and pressure.
Array of nondimensional species standard-state enthalpies at the current temperature and pressure.
Array of nondimensional species standard-state entropies at the current temperature and pressure.
Array of nondimensional species standard-state Gibbs free energies at the current temperature and pressure.
Array of nondimensional species standard-state internal energies at the current temperature and pressure.
Thermal expansion coefficient [1/K].
Internal energy in [J/kg or J/kmol].
Specific volume [m^3/kg].
Molar volume [m^3/kmol].
Bases: cantera._cantera.ThermoPhase
A pure substance that can be a gas, a liquid, a mixed gas-liquid fluid, or a fluid beyond its critical point.
Get the density [kg/m^3], pressure [Pa], and vapor fraction.
Get the enthalpy [J/kg or J/kmol], pressure [Pa] and vapor fraction.
Get/Set the pressure and vapor fraction of a two-phase state.
Get the entropy [J/kg/K or J/kmol/K], pressure [Pa], and vapor fraction.
Get the entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or m^3/kmol], and vapor fraction.
Get the temperature [K], density [kg/m^3 or kmol/m^3], and vapor fraction.
Get the temperature [K], pressure [Pa], and vapor fraction.
Get/Set the temperature and vapor fraction of a two-phase state.
Get the internal energy [J/kg or J/kmol], specific volume [m^3/kg or m^3/kmol], and vapor fraction.
Get/Set vapor fraction (quality). Can be set only when in the two-phase region.
Bases: object
Class Mixture represents mixtures of one or more phases of matter. To construct a mixture, supply a list of phases to the constructor, each paired with the number of moles for that phase:
>>> gas = cantera.Solution('gas.cti')
>>> gas.species_names
['H2', 'H', 'O2', 'O', 'OH']
>>> graphite = cantera.Solution('graphite.cti')
>>> graphite.species_names
['C(g)']
>>> mix = cantera.Mixture([(gas, 1.0), (graphite, 0.1)])
>>> mix.species_names
['H2', 'H', 'O2', 'O', 'OH', 'C(g)']
Note that the objects representing each phase compute only the intensive state of the phase – they do not store any information on the amount of this phase. Mixture objects, on the other hand, represent the full extensive state.
Mixture objects are ‘lightweight’ in the sense that they do not store parameters needed to compute thermodynamic or kinetic properties of the phases. These are contained in the (‘heavyweight’) phase objects. Multiple mixture objects may be constructed using the same set of phase objects. Each one stores its own state information locally, and synchronizes the phases objects whenever it requires phase properties.
Get or set the Pressure [Pa] of all phases in the mixture. When set, the temperature of the mixture is held fixed.
Get or set the Temperature [K] of all phases in the mixture. When set, the pressure of the mixture is held fixed.
The total charge in Coulombs, summed over all phases.
The chemical potentials of all species [J/kmol].
Index of element with name ‘element’.
>>> mix.element_index('H')
2
Total number of moles of element e, summed over all species. The element may be referenced either by index number or by name.
Set to a state of chemical equilibrium holding property pair XY constant. This method uses a version of the VCS algorithm to find the composition that minimizes the total Gibbs free energy of the mixture, subject to element conservation constraints. For a description of the theory, see Smith and Missen, “Chemical Reaction Equilibrium.”
Parameters: |
|
---|
The maximum temperature for which all species in multi-species solutions have valid thermo data. Stoichiometric phases are not considered in determining max_temp.
The minimum temperature for which all species in multi-species solutions have valid thermo data. Stoichiometric phases are not considered in determining min_temp.
Number of atoms of element m in the species with global index k. The element may be referenced either by name or by index.
>>> n = mix.n_atoms(3, 'H')
4.0
Total number of elements present in the mixture.
Number of phases
Number of species.
The charge of phase p in Coulombs.
Index of the phase named p.
Moles in phase p, if p is specified, otherwise the number of moles in all phases.
Names of all phases in the order added.
Generate a report describing the thermodynamic state of this mixture. To print the report to the screen, simply call the mixture object. The following two statements are equivalent:
>>> mix()
>>> print(mix.report())
Set the number of moles of phase p to moles
Parameters: |
|
---|
Returns the global index of species species in phase phase.
Get or set the number of moles of each species. May be set either as a string or as an array. If an array is used, it must be dimensioned at least as large as the total number of species in the mixture. Note that the species may belong to any phase, and unspecified species are set to zero.
>>> mix.species_moles = 'C(s):1.0, CH4:2.0, O2:0.2'
Name of the species with index k. Note that index numbers are assigned in order as phases are added.
Bases: object
Species(name=None, composition=None, charge=None, size=None, init=True, *args, **kwargs)
A class which stores data about a single chemical species that may be needed to add it to a Solution or Interface object (and to the underlying ThermoPhase and Transport objects).
Parameters: |
|
---|
Example: creating an ideal gas phase with a single species:
ch4 = ct.Species('CH4', 'C:1, H:4')
ch4.thermo = ct.ConstantCp(300, 1000, 101325,
(300, -7.453347e7, 1.865912e5, 3.576053e4))
tran = ct.GasTransportData()
tran.set_customary_units('nonlinear', 3.75, 141.40, 0.0, 2.60, 13.00)
ch4.transport = tran
gas = ct.Solution(thermo='IdealGas', species=[ch4])
The static methods fromCti, fromXml, listFromFile, listFromCti, and listFromXml can be used to create Species objects from existing definitions in the CTI or XML formats. All of the following will produce a list of 53 Species objects containing the species defined in the GRI 3.0 mechanism:
S = ct.Species.listFromFile('gri30.cti')
S = ct.Species.listFromCti(open('path/to/gri30.cti').read())
S = ct.Species.listFromXml(open('path/to/gri30.xml').read())
The electrical charge on the species, in units of the elementary charge.
A dict containing the elemental composition of the species. Keys are element names; values are the corresponding atomicities.
Create a Species object from its CTI string representation.
Create a Species object from its XML string representation.
Create a list of Species objects from all the species defined in a CTI string.
Create a list of Species objects from all of the species defined in a CTI or XML file.
Directories on Cantera’s input file path will be searched for the specified file.
In the case of an XML file, the <species> nodes are assumed to be children of the <speciesData> node in a document with a <ctml> root node, as in the XML files produced by conversion from CTI files.
Create a list of Species objects from all the species defined in an XML string. The <species> nodes are assumed to be children of the <speciesData> node in a document with a <ctml> root node, as in the XML files produced by conversion from CTI files.
The name of the species.
The effective size [m] of the species.
Get/Set the species reference-state thermodynamic data, as an instance of class SpeciesThermo.
Get/Set the species transport parameters, as an instance of class GasTransportData.
These classes are used to describe the reference-state thermodynamic properties of a pure species.
Bases: object
Base class for representing the reference-state thermodynamic properties of a pure species. These properties are a function of temperature. Derived classes implement a parameterization of this temperature dependence. This is a wrapper for the C++ class SpeciesThermoInterpType.
Parameters: |
|
---|
Molar heat capacity at constant pressure [J/kmol/K] at temperature T.
Molar enthalpy [J/kmol] at temperature T
Molar entropy [J/kmol/K] at temperature T
Bases: cantera._cantera.SpeciesThermo
Thermodynamic properties for a species that has a constant specific heat capacity. This is a wrapper for the C++ class ConstCpPoly.
Parameters: | coeffs – An array of 4 elements:
|
---|
Bases: cantera._cantera.SpeciesThermo
Thermodynamic properties for a species which is parameterized using the 7-coefficient NASA polynomial form in two temperature ranges. This is a wrapper for the C++ class NasaPoly2.
Parameters: | coeffs – An array of 15 elements, in the following order:
This is the coefficient order used in the standard fixed-format NASA input files. |
---|
Bases: cantera._cantera.SpeciesThermo
Thermodynamic properties for a species which is parameterized using the Shomate equation in two temperature ranges. This is a wrapper for the C++ class ShomatePoly2.
Parameters: | coeffs – An array of 15 elements, in the following order:
These coefficients should be provided in their customary units (i.e. such that \(c_p^o\) is in J/gmol-K and \(H^o\) is in kJ/gmol, as in the NIST Chemistry WebBook). |
---|