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
- add_funcs(names=None)[source]#
Add external functions for the block expressions will be written from.
- Parameters:
name (str) – function name
- 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_sat(T=None, p=None, result_basis=None, convert_args=True)[source]#
Return saturation vapor enthalpy as a function of T or p
- 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_sat(T=None, p=None, result_basis=None, convert_args=True)[source]#
Return saturation vapor entropy as a function of T or p
- 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.
- 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_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_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_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.
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,
)
)