-
Notifications
You must be signed in to change notification settings - Fork 235
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
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 ed3734a
Some pylint issues and tests for new cubic EoS functions
andrewlee94 851cc3b
Fixing broken tests
andrewlee94 251b7f7
Fixing more tests
andrewlee94 7997adf
Tests for identify_VL_component_list
andrewlee94 83539aa
Testing estimation of bubble and dew points
andrewlee94 59e22dd
First unit testing of SmoothVLE2
andrewlee94 d76b17d
First running version of code
andrewlee94 3555f58
Running example
andrewlee94 78d4372
Starting clean up and transition
andrewlee94 cf5d515
Merge branch 'main' of https://github.com/IDAES/idaes-pse into smooth…
andrewlee94 daf0502
Working on Tsweep test failure
andrewlee94 eb72019
Merging main
andrewlee94 7ddc023
Trying to debug Tsweep
andrewlee94 81d9d26
Catch for non-cubics with SmoothVLE2
andrewlee94 f4eb379
Fixing typo
andrewlee94 0f0bd72
Merging main
andrewlee94 860ad56
Tweaking eps values
andrewlee94 92394ee
Fixing T sweep test
andrewlee94 65087b6
Fixing some tests
andrewlee94 39f1180
Merging main branch
andrewlee94 f2b9813
Fixing some pylint issues
andrewlee94 47c29bb
Typo
andrewlee94 8e424cf
More pylinting
andrewlee94 31fba13
More pylint
andrewlee94 b27706a
Clean up debugging code
andrewlee94 8771323
Fixing final test
andrewlee94 8dd941b
Some clean up
andrewlee94 55a5074
Merging main branch
andrewlee94 f43e3e0
Using logspace
andrewlee94 7a0375b
Adding initial docs
andrewlee94 b563460
Documenting epsilons
andrewlee94 c0a9e18
Fixing test
andrewlee94 9d35277
Adjusting default value of epsilon
andrewlee94 a98597c
Fixing typo
andrewlee94 ad0da43
Merge branch 'main' into smooth_vle2
andrewlee94 8b951b8
Fixing pint version issue
andrewlee94 cbaf0aa
Addressing comments
andrewlee94 0a1c28c
Merge branch 'main' into smooth_vle2
andrewlee94 c2a593d
Fixing broken link in docs
andrewlee94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 5 additions & 2 deletions
7
docs/explanations/components/property_package/general/pe/smooth_flash.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
docs/explanations/components/property_package/general/pe/smooth_vle2.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.