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

Modelica.Media.Air.MoistAir.density_derX is not right #2868

Closed
finback-at opened this issue Mar 29, 2019 · 2 comments · Fixed by #2932
Closed

Modelica.Media.Air.MoistAir.density_derX is not right #2868

finback-at opened this issue Mar 29, 2019 · 2 comments · Fixed by #2932
Assignees
Labels
bug Critical/severe issue L: Media Issue addresses Modelica.Media
Milestone

Comments

@finback-at
Copy link

I think that the current algorithms of Modelica.Media.Air.MoistAir.density_derX,

dddX[Water] := pressure(state)*(steam.R - dryair.R)/((steam.R - dryair.R)
  *state.X[Water]*temperature(state) + dryair.R*temperature(state))^2;
dddX[Air] := pressure(state)*(dryair.R - steam.R)/((dryair.R - steam.R)*
  state.X[Air]*temperature(state) + steam.R*temperature(state))^2;

are not right.

Unit check

Mass fraction X [kg/kg] is unitless.
The unit of density_derX should be same as density.
But the unit of abouve equations are,
pressure*R/(R*temperature)^2 = pressure/(R*temperature^2) = density/temperature.
where, density = pressure/(R*temperature) is equation of state for ideal gases.

my derivation

density = p/(R*T)
=>
d(density)/dX = - p/(R^2*T) * dR/dX = {-p*(dR/dX)} / (R^2*T)  --- (a)

(1) dddX[Water]

R = steam.R*X[Water] + dryair.R*(1-X[Water]) 
   = (steam.R - dryair.R)*X[Water] + dryair.R 

dR/dX[Water] = steam.R - dryair.R

numerator of (a) = -p*(dR/dX) = - pressure(state)*(steam.R - dryair.R)
denominator of (a) = R^2*T 
   = ((steam.R - dryair.R)*X[Water] + dryair.R)^2*temperature(state)

dddX[Water] = - pressure(state)*(steam.R - dryair.R)/
    ( ((steam.R - dryair.R)*X[Water] + dryair.R)^2 * temperature(state))

(2) dddX[Air]

R = steam.R*(1-X[Air]) + dryair.R*X[Air]
  = steam.R + (dryair.R - steam.R)*X[Air]

dR/dX[Air] = dryair.R - steam.R

numerator of (*) = -p*(dR/dX) = - pressure(state)*(dryair.R - steam.R)
denominator of (*) = R^2*T
   = (steam.R + (dryair.R - steam.R)*X[Air])^2 * temperature(state)

dddX[Air] = - pressure(state)*(dryair.R - steam.R)/
              ( (steam.R + (dryair.R - steam.R)*X[Air])^2 * temperature(state) )
@tbeu tbeu added the L: Media Issue addresses Modelica.Media label Mar 29, 2019
@beutlich
Copy link
Member

That code is in there since MoMoLib was integrated more than 7 years ago:

redeclare function extends density_derX
algorithm
dddX[Water] := pressure(state)*(steam.R - dryair.R)/((steam.R - dryair.R)
*state.X[Water]*temperature(state) + dryair.R*temperature(state))^2;
dddX[Air] := pressure(state)*(dryair.R - steam.R)/((dryair.R - steam.R)*
state.X[Air]*temperature(state) + steam.R*temperature(state))^2;
annotation (Documentation(revisions="<html>
<p>2012-01-12 Stefan Wischhusen: Initial Release.</p>
</html>"));
end density_derX;

@wischhusen Can you please have a look at this.

@HansOlsson You once told (maybe for a similar fix of molarMass), that unit checks in function are tricky. Can you please cross-check.

@beutlich beutlich changed the title Modelica.Media.Air.MoistAir.density_derX is not right. Modelica.Media.Air.MoistAir.density_derX is not right Mar 29, 2019
@beutlich beutlich added this to the MSL4.0.0 milestone Mar 29, 2019
@wischhusen
Copy link
Contributor

Looks reasonable. Have to revisit the code later.

wischhusen added a commit to wischhusen/Modelica-1 that referenced this issue May 14, 2019
beutlich pushed a commit to wischhusen/Modelica-1 that referenced this issue May 14, 2019
@beutlich beutlich added the bug Critical/severe issue label May 14, 2019
beutlich pushed a commit that referenced this issue Jul 24, 2019
beutlich pushed a commit to beutlich/ModelicaStandardLibrary that referenced this issue Jul 24, 2019
beutlich pushed a commit to beutlich/ModelicaStandardLibrary that referenced this issue Jul 24, 2019
beutlich pushed a commit to beutlich/ModelicaStandardLibrary that referenced this issue Jul 24, 2019
beutlich pushed a commit to beutlich/ModelicaStandardLibrary that referenced this issue Sep 26, 2019
beutlich added a commit that referenced this issue Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Critical/severe issue L: Media Issue addresses Modelica.Media
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants