-
Notifications
You must be signed in to change notification settings - Fork 1
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 fixes #16
Conversation
Just a heads up @Mahaki-Leach @bertkdowns you can get some nasty infeasible solves if
|
…k` method in the platform
FPhx is still required, for pure components in the vapour phase region. If your state variable is "water at 100 degrees" you don't know what fraction of it is boiled. You need enthalpy to avoid this problem. I think it's worth the tradeoff of having one more variable and one more constraint, and yeah it's gonna be frustrating having to come up with bounds but we're gonna have to deal with it. Other than that, mostly sounds good! will talk through it more next week |
From what I have observed FPhx doesn't solve this problem.
Could be wrong, but we won't know unless we can get pure components to work. |
If the user constrains enthalpy to a value within the vapor-phase region, then the solver can't adjust temperature to get that enthalpy, since the same temperature value corresponds to many enthalpy values on that line. If we're in FPhx, don't we have the same problem? The solver still has to find a valid temperature for that enthalpy, since temperature is a variable. |
finding a valid temperature for that enthalpy is easy though, isn't it? there's only one correct temperature. It's when you're trying to find a valid enthalpy from a temperature that you get problems, as there's multiple valid enthalpies. I'll try make an idaes flowsheet with a single component in the phase region with ftpx and fphx and compare |
Ohhh, I see what the issue is here. It's impossible to have a defined model in the vapor-phase region using state variables T and P (can think of it as, "what value of the state variables corresponds to vapor_frac=0.5?", which is actually impossible in FTPx)
|
yeah you can create a state definition with T as an expression, but from my understanding of our conversations with Andrew, it's best not to. Having temperature as a variable allows the solver to "relax"/change it a little bit and might avoid the problems we had with smooth temperature. I'm pretty sure I remember andrew saying "temperature should always be a variable". And I'm pretty sure I remember him saying "Yay!" when we said we were gonna use fphx too 😄 |
I tend to disagree, more complexity is usually worse, and "allowing the solver to "relax"/change it a little bit" probably just means more unpredictability. That said, I have no idea how to make temperature an expression; it seems baked into the depths of the smooth VLE constraints... Edit: Generic property packages says that temperature needs to be a variable. So I don't think we're getting around this one... |
Generic property package fixes
Switch back to the
FTPx
state definitionFPhx
. See comments below.FPhx
is just an extension ofFTPx
by providingenth_mol
as a variable. It has the exact same variables and constraints when built, except for an extra variable and constraint inFPhx
. This meansFPhx
will not behave any better thanFTPx
.FPhx
doesn't have any special support for solving pure components Peng-Robinson failing to solve pure #9. The idaes docs seems to contradict this though, so might be worth double checking this actually the case. https://idaes-pse.readthedocs.io/en/latest/explanations/components/property_package/general/state/FPhx.html#applicationFPhx
, this increases the complexity of the model for no good reason (+1 variable and constraint). If we want to fixenth_mol
, adding a constraint for the expression inFTPx
has the same effect.FPhx
, We also have to worry about state bounds for enthalpy.T
andP
(recall:T
is still a variable in this state definition). But maybe this is not a bad thing? Since we want to be able to use temperature anyway.Increase
ITER_MAX
for estimatingtemperature_bubble
andtemperature_dew
Tbub
andTdew
. OurTbub
guess was higher than theTdew
guess!Fix solving with constraints instead of state variables
state_vars_fixed
kwarg in the generic property initialization routine toTrue
to indicate that all state variables are fixed, so it won't try to fix them, and instead just does a degrees-of-freedom check.pressure
(ie. usingenth_mol
/temperature
to definepressure
), so maybe this requires some more thought.fix_state_vars
method fromidaes.core.util.initialization
in the modular property package for handling constraints. Applied the same logic to the helmholtz property package and put the method inproperty_packages.utils
.Helmholtz initialization improvements
fix_state_vars
to get to 0 degrees of freedom, performs a solve, and releases state.super
initialize method (not needed)fix_state_block
method inadapter.py
actually causes a problem with compressor initialization, but it is actually an IDAES issue. I opened a PR for it here: Pressure changer initialization guesses IDAES/idaes-pse#1556. Just something to be aware of.constrain
andconstrain_component
methods in extended property packagesStateBlockConstraints
which both helmholtz and modular state blocks inherit fromconstrain
has the same functionality as before: fix var or create a constraint given a stringconstrain_component
allows passing in the direct var or expression to constrain.constrain_component
method is used in the updatedadapter.py
.constrain
andconstrain_component
methods. Returns either theVar
that was fixed, theConstraint
that was added, orNone
if no change.Smooth temperature (https://github.com/waikato-ahuora-smart-energy-systems/Ahuora-Adaptive-Digital-Twin-Platform/issues/969)
build
methodold_temperature
temperature
Bump version to
v0.0.10