ibpsa / modelica-ibpsa

Modelica library for building and district energy systems developed within IBPSA Project 1
https://ibpsa.github.io/project1
145 stars 84 forks source link

assert for flow reversal #963

Closed Mathadon closed 6 years ago

Mathadon commented 6 years ago

Many models define allowFlowReversal but do not check whether the flow does not revert. This can lead to model errors. In some cases I would like to check this explicitly. Therefore I propose to add an assertion check that is disabled by default in models such as PartialTwoPort and PartialThreeWayResistance. Are there objections against this?

mwetter commented 6 years ago

Isn't it sufficient to set the following: image This gives for example in Examples.PressureDrop:

dymosim started
... "dsin.txt" loading (dymosim input file)
Error: The following error was detected at time: 0
  Value is: 0.2
  Failed condition: sou.ports[1].m_flow <= 0.0

The stack of functions is:
Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(res.dp, 0.06324555320336758, 0.06)
Error: Integrator failed to start model.
Mathadon commented 6 years ago

That's indeed an option, which I forgot about, but this checks all min/max attributes while there may be only a few in which we're interested. Also, the allowed error has to be the same for all min/max checks, while allowFlowReversal allows to define m_flow_small, which is model-specific. Since min/max checks may operate on variables that have different orders of magnitude, it could be hard to find a convenient 'allowed error'. Furthermore, this feature is dymola-specific and it looks like you can't store the enabled flag 'all variables' in the model such that this option is always enabled when running a specific model.

mwetter commented 6 years ago

I see, this is fine then. I wonder however if you really want every pipe, sensor etc that extends from PartialTwoPort to have this test. Wouldn't it suffice in view of how you use the model to have it at the fans/pumps, and maybe at PartialThreeWayResistance?

Mathadon commented 6 years ago

Indeed, let's start with pumps and PartialThreeWayResistance :)