www.mooseframework.org
BrineFluidProperties.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "BrineFluidProperties.h"
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<MultiComponentFluidPropertiesPT>();
15  params.addClassDescription("Fluid properties for brine");
16  return params;
17 }
18 
19 BrineFluidProperties::BrineFluidProperties(const InputParameters & parameters)
20  : MultiComponentFluidPropertiesPT(parameters), _Mnacl(58.443e-3)
21 {
22  // Water97FluidProperties UserObject for water (needed to access vapor pressure)
23  std::string water97_name = name() + ":water97";
24  {
25  std::string class_name = "Water97FluidProperties";
26  InputParameters params = _app.getFactory().getValidParams(class_name);
27  _fe_problem.addUserObject(class_name, water97_name, params);
28  }
29  _water97_fp = &_fe_problem.getUserObject<Water97FluidProperties>(water97_name);
30 
31  // SinglePhaseFluidPropertiesPT UserObject for water to provide to getComponent
32  std::string water_name = name() + ":water";
33  {
34  std::string class_name = "Water97FluidProperties";
35  InputParameters params = _app.getFactory().getValidParams(class_name);
36  _fe_problem.addUserObject(class_name, water_name, params);
37  }
38  _water_fp = &_fe_problem.getUserObject<SinglePhaseFluidPropertiesPT>(water_name);
39 
40  // SinglePhaseFluidPropertiesPT UserObject for NaCl to provide to getComponent
41  std::string nacl_name = name() + ":nacl";
42  {
43  std::string class_name = "NaClFluidProperties";
44  InputParameters params = _app.getFactory().getValidParams(class_name);
45  _fe_problem.addUserObject(class_name, nacl_name, params);
46  }
47  _nacl_fp = &_fe_problem.getUserObject<SinglePhaseFluidPropertiesPT>(nacl_name);
48 
49  // Molar mass of NaCl and H20
52 }
53 
55 
58 {
59  switch (component)
60  {
61  case WATER:
62  return *_water_fp;
63 
64  case NACL:
65  return *_nacl_fp;
66 
67  default:
68  mooseError("BrineFluidProperties::getComponent has been provided an incorrect component");
69  }
70 }
71 
72 std::string
74 {
75  return "brine";
76 }
77 
78 Real
80 {
81  return 1.0 / (xnacl / _Mnacl + (1.0 - xnacl) / _Mh2o);
82 }
83 
84 Real
86 {
87  return _Mnacl;
88 }
89 
90 Real
92 {
93  return _Mh2o;
94 }
95 
96 Real
97 BrineFluidProperties::rho(Real pressure, Real temperature, Real xnacl) const
98 {
99  Real n1, n2, n11, n12, n1x1, n20, n21, n22, n23, n2x1, Tv;
100  Real water_density;
101 
102  // The correlation requires the pressure in bar, not Pa.
103  Real pbar = pressure * 1.0e-5;
104  Real pbar2 = pbar * pbar;
105  Real pbar3 = pbar2 * pbar;
106 
107  // The correlation requires mole fraction
108  Real Xnacl = massFractionToMoleFraction(xnacl);
109 
110  n11 = -54.2958 - 45.7623 * std::exp(-9.44785e-4 * pbar);
111  n21 = -2.6142 - 2.39092e-4 * pbar;
112  n22 = 0.0356828 + 4.37235e-6 * pbar + 2.0566e-9 * pbar2;
113  n1x1 = 330.47 + 0.942876 * std::sqrt(pbar) + 0.0817193 * pbar - 2.47556e-8 * pbar2 +
114  3.45052e-10 * pbar3;
115  n2x1 = -0.0370751 + 0.00237723 * std::sqrt(pbar) + 5.42049e-5 * pbar + 5.84709e-9 * pbar2 -
116  5.99373e-13 * pbar3;
117  n12 = -n1x1 - n11;
118  n20 = 1.0 - n21 * std::sqrt(n22);
119  n23 = n2x1 - n20 - n21 * std::sqrt(1.0 + n22);
120 
121  // The temperature Tv where the brine has the same molar volume as pure water
122  // Note: correlation uses temperature in Celcius
123  n1 = n1x1 + n11 * (1.0 - Xnacl) + n12 * (1.0 - Xnacl) * (1.0 - Xnacl);
124  n2 = n20 + n21 * std::sqrt(Xnacl + n22) + n23 * Xnacl;
125  Tv = n1 + n2 * (temperature - _T_c2k);
126 
127  // The density of water at temperature Tv
128  // Note: convert Tv to Kelvin to calculate water density
129  water_density = _water_fp->rho(pressure, Tv + _T_c2k);
130 
131  // The brine density is given by the water density scaled by the ratio of
132  // brine molar mass to pure water molar mass
133  return water_density * molarMass(xnacl) / _Mh2o;
134 }
135 
136 void
138  Real temperature,
139  Real xnacl,
140  Real & rho,
141  Real & drho_dp,
142  Real & drho_dT,
143  Real & drho_dx) const
144 {
145  rho = this->rho(pressure, temperature, xnacl);
146  // Derivatives are calculated using finite differences due to complexity of correlation
147  Real eps = 1.0e-8;
148  Real peps = pressure * eps;
149  Real Teps = temperature * eps;
150  drho_dp = (this->rho(pressure + peps, temperature, xnacl) - rho) / peps;
151  drho_dT = (this->rho(pressure, temperature + Teps, xnacl) - rho) / Teps;
152  drho_dx = (this->rho(pressure, temperature, xnacl + eps) - rho) / eps;
153 }
154 
155 Real
156 BrineFluidProperties::mu_from_rho_T(Real water_density, Real temperature, Real xnacl) const
157 {
158  // Correlation requires molal concentration (mol/kg)
159  Real mol = massFractionToMolalConc(xnacl);
160  Real mol2 = mol * mol;
161  Real mol3 = mol2 * mol;
162 
163  // Correlation requires temperature in C
164  Real Tc = temperature - _T_c2k;
165 
166  Real a = 1.0 + 0.0816 * mol + 0.0122 * mol2 + 0.128e-3 * mol3 +
167  0.629e-3 * Tc * (1.0 - std::exp(-0.7 * mol));
168 
169  return a * _water_fp->mu_from_rho_T(water_density, temperature);
170 }
171 
172 void
174  Real temperature,
175  Real xnacl,
176  Real dwater_density_dT,
177  Real & mu,
178  Real & dmu_drho,
179  Real & dmu_dT,
180  Real & dmu_dx) const
181 {
182  // Viscosity of water and derivatives wrt water density and temperature
183  Real muw, dmuw_drhow, dmuw_dT;
185  water_density, temperature, dwater_density_dT, muw, dmuw_drhow, dmuw_dT);
186 
187  // Correlation requires molal concentration (mol/kg)
188  Real mol = massFractionToMolalConc(xnacl);
189  Real dmol_dx = 1.0 / ((1.0 - xnacl) * (1.0 - xnacl) * _Mnacl);
190  Real mol2 = mol * mol;
191  Real mol3 = mol2 * mol;
192 
193  // Correlation requires temperature in C
194  Real Tc = temperature - _T_c2k;
195 
196  Real a = 1.0 + 0.0816 * mol + 0.0122 * mol2 + 0.128e-3 * mol3 +
197  0.629e-3 * Tc * (1.0 - std::exp(-0.7 * mol));
198  Real da_dx =
199  (0.0816 + 0.0244 * mol + 3.84e-4 * mol2 + 4.403e-4 * Tc * std::exp(-0.7 * mol)) * dmol_dx;
200  Real da_dT = 0.629e-3 * (1.0 - std::exp(-0.7 * mol));
201 
202  mu = a * muw;
203  dmu_drho = a * dmuw_drhow;
204  dmu_dx = da_dx * muw;
205  dmu_dT = da_dT * muw + a * dmuw_dT;
206 }
207 
208 Real
209 BrineFluidProperties::h(Real pressure, Real temperature, Real xnacl) const
210 {
211  Real q1, q2, q10, q11, q12, q20, q21, q22, q23, q1x1, q2x1, Th;
212 
213  // The correlation requires the pressure in bar, not Pa.
214  Real pbar = pressure * 1.0e-5;
215  Real pbar2 = pbar * pbar;
216 
217  // The correlation requires mole fraction
218  Real Xnacl = massFractionToMoleFraction(xnacl);
219 
220  q11 = -32.1724 + 0.0621255 * pbar;
221  q21 = -1.69513 - 4.52781e-4 * pbar - 6.04279e-8 * pbar2;
222  q22 = 0.0612567 + 1.88082e-5 * pbar;
223 
224  q1x1 = 47.9048 - 9.36994e-3 * pbar + 6.51059e-6 * pbar2;
225  q2x1 = 0.241022 + 3.45087e-5 * pbar - 4.28356e-9 * pbar2;
226 
227  q12 = -q11 - q1x1;
228  q10 = q1x1;
229 
230  q20 = 1.0 - q21 * std::sqrt(q22);
231  q23 = q2x1 - q20 - q21 * std::sqrt(1.0 + q22);
232 
233  q1 = q10 + q11 * (1.0 - Xnacl) + q12 * (1.0 - Xnacl) * (1.0 - Xnacl);
234  q2 = q20 + q21 * std::sqrt(Xnacl + q22) + q23 * Xnacl;
235  // The temperature Th where the brine has the same enthalpy as pure water
236  // Note: correlation uses temperature in Celcius
237  Th = q1 + q2 * (temperature - _T_c2k);
238 
239  // The brine enthalpy is then given by the enthalpy of water at temperature Th
240  // Note: water enthalpy requires temperature in Kelvin
241  return _water_fp->h(pressure, Th + _T_c2k);
242 }
243 
244 void
246  Real temperature,
247  Real xnacl,
248  Real & h,
249  Real & dh_dp,
250  Real & dh_dT,
251  Real & dh_dx) const
252 {
253  h = this->h(pressure, temperature, xnacl);
254  // Derivatives are calculated using finite differences due to complexity of correlation
255  Real eps = 1.0e-8;
256  Real peps = pressure * eps;
257  Real Teps = temperature * eps;
258  dh_dp = (this->h(pressure + peps, temperature, xnacl) - h) / peps;
259  dh_dT = (this->h(pressure, temperature + Teps, xnacl) - h) / Teps;
260  dh_dx = (this->h(pressure, temperature, xnacl + eps) - h) / eps;
261 }
262 
263 Real
264 BrineFluidProperties::cp(Real pressure, Real temperature, Real xnacl) const
265 {
266  Real q1, q2, q10, q11, q12, q20, q21, q22, q23, q1x1, q2x1, Th;
267 
268  // The correlation requires the pressure in bar, not Pa.
269  Real pbar = pressure * 1.0e-5;
270  Real pbar2 = pbar * pbar;
271 
272  // The correlation requires mole fraction
273  Real Xnacl = massFractionToMoleFraction(xnacl);
274 
275  q11 = -32.1724 + 0.0621255 * pbar;
276  q21 = -1.69513 - 4.52781e-4 * pbar - 6.04279e-8 * pbar2;
277  q22 = 0.0612567 + 1.88082e-5 * pbar;
278 
279  q1x1 = 47.9048 - 9.36994e-3 * pbar + 6.51059e-6 * pbar2;
280  q2x1 = 0.241022 + 3.45087e-5 * pbar - 4.28356e-9 * pbar2;
281 
282  q12 = -q11 - q1x1;
283  q10 = q1x1;
284 
285  q20 = 1.0 - q21 * std::sqrt(q22);
286  q23 = q2x1 - q20 - q21 * std::sqrt(1.0 + q22);
287 
288  q1 = q10 + q11 * (1.0 - Xnacl) + q12 * (1.0 - Xnacl) * (1.0 - Xnacl);
289  q2 = q20 + q21 * std::sqrt(Xnacl + q22) + q23 * Xnacl;
290  // The temperature Th where the brine has the same isobaric heat capacity
291  // as pure water. Note: correlation uses temperature in Celcius
292  Th = q1 + q2 * (temperature - _T_c2k);
293 
294  // The brine isobaric heat capacity is then given by the isobaric heat
295  // capacity of water at temperature Th multiplied by q2
296  // Note: water isobaric heat capacity requires temperature in Kelvin
297  return q2 * _water_fp->cp(pressure, Th + _T_c2k);
298 }
299 
300 Real
301 BrineFluidProperties::e(Real pressure, Real temperature, Real xnacl) const
302 {
303  Real enthalpy = h(pressure, temperature, xnacl);
304  Real density = rho(pressure, temperature, xnacl);
305 
306  return enthalpy - pressure / density;
307 }
308 
309 void
311  Real temperature,
312  Real xnacl,
313  Real & e,
314  Real & de_dp,
315  Real & de_dT,
316  Real & de_dx) const
317 {
318  e = this->e(pressure, temperature, xnacl);
319  // Derivatives are calculated using finite differences due to complexity of correlation
320  Real eps = 1.0e-8;
321  Real peps = pressure * eps;
322  Real Teps = temperature * eps;
323  de_dp = (this->e(pressure + peps, temperature, xnacl) - e) / peps;
324  de_dT = (this->e(pressure, temperature + Teps, xnacl) - e) / Teps;
325  de_dx = (this->e(pressure, temperature, xnacl + eps) - e) / eps;
326 }
327 
328 Real
329 BrineFluidProperties::k_from_rho_T(Real water_density, Real temperature, Real xnacl) const
330 {
331  // Correlation requires molal concentration (mol/kg)
332  Real mol = massFractionToMolalConc(xnacl);
333  // Correlation requires temperature in C
334  Real Tc = temperature - _T_c2k;
335 
336  Real S = 100.0 * _Mnacl * mol / (1.0 + _Mnacl * mol);
337  Real lambdaw = _water_fp->k_from_rho_T(water_density, temperature);
338  Real lambda = 1.0 - (2.3434e-3 - 7.924e-6 * Tc + 3.924e-8 * Tc * Tc) * S +
339  (1.06e-5 - 2.0e-8 * Tc - 1.2e-10 * Tc * Tc) * S * S;
340 
341  return lambda * lambdaw;
342 }
343 
344 Real
346 {
347  // Correlation requires molal concentration (mol/kg)
348  Real mol = massFractionToMolalConc(xnacl);
349  Real mol2 = mol * mol;
350  Real mol3 = mol2 * mol;
351 
352  Real a = 1.0 + 5.93582e-6 * mol - 5.19386e-5 * mol2 + 1.23156e-5 * mol3;
353  Real b = 1.1542e-6 * mol + 1.41254e-7 * mol2 - 1.92476e-8 * mol3 - 1.70717e-9 * mol * mol3 +
354  1.0539e-10 * mol2 * mol3;
355 
356  // The temperature of pure water at the same pressure as the brine is given by
357  Real th20 = std::exp(std::log(temperature) / (a + b * temperature));
358 
359  // The brine vapour pressure is then found by evaluating the saturation pressure for pure water
360  // using this effective temperature. Note: requires _water97_fp UserObject
361  return _water97_fp->vaporPressure(th20);
362 }
363 
364 Real
366 {
367  // This correlation requires temperature in Celcius
368  Real Tc = temperature - _T_c2k;
369 
370  return (26.18 + 7.2e-3 * Tc + 1.06e-4 * Tc * Tc) / 100.0;
371 }
372 
373 Real
375 {
376  return xnacl / ((1.0 - xnacl) * _Mnacl);
377 }
378 
379 Real
381 {
382  // The average molar mass of brine from the mass fraction
383  Real Mbrine = molarMass(xnacl);
384  // The mole fraction is then
385  return xnacl * Mbrine / _Mnacl;
386 }
Real massFractionToMolalConc(Real xnacl) const
Conversion from mass fraction to molal concentration (molality)
const SinglePhaseFluidPropertiesPT * _nacl_fp
NaClFluidProperties UserObject.
Real molarMass(Real xnacl) const
Average molar mass of brine.
virtual Real cp(Real pressure, Real temperature) const =0
Isobaric specific heat capacity.
virtual void rho_dpTx(Real pressure, Real temperature, Real xnacl, Real &rho, Real &drho_dp, Real &drho_dT, Real &drho_dx) const override
Density and its derivatives wrt pressure, temperature and mass fraction.
const Water97FluidProperties * _water97_fp
Water97FluidProperties UserObject.
const std::string density
Definition: NS.h:15
Real component(const SymmTensor &symm_tensor, unsigned int index)
virtual Real mu_from_rho_T(Real density, Real temperature) const =0
const std::string temperature
Definition: NS.h:25
virtual std::string fluidName() const override
Fluid name.
InputParameters validParams< BrineFluidProperties >()
const std::string enthalpy
Definition: NS.h:26
const Real _T_c2k
Conversion of temperature from Celcius to Kelvin.
Common class for single phase fluid properties using a pressure and temperature formulation.
virtual void h_dpTx(Real pressure, Real temperature, Real xnacl, Real &h, Real &dh_dp, Real &dh_dT, Real &dh_dx) const override
Enthalpy and derivatives wrt pressure, temperature and mass fraction.
virtual Real rho(Real pressure, Real temperature, Real xnacl) const override
Density.
static const unsigned int NACL
virtual Real molarMass() const =0
Molar mass.
Real _Mnacl
Molar mass of NaCl (kg/mol)
InputParameters validParams< MultiComponentFluidPropertiesPT >()
virtual Real cp(Real pressure, Real temperature, Real xnacl) const override
Isobaric specific heat capacity.
Real vaporPressure(Real temperature) const
Saturation pressure as a function of temperature.
virtual void mu_drhoT_from_rho_T(Real density, Real temperature, Real ddensity_dT, Real &mu, Real &dmu_drho, Real &dmu_dT) const =0
Dynamic viscosity and its derivatives wrt density and temperature.
BrineFluidProperties(const InputParameters &parameters)
Real vaporPressure(Real temperature, Real xnacl) const
Brine vapour pressure From Haas, Physical properties of the coexisting phases and thermochemical prop...
virtual Real e(Real pressure, Real temperature, Real xnacl) const override
Internal energy.
virtual Real k_from_rho_T(Real water_density, Real temperature, Real xnacl) const override
Thermal conductivity.
virtual Real h(Real p, Real T) const =0
Specific enthalpy.
Real _Mh2o
Molar mass of water (H2O) (kg/mol)
virtual Real rho(Real pressure, Real temperature) const =0
Density.
Water (H2O) fluid properties as a function of pressure (Pa) and temperature (K) from IAPWS-IF97: Revi...
const std::string pressure
Definition: NS.h:24
virtual Real mu_from_rho_T(Real water_density, Real temperature, Real xnacl) const override
Real molarMassNaCl() const
NaCl molar mass.
Real haliteSolubility(Real temperature) const
Solubility of halite (solid NaCl) in water Originally from Potter et al., A new method for determinin...
virtual const SinglePhaseFluidPropertiesPT & getComponent(unsigned int component) const override
Get UserObject for specified component.
virtual Real h(Real pressure, Real temperature, Real xnacl) const override
Enthalpy.
Real massFractionToMoleFraction(Real xnacl) const
Conversion from mass fraction to mole fraction.
virtual Real k_from_rho_T(Real density, Real temperature) const =0
Thermal conductivity as a function of density and temperature.
Common class for multiple component fluid properties using a pressure and temperature formulation...
Real molarMassH2O() const
H2O molar mass.
virtual void mu_drhoTx(Real water_density, Real temperature, Real xnacl, Real dwater_density_dT, Real &mu, Real &dmu_drho, Real &dmu_dT, Real &dmu_dx) const override
Dynamic viscosity and its derivatives wrt density, temperature and mass fraction. ...
virtual void e_dpTx(Real pressure, Real temperature, Real xnacl, Real &e, Real &de_dp, Real &de_dT, Real &de_dx) const override
Internal energy and its derivatives wrt pressure, temperature and mass fraction.
static const unsigned int WATER
Fluid component numbers for water and NaCl.
const SinglePhaseFluidPropertiesPT * _water_fp
Water97FluidProperties UserObject.