Declaring Heat Capacity Cp in Dymola

Viewed 87

I am having some problems to call the Specific Heat Capacity of my working fluid that in this case is Hydrogen, I can't call it using the Pressure or either the Temeperature, if someone could help me please, thanks in advance. Here is my code

import Modelica.SIunits;

  package Hyd
    extends ExternalMedia.Media.CoolPropMedium(
      mediumName="hydrogen",
      substanceNames={"hydrogen"},
      inputChoice=ExternalMedia.Common.InputChoice.pT);
  end Hyd;

SIunits.SpecificHeatCapacity cp_in;//[J/kg*K]
Hyd.AbsolutePressure Pb_0;
Hyd.Temperature Tin;
Hyd.SaturationProperties sat9,sat10;

Equation
sat9=Hyd.setSat_T(Tin);
sat10=Hyd.setSat_p(Pb_0);
cp_in=Hyd.specificHeatCapacityCp(sat9);//[J/kg*K]
cp_in=Hyd.specificHeatCapacityCp(sat10);//[J/kg*K]

The function is declared as:

function specificHeatCapacityCp_Unique8 
input ExternalMedia.Media.BaseClasses.ExternalTwoPhaseMedium.ThermodynamicState state ;
output Modelica.Media.Interfaces.Types.SpecificHeatCapacity cp := 1000.0 "Specific heat capacity at constant pressure";
end specificHeatCapacityCp_Unique8;
1 Answers

I'm not sure what you are trying to achieve, exactly, but you are passing a SaturationProperties object to a function expecting a ThermodynamicState, which cannot work (and is reported as such when using OpenModelica).

Here is a working version computing cp at the saturation pressure at 300 K:

model test_SO_68546587
import Modelica.SIunits;

  package Hyd
    extends ExternalMedia.Media.CoolPropMedium(
      mediumName="hydrogen",
      substanceNames={"hydrogen"},
      inputChoice=ExternalMedia.Common.InputChoice.pT);
  end Hyd;

SIunits.SpecificHeatCapacity cp_in;//[J/kg*K]
Hyd.AbsolutePressure Pb_0;
Hyd.Temperature Tin;
Hyd.ThermodynamicState state;
equation
state = Hyd.setState_pT(p=Pb_0, T=Tin);
Tin = 300;
Pb_0 = Hyd.saturationPressure(Tin);
cp_in=Hyd.specificHeatCapacityCp(state);// 14345.2 J/kg*K @ 300 K, 12.951 bar
end test_SO_68546587;
Related