Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in SmoothVLE2 initialization #1563

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ def calculate_teq(blk, pp):
vapor_phase,
raoult_comps,
henry_comps,
_,
l_only_comps,
v_only_comps,
) = identify_VL_component_list(blk, pp)

if v_only_comps is None:
if len(v_only_comps) == 0:
if blk.is_property_constructed("temperature_bubble"):
Tbub = value(blk.temperature_bubble[pp])
else:
Expand All @@ -258,7 +258,7 @@ def calculate_teq(blk, pp):
else:
t1 = value(blk.temperature)

if v_only_comps is None:
if len(l_only_comps) == 0:
if blk.is_property_constructed("temperature_dew"):
Tdew = value(blk.temperature_bubble[pp])
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
units as pyunits,
)

from idaes.core.base.phases import PhaseType
from idaes.core.util.exceptions import ConfigurationError

from idaes.models.properties.modular_properties.base.generic_property import (
GenericParameterBlock,
)
Expand All @@ -41,7 +44,8 @@
from idaes.models.properties.modular_properties.eos.ideal import Ideal
from idaes.models.properties.modular_properties.eos.ceos import Cubic, CubicType
from idaes.models.properties.modular_properties.phase_equil.forms import fugacity
from idaes.core.util.exceptions import ConfigurationError

from idaes.models.properties.modular_properties.pure.NIST import NIST


@pytest.mark.unit
Expand Down Expand Up @@ -339,3 +343,81 @@ def test_calculate_ceos_derivative_slacks(frame):

assert value(gp["Vap"]) == pytest.approx(EPS_INIT, abs=1e-8)
assert value(gn["Vap"]) == pytest.approx(EPS_INIT, abs=1e-8)


@pytest.fixture()
def H2O_H2_model():
m = ConcreteModel()

# Create a dummy parameter block
m.params = GenericParameterBlock(
components={
"H2O": {
"parameter_data": {
"pressure_crit": (220.6e5, pyunits.Pa),
"temperature_crit": (647, pyunits.K),
"omega": 0.344,
"pressure_sat_comp_coeff": { # NIST <- Stull 1947
"A": 4.6543,
"B": 1435.264,
"C": -64.848,
},
},
"pressure_sat_comp": NIST,
"phase_equilibrium_form": {("Vap", "Liq"): fugacity},
},
"H2": {
"valid_phase_types": [PhaseType.vaporPhase],
"parameter_data": {
"pressure_crit": (13e5, pyunits.Pa),
"temperature_crit": (33.2, pyunits.K),
"omega": -0.218,
},
},
},
phases={
"Liq": {
"equation_of_state": Cubic,
"equation_of_state_options": {"type": CubicType.PR},
},
"Vap": {
"equation_of_state": Cubic,
"equation_of_state_options": {"type": CubicType.PR},
},
},
state_definition=FTPx,
pressure_ref=100000.0,
temperature_ref=300,
base_units={
"time": pyunits.s,
"length": pyunits.m,
"mass": pyunits.kg,
"amount": pyunits.mol,
"temperature": pyunits.K,
},
phases_in_equilibrium=[("Vap", "Liq")],
phase_equilibrium_state={("Vap", "Liq"): CubicComplementarityVLE},
parameter_data={
"PR_kappa": {
("H2O", "H2O"): 0.000,
("H2", "H2O"): 0.000,
("H2O", "H2"): 0.000,
("H2", "H2"): 0.000,
}
},
)

# Create a dummy state block
m.props = m.params.state_block_class([1], parameters=m.params)

return m


@pytest.mark.unit
def test_calculate_teq_permanent_gas(H2O_H2_model):
m = H2O_H2_model
m.props[1].pressure.set_value(1e5)
m.props[1].temperature.set_value(300)
CubicComplementarityVLE.calculate_teq(m.props[1], ("Vap", "Liq"))
assert not m.props[1].is_property_constructed("temperature_dew")
assert not m.props[1].is_property_constructed("temperature_bubble")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that the framework does not create these equilibrium properties because there is only one VLE component in the system, which makes sense. Are there tests for other scenarios, for example one or more non-condensable or non-volatile components in a system with two or more VLE components? In those cases, these properties should still be created.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SmoothVLE2 method doesn't need bubble and dew points to operate, unlike the original SmoothVLE. The test coverage here is pretty poor, but I wanted to fix the outstanding issue quickly before moving onto other things.

Loading