-
Notifications
You must be signed in to change notification settings - Fork 35
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 notebook for scaling workshop #135
Conversation
@lbianchi-lbl @dangunter Could one of you double check to make sure I did all the things I need to to add a new example? |
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.
A couple of typos
Co-authored-by: agarciadiego <[email protected]>
"source": [ | ||
"These diagnostics can help give us an idea of what may be causing problems in our model. From the output above, we can see that the variables with large Jacobian norms (i.e., high sensitivities) are the outlet flow rate and temperature, as well as the rate-based extent of reaction. We can also see that the constraints with large Jacobian norms are the enthalpy balance and H20 material balance for the reactor. Understanding what this means however is often complicated and requires some thought.\n", | ||
"\n", | ||
"For example, one might wonder why the volumetric flow rate at the outlet of the reactor is so important as it is effectively determined by the inlet flow rate (due to the water balance effectively conserving volume). However, it is important to realize that from the point of view of the solver, the outlet flowrate is a free variable that can be manipulated, and that changing the volumetric flowrate at the outlet has a significant effect on the outlet concentrations (all other things kept constant). Thus as far as the solver is concerned, the outlet volumetric flowrate has a significant impact on the solution. This also explains why the H2O material balance is so important, as this is what governs the outlet flowrate. However, the material balances and concentrations of the other species in the system are what really matter, but this is not reflected in the model Jacobian. Once of the goals of scaling the model should be to balance these to ensure that the water balance does not come to dominate the other species.\n", |
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.
If you want to understand where those values are coming from, you need to use the method in the SVDToolbox
to print out Jacobian rows and columns. You'll quickly find that, for the volumetric flowrate, it has an enormous Jacobian value because it's being multiplied by the molar enthalpy (1e3 to 1e4 in J/mol) and the molar density (5.5e4 mol/m^3 for water) in the enthalpy balance constraint.
The volumetric flow rate being determined by the inlet flow rate is immaterial. Even if it is, changes in the volumetric flowrate to satisfy that constraint must be counteracted by other variables to make the residual small. And the volumetric flowrate does have a significant impact on the solution. The impact is just seen in variables like enthalpy, not the ones users typically look at.
I think it's worth mentioning that having a big value in the Jacobian does not mean a variable is "important". It's how sensitive the constraint residual is to that change in variable.
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.
Fixed.
" h_in += sum(\n", | ||
" self.get_expression_nominal_values(\n", | ||
" model.control_volume.properties_in[t].get_enthalpy_flow_terms(p)\n", | ||
" )\n", |
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.
Summing the absolute values here makes more sense than just summing everything in the Expression
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.
At any rate, this is probably something I change as soon as I get scaling hints working. I would much rather have a scaling factor for enthalpy flow terms determined by the property package than by some dodgy sum of whatever happens to be the present values.
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.
That one will depend on whether the property package uses an Expression
or not (most do but not all). Also, at this level that should work either way as we can only rely on having phase-bases terms.
Scaling Workshop Notebook
Requires IDAES/idaes-pse#1507 IDAES/idaes-pse#1454
This PR adds a new example notebook that covers how to create
Scalers
for IDAES models (we also have a recording of me presenting this to a small group at NETL (needs to be cleaned up yet)).Legal Acknowledgement
By contributing to this software project, I agree to the following terms and conditions for my contribution:
📚 Documentation preview 📚: https://idaes-examples--135.org.readthedocs.build/en/135/