#### 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.

# Thermodynamic Properties¶

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

class cantera.ThermoPhase

Bases: cantera._cantera._SolutionBase

ThermoPhase(*args, **kwargs)

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.

HP

Get/Set enthalpy [J/kg or J/kmol] and pressure [Pa].

HPX

Get/Set enthalpy [J/kg or J/kmol], pressure [Pa] and mole fractions.

HPY

Get/Set enthalpy [J/kg or J/kmol], pressure [Pa] and mass fractions.

ID

The ID of the phase. The default is taken from the CTI/XML input file.

P

Pressure [Pa].

P_sat

Saturation pressure [Pa] at the current temperature.

SP

Get/Set entropy [J/kg/K or J/kmol/K] and pressure [Pa].

SPX

Get/Set entropy [J/kg/K or J/kmol/K], pressure [Pa], and mole fractions.

SPY

Get/Set entropy [J/kg/K or J/kmol/K], pressure [Pa], and mass fractions.

SV

Get/Set entropy [J/kg/K or J/kmol/K] and specific volume [m^3/kg or m^3/kmol].

SVX

Get/Set entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or m^3/kmol], and mole fractions.

SVY

Get/Set entropy [J/kg/K or J/kmol/K], specific volume [m^3/kg or m^3/kmol], and mass fractions.

T

Temperature [K].

TD

Get/Set temperature [K] and density [kg/m^3 or kmol/m^3].

TDX

Get/Set temperature [K], density [kg/m^3 or kmol/m^3], and mole fractions.

TDY

Get/Set temperature [K] and density [kg/m^3 or kmol/m^3], and mass fractions.

TP

Get/Set temperature [K] and pressure [Pa].

TPX

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

TPY

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

T_sat

Saturation temperature [K] at the current pressure.

UV

Get/Set internal energy [J/kg or J/kmol] and specific volume [m^3/kg or m^3/kmol].

UVX

Get/Set internal energy [J/kg or J/kmol], specific volume [m^3/kg or m^3/kmol], and mole fractions.

UVY

Get/Set internal energy [J/kg or J/kmol], specific volume [m^3/kg or m^3/kmol], and mass fractions.

X

Get/Set the species mole fractions. Can be set as either an array 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
array([0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5])

Y

Get/Set the species mass fractions. Can be set as either an array 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
array([0.1, 0, 0, 0.4, 0, 0, 0, 0, 0.5])

atomic_weight(self, m)

Atomic weight [kg/kmol] of element m

atomic_weights

Array of atomic weight [kg/kmol] for each element in the mixture.

basis

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.

chemical_potentials

Array of species chemical potentials [J/kmol].

concentrations

Get/Set the species concentrations [kmol/m^3].

cp

Heat capacity at constant pressure [J/kg/K or J/kmol/K] depending on basis.

cp_mass

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

cp_mole

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

critical_density

Critical density [kg/m^3 or kmol/m^3] depending on basis.

critical_pressure

Critical pressure [Pa].

critical_temperature

Critical temperature [K].

cv

Heat capacity at constant volume [J/kg/K or J/kmol/K] depending on basis.

cv_mass

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

cv_mole

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

density

Density [kg/m^3 or kmol/m^3] depending on basis.

density_mass

(Mass) density [kg/m^3].

density_mole

Molar density [kmol/m^3].

electric_potential

Get/Set the electric potential [V] for this phase.

electrochemical_potentials

Array of species electrochemical potentials [J/kmol].

element_index(self, element) → int

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.

element_name(self, m)

Name of the element with index m.

element_names

A list of all the element names.

element_potentials(self)

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.

enthalpy_mass

Specific enthalpy [J/kg].

enthalpy_mole

Molar enthalpy [J/kmol].

entropy_mass

Specific entropy [J/kg].

entropy_mole

Molar entropy [J/kmol/K].

equilibrate(self, XY, solver='auto', double rtol=1e-09, int maxsteps=1000, int maxiter=100, int 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']  solver – Specifies the equilibrium solver to use. May be one of the following: ‘’element_potential’’ - a fast solver using the element potential method ‘gibbs’ - a slower but more robust Gibbs minimization solver ‘vcs’ - the VCS non-ideal equilibrium solver “auto” - The element potential solver will be tried first, then if it fails the gibbs solver 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, 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.
g

Gibbs free energy [J/kg or J/kmol] depending on basis.

gibbs_mass

Specific Gibbs free energy [J/kg].

gibbs_mole

Molar Gibbs free energy [J/kmol].

h

Enthalpy [J/kg or J/kmol] depending on basis.

int_energy_mass

Specific internal energy [J/kg].

int_energy_mole

Molar internal energy [J/kmol].

isothermal_compressibility

Isothermal compressibility [1/Pa].

max_temp

Maximum temperature for which the thermodynamic data for the phase are valid.

mean_molecular_weight

The mean molecular weight (molar mass) [kg/kmol].

min_temp

Minimum temperature for which the thermodynamic data for the phase are valid.

molecular_weights

Array of species molecular weights (molar masses) [kg/kmol].

n_atoms(self, species, element)

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

n_elements

Number of elements.

n_species

Number of species.

name

The name assigned to this phase. The default is taken from the CTI/XML input file.

partial_molar_cp

Array of species partial molar specific heat capacities at constant pressure [J/kmol/K].

partial_molar_enthalpies

Array of species partial molar enthalpies [J/kmol].

partial_molar_entropies

Array of species partial molar entropies [J/kmol/K].

partial_molar_int_energies

Array of species partial molar internal energies [J/kmol].

partial_molar_volumes

Array of species partial molar volumes [m^3/kmol].

reference_pressure

Reference state pressure [Pa].

report(self, show_thermo=True)

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())

