23 EXPECT_EQ((
unsigned int)2, _fs->numPhases());
24 EXPECT_EQ((
unsigned int)3, _fs->numComponents());
25 EXPECT_EQ((
unsigned int)0, _fs->aqueousPhaseIndex());
26 EXPECT_EQ((
unsigned int)1, _fs->gasPhaseIndex());
27 EXPECT_EQ((
unsigned int)0, _fs->aqueousComponentIndex());
28 EXPECT_EQ((
unsigned int)1, _fs->gasComponentIndex());
29 EXPECT_EQ((
unsigned int)2, _fs->saltComponentIndex());
40 const Real dT = 1.0e-6;
42 ADReal K0H2O = _fs->equilibriumConstantH2O(T);
43 ADReal K0CO2 = _fs->equilibriumConstantCO2(T);
45 ABS_TEST(K0H2O.value(), 0.412597711705, 1.0e-10);
46 ABS_TEST(K0CO2.value(), 74.0435888596, 1.0e-10);
48 Real K0H2O_2 = _fs->equilibriumConstantH2O(T + dT).value();
49 Real K0CO2_2 = _fs->equilibriumConstantCO2(T + dT).value();
51 Real dK0H2O_dT_fd = (K0H2O_2 - K0H2O.value()) / dT;
52 Real dK0CO2_dT_fd = (K0CO2_2 - K0CO2.value()) / dT;
53 REL_TEST(K0H2O.derivatives()[_Tidx], dK0H2O_dT_fd, 1.0e-6);
54 REL_TEST(K0CO2.derivatives()[_Tidx], dK0CO2_dT_fd, 1.0e-6);
60 K0H2O = _fs->equilibriumConstantH2O(T);
61 K0CO2 = _fs->equilibriumConstantCO2(T);
63 ABS_TEST(K0H2O.value(), 8.75944517916, 1.0e-10);
64 ABS_TEST(K0CO2.value(), 105.013867434, 1.0e-10);
66 K0H2O_2 = _fs->equilibriumConstantH2O(T + dT).value();
67 K0CO2_2 = _fs->equilibriumConstantCO2(T + dT).value();
69 dK0H2O_dT_fd = (K0H2O_2 - K0H2O.value()) / dT;
70 dK0CO2_dT_fd = (K0CO2_2 - K0CO2.value()) / dT;
71 REL_TEST(K0H2O.derivatives()[_Tidx], dK0H2O_dT_fd, 1.0e-6);
72 REL_TEST(K0CO2.derivatives()[_Tidx], dK0CO2_dT_fd, 1.0e-6);
90 ADReal co2_density = _co2_fp->rho_from_p_T(p, T);
93 _fs->fugacityCoefficientsLowTemp(p, T, co2_density, phiCO2, phiH2O);
94 ABS_TEST(phiCO2.value(), 0.401939386415, 1.0e-8);
95 ABS_TEST(phiH2O.value(), 0.0898968578757, 1.0e-8);
101 co2_density = _co2_fp->rho_from_p_T(p, T);
103 _fs->solveEquilibriumMoleFractionHighTemp(
104 p.value(), T.value(), Xnacl.value(), co2_density.value(), xco2.value(), yh2o.value());
105 phiH2O = _fs->fugacityCoefficientH2OHighTemp(p, T, co2_density, xco2, yh2o);
106 phiCO2 = _fs->fugacityCoefficientCO2HighTemp(p, T, co2_density, xco2, yh2o);
108 ABS_TEST(phiH2O.value(), 0.156303437579, 1.0e-8);
109 ABS_TEST(phiCO2.value(), 0.641936639599, 1.0e-8);
112 ADReal phiCO2_2, phiH2O_2;
113 _fs->fugacityCoefficientsHighTemp(p, T, co2_density, xco2, yh2o, phiCO2_2, phiH2O_2);
115 ABS_TEST(phiH2O, phiH2O_2, 1.0e-12);
116 ABS_TEST(phiCO2, phiCO2_2, 1.0e-12);
127 ADReal gammaH2O = _fs->activityCoefficientH2O(T, xco2);
128 ADReal gammaCO2 = _fs->activityCoefficientCO2(T, xco2);
130 ABS_TEST(gammaH2O.value(), 1.0, 1.0e-10);
131 ABS_TEST(gammaCO2.value(), 1.0, 1.0e-10);
135 gammaH2O = _fs->activityCoefficientH2O(T, xco2);
136 gammaCO2 = _fs->activityCoefficientCO2(T, xco2);
138 ABS_TEST(gammaH2O.value(), 1.00022113664, 1.0e-10);
139 ABS_TEST(gammaCO2.value(), 0.956736800255, 1.0e-10);
157 const Real dp = 1.0e-1;
158 const Real dT = 1.0e-6;
159 const Real dx = 1.0e-8;
162 ADReal gamma = _fs->activityCoefficient(p, T, Xnacl);
163 ABS_TEST(gamma.value(), 1.43276649338, 1.0e-8);
165 ADReal gamma_2 = _fs->activityCoefficient(p + dp, T, Xnacl);
167 Real dgamma_dp_fd = (gamma_2.value() - gamma.value()) / dp;
168 REL_TEST(gamma.derivatives()[_pidx], dgamma_dp_fd, 1.0e-6);
170 gamma_2 = _fs->activityCoefficient(p, T + dT, Xnacl);
172 Real dgamma_dT_fd = (gamma_2.value() - gamma.value()) / dT;
173 REL_TEST(gamma.derivatives()[_Tidx], dgamma_dT_fd, 1.0e-6);
175 gamma_2 = _fs->activityCoefficient(p, T, Xnacl + dx);
177 Real dgamma_dX_fd = (gamma_2.value() - gamma.value()) / dx;
178 REL_TEST(gamma.derivatives()[_Xidx], dgamma_dX_fd, 1.0e-6);
184 gamma = _fs->activityCoefficientHighTemp(T, Xnacl);
185 ABS_TEST(gamma.value(), 1.50047006243, 1.0e-8);
187 gamma_2 = _fs->activityCoefficientHighTemp(T + dT, Xnacl);
188 dgamma_dT_fd = (gamma_2.value() - gamma.value()) / dT;
189 REL_TEST(gamma.derivatives()[_Tidx], dgamma_dT_fd, 1.0e-6);
191 gamma_2 = _fs->activityCoefficientHighTemp(T, Xnacl + dx);
192 dgamma_dX_fd = (gamma_2.value() - gamma.value()) / dx;
193 REL_TEST(gamma.derivatives()[_Xidx], dgamma_dX_fd, 1.0e-6);
198 gamma = _fs->activityCoefficient(p, T, Xnacl);
199 ABS_TEST(gamma.value(), 1.0, 1.0e-12);
202 gamma = _fs->activityCoefficientHighTemp(T, Xnacl);
203 ABS_TEST(gamma.value(), 1.0, 1.0e-12);
214 const Real dT = 1.0e-6;
216 ADReal partial_density = _fs->partialDensityCO2(T);
217 ABS_TEST(partial_density.value(), 893.332, 1.0e-3);
219 ADReal partial_density_2 = _fs->partialDensityCO2(T + dT);
221 Real dpartial_density_dT_fd = (partial_density_2.value() - partial_density.value()) / dT;
222 REL_TEST(partial_density.derivatives()[_Tidx], dpartial_density_dT_fd, 1.0e-6);
240 const Real dp = 1.0e-2;
241 const Real dT = 1.0e-6;
242 const Real dx = 1.0e-8;
245 _fs->equilibriumMassFractions(p, T, Xnacl, X, Y);
247 ABS_TEST(X.value(), 0.0035573020148, 1.0e-10);
248 ABS_TEST(Y.value(), 0.0171977397214, 1.0e-10);
252 _fs->equilibriumMassFractions(p - dp, T, Xnacl, X1, Y1);
253 _fs->equilibriumMassFractions(p + dp, T, Xnacl, X2, Y2);
255 Real dX_dp_fd = (X2.value() - X1.value()) / (2.0 * dp);
256 Real dY_dp_fd = (Y2.value() - Y1.value()) / (2.0 * dp);
258 REL_TEST(X.derivatives()[_pidx], dX_dp_fd, 1.0e-6);
259 REL_TEST(Y.derivatives()[_pidx], dY_dp_fd, 1.0e-6);
262 _fs->equilibriumMassFractions(p, T - dT, Xnacl, X1, Y1);
263 _fs->equilibriumMassFractions(p, T + dT, Xnacl, X2, Y2);
265 Real dX_dT_fd = (X2.value() - X1.value()) / (2.0 * dT);
266 Real dY_dT_fd = (Y2.value() - Y1.value()) / (2.0 * dT);
268 REL_TEST(X.derivatives()[_Tidx], dX_dT_fd, 1.0e-6);
269 REL_TEST(Y.derivatives()[_Tidx], dY_dT_fd, 1.0e-6);
272 _fs->equilibriumMassFractions(p, T, Xnacl - dx, X1, Y1);
273 _fs->equilibriumMassFractions(p, T, Xnacl + dx, X2, Y2);
275 Real dX_dX_fd = (X2.value() - X1.value()) / (2.0 * dx);
276 Real dY_dX_fd = (Y2.value() - Y1).
value() / (2.0 * dx);
278 REL_TEST(X.derivatives()[_Xidx], dX_dX_fd, 1.0e-6);
279 REL_TEST(Y.derivatives()[_Xidx], dY_dX_fd, 1.0e-6);
288 _fs->equilibriumMassFractions(p, T, Xnacl, X, Y);
290 ABS_TEST(X.value(), 0.016299479086, 1.0e-10);
291 ABS_TEST(Y.value(), 0.249471400766, 1.0e-10);
310 const unsigned int np = _fs->numPhases();
311 const unsigned int nc = _fs->numComponents();
318 _fs->massFractions(p, T, Xnacl,
Z, phase_state, fsp);
322 ADReal Xco2 = fsp[0].mass_fraction[1];
323 ADReal Yco2 = fsp[1].mass_fraction[1];
324 ADReal Xh2o = fsp[0].mass_fraction[0];
325 ADReal Yh2o = fsp[1].mass_fraction[0];
326 ADReal Xnacl2 = fsp[0].mass_fraction[2];
327 ABS_TEST(Xco2.value(),
Z.value(), 1.0e-8);
328 ABS_TEST(Yco2.value(), 0.0, 1.0e-8);
329 ABS_TEST(Xh2o.value(), 1.0 -
Z.value(), 1.0e-8);
330 ABS_TEST(Yh2o.value(), 0.0, 1.0e-8);
331 ABS_TEST(Xnacl2.value(), Xnacl.value(), 1.0e-8);
334 ABS_TEST(Xco2.derivatives()[_pidx], 0.0, 1.0e-8);
335 ABS_TEST(Xco2.derivatives()[_Tidx], 0.0, 1.0e-8);
336 ABS_TEST(Xco2.derivatives()[_Xidx], 0.0, 1.0e-8);
337 ABS_TEST(Xco2.derivatives()[_Zidx], 1.0, 1.0e-8);
338 ABS_TEST(Yco2.derivatives()[_pidx], 0.0, 1.0e-8);
339 ABS_TEST(Yco2.derivatives()[_Tidx], 0.0, 1.0e-8);
340 ABS_TEST(Yco2.derivatives()[_Xidx], 0.0, 1.0e-8);
341 ABS_TEST(Yco2.derivatives()[_Zidx], 0.0, 1.0e-8);
342 ABS_TEST(Xnacl.derivatives()[_Xidx], 1.0, 1.0e-8);
348 _fs->massFractions(p, T, Xnacl,
Z, phase_state, fsp);
352 Xco2 = fsp[0].mass_fraction[1];
353 Yco2 = fsp[1].mass_fraction[1];
354 Xh2o = fsp[0].mass_fraction[0];
355 Yh2o = fsp[1].mass_fraction[0];
356 ADReal Ynacl = fsp[1].mass_fraction[2];
357 ABS_TEST(Xco2.value(), 0.0, 1.0e-8);
358 ABS_TEST(Yco2.value(),
Z.value(), 1.0e-8);
359 ABS_TEST(Xh2o.value(), 0.0, 1.0e-8);
360 ABS_TEST(Yh2o.value(), 1.0 -
Z.value(), 1.0e-8);
361 ABS_TEST(Ynacl.value(), 0.0, 1.0e-8);
364 ABS_TEST(Xco2.derivatives()[_pidx], 0.0, 1.0e-8);
365 ABS_TEST(Xco2.derivatives()[_Tidx], 0.0, 1.0e-8);
366 ABS_TEST(Xco2.derivatives()[_Xidx], 0.0, 1.0e-8);
367 ABS_TEST(Xco2.derivatives()[_Zidx], 0.0, 1.0e-8);
368 ABS_TEST(Yco2.derivatives()[_pidx], 0.0, 1.0e-8);
369 ABS_TEST(Yco2.derivatives()[_Tidx], 0.0, 1.0e-8);
370 ABS_TEST(Yco2.derivatives()[_Xidx], 0.0, 1.0e-8);
371 ABS_TEST(Yco2.derivatives()[_Zidx], 1.0, 1.0e-8);
372 ABS_TEST(Ynacl.derivatives()[_Xidx], 0.0, 1.0e-8);
380 _fs->massFractions(p, T, Xnacl,
Z, phase_state, fsp);
385 _fs->equilibriumMassFractions(p, T, Xnacl, Xco2_eq, Yh2o_eq);
389 Xco2 = fsp[0].mass_fraction[1];
390 Yco2 = fsp[1].mass_fraction[1];
391 Xh2o = fsp[0].mass_fraction[0];
392 Yh2o = fsp[1].mass_fraction[0];
393 ABS_TEST(Xco2, Xco2_eq, 1.0e-8);
394 ABS_TEST(Yco2, 1.0 - Yh2o_eq, 1.0e-8);
395 ABS_TEST(Xh2o, 1.0 - Xco2_eq, 1.0e-8);
396 ABS_TEST(Yh2o, Yh2o_eq, 1.0e-8);
399 const Real dZ = 1.0e-8;
400 _fs->massFractions(p, T, Xnacl,
Z + dZ, phase_state, fsp);
401 ADReal Xco21 = fsp[0].mass_fraction[1];
402 ADReal Yco21 = fsp[1].mass_fraction[1];
403 _fs->massFractions(p, T, Xnacl,
Z - dZ, phase_state, fsp);
404 ADReal Xco22 = fsp[0].mass_fraction[1];
405 ADReal Yco22 = fsp[1].mass_fraction[1];
407 ABS_TEST(Xco2.derivatives()[_Zidx], (Xco21.value() - Xco22.value()) / (2.0 * dZ), 1.0e-8);
408 ABS_TEST(Yco2.derivatives()[_Zidx], (Yco21.value() - Yco22.value()) / (2.0 * dZ), 1.0e-8);
428 const unsigned int np = _fs->numPhases();
429 const unsigned int nc = _fs->numComponents();
436 _fs->massFractions(p, T, Xnacl,
Z, phase_state, fsp);
440 _fs->gasProperties(p, T, fsp);
441 ADReal gas_density = fsp[1].density;
442 ADReal gas_viscosity = fsp[1].viscosity;
443 ADReal gas_enthalpy = fsp[1].enthalpy;
445 Real density = _co2_fp->rho_from_p_T(p.value(), T.value());
446 Real viscosity = _co2_fp->mu_from_p_T(p.value(), T.value());
447 Real enthalpy = _co2_fp->h_from_p_T(p.value(), T.value());
449 ABS_TEST(gas_density.value(),
density, 1.0e-8);
450 ABS_TEST(gas_viscosity.value(), viscosity, 1.0e-8);
451 ABS_TEST(gas_enthalpy.value(), enthalpy, 1.0e-8);
454 const Real dp = 1.0e-1;
455 _fs->gasProperties(p + dp, T, fsp);
456 Real rho1 = fsp[1].density.value();
457 Real mu1 = fsp[1].viscosity.value();
458 Real h1 = fsp[1].enthalpy.value();
460 _fs->gasProperties(p - dp, T, fsp);
461 Real rho2 = fsp[1].density.value();
462 Real mu2 = fsp[1].viscosity.value();
463 Real h2 = fsp[1].enthalpy.value();
465 REL_TEST(gas_density.derivatives()[_pidx], (rho1 - rho2) / (2.0 * dp), 1.0e-6);
466 REL_TEST(gas_viscosity.derivatives()[_pidx], (mu1 - mu2) / (2.0 * dp), 1.0e-6);
467 REL_TEST(gas_enthalpy.derivatives()[_pidx], (h1 - h2) / (2.0 * dp), 1.0e-6);
469 const Real dT = 1.0e-3;
470 _fs->gasProperties(p, T + dT, fsp);
471 rho1 = fsp[1].density.value();
472 mu1 = fsp[1].viscosity.value();
473 h1 = fsp[1].enthalpy.value();
475 _fs->gasProperties(p, T - dT, fsp);
476 rho2 = fsp[1].density.value();
477 mu2 = fsp[1].viscosity.value();
478 h2 = fsp[1].enthalpy.value();
480 REL_TEST(gas_density.derivatives()[_Tidx], (rho1 - rho2) / (2.0 * dT), 1.0e-6);
481 REL_TEST(gas_viscosity.derivatives()[_Tidx], (mu1 - mu2) / (2.0 * dT), 1.0e-6);
482 REL_TEST(gas_enthalpy.derivatives()[_Tidx], (h1 - h2) / (2.0 * dT), 1.0e-6);
485 const Real dZ = 1.0e-8;
486 _fs->massFractions(p, T, Xnacl,
Z + dZ, phase_state, fsp);
487 _fs->gasProperties(p, T, fsp);
488 rho1 = fsp[1].density.value();
489 mu1 = fsp[1].viscosity.value();
490 h1 = fsp[1].enthalpy.value();
492 _fs->massFractions(p, T, Xnacl,
Z - dZ, phase_state, fsp);
493 _fs->gasProperties(p, T, fsp);
494 rho2 = fsp[1].density.value();
495 mu2 = fsp[1].viscosity.value();
496 h2 = fsp[1].enthalpy.value();
498 ABS_TEST(gas_density.derivatives()[_Zidx], (rho1 - rho2) / (2.0 * dZ), 1.0e-8);
499 ABS_TEST(gas_viscosity.derivatives()[_Zidx], (mu1 - mu2) / (2.0 * dZ), 1.0e-8);
500 ABS_TEST(gas_enthalpy.derivatives()[_Zidx], (h1 - h2) / (2.0 * dZ), 1.0e-6);
518 const unsigned int np = _fs->numPhases();
519 const unsigned int nc = _fs->numComponents();
526 _fs->massFractions(p, T, Xnacl,
Z, phase_state, fsp);
530 _fs->liquidProperties(p, T, Xnacl, fsp);
532 ADReal liquid_density = fsp[0].density;
533 ADReal liquid_viscosity = fsp[0].viscosity;
534 ADReal liquid_enthalpy = fsp[0].enthalpy;
536 Real co2_partial_density = _fs->partialDensityCO2(T).value();
537 Real brine_density = _brine_fp->rho_from_p_T_X(p.value(), T.value(), Xnacl.value());
539 Real density = 1.0 / (
Z.value() / co2_partial_density + (1.0 -
Z.value()) / brine_density);
541 Real viscosity = _brine_fp->mu_from_p_T_X(p.value(), T.value(), Xnacl.value());
543 Real brine_enthalpy = _brine_fp->h_from_p_T_X(p.value(), T.value(), Xnacl.value());
544 Real hdis = _fs->enthalpyOfDissolution(T).value();
545 Real co2_enthalpy = _co2_fp->h_from_p_T(p.value(), T.value());
546 Real enthalpy = (1.0 -
Z.value()) * brine_enthalpy +
Z.value() * (co2_enthalpy + hdis);
548 ABS_TEST(liquid_density.value(),
density, 1.0e-12);
549 ABS_TEST(liquid_viscosity.value(), viscosity, 1.0e-12);
551 ABS_TEST(liquid_enthalpy.value(), enthalpy, 3.e-10);
556 _fs->liquidProperties(p + dp, T, Xnacl, fsp);
557 Real rho1 = fsp[0].density.value();
558 Real mu1 = fsp[0].viscosity.value();
559 Real h1 = fsp[0].enthalpy.value();
561 _fs->liquidProperties(p - dp, T, Xnacl, fsp);
562 Real rho2 = fsp[0].density.value();
563 Real mu2 = fsp[0].viscosity.value();
564 Real h2 = fsp[0].enthalpy.value();
566 REL_TEST(liquid_density.derivatives()[_pidx], (rho1 - rho2) / (2.0 * dp), 1.0e-6);
567 REL_TEST(liquid_viscosity.derivatives()[_pidx], (mu1 - mu2) / (2.0 * dp), 2.0e-6);
568 REL_TEST(liquid_enthalpy.derivatives()[_pidx], (h1 - h2) / (2.0 * dp), 1.0e-6);
571 const Real dT = 1.0e-4;
572 _fs->liquidProperties(p, T + dT, Xnacl, fsp);
573 rho1 = fsp[0].density.value();
574 mu1 = fsp[0].viscosity.value();
575 h1 = fsp[0].enthalpy.value();
577 _fs->liquidProperties(p, T - dT, Xnacl, fsp);
578 rho2 = fsp[0].density.value();
579 mu2 = fsp[0].viscosity.value();
580 h2 = fsp[0].enthalpy.value();
582 REL_TEST(liquid_density.derivatives()[_Tidx], (rho1 - rho2) / (2.0 * dT), 1.0e-6);
583 REL_TEST(liquid_viscosity.derivatives()[_Tidx], (mu1 - mu2) / (2.0 * dT), 1.0e-6);
584 REL_TEST(liquid_enthalpy.derivatives()[_Tidx], (h1 - h2) / (2.0 * dT), 1.0e-6);
587 const Real dx = 1.0e-8;
588 _fs->liquidProperties(p, T, Xnacl + dx, fsp);
589 rho1 = fsp[0].density.value();
590 mu1 = fsp[0].viscosity.value();
591 h1 = fsp[0].enthalpy.value();
593 _fs->liquidProperties(p, T, Xnacl - dx, fsp);
594 rho2 = fsp[0].density.value();
595 mu2 = fsp[0].viscosity.value();
596 h2 = fsp[0].enthalpy.value();
598 REL_TEST(liquid_density.derivatives()[_Xidx], (rho1 - rho2) / (2.0 * dx), 1.0e-6);
599 REL_TEST(liquid_viscosity.derivatives()[_Xidx], (mu1 - mu2) / (2.0 * dx), 1.0e-6);
600 REL_TEST(liquid_enthalpy.derivatives()[_Xidx], (h1 - h2) / (2.0 * dx), 1.0e-6);
603 const Real dZ = 1.0e-8;
604 _fs->massFractions(p, T, Xnacl,
Z + dZ, phase_state, fsp);
605 _fs->liquidProperties(p, T, Xnacl, fsp);
606 rho1 = fsp[0].density.value();
607 mu1 = fsp[0].viscosity.value();
608 h1 = fsp[0].enthalpy.value();
610 _fs->massFractions(p, T, Xnacl,
Z - dZ, phase_state, fsp);
611 _fs->liquidProperties(p, T, Xnacl, fsp);
612 rho2 = fsp[0].density.value();
613 mu2 = fsp[0].viscosity.value();
614 h2 = fsp[0].enthalpy.value();
616 REL_TEST(liquid_density.derivatives()[_Zidx], (rho1 - rho2) / (2.0 * dZ), 1.0e-6);
617 ABS_TEST(liquid_viscosity.derivatives()[_Zidx], (mu1 - mu2) / (2.0 * dZ), 1.0e-6);
618 REL_TEST(liquid_enthalpy.derivatives()[_Zidx], (h1 - h2) / (2.0 * dZ), 1.0e-6);
624 _fs->massFractions(p, T, Xnacl,
Z, phase_state, fsp);
628 _fs->liquidProperties(p, T, Xnacl, fsp);
630 liquid_density = fsp[0].density;
631 liquid_viscosity = fsp[0].viscosity;
632 liquid_enthalpy = fsp[0].enthalpy;
635 _fs->massFractions(p + dp, T, Xnacl,
Z, phase_state, fsp);
636 _fs->liquidProperties(p + dp, T, Xnacl, fsp);
637 rho1 = fsp[0].density.value();
638 mu1 = fsp[0].viscosity.value();
639 h1 = fsp[0].enthalpy.value();
641 _fs->massFractions(p - dp, T, Xnacl,
Z, phase_state, fsp);
642 _fs->liquidProperties(p - dp, T, Xnacl, fsp);
643 rho2 = fsp[0].density.value();
644 mu2 = fsp[0].viscosity.value();
645 h2 = fsp[0].enthalpy.value();
647 REL_TEST(liquid_density.derivatives()[_pidx], (rho1 - rho2) / (2.0 * dp), 1.0e-6);
648 REL_TEST(liquid_viscosity.derivatives()[_pidx], (mu1 - mu2) / (2.0 * dp), 2.0e-6);
649 REL_TEST(liquid_enthalpy.derivatives()[_pidx], (h1 - h2) / (2.0 * dp), 1.0e-6);
652 _fs->massFractions(p, T + dT, Xnacl,
Z, phase_state, fsp);
653 _fs->liquidProperties(p, T + dT, Xnacl, fsp);
654 rho1 = fsp[0].density.value();
655 mu1 = fsp[0].viscosity.value();
656 h1 = fsp[0].enthalpy.value();
658 _fs->massFractions(p, T - dT, Xnacl,
Z, phase_state, fsp);
659 _fs->liquidProperties(p, T - dT, Xnacl, fsp);
660 rho2 = fsp[0].density.value();
661 mu2 = fsp[0].viscosity.value();
662 h2 = fsp[0].enthalpy.value();
664 REL_TEST(liquid_density.derivatives()[_Tidx], (rho1 - rho2) / (2.0 * dT), 1.0e-6);
665 REL_TEST(liquid_viscosity.derivatives()[_Tidx], (mu1 - mu2) / (2.0 * dT), 1.0e-6);
666 REL_TEST(liquid_enthalpy.derivatives()[_Tidx], (h1 - h2) / (2.0 * dT), 1.0e-6);
669 _fs->massFractions(p, T, Xnacl + dx,
Z, phase_state, fsp);
670 _fs->liquidProperties(p, T, Xnacl + dx, fsp);
671 rho1 = fsp[0].density.value();
672 mu1 = fsp[0].viscosity.value();
673 h1 = fsp[0].enthalpy.value();
675 _fs->massFractions(p, T, Xnacl - dx,
Z, phase_state, fsp);
676 _fs->liquidProperties(p, T, Xnacl - dx, fsp);
677 rho2 = fsp[0].density.value();
678 mu2 = fsp[0].viscosity.value();
679 h2 = fsp[0].enthalpy.value();
681 REL_TEST(liquid_density.derivatives()[_Xidx], (rho1 - rho2) / (2.0 * dx), 1.0e-6);
682 REL_TEST(liquid_viscosity.derivatives()[_Xidx], (mu1 - mu2) / (2.0 * dx), 1.0e-6);
683 REL_TEST(liquid_enthalpy.derivatives()[_Xidx], (h1 - h2) / (2.0 * dx), 1.0e-6);
686 _fs->massFractions(p, T, Xnacl,
Z + dZ, phase_state, fsp);
687 _fs->liquidProperties(p, T, Xnacl, fsp);
688 rho1 = fsp[0].density.value();
689 mu1 = fsp[0].viscosity.value();
690 h1 = fsp[0].enthalpy.value();
692 _fs->massFractions(p, T, Xnacl,
Z - dZ, phase_state, fsp);
693 _fs->liquidProperties(p, T, Xnacl, fsp);
694 rho2 = fsp[0].density.value();
695 mu2 = fsp[0].viscosity.value();
696 h2 = fsp[0].enthalpy.value();
698 ABS_TEST(liquid_density.derivatives()[_Zidx], (rho1 - rho2) / (2.0 * dZ), 1.0e-6);
699 ABS_TEST(liquid_viscosity.derivatives()[_Zidx], (mu1 - mu2) / (2.0 * dZ), 1.0e-6);
700 ABS_TEST(liquid_enthalpy.derivatives()[_Zidx], (h1 - h2) / (2.0 * dZ), 1.0e-6);
718 const unsigned int np = _fs->numPhases();
719 const unsigned int nc = _fs->numComponents();
728 _fs->massFractions(p, T, Xnacl,
Z, phase_state, fsp);
732 ADReal gas_saturation = 0.25;
733 ADReal liquid_pressure = p - _pc->capillaryPressure(1.0 - gas_saturation);
736 _fs->gasProperties(p, T, fsp);
737 _fs->liquidProperties(liquid_pressure, T, Xnacl, fsp);
740 ADReal Zc = (gas_saturation * fsp[1].density * fsp[1].mass_fraction[1] +
741 (1.0 - gas_saturation) * fsp[0].
density * fsp[0].mass_fraction[1]) /
742 (gas_saturation * fsp[1].density + (1.0 - gas_saturation) * fsp[0].
density);
745 ADReal saturation = _fs->saturation(p, T, Xnacl, Zc, fsp);
746 ABS_TEST(saturation.value(), gas_saturation.value(), 1.0e-6);
749 gas_saturation = _fs->saturation(p, T, Xnacl,
Z, fsp);
751 const Real dp = 1.0e-1;
754 _fs->massFractions(p + dp, T, Xnacl,
Z, phase_state, fsp);
755 Real gsat1 = _fs->saturation(p + dp, T, Xnacl,
Z, fsp).value();
757 _fs->massFractions(p - dp, T, Xnacl,
Z, phase_state, fsp);
758 Real gsat2 = _fs->saturation(p - dp, T, Xnacl,
Z, fsp).value();
760 REL_TEST(gas_saturation.derivatives()[_pidx], (gsat1 - gsat2) / (2.0 * dp), 1.0e-6);
763 const Real dT = 1.0e-4;
764 _fs->massFractions(p, T + dT, Xnacl,
Z, phase_state, fsp);
765 gsat1 = _fs->saturation(p, T + dT, Xnacl,
Z, fsp).value();
767 _fs->massFractions(p, T - dT, Xnacl,
Z, phase_state, fsp);
768 gsat2 = _fs->saturation(p, T - dT, Xnacl,
Z, fsp).value();
770 REL_TEST(gas_saturation.derivatives()[_Tidx], (gsat1 - gsat2) / (2.0 * dT), 1.0e-6);
773 const Real dx = 1.0e-8;
774 _fs->massFractions(p, T, Xnacl + dx,
Z, phase_state, fsp);
775 gsat1 = _fs->saturation(p, T, Xnacl + dx,
Z, fsp).value();
777 _fs->massFractions(p, T, Xnacl - dx,
Z, phase_state, fsp);
778 gsat2 = _fs->saturation(p, T, Xnacl - dx,
Z, fsp).value();
780 REL_TEST(gas_saturation.derivatives()[_Xidx], (gsat1 - gsat2) / (2.0 * dx), 1.0e-6);
783 const Real dZ = 1.0e-8;
785 _fs->massFractions(p, T, Xnacl,
Z, phase_state, fsp);
786 gsat1 = _fs->saturation(p, T, Xnacl,
Z + dZ, fsp).value();
788 gsat2 = _fs->saturation(p, T, Xnacl,
Z - dZ, fsp).value();
790 REL_TEST(gas_saturation.derivatives()[_Zidx], (gsat1 - gsat2) / (2.0 * dZ), 1.0e-6);
798 const Real p = 1.0e6;
799 const Real T = 350.0;
800 const Real Xnacl = 0.1;
802 const unsigned qp = 0;
804 Real Z = _fs->totalMassFraction(p, T, Xnacl, s, qp);
808 const unsigned int np = _fs->numPhases();
809 const unsigned int nc = _fs->numComponents();
820 ABS_TEST(gas_saturation, s, 1.0e-6);
837 ADReal Kh = _fs->henryConstant(T, Xnacl);
838 REL_TEST(Kh.value(), 7.46559e+08, 1.0e-3);
846 Kh = _fs->henryConstant(T, Xnacl);
847 REL_TEST(Kh.value(), 1.66069e+09, 1.0e-3);
850 const Real dT = 1.0e-4;
851 ADReal Kh1 = _fs->henryConstant(T + dT, Xnacl);
852 ADReal Kh2 = _fs->henryConstant(T - dT, Xnacl);
854 REL_TEST(Kh.derivatives()[_Tidx], (Kh1.value() - Kh2.value()) / (2.0 * dT), 1.0e-6);
857 const Real dx = 1.0e-8;
858 Kh1 = _fs->henryConstant(T, Xnacl + dx);
859 Kh2 = _fs->henryConstant(T, Xnacl - dx);
861 REL_TEST(Kh.derivatives()[_Xidx], (Kh1.value() - Kh2.value()) / (2.0 * dx), 1.0e-6);
879 ADReal hdis = _fs->enthalpyOfDissolutionGas(T, Xnacl);
880 REL_TEST(hdis, -3.20130e5, 1.0e-3);
887 hdis = _fs->enthalpyOfDissolutionGas(T, Xnacl);
888 REL_TEST(hdis, 9.83813e+05, 1.0e-3);
891 const Real dT = 1.0e-4;
892 Real hdis1 = _fs->enthalpyOfDissolutionGas(T + dT, Xnacl).value();
893 Real hdis2 = _fs->enthalpyOfDissolutionGas(T - dT, Xnacl).value();
895 REL_TEST(hdis.derivatives()[_Tidx], (hdis1 - hdis2) / (2.0 * dT), 1.0e-5);
898 const Real dx = 1.0e-8;
899 hdis1 = _fs->enthalpyOfDissolutionGas(T, Xnacl + dx).value();
900 hdis2 = _fs->enthalpyOfDissolutionGas(T, Xnacl - dx).value();
902 REL_TEST(hdis.derivatives()[_Xidx], (hdis1 - hdis2) / (2.0 * dx), 1.0e-5);
918 ADReal hdis = _fs->enthalpyOfDissolution(T);
919 REL_TEST(hdis.value(), -3.38185e5, 1.0e-3);
926 hdis = _fs->enthalpyOfDissolution(T);
927 REL_TEST(hdis.value(), 5.78787e5, 1.0e-3);
930 const Real dT = 1.0e-4;
931 Real hdis1 = _fs->enthalpyOfDissolution(T + dT).value();
932 Real hdis2 = _fs->enthalpyOfDissolution(T - dT).value();
934 REL_TEST(hdis.derivatives()[_Tidx], (hdis1 - hdis2) / (2.0 * dT), 1.0e-5);
948 Real co2_density = _co2_fp->rho_from_p_T(p, T);
949 _fs->solveEquilibriumMoleFractionHighTemp(p, T, Xnacl, co2_density, xco2, yh2o);
950 ABS_TEST(yh2o, 0.161429743509, 1.0e-10);
951 ABS_TEST(xco2, 0.0236966821858, 1.0e-10);
958 _fs->solveEquilibriumMoleFractionHighTemp(p, T, Xnacl, co2_density, xco2, yh2o);
959 ABS_TEST(yh2o, 0.0468197608955, 1.0e-10);
960 ABS_TEST(xco2, 0.0236644599437, 1.0e-10);
966 co2_density = _co2_fp->rho_from_p_T(p, T);
967 _fs->solveEquilibriumMoleFractionHighTemp(p, T, Xnacl, co2_density, xco2, yh2o);
968 ABS_TEST(yh2o, 0.253292728991, 1.0e-10);
969 ABS_TEST(xco2, 0.0168344513321, 1.0e-10);
984 _fs->equilibriumMoleFractions(p, T, Xnacl,
x,
y);
985 ABS_TEST(
y.value(), 0.00696393845155, 1.0e-8);
986 ABS_TEST(
x.value(), 0.0236554537395, 1.0e-8);
991 _fs->equilibriumMoleFractions(p, T, Xnacl,
x,
y);
992 ABS_TEST(
y.value(), 0.0194394631944, 1.0e-8);
993 ABS_TEST(
x.value(), 0.020195776139, 1.0e-8);
999 _fs->equilibriumMoleFractions(p, T, Xnacl,
x,
y);
1000 ABS_TEST(
y.value(), 0.286117195565, 1.0e-8);
1001 ABS_TEST(
x.value(), 0.0409622051253, 1.0e-8);
1007 _fs->equilibriumMoleFractions(p, T, Xnacl,
x,
y);
1008 ABS_TEST(
y.value(), 1.0, 1.0e-8);
1009 ABS_TEST(
x.value(), 0.0, 1.0e-8);
1017 _fs->equilibriumMoleFractions(p, T, Xnacl,
x,
y);
1018 ABS_TEST(
y.value(), 0.00657335846826, 1.0e-8);
1019 ABS_TEST(
x.value(), 0.0152863933134, 1.0e-8);
1024 _fs->equilibriumMoleFractions(p, T, Xnacl,
x,
y);
1025 ABS_TEST(
y.value(), 0.01831360857, 1.0e-8);
1026 ABS_TEST(
x.value(), 0.0132653916293, 1.0e-8);
1032 _fs->equilibriumMoleFractions(p, T, Xnacl,
x,
y);
1033 ABS_TEST(
y.value(), 0.270258924237, 1.0e-8);
1034 ABS_TEST(
x.value(), 0.0246589135776, 1.0e-8);
TEST_F(PorousFlowBrineCO2Test, name)
Verify that the correct name is supplied.
static const std::string density
const std::vector< double > y
static const std::string temperature
DualNumber< Real, DNDerivativeType, true > ADReal
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const std::vector< double > x
AD data structure to pass calculated thermophysical properties.
FluidStatePhaseEnum
Phase state enum.
static const std::string Z
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string pressure
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)