-
Notifications
You must be signed in to change notification settings - Fork 238
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
Generic property package: estimating bubble and dew temperatures #1555
Comments
@alma-walmsley Hitting the maximum iteration limit is not necessarily an issue as long as it gets "close enough" - the idea is that you just need to get close enough that the main solve can take over and get the final solution. Thus, the iteration limit was kept relatively low to avoid doing too much computation in the initialization sequence (in fact it was written on the basis that it might hit the maximum iterations regularly). As such, I think instead of raising the warning if the iteration limit is hit that it would be better to check that Tbub an Tdew make sense and raise a warning/exception if you get Tbub > Tdew with a suggestion to change the iteration limit. Bumping the iteration limit a bit might not be bad either. However, if option c) is reliable, then that sounds like a good way to go. On a side note however, I have some ideas for an alternative formulation that might manage to avoid some of these issues by removing the need for the explicit calculation of the bubble and dew points (using a pseudo bubble and dew point instead). |
Cool as, thank you for your comments. These make sense to me. A warning for Tbub > Tdew is a much better approach than just seeing if max iterations is reached. The question then is what to do going forward:
|
The new complementarity formulation is only applicable for systems that use a cubic EoS for both phases, so it has some limitations. Thus, we do need to keep the older version around (at least for now). As for solving the problem with IPOPT, if I recall the initialization is solved for ideal conditions so the problem should be fairly straight forward. |
Do you have any more information about the specific case in which this method fails? IPOPT is probably performing better because it's actually using a line search to determine how big a step is necessary instead of the extremely heuristic step limiter
The problem with IPOPT, though, is that calls to it are expensive (due to writing the .nl file), so we want to limit the number of times we call it. For example, one thing I do in a similar situation is concatenate constraints from an indexed Are you using units of Kelvin? |
@dallan-keylogic Here is an example: from pyomo.environ import ConcreteModel
from idaes.core import FlowsheetBlock
import idaes.models.properties.modular_properties.base.utility as utility
from property_packages.build_package import build_package
m = ConcreteModel()
m.fs = FlowsheetBlock(dynamic=False)
m.fs.properties = build_package("peng-robinson", ["benzene", "toluene"], ["Liq","Vap"])
m.fs.state = m.fs.properties.build_state_block([0], defined_state=True)
m.fs.state[0].flow_mol.fix(1)
m.fs.state[0].pressure.fix(500000)
m.fs.state[0].temperature.fix(300)
m.fs.state[0].mole_frac_comp["benzene"].fix(0.5)
m.fs.state[0].mole_frac_comp["toluene"].fix(0.5)
utility.MAX_ITER = 30 # default is 30
m.fs.state.initialize() It uses the Again, I am not sure if this is indicative of a modelling error, but I have had no issues since increasing |
Summary
I was having problems with the "Bubble, dew, and critical point initialization" step in the generic property package initialization. I ended up finding out that the initial guess for
temperature_bubble
was higher than that oftemperature_dew
, which I suspect was the key cause of infeasibility. I then had a look through theestimate_Tbub
andestimate_Tdew
methods inidaes.models.properties.modular_properties.base.utility
. These use Newton's method to converge on a guess fortemperature_bubble
andtemperature_dew
respectively. I eventually realized that I was hitting the iteration limit of 30, which meant I got a bad guess which would cause major issues.I was able to resolve this by increasing the iteration limit via
idaes.models.properties.modular_properties.base.utility.MAX_ITER = 1000
. This ended up giving me a much better guess since I was actually converging rather than stopping early. Note, I don't have much chemical engineering knowledge, so I am not sure if this is a sign of a modelling error.I decided to open this issue since it took me a while to debug.
Potential actions:
a) Log a warning:
MAX_ITER
is reached in theestimate_Tbub
andestimate_Tdew
methods.b) Increase default max iterations:
MAX_ITER
iterations will cause major issues, so increase the default number of max iterations. The argument against this is that a poorly-defined model (ie. one that never manages to converge) would take extra time to end up reaching the same result. Also, I can imagine ifMAX_ITER
were set to something like 100 instead of 30, I never would have realized there was an issue (and then we get "flaky" initialization when a more complex model is used, which is not fun). However, some combination of a) and b) may be useful.c) Switch to a solver instead of using Newton's method
ipopt
could solve in ~"3-5 iterations" compared to what was ~60 iterations when using Newton's method in python. I imagine it is more scalable too (for complex models).For example,
Feedback would be useful 🙂
The text was updated successfully, but these errors were encountered: