Commit e103807b authored by Henning Francke's avatar Henning Francke
Browse files

fixed wrong molar mass and function UnitTests

parent b24f868c
within BrineProp.Examples.UnitTests;
model UnitTestsTwoPhase4Gas
//Compares calculation result with hardcoded values.
//no assert should be triggered
//To be filled...
//SPECIFY MEDIUM and COMPOSITION
package Medium = BrineProp.Brine3salts4gas(ignoreLimitN2_T=true,ignoreLimitSalt_T=fill(true,3));
Real[Medium.nXi] Xi = {0.0839077010751,0.00253365118988,0.122786737978,0.00016883,0.00073459,0.000065652,0.00001};
//DEFINE BRINE COMPOSITION (NaCl, KCl, CaCl2, MgCl2, SrCl2, CO2, N2, CH4)
/* package Medium = BrineProp.Brine5salts3gas;
Real[Medium.nXi] Xi = {0.0839077010751,0.00253365118988,0.122786737978,0,0,7.2426359111e-05,0.000689505657647,6.14906384726e-05} ;
*/
/* package Medium = BrineProp.Water_MixtureTwoPhase_pT;
Real[Medium.nXi] Xi= fill(0,0);*/
Medium.BaseProperties props;
equation
props.p = 20e5;
props.T = 330;
props.Xi = Xi;
assert(abs(props.GVF-0.0497710432105261)<1e6,"GVF differs!");
assert(abs(props.h-288702.455)<1e6,"GVF differs!");
annotation (experiment(StopTime=1, __Dymola_NumberOfIntervals=1),
__Dymola_experimentSetupOutput);
end UnitTestsTwoPhase4Gas;
UnitTestsTwoPhase
UnitTestsLiquid
H2solubility_Chabab
UnitTestsTwoPhase4Gas
......@@ -17,7 +17,7 @@ package GasData "Molar masses and ion numbers of gases"
constant SI.MolarMass M_CH4 = Modelica.Media.IdealGases.SingleGases.CH4.data.MM
"0.01604246 [kg/mol]";
constant Integer nM_CH4 = 1 "number of ions per molecule";
constant SI.MolarMass M_H2 = Modelica.Media.IdealGases.SingleGases.CH4.data.MM
constant SI.MolarMass M_H2 = Modelica.Media.IdealGases.SingleGases.H2.data.MM
"0.01604246 [kg/mol]";
constant Integer nM_H2 = 2 "number of ions per molecule";
......
......@@ -7,27 +7,18 @@ function solubility_H2_pTX_Chabab2020
extends partial_solubility_pTX;
protected
Types.Molality molalities[size(X, 1)]= Utilities.massFractionsToMolalities(X,MM_vec);
/* SI.Temp_C T_C = SI.Conversions.to_degC(T);
Real L_0=0.252 "N2 solubility in H2O at 25 atm, 75degC";
Real L_rel_p "pressure influence";
Real L_rel_c "salinity influence";
Real L_rel_T "Temperature influence";
Real c = sum(molalities[1:2])+sum(molalities[3:5])*1.8
"TODO: remove absolute indices";
Real p_atm = p_gas/101325;
*/
// SI.Temp_C T_C = SI.Conversions.to_degC(T);
// Real c = X[1]/Salt_Data.M_NaCl/X[end];
algorithm
// print("mola_N2("+String(p_gas)+","+String(T-273.16)+") (solubility_N2_pTX_Duan2006)");
if AssertLevel>0 then
assert(ignoreTlimit or ignoreLimitH2_T or ((if molalities[iNaCl] > 0 then 273.15 else 323.15)<T and T<373.15), "Temperature out of validity range: T=" + String(T - 273.15) + ".\nTo ignore set ignoreLimitN2_T=true",aLevel);
assert(ignoreLimitH2_p or ((if molalities[iNaCl] > 0 then 10e5 else 1e5)<p and p<203e5),"Pressure out of validity rangep=" + String(p/1e5) + " bar.\nTo ignore set ignoreLimitN2_p=true",aLevel);
assert(ignoreLimitH2_p or ((if molalities[iNaCl] > 0 then 10e5 else 1e5)<p and p<203e5),"Pressure out of validity range. p=" + String(p/1e5) + " bar.\nTo ignore set ignoreLimitN2_p=true",aLevel);
assert(ignoreLimitH2_b or molalities[iNaCl]<5,"Molality out of validity range: mola[NaCl]=" + String(molalities[iNaCl]) + " mol/kg.\nTo ignore set ignoreLimitH2_b=true",aLevel);
end if;
solu :=solubility_H2_pTX_Chabab2020_molality(p,T,X, MM_vec,p_gas); // mol/kg_H2O
solu :=solubility_H2_pTX_Chabab2020_molality(p,T,X, MM_vec,p_gas); // mol/kg_H2O
// print("solu:"+String(solu));
X_gas := solu * M_H2 * X[end]; //molality->mass fraction
// print("mola_N2("+String(p_gas)+"Pa,"+String(T-273.16)+"degC,"+String(molalities[1])+")="+String(solu)+" (solubility_N2_pTX_Harting)");
// print("mola_N2("+String(p_gas)+","+String(T-273.16)+")="+String(c_gas)+"->k="+String(c_gas/max(1,p_gas))+" (solubility_N2_pTX_Duan2006)");
// print("X_H2("+String(p_gas)+"Pa,"+String(T-273.16)+"degC,"+String(molalities[1])+")="+String(X_gas)+" (solubility_H2_pTX_Chabab2020)");
end solubility_H2_pTX_Chabab2020;
......@@ -18,12 +18,13 @@ protected
// Real m_SO4 = molalities[i_MgCl2];
Real b_NaCl = m_Na + m_K + 2 * m_Ca; // + 2 * m_Mg;
// Debug.Print "b_NaCl: "; b_NaCl
SI.Pressure p_H2O = Modelica.Media.Water.WaterIF97_pT.saturationPressure(T);
algorithm
// print("mola_H2("+String(p_gas)+","+String(T-273.16)+") (solubility_H2_pTX_Chabab2020_molality)");
b_H2 :=solubility_H2_pTb_Chabab2020_molality(
p_gas + p_H2O,
T,
b_NaCl); // mole fraction b_H2 / b/H2O
// print("b_H2: "+String(b_H2));
end solubility_H2_pTX_Chabab2020_molality;
within BrineProp.GasData;
within BrineProp.GasData;
function solubility_H2_pTb_Chabab2020_molality
// conversion mole fraction to molality
input Real p;
......@@ -9,4 +9,8 @@ protected
Real y_H2 = solubility_H2_pTb_Chabab2020_y(p, T, b_NaCl) "mole fraction b_H2 / b/H2O";
algorithm
b_H2 :=y_H2/(1 - y_H2)/M_H2O; // mol/kg_H2O
/* print("Δy_H2:"+String(y_H2-0.000958406222692535));
print("Δb_H2:"+String(b_H2-0.0532506062270179));
print("ΔM_H2O:"+String(M_H2O-0.018015268));
*/
end solubility_H2_pTb_Chabab2020_molality;
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