Helmholtz EoS Expression Writer

Contents

Helmholtz EoS Expression Writer#

In addition to the usual IDAES property block, property functions can be accessed directly as Pyomo expressions using the HelmholtzThermoExpressions class.

Class#

class idaes.models.properties.general_helmholtz.helmholtz_functions.HelmholtzThermoExpressions(blk, parameters, amount_basis=None)[source]#

Class to write thermodynamic property expressions. Take one of these possible sets of state variables: {h, p}, {u, p}, {s, p}, {s, T}, {T, x}, {P, x}, or {T, P, x}, and return an expression for a thermo property. This works by converting the given state variables to temperature, density, and vapor fraction expressions then using those to write an expression for requested property. This writes expressions in a way that looks like a thermodynamic property function.

Parameters:
  • blk (Block) – block to attach the external functions to

  • parameters (HelmholtzParameterBlock) – property parameter block

  • amount_basis (AmountBasis|None) – If none get the amount basis from the parameter block, otherwise use this amount basis for inputs.

Returns:

HelmholtzThermoExpressions

T(**kwargs)[source]#

Temperature

T_sat(p, convert_args=True)[source]#

Return saturation temperature as a function of p

add_funcs(names=None)[source]#

Add external functions for the block expressions will be written from.

Parameters:

name (str) – function name

cp(**kwargs)[source]#

Mixed phase isobaric heat capacity

cp_liq(**kwargs)[source]#

Liquid phase isobaric heat capacity

cp_vap(**kwargs)[source]#

Vapor phase isobaric heat capacity

cv(**kwargs)[source]#

Mixed phase isochoric heat capacity

cv_liq(**kwargs)[source]#

Liquid phase isochoric heat capacity

cv_vap(**kwargs)[source]#

Vapor phase isochoric heat capacity

f(**kwargs)[source]#

Mixed phase Helmholtz free energy

f_liq(**kwargs)[source]#

Liquid phase Helmholtz free energy

f_vap(**kwargs)[source]#

Vapor phase Helmholtz free energy

g(**kwargs)[source]#

Mixed phase Gibbs free energy

g_liq(**kwargs)[source]#

Liquid phase Gibbs free energy

g_vap(**kwargs)[source]#

Vapor phase Gibbs free energy

h(**kwargs)[source]#

Mixed phase enthalpy

h_liq(**kwargs)[source]#

Liquid phase enthalpy

h_liq_sat(T=None, p=None, result_basis=None, convert_args=True)[source]#

Return saturation liquid enthalpy as a function of T or p

h_vap(**kwargs)[source]#

Vapor phase enthalpy

h_vap_sat(T=None, p=None, result_basis=None, convert_args=True)[source]#

Return saturation vapor enthalpy as a function of T or p

p(**kwargs)[source]#

Pressure

p_sat(T)[source]#

Return saturation pressure as a function of T or tau

rho(**kwargs)[source]#

Mixed phase density

rho_liq(**kwargs)[source]#

Liquid density

rho_vap(**kwargs)[source]#

Vapor Density

s(**kwargs)[source]#

Mixed phase entropy

s_liq(**kwargs)[source]#

Liquid phase entropy

s_liq_sat(T=None, p=None, result_basis=None, convert_args=True)[source]#

Return saturation liquid entropy as a function of T or p

s_vap(**kwargs)[source]#

Vapor phase entropy

s_vap_sat(T=None, p=None, result_basis=None, convert_args=True)[source]#

Return saturation vapor entropy as a function of T or p

surface_tension(**kwargs)[source]#

Surface tension, this is only meaningful for two-phase region

tau(**kwargs)[source]#

Critical Temperature (K)/Temperature (K)

thermal_conductivity(**kwargs)[source]#

Mixed phase thermal conductivity (value for two-phase is not meaningful) use the liquid or vapor version if two phases are expected.

thermal_conductivity_liq(**kwargs)[source]#

Liquid phase thermal conductivity

thermal_conductivity_vap(**kwargs)[source]#

Vapor phase thermal conductivity

u(**kwargs)[source]#

Mixed phase internal energy

u_liq(**kwargs)[source]#

Liquid phase internal energy

u_liq_sat(T=None, p=None, result_basis=None, convert_args=True)[source]#

Return saturation liquid internal energy as a function of T or p

u_vap(**kwargs)[source]#

Vapor phase internal energy

u_vap_sat(T=None, p=None, result_basis=None, convert_args=True)[source]#

Return saturation vapor internal energy as a function of T or p

v(**kwargs)[source]#

Mixed phase volume

v_liq(**kwargs)[source]#

Liquid phase volume

v_liq_sat(T=None, p=None, result_basis=None, convert_args=True)[source]#

Return saturation liquid volume as a function of T or p

v_vap(**kwargs)[source]#

Vapor phase volume

v_vap_sat(T=None, p=None, result_basis=None, convert_args=True)[source]#

Return saturation vapor volume as a function of T or p

viscosity(**kwargs)[source]#

Mixed phase viscosity (value for two-phase is not meaningful) use the liquid or vapor version if two phases are expected.

viscosity_liq(**kwargs)[source]#

Liquid phase viscosity

viscosity_vap(**kwargs)[source]#

Vapor phase viscosity

w(**kwargs)[source]#

Mixed phase speed of sound (value for two-phase is not meaningful) use the liquid or vapor version if two phases are expected.

w_liq(**kwargs)[source]#

Liquid phase speed of sound

w_vap(**kwargs)[source]#

Vapor phase speed of sound

x(**kwargs)[source]#

Vapor fraction

All the property expression methods that take indeterminate **kwarg take the same set of arguments. The state variables should be provided as arguments and include units. The state variables are passed to external functions to calculate properties. If convert_units=False is passed the state variable expressions are assumed to include units native to the external functions and no unit conversion expression is needed; otherwise, units are assumed to be in SI. While you do need to provide units to check for consistency, arbitrary unit conversion is not currently supported, due to potentially slow model building. The state variables are on a mass or mole basis as determined by the amount_basis argument given when creating the HelmholtzThermoExpressions object. An optional result_basis argument can be provided as an AmountBasis Enum to set whether the resulting property expression is given on a mass or mole basis. If not provided, the amount_basis argument is used for the result.

State variables should be in one of the sets below.

  • {h, p}

  • {u, p}

  • {s, p}

  • {s, T}

  • {T, x}

  • {p, x}

  • {T, P, x}

Saturation properties are given as a function of either temperature or pressure, so only the temperature or pressure state variable are required. The convert_units and result_basis arguments are also taken by the saturated property methods.

Example#

The sample code below gives an example of how to use the expression writer in constructing a Pyomo model.

import pytest
import pyomo.environ as pyo
from idaes.models.properties.general_helmholtz import (
    HelmholtzParameterBlock,
    HelmholtzThermoExpressions,
    AmountBasis,
)
m = pyo.ConcreteModel()
m.hparam = HelmholtzParameterBlock(
    pure_component="r134a", amount_basis=AmountBasis.MASS
)
te = HelmholtzThermoExpressions(m, m.hparam)
m.density = pyo.Expression(expr=te.rho_liq(T=170 * pyo.units.K, x=0))

assert pytest.approx(1.5907, rel=1e-3) == pyo.value(
    pyo.units.convert(m.density,
        pyo.units.g / pyo.units.cm**3,
    )
)