-
Notifications
You must be signed in to change notification settings - Fork 169
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
ReferenceMoistAir, substances mass conservation issue #3666
Comments
Hello, After investigations, the problem seem to be solvable implementing the followings: 1/ Correction of the derivative within
becomes
2/ Reformulating of Globally, the whole media code might be subject to improvements and simplifications. |
I will check as soon as possible and revert back. Many thanks for the work. |
Sorry, I made two changes for issues in my master. Is someone else able to put pd_der := xw_der*Modelica.Media.Air.ReferenceMoistAir.k_mair/
(Modelica.Media.Air.ReferenceMoistAir.k_mair + xw)^2*p
+ xw/(Modelica.Media.Air.ReferenceMoistAir.k_mair + xw)*p_der; in function pd_pTX_der since the other PR is pending and I do not won't to roll back changes? Many thanks. |
Done. See #3834. |
Many thanks! |
Here is a test model for this function: model pd_der_test
replaceable package Medium = Modelica.Media.Air.ReferenceMoistAir;
Real der_T = 300;
Real T = 73.15 + der_T * time;
Real der_p = -1e5;
Real p = 1e7 + der_p * time;
Real[Medium.nS] X = Medium.reference_X;
Real var_from_function = Medium.Utilities.pd_pTX(p, T, X);
Real timederiv = Medium.Utilities.pd_pTX_der(p, T, X, der_p, der_T, {0,0});
Real var_from_timederiv;
Real error_abs = var_from_function - var_from_timederiv;
Real error_rel = abs(error_abs / var_from_function);
initial equation
var_from_timederiv = var_from_function;
equation
// var_from_timederiv = integral(timederiv);
// but integral() operator does not exist
// formulate it the other way round
der(var_from_timederiv) = timederiv;
annotation (experiment(StopTime=100));
end pd_der_test; |
Thanks. If you like you can add it to the corresponding PR #3834. |
Edit: I do not see how #3834 fixes the two error variables of test model pd_der_test. |
To me, the proposed derivative looks wrong. If the function is: |
That is also correct, i.e. for Still, my previous concern holds:
|
I believe there's a better solution will comment in #3834 |
Hello,
I would like to report an issue with the Modelica.Media.Air.ReferenceMoistAir media.
From unexpected simulation results, I implemented the following simple model (cf. enclosed model): a constant mass flow source (Modelica.Fluid.Sources.MassFlowSource_T) with X = {0, 1} connected to a constant volume tank (Modelica.Fluid.Vessels.ClosedVolume) with X = {0.5, 0.5} @ t = 0. The tank water mass is expected to remain the same and the total mass was expected to increase linearly. Instead, the tank water mass increased and the total fluid mass increasing beyond expectation and beyond the water mass increase.
XBalance.zip
The issue has been observed with Dymola 2020 using Modelica Standard Library - Version 3.2.3 and confirmed using Modelica Standard Library - Version 4.0.0. As a comparison, using Modelica.Media.IdealGases.MixtureGases.AirSteam, the observed error is more likely due to computing small error propagation.
Quick investigations pointed to ReferenceMoistAir density and derivated functions.
Please let me know if problem if the problem has already been reported and if solution has been developed.
Thank you !
The text was updated successfully, but these errors were encountered: