The ExternalMedia library provides a framework for interfacing external codes computing fluid properties to Modelica.Media-compatible component models.
53
stars
36
forks
source link
Selection of different state variables (ph, pt, dT) for a CoolProp 2-phase medium #87
I'm trying to understand how the selection of different state variables affects the resulting system of equations and I've encountered a possible inconsistency:
Looking at the CO2 CoolProp medium example, it says:
package CO2CoolProp "CoolProp model of CO2"extends ExternalMedia.Media.CoolPropMedium(mediumName = "CarbonDioxide",substanceNames = {"CO2"},ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,SpecificEnthalpy(start=2e5));end CO2CoolProp;
However, I think there is should be:
package CO2CoolProp "CoolProp model of CO2"extends ExternalMedia.Media.CoolPropMedium(mediumName = "CarbonDioxide",substanceNames = {"CO2"},ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph, // this doesn't affect the variable selectioninputChoice = ExternalMedia.Common.InputChoice.ph, // this DOES!SpecificEnthalpy(start=2e5));end CO2CoolProp;
I think that the constant named ThermoStates (defined in partial package PartialMedium) is not used in ExternalMedia, but instead you have created a parameter called basePropertiesInputChoice (defined in the re-declaration of BaseProperties model inside ExternalTwoPhaseMedium.mo).
The parameter basePropertiesInputChoice is of type ExternalMedia.Common.InputChoice and not of type Modelica.Media.Interfaces.Choices.IndependentVariables.
Note that, for instance, the enumerator type Modelica.Media.Interfaces.Choices.IndependentVariables does NOT include InputChoice.dT (density and temperature...is that a MSL bug?)...I guess that this is why you had to define a new enumerator type ExternalMedia.Common.InputChoice.
In any case, does anyone have an example of a dynamical system using a CoolProp medium, in which the state variables are changed from 'ph' to 'dT' or to 'pT', and the simulation runs correctly in both cases (with possibly a change in the number of non-linear equations)?
Hi there,
I'm trying to understand how the selection of different state variables affects the resulting system of equations and I've encountered a possible inconsistency:
Looking at the CO2 CoolProp medium example, it says:
package CO2CoolProp "CoolProp model of CO2"
extends ExternalMedia.Media.CoolPropMedium(
mediumName = "CarbonDioxide",
substanceNames = {"CO2"},
ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
SpecificEnthalpy(start=2e5));
end CO2CoolProp;
However, I think there is should be:
package CO2CoolProp "CoolProp model of CO2"
extends ExternalMedia.Media.CoolPropMedium(
mediumName = "CarbonDioxide",
substanceNames = {"CO2"},
ThermoStates = Modelica.Media.Interfaces.Choices.IndependentVariables.ph, // this doesn't affect the variable selection
inputChoice = ExternalMedia.Common.InputChoice.ph, // this DOES!
SpecificEnthalpy(start=2e5));
end CO2CoolProp;
I think that the
constant
namedThermoStates
(defined inpartial package PartialMedium
) is not used in ExternalMedia, but instead you have created aparameter
calledbasePropertiesInputChoice
(defined in the re-declaration ofBaseProperties
model insideExternalTwoPhaseMedium.mo
). The parameterbasePropertiesInputChoice
is of typeExternalMedia.Common.InputChoice
and not of typeModelica.Media.Interfaces.Choices.IndependentVariables
.Note that, for instance, the enumerator type
Modelica.Media.Interfaces.Choices.IndependentVariables
does NOT includeInputChoice.dT
(density and temperature...is that a MSL bug?)...I guess that this is why you had to define a new enumerator typeExternalMedia.Common.InputChoice
.In any case, does anyone have an example of a dynamical system using a CoolProp medium, in which the state variables are changed from 'ph' to 'dT' or to 'pT', and the simulation runs correctly in both cases (with possibly a change in the number of non-linear equations)?
Thank you!