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

pressure state for incompressible media #225

Closed
Mathadon opened this issue Apr 24, 2015 · 4 comments · Fixed by #245
Closed

pressure state for incompressible media #225

Mathadon opened this issue Apr 24, 2015 · 4 comments · Fixed by #245

Comments

@Mathadon
Copy link
Member

When using incompressible media derivatives of pressures are generated when massDynamics not = steadyState because of the stateSelect.prefer declaration. This causes additional derivatives to be computed since there is no real state for the pressure when the medium is incompressible.

I will do some tests to check if it's best to remove the stateSelect.prefer or to set it to the mixing volume mass. We should also run unit tests and performance benchmarks to assess the impact.

@mwetter
Copy link
Contributor

mwetter commented May 7, 2015

@Mathadon : I looked into that as on branch issue_313 of the Buildings library, the command

translateModel("Buildings.Fluid.FMI.Examples.FMUs.MixingVolume");

fails with

The model requires derivatives of some inputs as listed below:
1 inlet.p

Can you point to a test case where you see these additional derivatives? Simply setting

  redeclare replaceable model extends BaseProperties(
    Xi(each stateSelect=if preferredMediumStates then StateSelect.prefer else StateSelect.default),
    final standardOrderComponents=true) "Base properties"

in Media.Air is not sufficient to make the translation succeed. Without having a test case, I don't quite understand your issue above.

@Mathadon
Copy link
Member Author

Mathadon commented May 8, 2015

If you enable Output information when differentiating for index reduction you get:

Differentiated the equation
vol.dynBal.medium.p = inlet.p;

giving
der(vol.dynBal.medium.p) = der(inlet.p);

Differentiated the equation
0.8333333333333334*vol.dynBal.m = vol.dynBal.medium.p/101325;

giving
0.8333333333333334*der(vol.dynBal.m) = 9.869232667160129E-06*der(vol.dynBal.medium.p);

Differentiated the equation
vol.dynBal.medium.p = inlet.p;

giving
der(vol.dynBal.medium.p) = der(inlet.p);

Differentiated the equation
0.8333333333333334*vol.dynBal.m = vol.dynBal.medium.p/101325;

giving
0.8333333333333334*der(vol.dynBal.m) = 9.869232667160129E-06*der(vol.dynBal.medium.p);

Differentiated the equation
vol.dynBal.mXi[1] = vol.dynBal.m*vol.dynBal.medium.Xi[1];

giving
der(vol.dynBal.mXi[1]) = der(vol.dynBal.m)*vol.dynBal.medium.Xi[1]+ vol.dynBal.m*der(vol.dynBal.medium.Xi[1]);

The inlet pressure is identical to the pressure state value. A discontinuous change in inlet pressure would therefore lead to an infinite mass flow rate. For solving the problem correctly Dymola therefore requires the derivative of the inlet pressure to be known, since m_flow = f(der(m)) = f(der(p)). If you remove the pressure state by setting massDynamics = steadyState the problem disappears. Dymola still outputs:

Differentiated the equation
vol.dynBal.medium.p = inlet.p;

giving
der(vol.dynBal.medium.p) = der(inlet.p);

but this derivative is not used in the model so it seems to be no problem. This of course means that massDynamics need to be steady state. If you do want to use compressible air I think you'll need to make FMU's of a series connection of a pressure drop component and a mixing volume. And not of an individual mixing volume.

Note that this problem is not entirely related to the issue. An example of this issue is example Buildings.Fluid.MixingVolumes.Examples.MixingVolume. First change the medium to Buildings.Media.Water. Then you can compare the model with and without p(start=p_start, stateSelect=StateSelect.prefer),. With StateSelect.prefer the total number of derivatives der(*) in dsmodel.mof is 73 instead of 11. For instance you get equations like:

der(vol1.dynBal.medium.p) := Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp:der
        (res11.dp, 1.2649110640673518, 0.6, 1.0, 0.0, 0.0)*der(P.y)/(
        Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp:der(res12.dp,
         1.2649110640673518, 0.6, 1.0, 0.0, 0.0)+Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp:der
        (res11.dp, 1.2649110640673518, 0.6, 1.0, 0.0, 0.0));

while we're not at all interested in the derivative of the pressure, only in the pressure.

mwetter added a commit that referenced this issue May 20, 2015
This is for #225 and also required to export volumes as FMUs for lbl-srg/modelica-buildings#313
@mwetter mwetter reopened this May 21, 2015
mwetter added a commit that referenced this issue May 22, 2015
Reference results changed slightly
@mwetter
Copy link
Contributor

mwetter commented May 22, 2015

It turns out that 116194d gives smaller systems of equations in some models of the Buildings library. For example,
for Buildings.Examples.Tutorial.Boiler.System7:

*** Warning: BoilerSystem7.mat: Found translation statistics for initialization for linear in old but not in new results.
 Old = 11
*** Warning: BoilerSystem7.mat: Translation statistics for simulation and results changed for linear.
 Old = 0, 0, 0, 0, 0, 0, 0, 11
 New = 0, 0, 0, 0, 0, 0, 0

and computing time changed from about 10 to 9 seconds.

mwetter added a commit to lbl-srg/modelica-buildings that referenced this issue May 22, 2015
sjoelund pushed a commit to OpenModelica/OMLibraries that referenced this issue May 23, 2015
- https://github.com/lbl-srg/modelica-buildings.git branch master updated to 5a78c76d5b26d8910427db17f00ab3da49fb4712.
  * [lbl-srg/modelica-buildings@5a78c76 5a78c76] Removed stateSelect on pressure for ibpsa/modelica-ibpsa#225
  * [lbl-srg/modelica-buildings@d2149f9 d2149f9] Updated reference results for #417.
  * [lbl-srg/modelica-buildings@c62e6cb c62e6cb] Reformulated to reduce use of divmacro. For #417

- https://github.com/modelica-3rdparty/ExternData.git branch master has FAILING head - latest is e292e462e3bca6f1f1e18e70bb3af3f75ac85a58
  * [modelica-3rdparty/ExternData@e292e46 e292e46] Rebuild always
  * [modelica-3rdparty/ExternData@ab9c399 ab9c399] Rebuild always
  * [modelica-3rdparty/ExternData@503ed70 503ed70] Update version
  * [modelica-3rdparty/ExternData@8481e74 8481e74] Add library version and info

- https://github.com/modelica/Modelica.git branch master updated to e3494fcc35577ae95eb96c50e3276fbf73463c28.
  * [modelica/ModelicaStandardLibrary@e3494fc e3494fc] refs #1720: Fix explicit NULL test
sjoelund pushed a commit to OpenModelica/OpenModelica that referenced this issue May 23, 2015
  > Bump libraries - https://github.com/lbl-srg/modelica-buildings.git branch master updated to 5a78c76d5b26d8910427db17f00ab3da49fb4712.   * [lbl-srg/modelica-buildings@5a78c76 5a78c76] Removed stateSelect on pressure for ibpsa/modelica-ibpsa#225   * [lbl-srg/modelica-buildings@d2149f9 d2149f9] Updated reference results for #417.   * [lbl-srg/modelica-buildings@c62e6cb c62e6cb] Reformulated to reduce use of divmacro. For #417
mwetter added a commit that referenced this issue May 26, 2015
@Mathadon
Copy link
Member Author

Mathadon commented Jun 1, 2015

This was fixed by #248

@Mathadon Mathadon closed this as completed Jun 1, 2015
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 a pull request may close this issue.

2 participants