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

.. contents:: Contents
:depth: 2

.. note::
For property packages using cubic Equations of State, there is an alternative :ref:`CubicComplementarityVLE <explanations/components/property_package/general/pe/smooth_vle2:Cubic Smooth Vapor-Liquid Equilibrium Formulation (CubicComplementarityVLE)>` class that may give better performance.

Source
------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Cubic Smooth Vapor-Liquid Equilibrium Formulation (CubicComplementarityVLE)
===========================================================================

.. contents:: Contents
:depth: 2

.. note::
This formulation for vapor-liquid equilibrium is only valid if using a cubic Equation of State. For other equations of state, use :ref:`SmoothVLE <explanations/components/property_package/general/pe/smooth_flash:Smooth Vapor-Liquid Equilibrium Formulation (SmoothVLE)>`.

Source
------

Dabadghao, V., Ghouse, J., Eslick, J., Lee, A., Burgard, A., Miller, D., and Biegler, L., A Complementarity-based Vapor-Liquid Equilibrium Formulation for Equation-Oriented Simulation and Optimization, AIChE Journal, 2023, Volume 69(4), e18029. https://doi.org/10.1002/aic.18029

Introduction
------------

Often, a user may not know whether a state corresponds to a liquid, gas, or coexisting mixture. Even if a user knows the phase composition of a problem's initial condition, optimization may push the stream into or out of the two-phase region. Therefore, it is necessary to formulate phase equilibrium equations that are well-behaved for both one-phase and two-phase streams.

To address this, the cubic smooth vapor-liquid equilibrium (VLE) formulation always solves the equilibrium equations at a condition where a valid two-phase solution exists. In situations where only a single phase is present, the phase equilibrium is solved at the either the bubble or dew point, where the second phase is just beginning to form; in this way, a non-trivial solution is guaranteed. Rather than explicitly calculate the bubble and dew points (as is done in the :ref:`non-cubic formulation <explanations/components/property_package/general/pe/smooth_flash:Smooth Vapor-Liquid Equilibrium Formulation (SmoothVLE)>`), this formulation leverages properties of the cubic equation of state to identify the "equilibrium temperature".

Formulation
-----------

.. note::
For the full derivation of the cubic smooth VLE formulation, see the reference above.

.. note::
For consistency of naming between the cubic and non-cubic formulations, :math:`\bar{T}` is referred to as :math:`T_{eq}` in this document and the resulting model.

The approach used by the smooth VLE formulation is to define an "equilibrium temperature" (:math:`T_{eq}`) at which the equilibrium calculations will be performed. The equilibrium temperature is defined such that:

.. math:: T = T_{eq} - s_{vap} + s_{liq}

where :math:`T` is the actual state temperature, and :math:`s_{liq}` and :math:`s_{vap}` are non-negative slack variables. For systems existing the the liquid-only region, :math:`s_{liq}` will be non-zero whilst :math:`s_{vap}=0` (indicating that the system is below the bubble point and thus :math:`T_{eq}>T`). Similarly, for systems in the vapor-only region, :math:`s_{vap}` will be non-zero whilst :math:`s_{liq}=0`. Finally, in the two-phase region, :math:`s_{liq}=s_{vap}=0`, indicating that :math:`T_{eq}=T`.

In order to determine the values of :math:`s_{liq}` and :math:`s_{vap}`, the following complementarity constraints are written:

.. math:: 0 = \min(s_{liq}, F_{liq})
.. math:: 0 = \min(s_{vap}, F_{vap})

where :math:`F_{p}` is the flow rate of each phase :math:`p`. That is, for each phase (liquid and vapor), if there is any flowrate associated with that phase (i.e., the phase exists), its slack variable must be equal to zero.

Additionally, the follow complementarities are written to constraint the roots of the cubic equation of state.

.. math:: 0 = \min(g^{+}_{liq}, F_{liq})
.. math:: 0 = \min(g^{-}_{vap}, F_{vap})

where :math:`g^{+}_p` and :math:`g^{-}_p` are another pair of non-negative slack variables associated with each phase :math:`p`. These slack variables are defined such that:

.. math:: f''(Z_p) = g^{+}_{p} - g^{-}_{p}

where :math:`f''(Z_p)` is the second derivative of the cubic equation of state written in terms of the compressibility factor :math:`Z_p` for each phase :math:`p`.

Smooth Approximation
''''''''''''''''''''

In order to express the minimum operators in a tractable form, these equations are reformulated using the IDAES `smooth_min` function:

.. math:: \min(a, b) = 0.5{\left[a + b - \sqrt{(a-b)^2 + \epsilon^2}\right]}

Each complementarity requires a smoothing parameter, named :math:`\epsilon_T` and :math:`\epsilon_Z` for the temperature and cubic root constraints respectively. Within the IDAES model, these are rendered as ``eps_t_phase1_phase2`` and ``eps_z_phase1_phase2``, where ``phase1`` and ``phase2`` are the names assigned to the liquid and vapor phases in the property package (order will depend on the order these are declared).

The tractability of the VLE problem depends heavily upon the values chosen for :math:`\epsilon_T` and :math:`\epsilon_Z`, with larger values resulting in smoother transitions at the phase boundaries (and thus increased tractability) at the expense of decreased accuracy near these points. It is recommended that users employ a 2-stage approach to solving these problems, starting with a larger value of :math:`\epsilon_T` and :math:`\epsilon_Z` initially to determine which region the solution lies in, followed by a second solve using smaller values to refine the solution.
Copy link
Contributor

Choose a reason for hiding this comment

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

"It is recommended that users employ a 2-stage approach to solving these problems, starting with a larger value of :math:\epsilon_T and :math:\epsilon_Z initially to determine which region the solution lies in, followed by a second solve using smaller values to refine the solution."

How is this going to translate to a typical user of IDAES? Are the smoothing parameters global or stuck on state blocks? How can the user find them?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are local, as they potentially need to vary unit-to-unit. Their names are show in the docs.


As a rule of thumb, the values of :math:`\epsilon_T` and :math:`\epsilon_Z` should be between 2 and 4 orders of magnitude smaller than the largest quantify involved in the smooth maximum operation. This means the value of :math:`\epsilon_T` should be based on the larger of :math:`T` and :math:`F_p`, whilst :math:`\epsilon_Z` should be based on the larger of :math:`f''(Z_p)` and :math:`F_p`. The value of :math:`f''(Z_p)` may be difficult to determine *a priori*, however :math:`F_p` is likely to dominate in most cases unless :math:`F_p` is small or :math:`P` is large.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Phase Equilibrium State Libraries
:maxdepth: 1

pe/smooth_flash
pe/smooth_vle2

Necessary Properties
--------------------
Expand Down
Loading
Loading