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

Add new Complementarity formualtion for VLE with cubic EoSs #1397

Merged
merged 40 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a3f141f
Infrastructure work to support SmoothVLE2
Apr 17, 2024
ed3734a
Some pylint issues and tests for new cubic EoS functions
Apr 18, 2024
851cc3b
Fixing broken tests
Apr 18, 2024
251b7f7
Fixing more tests
Apr 18, 2024
7997adf
Tests for identify_VL_component_list
Apr 18, 2024
83539aa
Testing estimation of bubble and dew points
Apr 21, 2024
59e22dd
First unit testing of SmoothVLE2
Apr 22, 2024
d76b17d
First running version of code
Apr 23, 2024
3555f58
Running example
Apr 23, 2024
78d4372
Starting clean up and transition
Apr 23, 2024
cf5d515
Merge branch 'main' of https://github.com/IDAES/idaes-pse into smooth…
Apr 23, 2024
daf0502
Working on Tsweep test failure
Apr 29, 2024
eb72019
Merging main
May 9, 2024
7ddc023
Trying to debug Tsweep
May 9, 2024
81d9d26
Catch for non-cubics with SmoothVLE2
May 9, 2024
f4eb379
Fixing typo
May 9, 2024
0f0bd72
Merging main
May 17, 2024
860ad56
Tweaking eps values
May 17, 2024
92394ee
Fixing T sweep test
May 20, 2024
65087b6
Fixing some tests
May 21, 2024
39f1180
Merging main branch
May 21, 2024
f2b9813
Fixing some pylint issues
May 21, 2024
47c29bb
Typo
May 21, 2024
8e424cf
More pylinting
May 21, 2024
31fba13
More pylint
May 21, 2024
b27706a
Clean up debugging code
May 21, 2024
8771323
Fixing final test
May 21, 2024
8dd941b
Some clean up
May 24, 2024
55a5074
Merging main branch
May 26, 2024
f43e3e0
Using logspace
May 27, 2024
7a0375b
Adding initial docs
May 27, 2024
b563460
Documenting epsilons
May 27, 2024
c0a9e18
Fixing test
May 27, 2024
9d35277
Adjusting default value of epsilon
May 28, 2024
a98597c
Fixing typo
May 28, 2024
ad0da43
Merge branch 'main' into smooth_vle2
Jun 13, 2024
8b951b8
Fixing pint version issue
Jun 13, 2024
cbaf0aa
Addressing comments
Jun 17, 2024
0a1c28c
Merge branch 'main' into smooth_vle2
Jun 17, 2024
c2a593d
Fixing broken link in docs
Jun 17, 2024
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 @@ -13,6 +13,9 @@
"""
Framework for generic property packages
"""
# TODO: Pylint complains about variables with _x names as they are built by sub-classes
# pylint: disable=protected-access

# Import Pyomo libraries
from pyomo.environ import (
Block,
Expand Down Expand Up @@ -880,13 +883,10 @@ def build(self):
if build_parameters is not None:
try:
build_parameters(pobj)
except KeyError:
except KeyError as err:
raise ConfigurationError(
"{} values were not defined for parameter {} in "
"phase {}. Please check the parameter_data "
"argument to ensure values are provided.".format(
self.name, a, p
)
f"{self.name} - values were not defined for parameter {a} in "
f"phase {p}. {str(err)}"
)

# Next, add inherent reactions if they exist
Expand Down Expand Up @@ -1334,19 +1334,19 @@ def initialization_routine(

# Bubble temperature initialization
if hasattr(k, "_mole_frac_tbub"):
model._init_Tbub(k, T_units)
_init_Tbub(k, T_units)

# Dew temperature initialization
if hasattr(k, "_mole_frac_tdew"):
model._init_Tdew(k, T_units)
_init_Tdew(k, T_units)

# Bubble pressure initialization
if hasattr(k, "_mole_frac_pbub"):
model._init_Pbub(k, T_units)
_init_Pbub(k)

# Dew pressure initialization
if hasattr(k, "_mole_frac_pdew"):
model._init_Pdew(k, T_units)
_init_Pdew(k)

# Solve bubble, dew, and critical point constraints
for c in k.component_objects(Constraint):
Expand Down Expand Up @@ -2097,9 +2097,13 @@ def build(self):
):

t_units = self.params.get_metadata().default_units.TEMPERATURE
if self.temperature.value is not None:
t_value = value(self.temperature)
else:
t_value = None
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is None, does the model break or is there a catch for this case?

Copy link
Member Author

Choose a reason for hiding this comment

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

This just affects whether we can get initial guesses for Teq. Whether the model will solve or not is a separate issue at this point; the goal here is for the code to work without encountering a terminal error.

self._teq = Var(
self.params._pe_pairs,
initialize=value(self.temperature),
initialize=t_value,
dallan-keylogic marked this conversation as resolved.
Show resolved Hide resolved
doc="Temperature for calculating phase equilibrium",
units=t_units,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
)
from idaes.core.util.exceptions import ConfigurationError, PropertyPackageError
from idaes.models.properties.modular_properties.phase_equil.henry import HenryType
from idaes.models.properties.modular_properties.eos.ceos import Cubic, CubicType
from idaes.models.properties.modular_properties.state_definitions import FTPx
from idaes.core.base.property_meta import UnitSet
from idaes.core.initialization import BlockTriangularizationInitializer

Expand Down Expand Up @@ -1955,3 +1957,54 @@ def build_critical_properties(b, *args, **kwargs):
"Component declarations.",
):
_initialize_critical_props(m.props[1])


# Invalid property configuration to trigger configuration error
configuration = {
# Specifying components
"components": {
"H2O": {
"type": Component,
"parameter_data": {
"pressure_crit": (220.6e5, pyunits.Pa),
"temperature_crit": (647, pyunits.K),
"omega": 0.344,
},
},
},
# Specifying phases
"phases": {
"Liq": {
"type": LiquidPhase,
"equation_of_state": Cubic,
"equation_of_state_options": {"type": CubicType.PR},
},
"Vap": {
"type": VaporPhase,
"equation_of_state": Cubic,
"equation_of_state_options": {"type": CubicType.PR},
},
},
# Set base units of measurement
"base_units": {
"time": pyunits.s,
"length": pyunits.m,
"mass": pyunits.kg,
"amount": pyunits.mol,
"temperature": pyunits.K,
},
# Specifying state definition
"state_definition": FTPx,
"state_bounds": {
"flow_mol": (0, 100, 1000, pyunits.mol / pyunits.s),
"temperature": (273.15, 300, 500, pyunits.K),
"pressure": (5e4, 1e5, 1e6, pyunits.Pa),
},
"pressure_ref": (101325, pyunits.Pa),
"temperature_ref": (298.15, pyunits.K),
"parameter_data": {
"PR_kappa": {
("foo", "bar"): 0.000,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why "foo" and "bar"?

Copy link
Member Author

Choose a reason for hiding this comment

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

}
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def test_heater_w_inherent_rxns_comp_phase(self, frame):
rel=1e-5,
)

frame.fs.H101.outlet.mole_frac_comp.display()
andrewlee94 marked this conversation as resolved.
Show resolved Hide resolved
assert value(frame.fs.H101.outlet.mole_frac_comp[0, "a"]) == pytest.approx(
1 / 6, rel=1e-5
)
Expand Down
Loading
Loading