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

4 gases working

parent 781210f2
......@@ -32,7 +32,7 @@ package Brine3salts3gas "Two-phase aqueous solution of NaCl, KCl, CaCl2, N2, CO2
end setState_phX;
redeclare replaceable function extends solubilities_pTX
"solubility calculation of CO2 in seawater Duan, Sun(2003), returns gas concentration in kg/kg H2O"
"solubility calculation, 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)");
if debugmode then
......
......@@ -9,10 +9,24 @@ package Brine3salts4gas
redeclare function solubilities_pTX
"solubility calculation of CO2 in seawater Duan, Sun(2003), returns gas concentration in kg/kg H2O"
extends PartialBrineMultiSaltMultiGasTwoPhase.solubilities_pTX;
"solubility calculation"
// extends PartialBrineMultiSaltMultiGasTwoPhase.solubilities_pTX;
// TODO: avoid repeating the declarations below (extending Brine3salts3gas doesn't work [multiple algorithms]
input SI.Pressure p;
input SI.Temp_K T;
input SI.MassFraction X_l[nX] "mass fractions m_x/m_Sol";
input SI.MassFraction X[nX] "mass fractions m_x/m_Sol";
input SI.Pressure[nX_gas] p_gas;
input Boolean ignoreTlimit=false "activated by temperature_phX";
// input SI.MolarMass MM[:] "=fill(0,nX)molar masses of components";
// output Molality[nX_gas] solu;
output MassFraction solu[nX_gas] "gas concentration in kg_gas/kg_fluid";
algorithm
// print("p_gas={"+String(p_gas[1])+", "+String(p_gas[2])+", "+String(p_gas[3])+"} (solubilities_pTX)");
if debugmode then
//print("\nRunning setState_pTX("+String(p/1e5)+" bar,"+String(min(1000,T)-273.15)+" degC, ignoreTlimit="+String(ignoreTlimit)+", X="+Modelica.Math.Matrices.toString(transpose([X]))+")");
print("\nRunning setState_pTX(p_gas={"+String(p_gas[1])+", "+String(p_gas[2])+", "+String(p_gas[3])+"}) (solubilities_pTX)");
end if;
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;
......@@ -20,10 +34,9 @@ package Brine3salts4gas
"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";
......
......@@ -14,7 +14,7 @@ model BrineProps2Phase4gasMinimal
equation
//SPECIFY THERMODYNAMIC STATE
//degassing by heating starting at STP
props.p = 1.01325e5;
props.p = 10.01325e5;
props.T = 60+273.15;
//specify brine composition
......
......@@ -17,7 +17,6 @@ equation
323.15,
1) - 0.05325070081453114) < 1e-8, "Nope");
assert(abs(Medium.solubility_H2_pTX_Chabab2020_molality(102e5, 323.15,{0.0552160106873965,0,0,0,0,0,0}, 100e5, Modelica.Media.Water.WaterIF97_pT.saturationPressure(323.15))-0.05325070081453114)<1e-8, "Nope");
print("Hallo");
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)));
end H2solubility_Chabab;
......@@ -8,7 +8,8 @@ partial package PartialBrineMultiSaltMultiGasTwoPhase "Template medium for aqueo
"activates inversion for state definition by dT, slows calculation down";
// extends BrineProp.PartialFlags_(final nX_salt=size(saltNames, 1));
constant String saltNames[:]={""} "TODO replace by saltorder enumeration";
constant String saltNames[:]=fill("",0);
//{""} "TODO replace by saltorder enumeration";
constant Integer nX_salt = size(saltNames, 1) "Number of salt components" annotation(Evaluate=true);
......@@ -32,7 +33,8 @@ partial package PartialBrineMultiSaltMultiGasTwoPhase "Template medium for aqueo
constant SI.MolarMass[:] MM_vec = cat(1,MM_salt, MM_gas, {M_H2O});
constant Integer[:] nM_vec = cat(1,nM_salt, nM_gas, {1});
constant String gasNames[:]={""};
constant String gasNames[:]=fill("",0);
//{""};
extends BrineProp.GasData(final nX_salt_=nX_salt);
......
......@@ -2,7 +2,8 @@ within BrineProp;
partial package PartialBrineMultiSaltOnePhase "Template medium for one-phase aqueous solution of m Salts and n Gases based on PartialMediaMixtureMedium"
// extends PartialFlags;
constant String saltNames[:]={""} "TODO: replace by saltOrder";
constant String saltNames[:]=fill("",0);
//{""} "TODO: replace by saltOrder";
constant Integer nX_salt = size(saltNames, 1) "Number of salt components" annotation(Evaluate=true);
......
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