Objects Representing Phases

Solution

class Solution(src, id, trans)

Solution class constructor.

Class Solution() represents solutions of multiple species. A solution is defined as a mixture of two or more constituents (species) that are completely mixed on molecular length scales. The macroscopic intensive thermodynamic state of a solution is specified by two thermodynamic properties (for example, the temperature and pressure), and the relative amounts of each species, which may be given as mole fractions or mass fractions.

>> s = Solution('input.yaml'[, phase_name[, transport_model]])

constructs a Solution() object from a specification contained in file input.yaml. Optionally, the name of the phase to be imported can be specified with phase_name. If a Transport() model is included in input.yaml, it will be included in the Solution() instance with the default transport modeling as set in the input file. To specify the transport modeling, set the input argument trans to one of 'default', 'None', 'Mix', or 'Multi'. In this case, the phase name must be specified as well. Alternatively, change the transport node in the CTML file, or transport property in the CTI file before loading the phase. The transport modeling cannot be changed once the phase is loaded.

Class Solution() derives from three more basic classes, and most of its methods are inherited from these classes. These are:

See also: ThermoPhase(), Kinetics(), Transport()

Parameters
  • src – Input string of CTI or CTML file name.

  • id – Optional unless trans is specified. ID of the phase to import as specified in the CTML or CTI file.

  • trans – String, transport modeling. Possible values are 'default', 'None', 'Mix', or 'Multi'. If not specified, 'default' is used.

Returns

Instance of class Solution()

Air()

Create an object representing air.

Air is modeled as an ideal gas mixture. The specification is taken from file air.yaml. Several reactions among oxygen and nitrogen are defined. Mixture-averaged transport is specified by default.

Returns

Instance of class Solution()

GRI30(tr)

Create an object with the GRI-Mech 3.0 reaction mechanism.

Create a Solution instance representing reaction mechanism GRI-Mech 3.0.

GRI-Mech 3.0 is a widely-used reaction mechanism for natural gas combustion. It contains 53 species composed of the elements H, C, O, N, and/or Ar, and 325 reactions, most of which are reversible. GRI-Mech 3.0, like most combustion mechanisms, is designed for use at pressures where the ideal gas law holds. GRI-Mech 3.0 is available from http://www.me.berkeley.edu/gri_mech/

Function GRI30() creates the solution according to the specifications in file gri30.yaml. The ideal gas equation of state is used. Transport property evaluation is mixture-averaged by default. To change or disable transport properties, supply the name of the transport model to use.

g1 = GRI30           % mixture-averaged transport properties
g2 = GRI30('Mix')    % mixture-averaged transport properties
g3 = GRI30('Multi')  % miulticomponent transport properties
g4 = GRI30('None')   % no transport properties
Parameters

tr – Transport modeling, 'None', 'Mix', or 'Multi'

Returns

Instance of class Solution()

Mixture

class Mixture(phases)

Multiphase mixture class constructor.

Class Mixture() represents mixtures of one or more phases of matter. To construct a mixture, supply a cell array of phases and mole numbers:

>> gas = Solution('gas.yaml');
>> graphite = Solution('graphite.yaml');
>> mix = Mixture({gas, 1.0; graphite, 0.1});

Phases may also be added later using the addPhase method:

>> water = Solution('water.yaml');
>> addPhase(mix, water, 3.0);

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 phase objects whenever it requires phase properties.

Parameters

phases – Cell array of phases and mole numbers

Returns

Instance of class Mixture()

addPhase(self, phase, moles)

Add a phase to a mixture.

Parameters
  • self – Instance of class Mixture() to which phases should be added

  • phase – Instance of class ThermoPhase() which should be added

  • moles – Number of moles of the phase to be added to this mixture. Units: kmol

chemPotentials(self)

Get the chemical potentials of species in a mixture.

Parameters

self – Instance of class Mixture()

Returns

Vector of chemical potentials. Units: J/kmol

elementIndex(self, name)

Get the index of an element.

Parameters
  • self – Instance of class Mixture()

  • name – Name of the element whose index is desired

Returns

Index of element with name name

equilibrate(self, XY, err, maxsteps, maxiter, loglevel)

Set the mixture to a state of chemical equilibrium.

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.” The VCS algorithm is implemented in Cantera kernel class MultiPhaseEquil.

The VCS algorithm solves for the equilibrium composition for specified temperature and pressure. If any other property pair other than “TP” is specified, then an outer iteration loop is used to adjust T and/or P so that the specified property values are obtained.

>> equilibrate(mix, 'TP')
>> equilibrate('TP', 1.0e-6, 500)
Parameters
  • self – Instance of class Mixture()

  • XY – Two-letter string specifying the two properties to hold fixed. Currently, 'TP', 'HP', 'TV', and 'SP' are implemented. Default: 'TP'.

  • err – Error tolerance. Iteration will continue until \(\Delta\mu)/RT\) is less than this value for each reaction. Default: 1.0e-9. Note that this default is very conservative, and good equilibrium solutions may be obtained with larger error tolerances.

  • maxsteps – Maximum number of steps to take while solving the equilibrium problem for specified T and P. Default: 1000.

  • maxiter – Maximum number of temperature and/or pressure iterations. This is only relevant if a property pair other than (T,P) is specified. Default: 200.

  • loglevel – Set to a value > 0 to write diagnostic output. Larger values generate more detailed information.

Returns

The error in the solution

nElements(self)

Get the number of elements in a mixture.

Parameters

self – Instance of class Mixture()

Returns

Number of elements in the input

nPhases(self)

Get the number of phases in a mixture.

Parameters

self – Instance of class Mixture()

Returns

Number of phases in the input

nSpecies(self)

Get the number of species in a mixture.

Parameters

self – Instance of class Mixture()

Returns

Number of species in the input

phaseMoles(self, n)

Get the number of moles of a phase in a mixture.

Parameters
  • self – Instance of class Mixture()

  • n – Integer phase number in the input

Returns

Moles of phase number n. Units: kmol

pressure(self)

Get the pressure of the mixture.

Parameters

self – Instance of class Mixture()

Returns

Pressure. Units: Pa

setPhaseMoles(self, n, moles)

Set the number of moles of a phase in a mixture.

Parameters
  • self – Instance of class Mixture()

  • n – Phase number in the input

  • moles – Number of moles to add. Units: kmol

setPressure(self, P)

Set the pressure of the mixture.

Parameters
  • self – Instance of class Mixture()

  • P – Pressure. Units: Pa

setSpeciesMoles(self, moles)

Set the moles of the species.

Set the moles of the species in kmol. The moles may be specified either as a string, or as an vector. If a vector 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.

>> setSpeciesMoles(mix, 'C(s):1.0, CH4:2.0, O2:0.2');
Parameters
  • self – Instance of class Mixture()

  • moles – Vector or string specifying the moles of species

setTemperature(self, T)

Set the mixture temperature.

Parameters
  • self – Instance of class Mixture()

  • T – Temperature. Units: K

speciesIndex(self, k, p)

Get the index of a species in a mixture.

Parameters
  • self – Instance of class Mixture()

  • name – Name of the speces whose index is desired

Returns

Index of species with name name

temperature(self)

Get the temperature of a mixture.

Parameters

self – Instance of class Mixture()

Returns

Temperature (K)

Interface

class Interface(src, id, p1, p2, p3, p4)

Interface class constructor.

See Interfaces.

See also: importEdge(), importInterface()

Parameters
  • src – CTI or CTML file containing the interface or edge phase.

  • id – Name of the interface or edge phase in the CTI or CTML file.

  • p1 – Adjoining phase to the interface.

  • p2 – Adjoining phase to the interface.

  • p3 – Adjoining phase to the interface.

  • p4 – Adjoining phase to the interface.

Returns

Instance of class Interface()

concentrations(s)

Get the concentrations of the species on an interface.

Parameters

s – Instance of class Interface() with surface species

Returns

If no output value is assigned, a bar graph will be plotted. Otherwise, a vector of length n_surf_species will be returned.

coverages(s)

Get the surface coverages of the species on an interface.

Parameters

s – Instance of class Interface() with surface species

Returns

If no output value is assigned, a bar graph will be plotted. Otherwise, a vector of length n_surf_species will be returned.

importEdge(file, name, phase1, phase2, phase3, phase4)

Import edges between phases.

Supports up to four neighbor phases. See Interfaces

Parameters
  • file – File containing phases

  • name – Name of phase

  • phase1 – First neighbor phase

  • phase2 – Second neighbor phase

  • phase3 – Third neighbor phase

  • phase4 – Fourth neighbor phase

Returns

Instance of class Interface()

importInterface(file, name, phase1, phase2)

Import an interface between phases.

See Interfaces.

Parameters
  • file – CTI or CTML file containing the interface

  • name – Name of the interface to import

  • phase1 – First phase in the interface

  • phase2 – Second phase in the interface

Returns

Instance of class Interface()

setCoverages(s, cov, norm)

Set surface coverages of the species on an interface.

Parameters
  • s – Instance of class Interface()

  • cov – Coverage of the species. cov can be either a vector of length n_surf_species, or a string in the format 'Species:Coverage, Species:Coverage'

  • norm – Optional flag that denotes whether or not to normalize the species coverages. norm is either of the two strings 'nonorm'` or 'norm'. If left unset, the default is norm. This only works if s is a vector, not a string. Since unnormalized coverages can lead to unphysical results, 'nonorm' should be used only in rare cases, such as computing partial derivatives with respect to a species coverage.

Pure Fluid Phases

CarbonDioxide()

Return an object representing carbon dioxide.

The object returned by this method implements an accurate equation of state for carbon dioxide that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

Reynolds, W. C. Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances. Stanford: Stanford University, 1979. Print.

For more details, see classes Cantera::PureFluid and tpx::CarbonDioxide in the Cantera C++ source code documentation.

Returns

Instance of class Solution()

HFC134a()

Return an object representing refrigerant HFC134a.

The object returned by this method implements an accurate equation of state for refrigerant HFC134a (R134a) that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. Implements the equation of state given in: R. Tillner-Roth and H. D. Baehr. “An International Standard Formulation for The Thermodynamic Properties of 1,1,1,2-Tetrafluoroethane (HFC-134a) for Temperatures From 170 K to 455 K and Pressures up to 70 MPa”. J. Phys. Chem. Ref. Data, Vol. 23, No. 5, 1994. pp. 657–729. http://dx.doi.org/10.1063/1.555958

For more details, see classes Cantera::PureFluid and tpx::HFC134a in the Cantera C++ source code documentation.

Returns

Instance of class Solution()

Hydrogen()

Return an object representing hydrogen.

The object returned by this method implements an accurate equation of state for hydrogen that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

Reynolds, W. C. Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances Stanford: Stanford University, 1979. Print.

For more details, see classes Cantera::PureFluid and tpx::hydrogen in the Cantera C++ source code documentation.

Returns

Instance of class Solution()

Methane()

Return an object representing methane.

The object returned by this method implements an accurate equation of state for methane that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

Reynolds, W. C. Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances Stanford: Stanford University, 1979. Print.

Returns

Instance of class Solution()

Nitrogen()

Return an object representing nitrogen.

The object returned by this method implements an accurate equation of state for nitrogen that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

Reynolds, W. C. Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances Stanford: Stanford University, 1979. Print.

Returns

Instance of class Solution()

Oxygen()

Return an object representing oxygen.

The object returned by this method implements an accurate equation of state for oxygen that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

Reynolds, W. C. Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances Stanford: Stanford University, 1979. Print.

Returns

Instance of class Solution()

Water()

Return an object representing water.

The object returned by this method implements an accurate equation of state for water that can be used in the liquid, vapor, saturated liquid/vapor, and supercritical regions of the phase diagram. The equation of state is taken from

Reynolds, W. C. Thermodynamic Properties in SI: graphs, tables, and computational equations for forty substances. Stanford: Stanford University, 1979. Print.

For more details, see classes Cantera::PureFluid and tpx::water in the Cantera C++ source code documentation.

Returns

Instance of class Solution()