#### Previous topic

Importing Phase Objects

#### Next topic

Chemical Kinetics

Warning

This documentation is for an old version of Cantera. You can find docs for newer versions here.

# Thermodyamic Properties¶

These classes are used to describe the thermodynamic state of a system.

class Cantera.Phase.Phase

Phases of matter.

Class Phase manages basic state and constituent property information for a homogeneous phase of matter. It handles only those properties that do not require the equation of state, namely the temperature, density, chemical composition, and attributes of the elements and species.

It does not know about the pressure, or any other thermodynamic property requiring the equation of state – class ThermoPhase derives from Phase and adds those properties.

Class Phase is not usually instantiated directly. It is used as a base class for class ThermoPhase.

atomicWeights(elements=[])

Array of element molar masses [kg/kmol].

If a sequence of element symbols is supplied, only the values for those elements are returned, ordered as in the list. Otherwise, the values are for all elements in the phase, ordered as in the input file.

density()

Mass density [kg/m^3].

elementIndex(element)

The index of element element, which may be specified as a string or an integer index. In the latter case, the index is checked for validity and returned. If no such element is present, an exception is thrown.

elementName(m)

Name of the element with index number m.

elementNames()

Return a tuple of all element names.

massFraction(species)

Mass fraction of one species, referenced by name or index number.

>>> ph.massFraction(4)
>>> ph.massFraction('CH4')

massFractions(species=None)

Species mass fraction array. If optional argument species is supplied, then only the values for the selected species are returned.

>>> y1 = ph.massFractions()   # all species
>>> y2 = ph.massFractions(['OH', 'CH3'. 'O2'])

meanMolarMass()

Mean molar mass [kg/kmol].

meanMolecularWeight()

Mean molar mass [kg/kmol].

molarDensity()

Molar density [kmol/m^3].

molarMasses(species=None)

Array of species molar masses [kg/kmol].

moleFraction(species)

Mole fraction of a species, referenced by name or index number.

>>> ph.moleFraction(4)
>>> ph.moleFraction('CH4')

moleFractions(species=None)

Species mole fraction array. If optional argument species is supplied, then only the values for the selected species are returned.

>>> x1 = ph.moleFractions()   # all species
>>> x2 = ph.moleFractions(['OH', 'CH3'. 'O2'])

molecularWeights(species=None)

Array of species molar masses [kg/kmol].

nAtoms(species=None, element=None)

Number of atoms of element element in species species. The element and species may be specified by name or by number.

>>> ph.nAtoms('CH4','H')
4

nElements()

Number of elements.

nSpecies()

Number of species.

phase_id()

The integer index used to access the kernel-level object. Internal.

selectElements(f, elements)

Given an array f of floating-point element properties, return a those values corresponding to elements listed in elements. Returns an array if elements is a sequence, or a scalar if elements is a scalar.

>>> f = ph.elementPotentials()
>>> lam_o, lam_h = ph.selectElements(f, ['O', 'H'])
>>> lam_h = ph.selectElements(f, 'H')

selectSpecies(f, species)

Given an array f of floating-point species properties, return those values corresponding to species listed in species. Returns an array if species is a sequence, or a scalar if species is a scalar. This method is used internally to implement species selection in methods like moleFractions, massFractions, etc.

>>> f = ph.chemPotentials()
>>> muo2, muh2 = ph.selectSpecies(f, ['O2', 'H2'])
>>> muh2 = ph.selectSpecies(f, 'H2')

setDensity(rho)

Set the density [kg/m3].

setMassFractions(x, norm=1)

Set the mass fractions. See setMoleFractions()

setMolarDensity(n)

Set the density [kmol/m3].

setMoleFractions(x, norm=1)

Set the mole fractions.

Parameters: x – string or array of mole fraction values norm – If non-zero (default), array values will be scaled to sum to 1.0.
>>> ph.setMoleFractions('CO:1, H2:7, H2O:7.8')
>>> x = [1.0]*ph.nSpecies()
>>> ph.setMoleFractions(x)
>>> ph.setMoleFractions(x, norm = 0)  # don't normalize values

setState_TNX(t, n, x)

Set the temperature, molardensity, and mole fractions. The mole fractions may be entered as a string or array,

>>> ph.setState_TNX(600.0, 2.0e-3, 'CH4:0.4, O2:0.6')

setState_TR(t, rho)

Set the temperature and density, leaving the composition unchanged.

setState_TRX(t, rho, x)

Set the temperature, density, and mole fractions. The mole fractions may be entered as a string or array, >>> ph.setState_TRX(600.0, 2.0e-3, ‘CH4:0.4, O2:0.6’)

setState_TRY(t, rho, y)

Set the temperature, density, and mass fractions.

setTemperature(t)

Set the temperature [K].

speciesIndex(species)

The index of species species, which may be specified as a string or an integer index. In the latter case, the index is checked for validity and returned. If no such species is present, an exception is thrown.

speciesName(k)

Name of the species with index k.

speciesNames()

Return a tuple of all species names.

temperature()

Temperature [K].

volume_mass()

Specific volume [m^3/kg].

class Cantera.ThermoPhase.ThermoPhase(xml_phase=None, index=-1)

Bases: Cantera.Phase.Phase

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 extends class Phase by providing methods that require knowledge of the equation of state.

Class ThermoPhase is not usually instantiated directly. It is used as base class for classes Solution and Interface.

Parameters: xml_phase – CTML node specifying the attributes of this phase index – optional. If positive, create only a Python wrapper for an existing kernel object, instead of creating a new kernel object. The value of index is the integer index number to reference the existing kernel object.
chemPotentials(species=[])

Species chemical potentials.

This method returns an array containing the species chemical potentials [J/kmol]. The expressions used to compute these depend on the model implemented by the underlying kernel thermo manager.

cp_R(species=[])

Pure species non-dimensional heat capacities at constant pressure.

This method returns an array containing the pure-species standard-state heat capacities divided by R. For gaseous species, these values are ideal gas heat capacities.

cp_mass()

Specific heat at constant pressure [J/kg/K].

cp_mole()

The molar heat capacity at constant pressure [J/kmol/K].

cv_mass()

Specific heat at constant volume [J/kg/K].

cv_mole()

The molar heat capacity at constant volume [J/kmol/K].

electricPotential()

Electric potential [V].

elementPotentials(elements=[])

Element potentials of the elements.

This method returns an array containing the element potentials [J/kmol]. The element potentials are only defined for equilibrium states. This method first sets the composition to a state of equilibrium holding T and P constant, then computes the element potentials for this equilibrium state.

enthalpies_RT(species=[])

Pure species non-dimensional reference state enthalpies.

This method returns an array containing the pure-species standard-state enthalpies divided by RT. For gaseous species, these values are ideal gas enthalpies.

enthalpy_mass()

Specific enthalpy [J/kg].

enthalpy_mole()

The molar enthalpy [J/kmol].

entropies_R(species=[])

Pure species non-dimensional entropies.

This method returns an array containing the pure-species standard-state entropies divided by R. For gaseous species, these values are ideal gas entropies.

entropy_mass()

Specific entropy [J/kg/K].

entropy_mole()

The molar entropy [J/kmol/K].

equilibrate(XY, solver=-1, rtol=1e-09, maxsteps=1000, maxiter=100, loglevel=0)

Set to a state of chemical equilibrium holding property pair XY constant.

Parameters: XY – A two-letter string, which must be one of the set: ['TP','TV','HP','SP','SV','UV','PT','VT','PH','PS','VS','VU']  If H, U, S, or V is specified, the value must be the specific value (per unit mass) solver – Specifies the equilibrium solver to use. If solver = 0, a fast solver using the element potential method will be used. If solver > 0, a slower but more robust Gibbs minimization solver will be used. If solver < 0 or unspecified, the fast solver will be tried first, then if it fails the other will be tried. rtol – the relative error tolerance. maxsteps – maximum number of steps in composition to take to find a converged solution. maxiter – For the Gibbs minimization solver only, this specifies the number of ‘outer’ iterations on T or P when some property pair other than TP is specified. loglevel – Set to a value > 0 to write diagnostic output to a file in HTML format. Larger values generate more detailed information. The file will be named equilibrate_log.html. Subsequent files will be named equilibrate_log1.html, etc., so that log files are not overwritten.
gibbs_RT(species=[])

Pure species non-dimensional Gibbs free energies.

This method returns an array containing the pure-species standard-state Gibbs free energies divided by R. For gaseous species, these are ideal gas values.

gibbs_mass()

Specific Gibbs free energy [J/kg].

gibbs_mole()

The molar Gibbs function [J/kmol].

intEnergy_mass()

Specific internal energy [J/kg].

intEnergy_mole()

The molar internal energy [J/kmol].

maxTemp(sp=None)

Maximum temperature for which thermodynamic property fits are valid. If a species is specified (by name or number), then the maximum temperature is for only this species. Otherwise it is the highest temperature for which the properties are valid for all species.

minTemp(sp=None)

Minimum temperature for which thermodynamic property fits are valid. If a species is specified (by name or number), then the minimum temperature is for only this species. Otherwise it is the lowest temperature for which the properties are valid for all species.

name()

The name assigned to the phase. The default value is the name attribute from the CTI file. But method setName can be used to set the name to anything desired, e.g. ‘gas at inlet’ or ‘exhaust’

pressure()

The pressure [Pa].

refPressure()

Reference pressure [Pa]. All standard-state thermodynamic properties are for this pressure.

restoreState(s)

Restore the state to that stored in array s.

saveState()

Return an array with state information that can later be used to restore the state.

setElectricPotential(v)

Set the electric potential.

setName(name)

Set the name attribute. This can be any string

setPressure(p)

Set the pressure [Pa].

setState_HP(h, p)

Set the state by specifying the specific enthalpy and the pressure.

setState_PX(p, x)

Set the pressure [Pa], and mole fractions.

setState_PY(p, y)

Set the pressure [Pa], and mass fractions.

setState_SP(s, p)

Set the state by specifying the specific entropy energy and the pressure.

setState_SV(s, v)

Set the state by specifying the specific entropy and the specific volume.

setState_TP(t, p)

Set the temperature [K] and pressure [Pa].

setState_TPX(t, p, x)

Set the temperature [K], pressure [Pa], and mole fractions.

setState_TPY(t, p, y)

Set the temperature [K], pressure [Pa], and mass fractions.

setState_UV(u, v)

Set the state by specifying the specific internal energy and the specific volume.

thermo_hndl()

Return the integer index that is used to reference the kernel object. For internal use.

thermophase()

Return the integer index that is used to reference the kernel object. For internal use.

class Cantera.SurfacePhase.EdgePhase(xml_phase=None, index=-1)

A one-dimensonal edge.

class Cantera.SurfacePhase.SurfacePhase(xml_phase=None, index=-1)

A class for surface phases.

concentrations()

Return the array of surface concentrations [kmol/m2].

coverages()

Return the array of surface coverages.

setConcentrations(conc)

Set the surface concentrations to the values in array conc.

setCoverages(theta)

Set the surface coverages to the values in array theta.

setSiteDensity(n0)

Set the site density.

siteDensity()

Site density [kmol/m2]