-
-
Notifications
You must be signed in to change notification settings - Fork 277
HOTFIX: Tanks Overfill not Being Detected #479
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
Changes from 2 commits
88a2991
09260e4
9f69c74
d1a5dd5
21e9f58
6894dd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1292,7 +1292,20 @@ def fluid_volume(self): | |
| Function | ||
| Volume of the fluid as a function of time. | ||
| """ | ||
| return self.liquid_volume + self.gas_volume | ||
| fluid_volume = self.liquid_volume + self.gas_volume | ||
|
|
||
| # Check if within bounds | ||
| diff = fluid_volume - self.geometry.total_volume | ||
|
|
||
| if (diff > 1e-6).any(): | ||
| raise ValueError( | ||
| "The `fluid_volume`, defined as the sum of `gas_volume` and " | ||
| + "`liquid_volume`, is not equal to the total volume of the tank." | ||
| + "\n\t\tThe difference is more than 1e-6 m^3 at " | ||
| + f"{diff.x_array[np.argmin(diff.y_array)]} s." | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this error message could be improved a bit This is a MassBasedTank, meaning the user will have given mass curves to the tank. If this error pops up warning about volume issues, the user might get confused and the correction to this error will not be clear. I would suggest telling the user that the masses, the densities or the tank geometry might be wrong |
||
| ) | ||
|
|
||
| return fluid_volume | ||
|
|
||
| @funcify_method("Time (s)", "Volume (m³)") | ||
| def gas_volume(self): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Just checking: we need to guarantee, for now, that
fluid_volumedoes not exceedself.geometry.total_volume, but we don't really care yet iffluid_volumeis much less thenself.geometry.total_volume?If this is the case, shouldn't we use
np.argmaxinstead ofnp.argmin?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.
I do think you are right regarding
np.argmax, but, just to make sure we are on the same page, this would need to be changed in all error messages of this class, right?Uh oh!
There was an error while loading. Please reload this page.
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.
Actually, I correct myself: the computation should be
np.argminsince we are looking for the smallest of the differences between the fluid volume and the tank volume to determine exactly where it overfilled.Uh oh!
There was an error while loading. Please reload this page.
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.
@phmbressan with
np.argmin, don't you have the risk of getting a negative value, in which case the tank is underfilled?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.
The check here is made following these assumptions:
diffpointed out that theTankis, at some time, overfilled;Perhaps I should mention that the time is approximate or, likely a better solution, use
Function.find_input. I favored the implemented way due the fact this is a hotfix and thenp.argminwas already being used in the other exceptions of this class.Let me know if I made it clearer now or if there is any mistake in my reasoning.