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
Energy not conserved in non-linear systems containing Annex60.Fluid.Interfaces.StaticTwoPortConservationEquation #282
Comments
…ound zero flow this is for issue ibpsa#282
See https://github.com/Mathadon/modelica-annex60/tree/issue282_singularMixVol for an example |
Setting |
If m_flow is that small to be inside the region where this regularization happens, then no heat should be exchanged anyway as any small perturbation would yield to very large outlet temperatures in such steady-state models. All we attempt to do is to get robustly through the zero flow region. If you want to exchange heat at or near zero mass flow rate, you will need a dynamic model which then won't use this equation. The parameter |
I agree that no heat should be exchanged when I think I found a solution. I'll try to explain. In any model Case 1:
|
An important note for debugging this: Dymola does not always generate errors when divisions by zero occur, this seems to be the case when the division is 'consistent', i.e. equation (1) can be evaluated as |
An additional advantage of this approach is that more systems will be linear and that they can therefore be solved more easily. |
around zero flow updated documentation this is for ibpsa#282
The pull request contains an example model ( I did not implement |
Case 1 is OK. For Case 2, I suggest to go with option 2, e.g., use
Please also write in the code and the info section that this relies on
Also, at the above statement, a remark should be made to avoid that someone removes the For Case 3, I think we should stay with the current formulation that uses Using
I also don't understand the title for Case 3: You wrote "vol.heatPort.T and vol.heatPort.Q_flow need to be computed...". But in fact, only Do you agree with Case 3? |
Case 1: Ok Note that keeping I'm not sure what you mean but
It's important that the current (updated) implementation of the residual equation is used since this guarantees that Using the old implementation with
where Regarding the paper: you there assume that So I'd like to stick with the proposed implementation. Note that the examples show that it works. Regarding the enumeration. I would stick with a parameter since case 2 and case 3 have identical code and therefore only 2 different cases need to exist. Moreover case 1 is pretty easy to identify and quite rare whereas the other cases are not and this could confuse the user. I do propose to rename |
Note that the above problem was only introduced recently when we started using |
I see why you get the wrong results in Case 3. So let's use your proposed formulation for Case 3, e.g.,
Renaming Please also update the info section in The proper explanation is "prescribedHeatFlow should be |
Fixed. I also updated and documented |
@Mathadon I revised the comments and refactored I also set a All unit tests are fine on the
I also updated These are on the branch |
That's interesting. I'll have a look at it! |
I cannot reproduce these results using branch Can you verify their result when doing a manual translation? |
@Mathadon : The large tests in the Buildings library work fine. I also verified the above statistics for @Mathadon This is ready to merge from my point of view after these issues are fixed:
|
@Mathadon : Can you please check why A related problem is that after merging this branch into https://github.com/lbl-srg/modelica-buildings/tree/issue428_fmu_stat, the model In version 2.1.0 of the Buildings library, this model worked. Revision: |
The model Fluid/Interfaces/Examples/StaticTwoPortConservationEquation.mo does not translate
@Mathadon : I think we should look at setting Using
While the results are correct (because the volumes are steady-state and hence the temperature is not defined if |
Changed parameter to constant as we can assume that users won't need to change this, and hence should not be shown the complexity of having this parameter when they instanciate a volume. Update documentation. Removed non-required assignments
I agree that we should set I'm not sure if it should be a |
@Mathadon If you agree with the current implementation, I (or you) can merge I merged this already to the master of the |
That's good news :) I'll do the merge! |
This is closed by #289 |
@firasomran I cannot see the file that you attached. |
See here (http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.571.9335&rep=rep1&type=pdf) for more information about tearing / torn equations. Instead of looking at the dsmodel.mof, you can also just look at the model equations of course :) But most equations should be in the dsmodel.mof |
In the Modelica text view of the individual models. E.g. |
An example based on your file:
This is nonlinear system number 2 with 1 iteration variable and 3+1 equations. So in the Dymola statistics this would be listed as a non-linear system of equations with size 4 before reduction and size 1 after reduction. The torn equations are the equations that could be solved for the variable in the left hand side of the equation. These variables can be evaluated using the iteration variable(s) and 'inputs' to the algebraic loop only. I.e. no other variable values of the algebraic loop are required. So the model equations are all four equations (3 torn and 1 residual equation) that are listed in the above excerpt. |
@firasomran |
I think they should be included in the translation statistics, but they simply don't have a number in dsmodel.mof? |
When a
MixingVolume
is configured to steady state (i.e.Annex60.Fluid.Interfaces.StaticTwoPortConservationEquation
is used) energy is in some cases not conserved at zero flow. The problem arises when the following equation is used in a non-linear system:A resulting non-linear algebraic loop may look like:
In the last equation
vol.steBal.m_flowInv
is zero around zero flow. This meansQ_flow
can take any value in the last equation and the equation will still be satisfied.An example:
results in:
ie
Q_flow
is not 0 when time > 1s. Note that this problem exists regardless of ifprescribedHeatFlow
is used.Note that this is the same problem as #280 , and this problem can again be solved by setting
use_safeDivision=false
. The only difference is that the singularity of this equation does not lead to a division by zero since the equation is used in a non-linear loop, where less symbolic manipulations are performed. The implication is however that the singularity is not detected and that this leads to non-physical results.I think we'll need to think of an approach for handling this properly, or provide good parameters to the user, like suggested in #280 .
The text was updated successfully, but these errors were encountered: