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

Source sink flow asserts #132

Merged
merged 8 commits into from
Oct 6, 2023
Merged

Conversation

kentrutan
Copy link
Contributor

This adds to the Source and Sink components an assert on m_flow direction
similar to what is already in the PartialVolume components.

Some models in Examples such as SimpleStream and WaterHammer do
not have volumes so without this commit there is no check for invalid
mass flow direction when users modify the models. This also catches a
mass flow reversal in the EspressoMachine example that is larger than
the default threshold, so the threshold for that example has been
increased so there is no assert.

With this commit, some topologies may still have invalid flow direction
without an assert. To make a complete check, the SISOFlow or Inlet
and Outlet connectors need an assert, but that will lead to many more
assert messages. This commit is a compromise to catch most errors
with fewer messages.

Kent Rutan added 2 commits July 6, 2023 09:19
This adds to the Source and Sink components an assert on m_flow direction
similar to what is already in the PartialVolume components.

Some models in Examples such as SimpleStream and WaterHammer do
not have volumes so without this commit there is no check for invalid
mass flow direction if users modify the models.

With this commit, some topologies may still have invalid flow direction
without an assert. To make a complete check, the SISOFlow or Inlet
and Outlet connectors need an assert, but that will lead to many more
assert messages. This commit is a compromise to catch most errors
with fewer messages.
The new assertion for reversed mass flow in Boundaries.Source catches an
excursion larger than the default threshold in the ExpressoMachine
example. Making the threshold 3 times larger avoids the assertion.
@github-actions github-actions bot added the p::Boundaries Concerns package Boundaries and Undirected.Boundaries label Jul 6, 2023
Copy link
Contributor

@nieweber nieweber left a comment

Choose a reason for hiding this comment

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

In general it is a good idea to indicate flow reversal!
I would like to avoid putting negative values for m_flow_assert. Hence I proposed a reformulation of the assert condition.

@@ -13,6 +13,8 @@ the outlet the sink is connected to.
annotation(Dialog(enable = not pressureFromInput));
parameter Utilities.Units.Inertance L=dropOfCommons.L "Inertance of pressure"
annotation (Dialog(tab="Advanced"));
parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative massflows"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nieweber The existing PartialVolume has this:

  parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative massflows"

Per your suggestions, Source and Sink will be inconsistent. If we instead change PartialVolume, then it would not be backward compatible.

Please confirm that you want it to be inconsistent or let me know what you would like instead and I'll make the change per your suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yes thank you, you are completely right. Sorry, I didn't cross-check with the assert in the PartialVolume. The components should indeed be consistent so we will discuss, if we want to include it in the next minor release (1.1.0) and keep the negative sign or if we shift this change to the next major release and adjust the PartialVolume assert.
I will let you know what we would like to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I think the best way is to add the assert to the source and sink models as it is implemented in the PartialVolume. We might change the sign of the m_flow_assert parameter in the next major release. I just did some small corrections on the spelling that I will also introduce in the assert in the PartialVolume component.

Thanks a lot for your contribution!

@@ -13,6 +13,8 @@ the outlet the sink is connected to.
annotation(Dialog(enable = not pressureFromInput));
parameter Utilities.Units.Inertance L=dropOfCommons.L "Inertance of pressure"
annotation (Dialog(tab="Advanced"));
parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative massflows"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nieweber The existing PartialVolume has this:

  parameter SI.MassFlowRate m_flow_assert(max=0) = -dropOfCommons.m_flow_reg "Assertion threshold for negative massflows"

Per your suggestions, Source and Sink will be inconsistent. If we instead change PartialVolume, then it would not be backward compatible.

Please confirm that you want it to be inconsistent or let me know what you would like instead and I'll make the change per your suggestions.

ThermofluidStream/Boundaries/Sink.mo Outdated Show resolved Hide resolved
ThermofluidStream/Boundaries/Source.mo Outdated Show resolved Hide resolved
ThermofluidStream/Boundaries/Sink.mo Outdated Show resolved Hide resolved
Copy link
Contributor

@tobolar tobolar left a comment

Choose a reason for hiding this comment

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

I have added two minor changes in the parameter description. After committing, I'm fine with the changes.

ThermofluidStream/Boundaries/Sink.mo Outdated Show resolved Hide resolved
ThermofluidStream/Boundaries/Source.mo Outdated Show resolved Hide resolved
nieweber and others added 2 commits October 6, 2023 09:17
@nieweber nieweber merged commit 887937c into DLR-SR:main Oct 6, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p::Boundaries Concerns package Boundaries and Undirected.Boundaries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants