-
Notifications
You must be signed in to change notification settings - Fork 505
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
Units not consistent when differentiate returns zero #3258
Comments
Interesting. I've never even considered what happens to units when using @dallan-keylogic - can you provide a little more context about what you are trying to do? Where are these derivatives getting used? |
@michaelbynum , they're getting used as part of building up an expression for excess molar enthalpy in an activity coefficient model. Initially, I was using AD to build up the entire expression, but it generally builds expressions that are considerably larger than those I can generate by hand. Right now, I'm using it to get derivatives of other user-defined properties to avoid requiring the user to provide the derivative in addition to the property.
|
Could you use numeric differentiation instead of symbolic? Or you need symbolic? |
This is in the context of building up a big Pyomo expression, so it has to be symbolic. |
I think we could add some logic to the |
Oh, this is actually because of the way we initialize the derivative map here:
|
No, I think this is probably easier to handle inside of |
Somewhat tangential to this issue, I have another entry in the "zero should be treated as being equivalent with any set of units" file:
I have this expression as part of an eNRTL expression, and have just debugged an issue arising when There's a straightforward solution in this case, however: return zero with correct units if |
Summary
When trying to use Pyomo's AD to avoid having the user provide derivative expressions, I discovered that, if the resulting derivative is zero, its units get lost and result in dimensional inconsistencies.
It might make sense to treat zero as having units compatible with everything, but I don't know whether that's possible.
Is there a workaround where I can check if the expression returned by
differentiate
is zero and provide appropriate units manually?Steps to reproduce the issue
Error Message
Information on your system
Pyomo version: 6.7.2a0
Python version: 3.10.14
Operating system: Windows 10
How Pyomo was installed (PyPI, conda, source): IDAES advanced user installation
Solver (if applicable): n/a
The text was updated successfully, but these errors were encountered: