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

Fluid boundaries not working with ideal gas mixtures #1205

Closed
mwetter opened this issue Sep 13, 2019 · 1 comment · Fixed by #1207
Closed

Fluid boundaries not working with ideal gas mixtures #1205

mwetter opened this issue Sep 13, 2019 · 1 comment · Fixed by #1207
Assignees
Labels

Comments

@mwetter
Copy link
Contributor

mwetter commented Sep 13, 2019

This is to correct the issue reported by @justnielsen through lbl-srg/modelica-buildings#1543


I am trying to use Modelica Buildings with MSL mixture gasses.

In the simples possible case I connect a mass flow source to a pressure sink and use Modelica.Media.IdealGases.MixtureGases.FlueGasSixComponents.

model SourceToSink
  package Medium = Modelica.Media.IdealGases.MixtureGases.FlueGasSixComponents;
  Buildings.Fluid.Sources.MassFlowSource_T boundary(redeclare package Medium = Medium, nPorts=1);
  Buildings.Fluid.Sources.Boundary_pT bou(redeclare package Medium = Medium, nPorts=1);
equation 
  connect(boundary.ports[1], bou.ports[1]);
end SourceToSink;

This gives a model with 26 equations and 25 unknowns.

Looking into Buildings.Fluid.Sources.BaseClasses.PartialSource_Xi_C.mo, I see some problems around the lines

if not use_X_in then
  X_in_internal[1:Medium.nXi] = Xi_in_internal[1:Medium.nXi];
  X_in_internal[Medium.nX] = 1-sum(X_in_internal[1:Medium.nXi]);
end if;

Since I have chosen not to use an external mass fraction input, I would expect a connection between X_in_internal and X. If I replace the two lines in the if statement with
X_in_internal = X (like in the Modelica.Fluid.Sources) the model works.

Also, if I specify the X as an internal input vector in the simple model above, it fails to work.

@mwetter
Copy link
Contributor Author

mwetter commented Sep 13, 2019

The problem seems to be caused because FlueGasSixComponents has reducedX=false. If it is instantiated with
Modelica.Media.IdealGases.MixtureGases.FlueGasSixComponents(reducedX=true) the model works. While this is not a work-around, it points to the problem.

Note that

  constant Boolean reducedX=true 
    "= true if medium contains the equation sum(X) = 1.0; set reducedX=true if only one substance (see docu for details)";

  constant Boolean fixedX=false 
    "= true if medium contains the equation X = reference_X";

  final constant Integer nS=size(substanceNames, 1) "Number of substances";
  constant Integer nX=nS "Number of mass fractions";
  constant Integer nXi=if fixedX then 0 else if reducedX then nS - 1 else nS 
    "Number of structurally independent mass fractions (see docu for details)";

and in BaseProperties,

      if reducedX and not fixedX then
        X[nX] = 1 - sum(Xi);
      end if;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant