Commit 515a09a9 authored by Henning Francke's avatar Henning Francke
Browse files

Added missing (dummy) functions for onePhaseBrine to get rid of warnings

parent 45109ae6
......@@ -19,6 +19,17 @@ package Brine3salts "One-phase (liquid) multisalt brine solution"
final MM_salt = Salt_data.MM_salt,
final nM_salt = Salt_data.nM_salt*/
redeclare function extends setState_pTX
"Return thermodynamic state as function of p and T"
algorithm
state := ThermodynamicState(
d=density_pTX(p, T, X),
T=T,
p=p,
X=X);
// h=specificEnthalpy_pTX(p,T,X),
end setState_pTX;
redeclare function extends density_pTX
// extends density_Duan2008_pTX(MM_vec=cat(1,MM_salt, {M_H2O}));
//TODO should take MM_vec;
......@@ -30,8 +41,9 @@ package Brine3salts "One-phase (liquid) multisalt brine solution"
// d := Modelica.Media.Water.WaterIF97_pT.density_pT(p,T) "*(1+sum(X[1:nX_salt]))/X[end]";
end density_pTX;
redeclare function specificEnthalpy_pTX
extends specificEnthalpy_pTX_liq_Francke_cp(MM_vec=MM_salt);
redeclare function extends specificEnthalpy_pTX
algorithm
h :=specificEnthalpy_pTX_liq_Francke_cp(p,T,X,MM_vec=MM_salt,ignoreTlimit=ignoreTlimit);
end specificEnthalpy_pTX;
redeclare function extends dynamicViscosity_pTXd
......@@ -95,6 +107,15 @@ protected
saltConstants);
end dynamicViscosity_pTX;
redeclare function extends setState_dTX
algorithm
assert(false,"Running dummy setState_dTX. Shouldn't be called.");
state := setState_pTX(
1e5,
T,
X) ",fluidnames)";
end setState_dTX;
annotation (Documentation(info="<html>
<p><b>BrineProp.Brine_5salts</b> is a medium package that provides properties of one-phase solution of five salts (NaCl, KCl, CaCl<sub>2</sub>, MgCl<sub>2</sub>, SrCl<sub>2</sub>).</p>
<h4>Usage</h4>
......
setState_pTX
density_pTX
specificEnthalpy_pTX
dynamicViscosity_pTXd
......@@ -5,3 +6,4 @@ specificHeatCapacityCp
surfaceTension_T
thermalConductivity
dynamicViscosity_pTX
setState_dTX
......@@ -32,6 +32,15 @@ package Brine3salts3gas "Two-phase aqueous solution of NaCl, KCl, CaCl2, N2, CO2
redeclare function extends setState_phX "to avoid check error"
end setState_phX;
redeclare function extends setState_dTX
algorithm
assert(false,"Running dummy setState_dTX. Shouldn't be called.");
state := setState_pTX(
1e5,
T,
X) ",fluidnames)";
end setState_dTX;
redeclare replaceable function extends solubilities_pTX
"solubility calculation, returns gas concentration in kg/kg H2O"
algorithm
......
fugacity_H2O
setState_pTX
setState_phX
setState_dTX
solubilities_pTX
density_liq_pTX
density_gas_pTX
......
......@@ -91,13 +91,9 @@ package Brine3salts4gas
liquid and vapour state heat capacities.</p>
</html>"));
end specificHeatCapacityCp_gas;
redeclare function density_gas_pTX
extends PartialBrineMultiSaltMultiGasTwoPhase.density_gas_pTX;
/* input SI.Pressure p;
input SI.Temp_K T;
input MassFraction X[:] "nX_gas mass fraction";
input SI.MolarMass MM[:] "=MM_vec =fill(0,nX) molar masses of components";
output SI.Density d;*/
algorithm
d := BrineGas4Gas.density_pTX(p,T,X,MM);
// print("density_liquid_pTX: "+String(p*1e-5)+" bar,"+String(T)+" K->"+String(d)+"kg/m^3");
......
......@@ -13,7 +13,6 @@ package BrineDriesner "NaCl solution using Driesner density and enthalpy functio
d:=Densities.density_Driesner2007_pTX(p,T,X);
end density_pTX;
redeclare function extends specificEnthalpy_pTX
"enthalpy calculation according to Driesner 2007 et al: 0-1000degC; 0.1-500MPa (doi:10.1016/j.gca.2007.05.026)"
//Pressure limited to 100 MPa by Modelica Water property function
......
......@@ -16,13 +16,11 @@ package BrineDuan "NaCl solution using Duan density"
h :=BrineDriesner.specificEnthalpy_pTX(p,T,X);
end specificEnthalpy_pTX;
redeclare function extends density_pTX
algorithm
d:=density_Duan2008_pTX(p,T,X,MM_vec,saltConstants);
end density_pTX;
redeclare function extends dynamicViscosity_pTX
algorithm
// eta :=dynamicViscosity_Duan2009NaCl_pTX(p,T,X);
......
UnitTestBrine3Gas
Brine3Gas_Minimal
Brine4Gas_Minimal
UnitTestBrine3Gas
within BrineProp.Examples.Liquid;
model UnitTestsLiquid "To be filled..."
package Medium_3s = BrineProp.Brine3salts (ignoreLimitSalt_p={false,true,true});
Medium_3s.BaseProperties props_3s;
package Medium = BrineProp.Brine3salts (ignoreLimitSalt_p={false,true,true});
Medium.BaseProperties props;
Medium.ThermodynamicState state = Medium.setState_pTX(10e5, 300, props.X);
Medium.ThermodynamicState state2 = Medium.setState_phX(10e5, 1e6, props.X);
package Medium = Brine3salts3gas (ignoreLimitN2_T=true);
Medium.BaseProperties props_3s3g;
equation
props_3s.p = 455e5;
props_3s.T = 145+273.15;
props_3s.Xi = {0.082870031,0.00486001,0.125914128};
assert(abs(props_3s.d-1127.8458262083673)<1e9, "Not the expecteded density!");
props.p = 455e5;
props.T = 145+273.15;
props.Xi = {0.082870031,0.00486001,0.125914128};
assert(abs(props.d-1127.8458262083673)<1e9, "Not the expecteded density!");
props_3s3g.p = 455e5;
props_3s3g.T = 145+273.15;
props_3s3g.Xi = {0.082870031,0.00486001,0.125914128,1.6E-6, 465.6E-6, 49.9E-6};//-2313 m
assert(abs(props_3s3g.d-1127.8458262083673)<1e9, "Not the expecteded density!");
// print(String(props_3s.d-1127.85417379));
......
......@@ -126,11 +126,6 @@ partial package PartialBrineMultiSaltMultiGasTwoPhase "Template medium for aqueo
</html>"));
end ThermodynamicState;
redeclare function extends density "return density of ideal gas"
algorithm
d := state.d;
end density;
redeclare function density_pTX "wrapper to extract d from state"
//necessary for declaration of inverse function p(T,d)
input SI.Pressure p;
......@@ -387,7 +382,7 @@ protected
//necessary for declaration of inverse function T(p,h)
input SI.Pressure p;
input SI.Temp_K T;
input MassFraction X[:] "mass fraction m_NaCl/m_Sol";
input MassFraction X[:];
input FixedPhase phase=0
"2 for two-phase, 1 for one-phase, 0 if not known";
input Real[nX_gas+1] n_g_norm_start=fill(0.5,nX_gas+1)
......
......@@ -14,7 +14,6 @@ MM_gas
nM_gas
BaseProperties
ThermodynamicState
density
density_pTX
density_liq_pTX
density_gas_pTX
......
......@@ -29,7 +29,9 @@ partial package PartialBrineMultiSaltOnePhase "Template medium for one-phase aq
final reducedX = true,
final singleState=false,
reference_X=cat(1,fill(0,nX-1),{1}),
fluidConstants = BrineConstants);
fluidConstants = BrineConstants,
ThermoStates=Choices.IndependentVariables.pTX); //ThermoStates was added for compatibility with Modelica.Fluid, don't really know what it does
constant FluidConstants[nS] BrineConstants(
each chemicalFormula = "H2O+NaCl+KCl+CaCl2+MgCl2+SrCl2",
......@@ -85,8 +87,6 @@ end ThermodynamicState;
end dynamicViscosity_pTXd;
redeclare model extends BaseProperties "Base properties of medium"
// import BrineProp;
// BrineProp.Partial_Units.Molality y_vec[:]=BrineProp.massToMoleFractions(X,MM_vec);
SI.MoleFraction y_vec[:]=Utilities.massToMoleFractions(X,MM_vec);
equation
d = density_pTX(p,T,X);
......@@ -94,14 +94,12 @@ end ThermodynamicState;
// T = temperature_phX(p,h,X);
u = h - p/d;
MM = y_vec*MM_vec;
R = 8.3144/MM;
R = Modelica.Constants.R/MM;
state.p = p;
state.T = T;
state.d = d;
state.X = X;
/*algorithm
print("MM_vec: "+String(size(MM_vec,1)));*/
annotation (Documentation(revisions="<html>
</html>"));
......@@ -119,9 +117,10 @@ end ThermodynamicState;
end density_pTX;
redeclare replaceable function specificEnthalpy_pTX
input SI.Pressure p;
input SI.Pressure p;
input SI.Temp_K T;
input MassFraction X[:] "mass fraction m_NaCl/m_Sol";
input Boolean ignoreTlimit=false;
output SI.SpecificEnthalpy h;
/*algorithm
......@@ -152,10 +151,9 @@ protected
print("temperature_phX("+String(p)+","+String(h)+")");
end if;
//Find temperature with h above given h ->T_b
assert(h>specificEnthalpy_pTX(p,T_a,X),"h="+String(h/1e3)+" kJ/kg -> Enthalpy too low (< 0degC)");
assert(h>specificEnthalpy_pTX(p,T_a,X,ignoreTlimit=true),"h="+String(h/1e3)+" kJ/kg -> Enthalpy too low (< 0degC)");
while true loop
h_T:=specificEnthalpy_pTX(p,T_b,X);
// print(String(p)+","+String(T_b)+" K->"+String(h_T)+" J/kg (PartialBrine_ngas_Newton.temperature_phX)");
h_T:=specificEnthalpy_pTX(p,T_b,X,ignoreTlimit=true);
if h>h_T then
T_a := T_b;
T_b := T_b + 50;
......@@ -170,7 +168,7 @@ protected
// print("T_b-T_a="+String(T_b-T_a)+", abs(h-h_T)/h="+String(abs(h-h_T)/h));
T:=(T_a+T_b)/2 "Halbieren";
// print("T_neu="+String(T)+"K");
h_T:=specificEnthalpy_pTX(p,T,X);
h_T:=specificEnthalpy_pTX(p,T,X,ignoreTlimit=true);
if h_T > h then
T_b:=T;
// print("T_b="+String(T)+"K -> h="+String(h_T-h));
......@@ -251,6 +249,30 @@ algorithm
beta :=(1 - state.d/(density_pTX(state.p,state.T - Delta_T,state.X)))/Delta_T;
end isobaricExpansionCoefficient;
redeclare replaceable function extends temperature
"returns density from state - seems useless, but good for compatibility between PartialMedium and PartialMixedMediumTwoPhase"
algorithm
T := state.T;
end temperature;
redeclare function extends specificEnthalpy "to avoid check error"
algorithm
h :=specificEnthalpy_pTX(state.p,state.T,state.X);
end specificEnthalpy;
redeclare replaceable function extends pressure
/* input ThermodynamicState state "Thermodynamic state record";
output Modelica.SIunits.Pressure p;
*/
algorithm
p := state.p;
end pressure;
redeclare function extends density "density from state"
algorithm
d := state.d;
end density;
annotation (Documentation(info="<html>
<h5>Usage</h5>
<p>This partial package cannot be used as is. See <a href=\"Modelica://BrineProp.Examples.BrineProps1Phase\">BrineProp.Examples.BrineProps1Phase</a> or info of <a href=\"Modelica://BrineProp.Brine_5salts\">BrineProp.Brine_5salts</a> for examples.</p>
......
......@@ -19,3 +19,7 @@ setState_phX
surfaceTension_T
dynamicViscosity_pTX
isobaricExpansionCoefficient
temperature
specificEnthalpy
pressure
density
within BrineProp;
partial package PartialMixtureTwoPhaseMedium "Template class for two phase medium of a mixture of substances "
partial package PartialMixtureTwoPhaseMedium "Template class for two-phase medium of a mixture of substances "
/*
// Uncomment this for MSL 3.2
type FixedPhase = Integer(min=0,max=2) "phase of the fluid: 1 for 1-phase, 2 for two-phase, 0 for not known, e.g. interactive use";
......@@ -19,7 +19,7 @@ redeclare replaceable record SaturationProperties "MSL 3.2.1"
extends Modelica.Icons.Record;
AbsolutePressure psat "saturation pressure";
Temperature Tsat "saturation temperature";
MassFraction X[nX] "Mass fractions";
MassFraction X[nX] "Mass fractions"; //causes downward incompatibility -> warnings (missing subtype)
annotation (Documentation(info="<html></html>"));
end SaturationProperties;
......@@ -311,6 +311,35 @@ algorithm
annotation (Documentation(info="<html></html>"));
end temperature_phX;
redeclare function extends density "density from state"
algorithm
d := state.d;
end density;
replaceable function density_liq
input ThermodynamicState state "Thermodynamic state record";
output Modelica.SIunits.Density d_l;
algorithm
d_l := state.d_l;
end density_liq;
replaceable function density_ph "Return density from p and h"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input SpecificEnthalpy h "Specific enthalpy";
input FixedPhase phase=0 "2 for two-phase, 1 for one-phase, 0 if not known";
output Density d "Density";
algorithm
assert(nX == 1,
"This function is not allowed for mixtures. Use density_phX() instead!");
d := density_phX(
p,
h,
fill(0, 0),
phase);
annotation (Documentation(info="<html></html>"));
end density_ph;
redeclare replaceable function density_phX
"Return density from p, h, and X or Xi"
extends Modelica.Icons.Function;
......@@ -328,39 +357,39 @@ algorithm
annotation (Documentation(info="<html></html>"));
end density_phX;
redeclare replaceable function temperature_psX
"Return temperature from p, s, and X or Xi"
redeclare replaceable function density_psX
"Return density from p, s, and X or Xi"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input SpecificEntropy s "Specific entropy";
input MassFraction X[nX] "Mass fractions";
input FixedPhase phase=0 "2 for two-phase, 1 for one-phase, 0 if not known";
output Temperature T "Temperature";
output Density d "Density";
algorithm
T := temperature(setState_psX(
d := density(setState_psX(
p,
s,
X,
phase));
annotation (Documentation(info="<html></html>"));
end temperature_psX;
end density_psX;
redeclare replaceable function density_psX
"Return density from p, s, and X or Xi"
redeclare replaceable function temperature_psX
"Return temperature from p, s, and X or Xi"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input SpecificEntropy s "Specific entropy";
input MassFraction X[nX] "Mass fractions";
input FixedPhase phase=0 "2 for two-phase, 1 for one-phase, 0 if not known";
output Density d "Density";
output Temperature T "Temperature";
algorithm
d := density(setState_psX(
T := temperature(setState_psX(
p,
s,
X,
phase));
annotation (Documentation(info="<html></html>"));
end density_psX;
end temperature_psX;
redeclare replaceable function specificEnthalpy_psX
"Return specific enthalpy from p, s, and X or Xi"
......@@ -485,23 +514,6 @@ algorithm
annotation (Documentation(info="<html></html>"));
end vapourQuality;
replaceable function density_ph "Return density from p and h"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input SpecificEnthalpy h "Specific enthalpy";
input FixedPhase phase=0 "2 for two-phase, 1 for one-phase, 0 if not known";
output Density d "Density";
algorithm
assert(nX == 1,
"This function is not allowed for mixtures. Use density_phX() instead!");
d := density_phX(
p,
h,
fill(0, 0),
phase);
annotation (Documentation(info="<html></html>"));
end density_ph;
replaceable function temperature_ph "Return temperature from p and h"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
......@@ -638,6 +650,11 @@ algorithm
annotation (Documentation(info="<html></html>"));
end density_pT;
redeclare function extends specificEnthalpy "to avoid check error"
algorithm
h :=state.h;
end specificEnthalpy;
replaceable function specificEnthalpy_dTX
"Return specific enthalpy from d, T, and X or Xi"
extends Modelica.Icons.Function;
......@@ -664,13 +681,6 @@ algorithm
p := state.p;
end pressure;
replaceable function density_liq
input ThermodynamicState state "Thermodynamic state record";
output Modelica.SIunits.Density d_l;
algorithm
d_l := state.d_l;
end density_liq;
replaceable function dynamicViscosity_liq "Viscosity of liquid phase"
// extends dynamicViscosity; Warum funzt das nicht? Er sagt "multiple algorithms"
extends Modelica.Icons.Function;
......
......@@ -30,9 +30,12 @@ dBubbleEnthalpy_dPressure
dDewEnthalpy_dPressure
specificEnthalpy_pTX
temperature_phX
density
density_liq
density_ph
density_phX
temperature_psX
density_psX
temperature_psX
specificEnthalpy_psX
setState_pT
setState_ph
......@@ -41,7 +44,6 @@ setState_dT
setState_px
setState_Tx
vapourQuality
density_ph
temperature_ph
pressure_dT
specificEnthalpy_dT
......@@ -50,9 +52,9 @@ temperature_ps
density_ps
specificEnthalpy_pT
density_pT
specificEnthalpy
specificEnthalpy_dTX
pressure
density_liq
dynamicViscosity_liq
dynamicViscosity_gas
temperature
......
within BrineProp.WaterMixtureTwoPhase_pT;
function fugacity_H2O
"Calculation of fugacity coefficient according to (Duan 2003)"
// extends fugacity_pTX;
input SI.Pressure p;
input SI.Temp_K T;
output Real phi=0;
algorithm
assert(false, "dummy function for compatibility, should not be called");
end fugacity_H2O;
......@@ -232,6 +232,12 @@ algorithm
// GVF=-1,
end setState_pTX;
redeclare function extends setState_dTX
algorithm
assert(false,"Running dummy setState_dTX. Shouldn't be called.");
state := setState_pTX(1e5,T,X) ",fluidnames)";
end setState_dTX;
redeclare function specificEntropy_pTX
"Computes specific entropy as a function of pressure and temperature"
extends Modelica.Icons.Function;
......@@ -333,7 +339,6 @@ protected
/(dewEnthalpy(setSat_pX(p,X)) - hl
+ eps), 0), 1);
algorithm
if debugmode then
Modelica.Utilities.Streams.print("Running setState_phX(" + String(p/1e5) + " bar,"
+ String(h) + " J/kg,X)...");
......@@ -386,20 +391,15 @@ end setState_phX;
// x := state.x;
annotation(Documentation(info="<html></html>"));
end vapourQuality;
//DUMMY FUNCTIONS
redeclare function extends temperature_ph "to avoid check error"
end temperature_ph;
redeclare function extends temperature_ph "to avoid check error"
end temperature_ph;
redeclare function extends specificEnthalpy_pT "to avoid check error"
end specificEnthalpy_pT;
redeclare function extends specificEnthalpy_pT "to avoid check error"
end specificEnthalpy_pT;
redeclare function extends density_pT "to avoid check error"
end density_pT;
redeclare function extends density "density from state"
algorithm
d := state.d;
end density;
redeclare function extends density_pT "to avoid check error"
end density_pT;
annotation (Documentation(info="<html>
<h1>Water_MixtureTwoPhase_pT</h1>
......
......@@ -13,6 +13,7 @@ specificEntropy
specificEnthalpy_ps
setState_psX
setState_pTX
setState_dTX
specificEntropy_pTX
thermalConductivity
specificHeatCapacityCp
......@@ -28,4 +29,4 @@ vapourQuality
temperature_ph
specificEnthalpy_pT
density_pT
density
fugacity_H2O
......@@ -110,6 +110,6 @@ package BrineProp "Media models for p-h-T-rho-eta properties of aqueous solution
revisions="<html></html>"),
version="0.5.6",
versionDate="2017-09-28",
uses( Modelica(version="3.2.3"), DataFiles(version
="1.0.5")));
uses( Modelica(version="3.2.3"), DataFiles(version=
"1.0.5")));
end BrineProp;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment