Commit 781210f2 authored by Henning Francke's avatar Henning Francke
Browse files

Added brine model with 3 salt 4 gas and defunct example

parent f6132219
......@@ -21,9 +21,9 @@ package Brine3salts3gas "Two-phase aqueous solution of NaCl, KCl, CaCl2, N2, CO2
iCO2=4,
iN2=5,
iCH4=6,
final gasNames = {"carbondioxide","nitrogen","methane"},
final MM_gas = {M_CO2,M_N2,M_CH4},
final nM_gas = {nM_CO2,nM_N2,nM_CH4}); //iGas not final, because reassigned in Brine5salts3gas
gasNames = {"carbondioxide","nitrogen","methane"},
MM_gas = {M_CO2,M_N2,M_CH4},
nM_gas = {nM_CO2,nM_N2,nM_CH4}); //iGas not final, because reassigned in Brine5salts3gas
redeclare function extends setState_pTX "to avoid check error"
end setState_pTX;
......@@ -31,7 +31,7 @@ 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 solubilities_pTX
redeclare replaceable function extends solubilities_pTX
"solubility calculation of CO2 in seawater Duan, Sun(2003), returns gas concentration in kg/kg H2O"
algorithm
// print("p_gas={"+String(p_gas[1])+", "+String(p_gas[2])+", "+String(p_gas[3])+"} (solubilities_pTX)");
......
within BrineProp;
package Brine3salts4gas
"Two-phase aqueous solution of NaCl, KCl, CaCl2, N2, CO2, CH4, H2"
extends Brine3salts3gas(
iH2=7,
final gasNames = {"carbondioxide","nitrogen","methane","hydrogen"},
final MM_gas = {M_CO2,M_N2,M_CH4,M_H2},
final nM_gas = {nM_CO2,nM_N2,nM_CH4,nM_H2}); //iGas not final, because reassigned in Brine5salts3gas
redeclare function solubilities_pTX
"solubility calculation of CO2 in seawater Duan, Sun(2003), returns gas concentration in kg/kg H2O"
extends PartialBrineMultiSaltMultiGasTwoPhase.solubilities_pTX;
algorithm
// print("p_gas={"+String(p_gas[1])+", "+String(p_gas[2])+", "+String(p_gas[3])+"} (solubilities_pTX)");
if debugmode then
print("Running solubilities_pTX("+String(p/1e5)+" bar,"+String(T-273.15)+" C, ignoreTlimit="+String(ignoreTlimit)+", X="+Modelica.Math.Matrices.toString(transpose([X]))+")");
end if;
solu[iCO2-nX_salt] := if X[iCO2]>0 then solubility_CO2_pTX_Duan2006(p,T,X_l,MM_vec,p_gas[iCO2-nX_salt],ignoreTlimit) else -1
"aus GasData, mol/kg_H2O -> kg_CO2/kg_H2O";
solu[iN2-nX_salt] :=if X[iN2] > 0 then solubility_N2_pTX_Mao2006(p,T,X_l,MM_vec,p_gas[iN2-nX_salt],ignoreTlimit) else -1
"aus GasData, mol/kg_H2O -> kg_N2/kg_H2O";
// solu[2] := if X[nX_salt+2]>0 then solubility_N2_pTX_Harting(p,T,X_l,MM_vec,p_gas[2]) else -1
solu[iCH4-nX_salt] := if X[iCH4]>0 then solubility_CH4_pTX_Duan2006(p,T,X_l,MM_vec,p_gas[iCH4-nX_salt],ignoreTlimit) else -1
"aus GasData, mol/kg_H2O -> kg_CH4/kg_H2O";
// solu[3] := if X[nX_salt+3]>0 then solubility_CH4_pTX_Harting(p,T,X_l,MM_vec,p_gas[3]) else -1
solu[iH2-nX_salt] := if X[iH2]>0 then solubility_H2_pTX_Chabab2020(p,T,X_l,MM_vec,p_gas[iH2-nX_salt],ignoreTlimit) else -1
"aus GasData, mol/kg_H2O -> kg_CH4/kg_H2O";
// print("k={"+String(solu[1]/p_gas[1])+", "+String(solu[2]/p_gas[2])+", "+String(solu[3]/p_gas[3])+"}(solubilities_pTX)");
// print("solu={"+String(solu[1])+", "+String(solu[2])+", "+String(solu[3])+"}(solubilities_pTX)");
// print(Modelica.Math.Matrices.toString({MM_vec}));
end solubilities_pTX;
redeclare function extends dynamicViscosity_gas
algorithm
eta :=BrineGas3Gas.dynamicViscosity(BrineGas3Gas.ThermodynamicState(
state.p,
state.T,
state.X_g));
assert(eta>0,"Error in gas viscosity calculation.");
end dynamicViscosity_gas;
redeclare function extends saturationPressures
algorithm
// if gasname =="carbondioxide" then
p_sat[iCO2-nX_salt] := if X[iCO2]>0 then degassingPressure_CO2_Duan2006(p,T,X,MM_vec) else 0
"aus GasData TODO: use numeral";
// elseif gasname =="nitrogen" then
p_sat[iN2-nX_salt] :=if X[iN2] > 0 then GasData.degassingPressure_N2_Mao2006(p,T,X,MM_vec) else 0
"aus GasData";
// elseif gasname =="methane" then
p_sat[iCH4-nX_salt] := if X[iCH4]>0 then degassingPressure_CH4_Duan2006(p,T,X,MM_vec) else 0
"aus GasData";
// end if;
if debugmode then
print("saturationPressures("+String(p)+","+String(T)+")={"+Modelica.Math.Matrices.toString({p_sat})+"}");
end if;
end saturationPressures;
redeclare function extends specificHeatCapacityCp_gas
"calculation of gas specific heat capacity"
import SG = Modelica.Media.IdealGases.SingleGases;
algorithm
if state.x>0 then
cp :=BrineGas3Gas.specificHeatCapacityCp_pTX(
p=state.p,
T=state.T,
X=X_g[end - nX_gas:end]);
else
cp:=-1;
end if;
annotation (Documentation(info="<html>
<p>In the two phase region this function returns the interpolated heat capacity between the
liquid and vapour state heat capacities.</p>
</html>"));
end specificHeatCapacityCp_gas;
end Brine3salts4gas;
within BrineProp.Examples.TwoPhase;
model BrineProps2Phase4gasMinimal
"Minimal degassing example for 2-phase brine property model"
//needs "Advanced.PedanticModelica:=false" to run
//SPECIFY MEDIUM and COMPOSITION
package Medium = BrineProp.Brine3salts4gas (
AssertLevel=2);
//DEFINE BRINE COMPOSITION (NaCl, KCl, CaCl2, CO2, N2, CH4)
Real[Medium.nXi] Xi = {0.1,0.1,0.1,1e-05,1e-5,1e-5, 1e-6}
"GrSk brine (Feldbusch 2-2013 1.1775g/ml V2)";
Medium.BaseProperties props;
equation
//SPECIFY THERMODYNAMIC STATE
//degassing by heating starting at STP
props.p = 1.01325e5;
props.T = 60+273.15;
//specify brine composition
props.Xi = Xi;
end BrineProps2Phase4gasMinimal;
......@@ -11,3 +11,4 @@ InitializationTest
DeepWellSampleTakingGasIncrease
SolubilityValidation
MethaneSolubility
BrineProps2Phase4gasMinimal
......@@ -146,7 +146,7 @@ partial package PartialBrineMultiSaltMultiGasTwoPhase "Template medium for aqueo
output SI.SpecificEnthalpy Delta_h_solution;
end solutionEnthalpy;
replaceable partial function solubilities_pTX
partial function solubilities_pTX
"solubility calculation of gas in m_gas/m_H2O"
input SI.Pressure p;
input SI.Temp_K T;
......
......@@ -30,6 +30,9 @@ package PartialFlags
constant Boolean ignoreLimitCH4_T=false;
constant Boolean ignoreLimitCH4_p=false;
constant Boolean ignoreLimitCH4_b=false;
constant Boolean ignoreLimitH2_T=false;
constant Boolean ignoreLimitH2_p=false;
constant Boolean ignoreLimitH2_b=false;
constant Boolean ignoreNoCompositionInBrineGas=false;
protected
......
......@@ -29,3 +29,4 @@ WaterMixtureTwoPhase_pT
PartialBrineMultiSaltMultiGasTwoPhase
Brine3salts3gas
Brine5salts3gas
Brine3salts4gas
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