s

Entropy [J/kg/K or J/kmol/K] depending on basis.

species_index(self, species) → int

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.

species_name(self, k)

Name of the species with index k.

species_names

A list of all the species names.

standard_cp_R

Array of nondimensional species standard-state specific heat capacities at constant pressure at the current temperature and pressure.

standard_enthalpies_RT

Array of nondimensional species standard-state enthalpies at the current temperature and pressure.

standard_entropies_R

Array of nondimensional species standard-state entropies at the current temperature and pressure.

standard_gibbs_RT

Array of nondimensional species standard-state Gibbs free energies at the current temperature and pressure.

standard_int_energies_RT

Array of nondimensional species standard-state internal energies at the current temperature and pressure.

thermal_expansion_coeff

Thermal expansion coefficient [1/K].

u

Internal energy in [J/kg or J/kmol].

v

Specific volume [m^3/kg or m^3/kmol] depending on basis.

volume_mass

Specific volume [m^3/kg].

volume_mole

Molar volume [m^3/kmol].

class cantera.InterfacePhase

Bases: cantera._cantera.ThermoPhase

A class representing a surface or edge phase

coverages

Get/Set the fraction of sites covered by each species.

site_density

Get/Set the site density. [kmol/m^2] for surface phases; [kmol/m] for edge phases.

class cantera.PureFluid

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.

PX

Get/Set the pressure and vapor fraction of a two-phase state.

TX

Get/Set the temperature and vapor fraction of a two-phase state.

X

Vapor fraction (quality).

class cantera.Mixture

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.

P

The Pressure [Pa] of all phases in the mixture. When set, the temperature of the mixture is held fixed.

T

The Temperature [K] of all phases in the mixture. When set, the pressure of the mixture is held fixed.

charge

The total charge in Coulombs, summed over all phases.

chemical_potentials

The chemical potentials of all species [J/kmol].

element_index(self, element) → int

Index of element with name ‘element’:

>>> mix.element_index('H')


2

element_moles(self, e)

Total number of moles of element e, summed over all species. The element may be referenced either by index number or by name.

equilibrate(self, XY, solver='vcs', rtol=1e-09, max_steps=1000, max_iter=100, estimate_equil=0, print_level=0, log_level=0)

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: XY – A two-letter string, which must be one of the set: ['TP', 'HP', 'SP']  solver – Set to either ‘vcs’ or ‘gibbs’ to choose implementation of the solver to use. ‘vcs’ uses the solver implemented in the C++ class ‘VCSnonideal’, and ‘gibbs’ uses the one implemented in class ‘MultiPhaseEquil’. rtol – Error tolerance. Iteration will continue until (Delta mu)/RT is less than this value for each reaction. Note that this default is very conservative, and good equilibrium solutions may be obtained with larger error tolerances. max_steps – Maximum number of steps to take while solving the equilibrium problem for specified T and P. max_iter – Maximum number of temperature and/or pressure iterations. This is only relevant if a property pair other than (T,P) is specified. estimate_equil – Flag indicating whether the solver should estimate its own initial condition. If 0, the initial mole fraction vector in the phase objects are used as the initial condition. If 1, the initial mole fraction vector is used if the element abundances are satisfied. if -1, the initial mole fraction vector is thrown out, and an estimate is formulated. print_level – Determines the amount of output displayed during the solution process. 0 indicates no output, while larger numbers produce successively more verbose information. log_level – Controls the amount of diagnostic output written to an HTML log file. If log_level = 0, no diagnostic output is written. For values > 0, more detailed information is written to the log file as log_level increases. The default log file name is “equilibrium_log.html”, but if this file exists, the log information will be written to “equilibrium_log{n}.html”, where {n} is an integer chosen to avoid overwriting existing log files.
max_temp

The maximum temperature for which all species in multi-species solutions have valid thermo data. Stoichiometric phases are not considered in determining max_temp.

min_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.

n_atoms(self, k, m)

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

n_elements

Total number of elements present in the mixture.

n_phases

Number of phases

n_species

Number of species.

phase(self, n)
phase_charge(self, p)

The charge of phase p in Coulumbs.

phase_index(self, p)

Index of the phase named p.

phase_moles(self, p=None)

Moles in phase p, if p is specified, otherwise the number of moles in all phases.

phase_names

Names of all phases in the order added.

report(self)

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_phase_moles(self, p, moles)

Set the number of moles of phase p to moles

species_index(self, phase, species)
Parameters: phase – Phase object, index or name species – Species name or index

Returns the global index of species species in phase phase.

species_moles

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'

species_name(self, k)

Name of the species with index k. Note that index numbers are assigned in order as phases are added.

species_names