Skip to content
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

Avoid the tank to ever become completely empty - fixes #4526 #4527

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

casella
Copy link
Contributor

@casella casella commented Feb 9, 2025

This fixes #4526 by:

  • adding an assert that prevents the tank to ever become completely empty, a condition in which the energy balance equation becomes singular
  • putting the height of the bottom port 1 mm above the bottom of the tank, to avoid it getting completely empty
  • initializing the tank level at 1 mm, not 0, which is singular and no longer allowed.

With the following prescribed incoming flow (which is unchanged w.r.t. MSL 4.0.0)
immagine
OMC can now simulate the system successfully and produces the following transient for the level
immagine

As expected, the tank starts near empty at 1 mm level and the check-valve behaviour on the bottom port prevents the fluid from going down the drain. When providing 40 kg/s of incoming flow rate ,which is more than the out-going pipe can drain, the level goes up; however, when that flow rate is reduced to 10 kg/s, the level goes down, until it settles to a value very close to the level of the outlet port, which swallows the incoming flow while keeping the level constant. When the flow rate is reduced to zero, the level settles down to 1 mm, i.e., the port level. And so on and so forth...

As expected, since the tank fluid is initialized at ambient temperature and the fed fluid is also at ambient temperature, the fluid temperature is always well defined and always equal to ambient temperature, i.e., 20 degC
immagine

Copy link
Collaborator

@arunkumar-narasimhan arunkumar-narasimhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

As discussed at the meeting
@@ -307,7 +307,7 @@ of the modeller. Increase nPorts to add an additional port.
end for;
// Check for correct solution
assert(fluidLevel <= fluidLevel_max, "Vessel is overflowing (fluidLevel > fluidLevel_max = " + String(fluidLevel) + ")");
assert(fluidLevel > -1e-6*fluidLevel_max, "Fluid level (= " + String(fluidLevel) + ") is below zero meaning that the solution failed.");
assert(fluidLevel > 0, "Fluid level (= " + String(fluidLevel) + ") is too small, the tank cannot be completely empty otherwise the energy balance equation becomes singular.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert(fluidLevel > 0, "Fluid level (= " + String(fluidLevel) + ") is too small, the tank cannot be completely empty otherwise the energy balance equation becomes singular.");
assert(fluidLevel > 0, "Fluid level is too small, the tank cannot be completely empty otherwise the energy balance equation becomes singular.");

Might be advisable to remove the value directly here (and in the assert message above) to follow #4399 (see also #4519).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problems with ModelicaTest.Fluid.TestComponents.Vessels.TestSimpleTank
4 participants