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

Complementarity-based VLE formulation #977

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
def94f9
Introducing subcritical ncp formulation for flash
viiibhav Oct 3, 2022
e062d40
Deleting simulation file
viiibhav Oct 3, 2022
4118fe3
Amended original property package scripts and deleted _ncp scripts
viiibhav Oct 11, 2022
75c6226
Adding black-formatted test script
viiibhav Oct 11, 2022
0cbdb7a
Changed metre to meter
viiibhav Oct 19, 2022
3aba1eb
Modified the call to critical properties and Cubic import is removed
viiibhav Oct 19, 2022
1742351
Changed call to supercritical_extension instead of just supercritical
viiibhav Oct 19, 2022
54aa61e
Changed tbar to _tbar, tbar_constraint to _tbar_constraint
viiibhav Oct 19, 2022
5aa473a
Moved initialization of cubic properties (partially) to ceos. Used re…
viiibhav Oct 26, 2022
2fa5910
Cleaned initialization, integrated _pbar, modified state and phase eq…
viiibhav Oct 26, 2022
c937653
Added terse syntax to create vars
viiibhav Oct 26, 2022
c8f7f04
fixed typo fix --> unfix
viiibhav Oct 27, 2022
f6cfd85
Minor changes to test alternative bubble-dew construction
viiibhav Oct 30, 2022
aab4cf0
Changes associated with having bubble and dew temperatures as Python …
viiibhav Dec 1, 2022
b62e1c2
Renamed to _pp and _pn to avoid name collision with phase_pair
viiibhav Dec 1, 2022
e655798
Fixed units of _pp and _pn
viiibhav Dec 1, 2022
5b8ba80
Removed hardcoded phase names
viiibhav Dec 2, 2022
b0f7bf1
Added supercritical extension toggle option
viiibhav Dec 13, 2022
8deffc2
Added volume_crit and compress_factor_crit to Component
viiibhav Dec 15, 2022
ff5d334
Fixed merge conflicts
viiibhav Dec 16, 2022
862fd25
Added VOLUME_MOL and VOLUME_MASS properties
viiibhav Dec 16, 2022
3d61782
Black formatted scripts
viiibhav Dec 16, 2022
d32dba4
Updated test script
viiibhav Dec 16, 2022
247fd57
Minor structural change of critical properties initialization
viiibhav Dec 20, 2022
05d5f76
Fixed import error
viiibhav Dec 20, 2022
c27503c
Black formatted again
viiibhav Dec 20, 2022
0936bbe
Workaround for defining cubic_second_derivative
viiibhav Jan 26, 2023
dc6b1a3
Minor changes
viiibhav Jan 26, 2023
397d83d
Merge branch 'main' into flash-pr
andrewlee94 Feb 7, 2023
8ce8893
Standardized names: temperature_crit_mix --> temperature_crit; same f…
viiibhav Feb 11, 2023
fd94de5
Modifications to account for bubble-dew construction changes
viiibhav Feb 14, 2023
d0b7dfc
Replaced _teq with _tbar
viiibhav Feb 14, 2023
c28d75b
Modified bubble-dew construction
viiibhav Feb 14, 2023
1cbb139
Cubic roots involved only with ceos
viiibhav Feb 14, 2023
540e9a6
Run black
viiibhav Feb 14, 2023
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
2 changes: 2 additions & 0 deletions idaes/core/base/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ def build(self):
"omega": pyunits.dimensionless,
"pressure_crit": base_units.PRESSURE,
"temperature_crit": base_units.TEMPERATURE,
"volume_crit": base_units.VOLUME_MOL,
"compress_factor_crit": pyunits.dimensionless,
}
for p, u in var_dict.items():
if p in self.config.parameter_data:
Expand Down
8 changes: 8 additions & 0 deletions idaes/core/base/property_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,14 @@ def MOLALITY(self):
def MOLECULAR_WEIGHT(self):
return self._mass / self._amount

@property
def VOLUME_MOL(self):
return self._length**3 / self._amount

@property
def VOLUME_MASS(self):
return self._length**3 / self._mass

# Energy
@property
def ENERGY(self):
Expand Down
2 changes: 2 additions & 0 deletions idaes/core/base/tests/test_property_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ def test_luminous_intensity(unit_set):
"density_mass": (units.kg * units.m**-3),
"density_mole": (units.mol * units.m**-3),
"molecular_weight": (units.kg / units.mol),
"volume_mol": (units.m**3 / units.mol),
"volume_mass": (units.m**3 / units.kg),
"energy": (units.kg * units.m**2 * units.s**-2),
"energy_mass": (units.m**2 * units.s**-2),
"energy_mole": (units.kg * units.m**2 * units.s**-2 * units.mol**-1),
Expand Down
31 changes: 27 additions & 4 deletions idaes/core/util/phase_equilibria.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
)
import idaes.logger as idaeslog
from idaes.core.solvers import get_solver
from idaes.core.util.exceptions import PropertyNotSupportedError

import idaes.logger as idaeslog

Expand Down Expand Up @@ -134,6 +135,26 @@ def Txy_data(

model.props = model.params.build_state_block([1], defined_state=True)

# Check tbub etc
property_exists = False
try:
if hasattr(model.props[1], "temperature_bubble"):
property_exists = True
except PropertyNotSupportedError:
pass

try:
if hasattr(model.props[1], "temperature_dew"):
property_exists = True
except PropertyNotSupportedError:
pass

if not property_exists:
raise PropertyNotSupportedError(
"Txy_data require property package to support bubble and/or "
"dew point calculations."
)

# Set intial concentration of component 1 close to 1
x = 0.99

Expand Down Expand Up @@ -169,12 +190,14 @@ def Txy_data(
Punit = pyunits.get_units(model.props[1].pressure)
Tunit = pyunits.get_units(model.props[1].temperature)

# import pdb; pdb.set_trace()
count = 1
# Create and run loop to calculate temperatures at every composition
for i in range(len(x_d)):
model.props[1].mole_frac_comp[component_1].fix(x_d[i])
model.props[1].mole_frac_comp[component_2].fix(1 - x_d[i] - xs)
# solve the model
model.display()
status = solver.solve(model, tee=False)
# If solution is optimal store the concentration, and calculated temperatures in the created arrays
if check_optimal_termination(status):
Expand All @@ -183,17 +206,17 @@ def Txy_data(
"Case: ", count, " Optimal. ", component_1, "x = {:.2f}".format(x_d[i])
)

if hasattr(model.props[1], "_mole_frac_tdew") and hasattr(
model.props[1], "_mole_frac_tbub"
if hasattr(model.props[1], "temperature_dew") and hasattr(
model.props[1], "temperature_bubble"
):
Tbubb.append(value(model.props[1].temperature_bubble["Vap", "Liq"]))
Tdew.append(value(model.props[1].temperature_dew["Vap", "Liq"]))

elif hasattr(model.props[1], "_mole_frac_tdew"):
elif hasattr(model.props[1], "temperature_dew"):
print("One of the components only exists in vapor phase.")
Tdew.append(value(model.props[1].temperature_dew["Vap", "Liq"]))

elif hasattr(model.props[1], "_mole_frac_tbub"):
elif hasattr(model.props[1], "temperature_bubble"):
print("One of the components only exists in liquid phase.")
Tbubb.append(value(model.props[1].temperature_bubble["Vap", "Liq"]))

Expand Down
Loading