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

Issues with Modelica.Media.IdealGases.Common.MixtureGasNasa.T_hX #3400

Closed
HansOlsson opened this issue Feb 11, 2020 · 0 comments · Fixed by #3404
Closed

Issues with Modelica.Media.IdealGases.Common.MixtureGasNasa.T_hX #3400

HansOlsson opened this issue Feb 11, 2020 · 0 comments · Fixed by #3404
Assignees
Labels
bug Critical/severe issue L: Media Issue addresses Modelica.Media
Milestone

Comments

@HansOlsson
Copy link
Contributor

HansOlsson commented Feb 11, 2020

It seems that these implicit functions are problematic, see also #3399

The function:

function T_hX "Return temperature from specific enthalpy and mass fraction"
  extends Modelica.Icons.Function;
  input SpecificEnthalpy h "Specific enthalpy";
  input MassFraction[nX] X "Mass fractions of composition";
  input Boolean exclEnthForm=excludeEnthalpyOfFormation
    "If true, enthalpy of formation Hf is not included in specific enthalpy h";
  input Modelica.Media.Interfaces.Choices.ReferenceEnthalpy
                                   refChoice=referenceChoice
    "Choice of reference enthalpy";
  input SI.SpecificEnthalpy h_off=h_offset
    "User defined offset for reference enthalpy, if referenceChoice = UserDefined";
  output Temperature T "Temperature";
protected 
  MassFraction[nX] Xfull = if size(X,1) == nX then X else cat(1,X,{1-sum(X)});

  function f_nonlinear "Solve h_TX(T,X) for T with given h"
    extends Modelica.Math.Nonlinear.Interfaces.partialScalarFunction;
    input SpecificEnthalpy h "Specific enthalpy";
    input MassFraction[:] Xfull "Mass fractions of composition";
  algorithm 
    y := h_TX(T=u, X=Xfull) - h;
  end f_nonlinear;

algorithm 
  T := Modelica.Math.Nonlinear.solveOneNonlinearEquation(
    function f_nonlinear(h=h, Xfull=Xfull), 200, 6000);
  annotation(inverse(h = h_TX(T,X,exclEnthForm,refChoice,h_off)));
end T_hX;

Has the following issues:

  • The inverse-annotation uses the extra arguments, exclEnthForm, refChoice, h_off, but the actual solution ignores them. I believe it is simplest to just remove them completely.
  • Creating Xfull is unnecessary since the input X is declared with the size nX. The inverse also uses X directly.
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
2 participants