예제 #1
0
void
CO2FluidPropertiesTest::partialDensity()
{
  REL_TEST("partial density", _fp->partialDensity(373.15), 1182.8, 5.0e-2);
  REL_TEST("partial density", _fp->partialDensity(473.35), 880.0, 5.0e-2);
  REL_TEST("partial density", _fp->partialDensity(573.15), 593.8, 5.0e-2);
}
예제 #2
0
/*
 * Verify calculation of Henry constant with brine correction. Note: the values
 * calculated compare well by eye to the values presented in Figure 4 of
 * Battistelli et al, "A fluid property module for the TOUGH2 simulator for saline
 * brines with non-condensible gas"
 */
TEST_F(PorousFlowBrineCO2Test, henryConstant)
{
  Real T = 373.15;
  Real Xnacl = 0.1;

  Real Kh, dKh_dT, dKh_dX;
  _fp->henryConstant(T, Xnacl, Kh, dKh_dT, dKh_dX);
  REL_TEST(Kh, 7.46559e+08, 1.0e-3);

  T = 473.15;
  Xnacl = 0.2;

  _fp->henryConstant(T, Xnacl, Kh, dKh_dT, dKh_dX);
  REL_TEST(Kh, 1.66069e+09, 1.0e-3);

  // Test the derivative wrt temperature
  const Real dT = 1.0e-4;
  Real Kh2, dKh2_dT, dKh2_dX;
  _fp->henryConstant(T + dT, Xnacl, Kh, dKh_dT, dKh_dX);
  _fp->henryConstant(T - dT, Xnacl, Kh2, dKh2_dT, dKh2_dX);

  REL_TEST(dKh_dT, (Kh - Kh2) / (2.0 * dT), 1.0e-5);

  // Test the derivative wrt Xnacl
  const Real dx = 1.0e-8;
  _fp->henryConstant(T, Xnacl + dx, Kh, dKh_dT, dKh_dX);
  _fp->henryConstant(T, Xnacl - dx, Kh2, dKh2_dT, dKh2_dX);

  REL_TEST(dKh_dX, (Kh - Kh2) / (2.0 * dx), 1.0e-5);
}
예제 #3
0
/*
 * Verify calculation of enthalpy of dissolution. Note: the values calculated compare
 * well by eye to the values presented in Figure 4 of Battistelli et al, "A fluid property
 * module for the TOUGH2 simulator for saline brines with non-condensible gas"
 */
TEST_F(PorousFlowBrineCO2Test, enthalpyOfDissolutionGas)
{
  // T = 50C
  Real T = 323.15;
  Real Xnacl = 0.1;

  // Enthalpy of dissolution of CO2 in brine
  Real hdis, dhdis_dT, dhdis_dX;
  _fp->enthalpyOfDissolutionGas(T, Xnacl, hdis, dhdis_dT, dhdis_dX);
  REL_TEST(hdis, -3.20130e5, 1.0e-3);

  // T = 350C
  T = 623.15;

  // Enthalpy of dissolution of CO2 in brine
  _fp->enthalpyOfDissolutionGas(T, Xnacl, hdis, dhdis_dT, dhdis_dX);
  REL_TEST(hdis, 9.83813e+05, 1.0e-3);

  // Test the derivative wrt temperature
  const Real dT = 1.0e-4;
  Real hdis1, dhdis1_dT, dhdis1_dX, hdis2, dhdis2_dT, dhdis2_dX;
  _fp->enthalpyOfDissolutionGas(T + dT, Xnacl, hdis1, dhdis1_dT, dhdis1_dX);
  _fp->enthalpyOfDissolutionGas(T - dT, Xnacl, hdis2, dhdis2_dT, dhdis2_dX);

  REL_TEST(dhdis_dT, (hdis1 - hdis2) / (2.0 * dT), 1.0e-5);

  // Test the derivative wrt salt mass fraction
  const Real dx = 1.0e-8;
  _fp->enthalpyOfDissolutionGas(T, Xnacl + dx, hdis1, dhdis1_dT, dhdis1_dX);
  _fp->enthalpyOfDissolutionGas(T, Xnacl - dx, hdis2, dhdis2_dT, dhdis2_dX);

  REL_TEST(dhdis_dX, (hdis1 - hdis2) / (2.0 * dx), 1.0e-5);
}
예제 #4
0
/**
 * Verify calculation of Henry's constant using data from
 * Guidelines on the Henry's constant and vapour liquid distribution constant
 * for gases in H20 and D20 at high temperatures, IAPWS (2004).
 */
TEST_F(MethaneFluidPropertiesTest, henry)
{
  REL_TEST(_fp->henryConstant(300.0), 4069.0e6, REL_TOL_EXTERNAL_VALUE);
  REL_TEST(_fp->henryConstant(400.0), 6017.1e6, REL_TOL_EXTERNAL_VALUE);
  REL_TEST(_fp->henryConstant(500.0), 2812.9e6, REL_TOL_EXTERNAL_VALUE);
  REL_TEST(_fp->henryConstant(600.0), 801.8e6, REL_TOL_EXTERNAL_VALUE);
}
예제 #5
0
/*
 * Verify calculation of enthalpy of dissolution. Note: the values calculated compare
 * well by eye to the values presented in Figure 4 of Battistelli et al, "A fluid property
 * module for the TOUGH2 simulator for saline brines with non-condensible gas"
 */
TEST_F(PorousFlowWaterNCGTest, enthalpyOfDissolution)
{
  // T = 50C
  Real T = 323.15;

  // Enthalpy of dissolution of NCG in water
  Real hdis, dhdis_dT;
  _fp->enthalpyOfDissolution(T, hdis, dhdis_dT);
  REL_TEST(hdis, -3.45731e5, 1.0e-3);

  // T = 350C
  T = 623.15;

  // Enthalpy of dissolution of NCG in water
  _fp->enthalpyOfDissolution(T, hdis, dhdis_dT);
  REL_TEST(hdis, 1.23423e+06, 1.0e-3);

  // Test the derivative wrt temperature
  const Real dT = 1.0e-4;
  Real hdis2, dhdis2_dT;
  _fp->enthalpyOfDissolution(T + dT, hdis, dhdis_dT);
  _fp->enthalpyOfDissolution(T - dT, hdis2, dhdis2_dT);

  REL_TEST(dhdis_dT, (hdis - hdis2) / (2.0 * dT), 1.0e-5);
}
예제 #6
0
void
CO2FluidPropertiesTest::melting()
{
  REL_TEST("melting", _fp->meltingPressure(217.03), 2.57e6, 1.0e-2);
  REL_TEST("melting", _fp->meltingPressure(235.29), 95.86e6, 1.0e-2);
  REL_TEST("melting", _fp->meltingPressure(266.04), 286.77e6, 1.0e-2);
}
예제 #7
0
/**
 * Verify calculation of the derivatives of all properties by comparing with finite
 * differences
 */
TEST_F(MethaneFluidPropertiesTest, derivatives)
{
  const Real tol = REL_TOL_DERIVATIVE;

  const Real p = 10.0e6;
  Real T = 350.0;

  DERIV_TEST(_fp->rho, _fp->rho_from_p_T, p, T, tol);
  DERIV_TEST(_fp->mu, _fp->mu_dpT, p, T, tol);
  DERIV_TEST(_fp->e, _fp->e_dpT, p, T, tol);
  DERIV_TEST(_fp->h, _fp->h_dpT, p, T, tol);
  DERIV_TEST(_fp->k, _fp->k_dpT, p, T, tol);

  // Test derivative of enthalpy for T > 755 as well as it has a different formulation
  T = 800.0;
  DERIV_TEST(_fp->h, _fp->h_dpT, p, T, tol);

  // Henry's constant
  T = 350.0;
  const Real dT = 1.0e-4;

  Real dKh_dT_fd = (_fp->henryConstant(T + dT) - _fp->henryConstant(T - dT)) / (2.0 * dT);
  Real Kh = 0.0, dKh_dT = 0.0;
  _fp->henryConstant_dT(T, Kh, dKh_dT);
  REL_TEST(Kh, _fp->henryConstant(T), REL_TOL_SAVED_VALUE);
  REL_TEST(dKh_dT_fd, dKh_dT, REL_TOL_DERIVATIVE);
}
예제 #8
0
/**
 * Verify calculation of Henry's constant using data from
 * Guidelines on the Henry's constant and vapour liquid distribution constant
 * for gases in H20 and D20 at high temperatures, IAPWS (2004).
 */
TEST_F(CO2FluidPropertiesTest, henry)
{
  REL_TEST("henry", _fp->henryConstant(300.0), 173.63e6, 1.0e-3);
  REL_TEST("henry", _fp->henryConstant(400.0), 579.84e6, 1.0e-3);
  REL_TEST("henry", _fp->henryConstant(500.0), 520.79e6, 1.0e-3);
  REL_TEST("henry", _fp->henryConstant(600.0), 259.53e6, 1.0e-3);
}
예제 #9
0
void
CO2FluidPropertiesTest::viscosity()
{
  REL_TEST("viscosity", _fp->mu(20.199, 280.0), 14.15e-6, 1.0e-3);
  REL_TEST("viscosity", _fp->mu(15.105, 360.0), 17.94e-6, 1.0e-3);
  REL_TEST("viscosity", _fp->mu(10.664, 500.0), 24.06e-6, 1.0e-3);
}
예제 #10
0
void
CO2FluidPropertiesTest::thermalConductivity()
{
  REL_TEST("thermal conductivity", _fp->k(23.435, 250.0), 13.45e-3, 1.0e-3);
  REL_TEST("thermal conductivity", _fp->k(18.579, 300.0), 17.248e-3, 1.0e-3);
  REL_TEST("thermal conductivity", _fp->k(11.899, 450.0), 29.377e-3, 1.0e-3);
}
예제 #11
0
/*
 * Verify calculation of equilibrium mass fraction and derivatives
 */
TEST_F(PorousFlowWaterNCGTest, equilibriumMassFraction)
{
  const Real p = 1.0e6;
  const Real T = 350.0;
  const Real dp = 1.0e-2;
  const Real dT = 1.0e-6;
  Real Xncg, dXncg_dp, dXncg_dT, Yh2o, dYh2o_dp, dYh2o_dT;
  Real Xncg1, dXncg1_dp, dXncg1_dT, Yh2o1, dYh2o1_dp, dYh2o1_dT;
  Real Xncg2, dXncg2_dp, dXncg2_dT, Yh2o2, dYh2o2_dp, dYh2o2_dT;
  _fp->equilibriumMassFractions(p, T, Xncg, dXncg_dp, dXncg_dT, Yh2o, dYh2o_dp, dYh2o_dT);
  _fp->equilibriumMassFractions(
      p - dp, T, Xncg1, dXncg1_dp, dXncg1_dT, Yh2o1, dYh2o1_dp, dYh2o1_dT);
  _fp->equilibriumMassFractions(
      p + dp, T, Xncg2, dXncg2_dp, dXncg2_dT, Yh2o2, dYh2o2_dp, dYh2o2_dT);

  Real dXncg_dp_fd = (Xncg2 - Xncg1) / (2.0 * dp);
  Real dYh2o_dp_fd = (Yh2o2 - Yh2o1) / (2.0 * dp);

  REL_TEST(dXncg_dp, dXncg_dp_fd, 1.0e-6);
  REL_TEST(dYh2o_dp, dYh2o_dp_fd, 1.0e-6);

  _fp->equilibriumMassFractions(
      p, T - dT, Xncg1, dXncg1_dp, dXncg1_dT, Yh2o1, dYh2o1_dp, dYh2o1_dT);
  _fp->equilibriumMassFractions(
      p, T + dT, Xncg2, dXncg2_dp, dXncg2_dT, Yh2o2, dYh2o2_dp, dYh2o2_dT);

  Real dXncg_dT_fd = (Xncg2 - Xncg1) / (2.0 * dT);
  Real dYh2o_dT_fd = (Yh2o2 - Yh2o1) / (2.0 * dT);

  REL_TEST(dXncg_dT, dXncg_dT_fd, 1.0e-6);
  REL_TEST(dYh2o_dT, dYh2o_dT_fd, 1.0e-6);
}
예제 #12
0
/*
 * Verify calculation of enthalpy of dissolution of CO2. Note: the values calculated compare
 * well by eye to the values presented in Figure 6 of Duan and Sun, An improved model
 * calculating CO2 solubility in pure water and aqueous NaCl solutions from 273 to 533 K
 * and from 0 to 2000 bar, Chemical geology, 193, 257--271 (2003)
 */
TEST_F(PorousFlowBrineCO2Test, enthalpyOfDissolution)
{
  // T = 50C
  Real T = 323.15;

  // Enthalpy of dissolution of CO2 in water
  Real hdis, dhdis_dT;
  _fp->enthalpyOfDissolution(T, hdis, dhdis_dT);
  REL_TEST(hdis, -3.38185e5, 1.0e-3);

  // T = 350C
  T = 623.15;

  // Enthalpy of dissolution of CO2 in water
  _fp->enthalpyOfDissolution(T, hdis, dhdis_dT);
  REL_TEST(hdis, 5.78787e5, 1.0e-3);

  // Test the derivative wrt temperature
  const Real dT = 1.0e-4;
  Real hdis1, dhdis1_dT, hdis2, dhdis2_dT;
  _fp->enthalpyOfDissolution(T + dT, hdis1, dhdis1_dT);
  _fp->enthalpyOfDissolution(T - dT, hdis2, dhdis2_dT);

  REL_TEST(dhdis_dT, (hdis1 - hdis2) / (2.0 * dT), 1.0e-5);
}
예제 #13
0
/**
 * Verify calculation of the derivatives in all regions by comparing with finite
 * differences
 */
TEST_F(Water97FluidPropertiesTest, derivatives)
{
  // Region 1
  Real p = 3.0e6;
  Real T = 300.0;
  regionDerivatives(p, T, 1.0e-6);

  // Region 2
  p = 3.5e3;
  T = 300.0;
  regionDerivatives(p, T, 1.0e-6);

  // Region 3
  p = 26.0e6;
  T = 650.0;
  regionDerivatives(p, T, 1.0e-2);

  // Region 4 (saturation curve)
  T = 300.0;
  Real dT = 1.0e-4;

  Real dpSat_dT_fd = (_fp->vaporPressure(T + dT) - _fp->vaporPressure(T - dT)) / (2.0 * dT);
  Real pSat = 0.0, dpSat_dT = 0.0;
  _fp->vaporPressure_dT(T, pSat, dpSat_dT);

  REL_TEST("dvaporPressure_dT", dpSat_dT, dpSat_dT_fd, 1.0e-6);

  // Region 5
  p = 30.0e6;
  T = 1500.0;
  regionDerivatives(p, T, 1.0e-6);

  // Viscosity
  Real rho = 998.0, drho_dp = 0.0, drho_dT = 0.0;
  T = 298.15;
  Real drho = 1.0e-4;

  Real dmu_drho_fd =
      (_fp->mu_from_rho_T(rho + drho, T) - _fp->mu_from_rho_T(rho - drho, T)) / (2.0 * drho);
  Real mu = 0.0, dmu_drho = 0.0, dmu_dT = 0.0;
  _fp->mu_drhoT_from_rho_T(rho, T, drho_dT, mu, dmu_drho, dmu_dT);

  ABS_TEST("mu", mu, _fp->mu_from_rho_T(rho, T), 1.0e-15);
  REL_TEST("dmu_dp", dmu_drho, dmu_drho_fd, 1.0e-6);

  // To properly test derivative wrt temperature, use p and T and calculate density,
  // so that the change in density wrt temperature is included
  p = 1.0e6;
  dT = 1.0e-4;
  _fp->rho_dpT(p, T, rho, drho_dp, drho_dT);
  _fp->mu_drhoT_from_rho_T(rho, T, drho_dT, mu, dmu_drho, dmu_dT);
  Real dmu_dT_fd = (_fp->mu_from_rho_T(_fp->rho(p, T + dT), T + dT) -
                    _fp->mu_from_rho_T(_fp->rho(p, T - dT), T - dT)) /
                   (2.0 * dT);

  REL_TEST("dmu_dT", dmu_dT, dmu_dT_fd, 1.0e-6);
}
예제 #14
0
/*
 * Verify calculation of the Duan and Sun activity coefficient and its derivatives wrt
 * pressure, temperature and salt mass fraction
 */
TEST_F(PorousFlowBrineCO2Test, activityCoefficientCO2Brine)
{
  const Real p = 10.0e6;
  Real T = 350.0;
  Real Xnacl = 0.1;
  const Real dp = 1.0e-1;
  const Real dT = 1.0e-6;
  const Real dx = 1.0e-8;

  // Low temperature regime
  Real gamma, dgamma_dp, dgamma_dT, dgamma_dX;
  _fp->activityCoefficient(p, T, Xnacl, gamma, dgamma_dp, dgamma_dT, dgamma_dX);
  ABS_TEST(gamma, 1.43276649338, 1.0e-8);

  Real gamma_2, dgamma_2_dp, dgamma_2_dT, dgamma_2_dX;
  _fp->activityCoefficient(p + dp, T, Xnacl, gamma_2, dgamma_2_dp, dgamma_2_dT, dgamma_2_dX);

  Real dgamma_dp_fd = (gamma_2 - gamma) / dp;
  REL_TEST(dgamma_dp, dgamma_dp_fd, 1.0e-6);

  _fp->activityCoefficient(p, T + dT, Xnacl, gamma_2, dgamma_2_dp, dgamma_2_dT, dgamma_2_dX);

  Real dgamma_dT_fd = (gamma_2 - gamma) / dT;
  REL_TEST(dgamma_dT, dgamma_dT_fd, 1.0e-6);

  _fp->activityCoefficient(p, T, Xnacl + dx, gamma_2, dgamma_2_dp, dgamma_2_dT, dgamma_2_dX);

  Real dgamma_dX_fd = (gamma_2 - gamma) / dx;
  REL_TEST(dgamma_dX, dgamma_dX_fd, 1.0e-6);

  // High temperature regime
  T = 523.15;
  _fp->activityCoefficientHighTemp(T, Xnacl, gamma, dgamma_dT, dgamma_dX);
  ABS_TEST(gamma, 1.50047006243, 1.0e-8);

  _fp->activityCoefficientHighTemp(T + dT, Xnacl, gamma_2, dgamma_2_dT, dgamma_2_dX);
  dgamma_dT_fd = (gamma_2 - gamma) / dT;
  REL_TEST(dgamma_dT, dgamma_dT_fd, 1.0e-6);

  _fp->activityCoefficientHighTemp(T, Xnacl + dx, gamma_2, dgamma_2_dT, dgamma_2_dX);
  dgamma_dX_fd = (gamma_2 - gamma) / dx;
  REL_TEST(dgamma_dX, dgamma_dX_fd, 1.0e-6);

  // Check that both formulations return gamma = 1 for Xnacl = 0
  Xnacl = 0.0;
  T = 350.0;
  _fp->activityCoefficient(p, T, Xnacl, gamma, dgamma_dp, dgamma_dT, dgamma_dX);
  ABS_TEST(gamma, 1.0, 1.0e-12);

  T = 523.15;
  _fp->activityCoefficientHighTemp(T, Xnacl, gamma, dgamma_dT, dgamma_dX);
  ABS_TEST(gamma, 1.0, 1.0e-12);
}
예제 #15
0
void
CO2FluidPropertiesTest::derivatives()
{
  Real p = 1.0e6;
  Real T = 350.0;

  // Finite differencing parameters
  Real dp = 1.0e1;
  Real dT = 1.0e-4;

  // density
  Real drho_dp_fd = (_fp->rho(p + dp, T) - _fp->rho(p - dp, T)) / (2.0 * dp);
  Real drho_dT_fd = (_fp->rho(p, T + dT) - _fp->rho(p, T - dT)) / (2.0 * dT);
  Real rho = 0.0, drho_dp = 0.0, drho_dT = 0.0;
  _fp->rho_dpT(p, T, rho, drho_dp, drho_dT);

  ABS_TEST("rho", rho, _fp->rho(p, T), 1.0e-15);
  REL_TEST("drho_dp", drho_dp, drho_dp_fd, 1.0e-6);
  REL_TEST("drho_dT", drho_dT, drho_dT_fd, 1.0e-6);

  // enthalpy
  Real dh_dp_fd = (_fp->h(p + dp, T) - _fp->h(p - dp, T)) / (2.0 * dp);
  Real dh_dT_fd = (_fp->h(p, T + dT) - _fp->h(p, T - dT)) / (2.0 * dT);
  Real h = 0.0, dh_dp = 0.0, dh_dT = 0.0;
  _fp->h_dpT(p, T, h, dh_dp, dh_dT);

  ABS_TEST("h", h, _fp->h(p, T), 1.0e-15);
  REL_TEST("dh_dp", dh_dp, dh_dp_fd, 1.0e-6);
  REL_TEST("dh_dT", dh_dT, dh_dT_fd, 1.0e-6);

  // internal energy
  Real de_dp_fd = (_fp->e(p + dp, T) - _fp->e(p - dp, T)) / (2.0 * dp);
  Real de_dT_fd = (_fp->e(p, T + dT) - _fp->e(p, T - dT)) / (2.0 * dT);
  Real e = 0.0, de_dp = 0.0, de_dT = 0.0;
  _fp->e_dpT(p, T, e, de_dp, de_dT);

  ABS_TEST("e", e, _fp->e(p, T), 1.0e-15);
  REL_TEST("de_dp", de_dp, de_dp_fd, 1.0e-6);
  REL_TEST("de_dT", de_dT, de_dT_fd, 1.0e-6);

  // Viscosity
  rho = 15.105;
  T = 360.0;
  Real drho = 1.0e-4;

  Real dmu_drho_fd = (_fp->mu(rho + drho, T) - _fp->mu(rho - drho, T)) / (2.0 * drho);
  Real dmu_dT_fd = (_fp->mu(rho, T + dT) - _fp->mu(rho, T - dT)) / (2.0 * dT);
  Real mu = 0.0, dmu_drho = 0.0, dmu_dT = 0.0;
  _fp->mu_drhoT(rho, T, mu, dmu_drho, dmu_dT);

  ABS_TEST("mu", mu, _fp->mu(rho, T), 1.0e-15);
  REL_TEST("dmu_dp", dmu_drho, dmu_drho_fd, 1.0e-6);
  REL_TEST("dmu_dT", dmu_dT, dmu_dT_fd, 1.0e-6);
}
예제 #16
0
/**
 * Verify calculation of vapor pressure, vapor density and saturated liquid
 * density using experimental data from
 * Duschek et al., Measurement and correlation of the (pressure, density, temperature)
 * relation of cabon dioxide II. Saturated-liquid and saturated-vapor densities and
 * the vapor pressure along the entire coexstance curve, J. Chem. Thermo. 22 (1990).
 * As we are comparing with experimental data, calculated values within 1% are
 * considered satisfactory.
 */
TEST_F(CO2FluidPropertiesTest, vapor)
{
  // Vapor pressure
  REL_TEST("vapor", _fp->vaporPressure(217.0), 0.52747e6, 1.0e-2);
  REL_TEST("vapor", _fp->vaporPressure(245.0), 1.51887e6, 1.0e-2);
  REL_TEST("vapor", _fp->vaporPressure(303.8), 7.32029e6, 1.0e-2);

  // Saturated vapor density
  REL_TEST("saturated vapor density", _fp->saturatedVaporDensity(217.0), 14.0017, 1.0e-2);
  REL_TEST("saturated vapor density", _fp->saturatedVaporDensity(245.0), 39.5048, 1.0e-2);
  REL_TEST("saturated vapor density", _fp->saturatedVaporDensity(303.8), 382.30, 1.0e-2);

  // Saturated liquid density
  REL_TEST("saturated liquid density", _fp->saturatedLiquidDensity(217.0), 1177.03, 1.0e-2);
  REL_TEST("saturated liquid density", _fp->saturatedLiquidDensity(245.0), 1067.89, 1.0e-2);
  REL_TEST("saturated liquid density", _fp->saturatedLiquidDensity(303.8), 554.14, 1.0e-2);
}
예제 #17
0
/**
 * Verify calculation of Sodium Properties from ANL/RE-95/2 report
 * "Thermodynamic and Transport Properties of Sodium Liquid and Vapor"
 * from ANL Reactor Engineering Division.
 */
TEST_F(SodiumPropertiesTest, testSodium)
{
  double T = 500; // K
  REL_TEST("thermal_conductivity", _fp->k(T), 80.09125, 1.0E-5);
  REL_TEST("enthalpy", _fp->h(T), 381886.450000, 1.0E-5);
  REL_TEST("heat_capacity", _fp->heatCapacity(T), 1345.578559, 1.0E-2);
  REL_TEST("temperature", _fp->temperature(_fp->h(T)), T, 1.0E-5);
  REL_TEST("density", _fp->rho(T), 896.9929544, 1E-05);
  REL_TEST("drhodT", _fp->drho_dT(T), -0.224167872, 1E-05);
  REL_TEST("drhodh", _fp->drho_dh(_fp->h(T)), -0.00016659590, 1E-2);
}
예제 #18
0
/**
 * Verify calculation of Sodium Properties from ANL/RE-95/2 report
 * "Thermodynamic and Transport Properties of Sodium Liquid and Vapor"
 * from ANL Reactor Engineering Division.
 */
TEST_F(SodiumPropertiesTest, testSodium)
{
  Real T = 500; // K
  REL_TEST(_fp->k(T), 80.09125, 1.0E-5);
  REL_TEST(_fp->h(T), 381886.450000, 1.0E-5);
  REL_TEST(_fp->heatCapacity(T), 1345.578559, 1.0E-2);
  REL_TEST(_fp->temperature(_fp->h(T)), T, 1.0E-5);
  REL_TEST(_fp->rho(T), 896.9929544, 1E-05);
  REL_TEST(_fp->drho_dT(T), -0.224167872, 1E-05);
  REL_TEST(_fp->drho_dh(_fp->h(T)), -0.00016659590, 1E-2);
}
예제 #19
0
/*
 * Verify calculation of the equilibrium constants and their derivatives wrt temperature
 */
TEST_F(PorousFlowBrineCO2Test, equilibriumConstants)
{
  Real T = 350.0;
  const Real dT = 1.0e-6;

  Real K0H2O, dK0H2O_dT, K0CO2, dK0CO2_dT;
  _fp->equilibriumConstantH2O(T, K0H2O, dK0H2O_dT);
  _fp->equilibriumConstantCO2(T, K0CO2, dK0CO2_dT);

  ABS_TEST(K0H2O, 0.412597711705, 1.0e-10);
  ABS_TEST(K0CO2, 74.0435888596, 1.0e-10);

  Real K0H2O_2, dK0H2O_2_dT, K0CO2_2, dK0CO2_2_dT;
  _fp->equilibriumConstantH2O(T + dT, K0H2O_2, dK0H2O_2_dT);
  _fp->equilibriumConstantCO2(T + dT, K0CO2_2, dK0CO2_2_dT);

  Real dK0H2O_dT_fd = (K0H2O_2 - K0H2O) / dT;
  Real dK0CO2_dT_fd = (K0CO2_2 - K0CO2) / dT;
  REL_TEST(dK0H2O_dT, dK0H2O_dT_fd, 1.0e-6);
  REL_TEST(dK0CO2_dT, dK0CO2_dT_fd, 1.0e-6);

  // Test the high temperature formulation
  T = 450.0;

  _fp->equilibriumConstantH2O(T, K0H2O, dK0H2O_dT);
  _fp->equilibriumConstantCO2(T, K0CO2, dK0CO2_dT);

  ABS_TEST(K0H2O, 8.75944517916, 1.0e-10);
  ABS_TEST(K0CO2, 105.013867434, 1.0e-10);

  _fp->equilibriumConstantH2O(T + dT, K0H2O_2, dK0H2O_2_dT);
  _fp->equilibriumConstantCO2(T + dT, K0CO2_2, dK0CO2_2_dT);

  dK0H2O_dT_fd = (K0H2O_2 - K0H2O) / dT;
  dK0CO2_dT_fd = (K0CO2_2 - K0CO2) / dT;
  REL_TEST(dK0H2O_dT, dK0H2O_dT_fd, 1.0e-6);
  REL_TEST(dK0CO2_dT, dK0CO2_dT_fd, 1.0e-5);
}
예제 #20
0
/*
 * Verify calculation of the partial density of CO2 and its derivative wrt temperature
 */
TEST_F(PorousFlowBrineCO2Test, partialDensity)
{
  const Real T = 473.15;
  const Real dT = 1.0e-6;

  Real partial_density, dpartial_density_dT;
  _fp->partialDensityCO2(T, partial_density, dpartial_density_dT);
  ABS_TEST(partial_density, 893.332, 1.0e-3);

  Real partial_density_2, dpartial_density_2_dT;
  _fp->partialDensityCO2(T + dT, partial_density_2, dpartial_density_2_dT);

  Real dpartial_density_dT_fd = (partial_density_2 - partial_density) / dT;
  REL_TEST(dpartial_density_dT, dpartial_density_dT_fd, 1.0e-6);
}
예제 #21
0
/**
 * Verify calculation of thermophysical properties of methane using
 * verification data provided in
 * Irvine Jr, T. F. and Liley, P. E. (1984) Steam and Gas Tables with
 * Computer Equations
 */
TEST_F(MethaneFluidPropertiesTest, properties)
{
  // Pressure = 10 MPa, temperature = 350 K
  Real p = 10.0e6;
  Real T = 350.0;
  const Real tol = REL_TOL_EXTERNAL_VALUE;

  REL_TEST(_fp->rho_from_p_T(p, T), 55.13, tol);
  REL_TEST(_fp->h(p, T), 708.5e3, tol);
  REL_TEST(_fp->e(p, T), 527.131e3, tol);
  REL_TEST(_fp->s(p, T), 11.30e3, tol);
  REL_TEST(_fp->cp_from_p_T(p, T), 2.375e3, tol);
  REL_TEST(_fp->cv_from_p_T(p, T), 1.857e3, tol);
  REL_TEST(_fp->c(p, T), 481.7, tol);
  REL_TEST(_fp->mu(p, T), 0.01276e-3, tol);
  REL_TEST(_fp->k(p, T), 0.04113, tol);

  // Test s, h and cp for temperatures > 755K as well as these methods have a
  // different formulation in this regime
  T = 800.0;

  REL_TEST(_fp->h(p, T), 2132.0e3, tol);
  REL_TEST(_fp->s(p, T), 13.83e3, tol);
  REL_TEST(_fp->cp_from_p_T(p, T), 3.934e3, tol);
}
예제 #22
0
/**
 * Verify calculation of the NACL properties the solid halite phase.
 * Density data from Brown, "The NaCl pressure standard", J. Appl. Phys., 86 (1999).
 *
 * Values for cp and enthalpy are difficult to compare against. Instead, the
 * values provided by the BrineFluidProperties UserObject were compared against
 * simple correlations, eg. from NIST sodium chloride data.
 *
 * Values for thermal conductivity from Urqhart and Bauer,
 * Experimental determination of single-crystal halite thermal conductivity,
 * diffusivity and specific heat from -75 C to 300 C, Int. J. Rock Mech.
 * and Mining Sci., 78 (2015)
 */
TEST_F(NaClFluidPropertiesTest, halite)
{
  // Density and cp
  Real p0, p1, p2, T0, T1, T2;

  const Real tol = REL_TOL_EXTERNAL_VALUE;

  p0 = 30.0e6;
  p1 = 60.0e6;
  p2 = 80.0e6;
  T0 = 300.0;
  T1 = 500.0;
  T2 = 700.0;

  REL_TEST(_fp->rho_from_p_T(p0, T0), 2167.88, tol);
  REL_TEST(_fp->rho_from_p_T(p1, T1), 2116.0, tol);
  REL_TEST(_fp->rho_from_p_T(p2, T2), 2056.8, tol);
  REL_TEST(_fp->cp_from_p_T(p0, T0), 0.865e3, 40.0 * tol);
  REL_TEST(_fp->cp_from_p_T(p1, T1), 0.922e3, 40.0 * tol);
  REL_TEST(_fp->cp_from_p_T(p2, T2), 0.979e3, 40.0 * tol);

  // Test enthalpy at the triple point pressure of water
  Real pt = 611.657;

  ABS_TEST(_fp->h_from_p_T(pt, 273.16), 0.0, tol);
  REL_TEST(_fp->h_from_p_T(pt, 573.15), 271.13e3, tol);
  REL_TEST(_fp->h_from_p_T(pt, 673.15), 366.55e3, tol);

  // Thermal conductivity (function of T only)
  REL_TEST(_fp->k_from_p_T(p0, 323.15), 5.488, 10.0 * tol);
  REL_TEST(_fp->k_from_p_T(p0, 423.15), 3.911, 10.0 * tol);
  REL_TEST(_fp->k_from_p_T(p0, 523.15), 3.024, 20.0 * tol);
}
TEST_F(IdealGasFluidPropertiesTest, testAll)
{
  const Real T = 120. + 273.15; // K
  const Real p = 101325;        // Pa

  const Real rho = _fp->rho_from_p_T(p, T);
  const Real v = 1 / rho;
  const Real e = _fp->e_from_p_rho(p, rho);
  const Real s = _fp->s_from_v_e(v, e);
  const Real h = _fp->h_from_p_T(p, T);

  Real e_inv = _fp->e_from_T_v(T, v);
  REL_TEST(e_inv, e, 10.0 * REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->e_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  Real p_inv = _fp->p_from_T_v(T, v);
  REL_TEST(p_inv, p, 10.0 * REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->p_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  REL_TEST(_fp->h_from_T_v(T, v), h, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->h_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  REL_TEST(_fp->s_from_T_v(T, v), s, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->s_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  REL_TEST(_fp->cv_from_T_v(T, v), _fp->cv(), REL_TOL_CONSISTENCY);

  REL_TEST(_fp->p_from_h_s(h, s), p, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->p_from_h_s, h, s, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->rho_from_p_s(p, s), rho, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->rho_from_p_s, p, s, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->p_from_v_e(v, e), p, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->p_from_v_e, v, e, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->T_from_v_e(v, e), T, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->T_from_v_e, v, e, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->c_from_v_e(v, e), 398.896207251962, REL_TOL_SAVED_VALUE);
  REL_TEST(_fp->cp_from_v_e(v, e), 987.13756097561, REL_TOL_SAVED_VALUE);
  REL_TEST(_fp->cv_from_v_e(v, e), 700.09756097561, REL_TOL_SAVED_VALUE);
  REL_TEST(_fp->mu_from_v_e(v, e), 0.0, 1e-15);
  REL_TEST(_fp->k_from_v_e(v, e), 0.0, 1e-15);

  REL_TEST(_fp->beta_from_p_T(p, T), 2.54355843825512e-3, REL_TOL_SAVED_VALUE);

  REL_TEST(_fp->s_from_v_e(v, e), 2.58890011905277e3, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->s_from_v_e, v, e, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->rho_from_p_T(p, T), 0.897875065343506, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->rho_from_p_T, p, T, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->v_from_p_T(p, T), 1.0 / 0.897875065343506, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->v_from_p_T, p, T, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->e_from_p_rho(p, rho), 2.75243356097561e5, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->e_from_p_rho, p, rho, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->h_from_p_T(p, T), 3.88093132097561e5, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->h_from_p_T, p, T, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->s_from_p_T(p, T), 2.588900119052767e3, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->s_from_p_T, p, T, REL_TOL_DERIVATIVE);
  ABS_TEST(_fp->s_from_h_p(h, p), 2.588900119052767e3, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->s_from_h_p, h, p, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->e_from_p_T(p, T), 2.75243356097561e5, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->e_from_p_T, p, T, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->molarMass(), 34.522988492890422, REL_TOL_SAVED_VALUE);

  ABS_TEST(_fp->T_from_p_h(p, h), T, REL_TOL_CONSISTENCY);
}
예제 #24
0
TEST_F(IdealGasFluidPropertiesTest, testAll)
{
  // Test when R and gamma are provided
  Real T = 120. + 273.15; // K
  Real p = 101325;        // Pa

  const Real rho = _fp->rho_from_p_T(p, T);
  const Real v = 1.0 / rho;
  const Real e = _fp->e_from_p_rho(p, rho);
  const Real s = _fp->s_from_v_e(v, e);
  const Real h = _fp->h_from_p_T(p, T);

  Real e_inv = _fp->e_from_T_v(T, v);
  REL_TEST(e_inv, e, 10.0 * REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->e_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  Real p_inv = _fp->p_from_T_v(T, v);
  REL_TEST(p_inv, p, 10.0 * REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->p_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  REL_TEST(_fp->h_from_T_v(T, v), h, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->h_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  REL_TEST(_fp->s_from_T_v(T, v), s, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->s_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  REL_TEST(_fp->cv_from_T_v(T, v), _fp->cv_from_v_e(v, e), REL_TOL_CONSISTENCY);

  REL_TEST(_fp->p_from_h_s(h, s), p, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->p_from_h_s, h, s, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->rho_from_p_s(p, s), rho, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->rho_from_p_s, p, s, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->p_from_v_e(v, e), p, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->p_from_v_e, v, e, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->T_from_v_e(v, e), T, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->T_from_v_e, v, e, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->c_from_v_e(v, e), 398.896207251962, REL_TOL_SAVED_VALUE);
  REL_TEST(_fp->cp_from_v_e(v, e), 987.13756097561, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->cp_from_v_e, v, e, REL_TOL_DERIVATIVE);
  REL_TEST(_fp->cv_from_v_e(v, e), 700.09756097561, REL_TOL_SAVED_VALUE);
  REL_TEST(_fp->mu_from_v_e(v, e), 18.23e-6, 1e-15);
  REL_TEST(_fp->k_from_v_e(v, e), 25.68e-3, 1e-15);

  REL_TEST(_fp->beta_from_p_T(p, T), 2.54355843825512e-3, REL_TOL_SAVED_VALUE);

  REL_TEST(_fp->s_from_v_e(v, e), 2.58890011905277e3, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->s_from_v_e, v, e, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->rho_from_p_T(p, T), 0.897875065343506, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->rho_from_p_T, p, T, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->v_from_p_T(p, T), 1.0 / 0.897875065343506, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->v_from_p_T, p, T, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->e_from_p_rho(p, rho), 2.75243356098e5, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->e_from_p_rho, p, rho, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->h_from_p_T(p, T), 3.88093132097561e5, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->h_from_p_T, p, T, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->s_from_p_T(p, T), 2.588900119052767e3, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->s_from_p_T, p, T, REL_TOL_DERIVATIVE);
  ABS_TEST(_fp->s_from_h_p(h, p), 2.588900119052767e3, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->s_from_h_p, h, p, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->e_from_p_T(p, T), 2.75243356097561e5, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->e_from_p_T, p, T, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->molarMass(), 0.0289662061037, REL_TOL_SAVED_VALUE);

  ABS_TEST(_fp->T_from_p_h(p, h), T, REL_TOL_CONSISTENCY);

  REL_TEST(_fp->mu_from_p_T(p, T), 18.23e-6, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->mu_from_p_T, p, T, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->k_from_p_T(p, T), 25.68e-3, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->k_from_p_T, p, T, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->cv_from_p_T(p, T), 700.09756097561, REL_TOL_SAVED_VALUE);
  REL_TEST(_fp->cp_from_p_T(p, T), 987.13756097561, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->cp_from_p_T, p, T, REL_TOL_DERIVATIVE);

  // Test when R and gamma are not provided
  const Real molar_mass = 0.029;
  const Real cv = 718.0;
  const Real cp = 1005.0;
  const Real thermal_conductivity = 0.02568;
  const Real entropy = 1767.24985689;
  const Real viscosity = 18.23e-6;
  Real henry = 0.0;
  const Real R = 8.3144598;

  const Real tol = REL_TOL_CONSISTENCY;

  p = 1.0e6;
  T = 300.0;

  REL_TEST(_fp_pT->beta_from_p_T(p, T), 1.0 / T, tol);
  REL_TEST(_fp_pT->cp_from_p_T(p, T), cp, tol);
  REL_TEST(_fp_pT->cv_from_p_T(p, T), cv, tol);
  REL_TEST(_fp_pT->c_from_p_T(p, T), std::sqrt(cp * R * T / (cv * molar_mass)), tol);
  REL_TEST(_fp_pT->k_from_p_T(p, T), thermal_conductivity, tol);
  REL_TEST(_fp_pT->k_from_p_T(p, T), thermal_conductivity, tol);
  REL_TEST(_fp_pT->s_from_p_T(p, T), entropy, tol);

  REL_TEST(_fp_pT->rho_from_p_T(p, T), p * molar_mass / (R * T), tol);
  REL_TEST(_fp_pT->e_from_p_T(p, T), cv * T, tol);
  REL_TEST(_fp_pT->mu_from_p_T(p, T), viscosity, tol);
  REL_TEST(_fp_pT->mu_from_p_T(p, T), viscosity, tol);
  REL_TEST(_fp_pT->h_from_p_T(p, T), cp * T, tol);
  ABS_TEST(_fp_pT->henryConstant(T), henry, tol);

  DERIV_TEST(_fp_pT->rho_from_p_T, p, T, REL_TOL_DERIVATIVE);
  DERIV_TEST(_fp_pT->mu_from_p_T, p, T, REL_TOL_DERIVATIVE);
  DERIV_TEST(_fp_pT->e_from_p_T, p, T, REL_TOL_DERIVATIVE);
  DERIV_TEST(_fp_pT->h_from_p_T, p, T, REL_TOL_DERIVATIVE);
  DERIV_TEST(_fp_pT->k_from_p_T, p, T, REL_TOL_DERIVATIVE);

  Real dhenry_dT;
  _fp_pT->henryConstant(T, henry, dhenry_dT);
  ABS_TEST(dhenry_dT, 0.0, tol);
}
TEST_F(IdealRealGasMixtureFluidPropertiesTest, test)
{
  Real T = 400.;
  Real p = 100000.;
  std::vector<Real> x = {0.9};

  // pure fluids
  Real rho_nitrogen = _fp_nitrogen->rho_from_p_T(p, T);
  Real rho_steam = _fp_steam->rho_from_p_T(p, T);
  REL_TEST(rho_nitrogen, 0.84228968026683726, REL_TOL_CONSISTENCY);
  REL_TEST(rho_steam, 0.61493738819320221, REL_TOL_CONSISTENCY);

  // mixture properties
  Real rho_mix = _fp_mix->rho_from_p_T(p, T, x);
  Real v_mix = _fp_mix->v_from_p_T(p, T, x);
  Real e_mix = _fp_mix->e_from_p_T(p, T, x);
  Real c_mix = _fp_mix->c_from_p_T(p, T, x);
  Real cp_mix = _fp_mix->cp_from_p_T(p, T, x);
  Real cv_mix = _fp_mix->cv_from_p_T(p, T, x);
  Real mu_mix = _fp_mix->mu_from_p_T(p, T, x);
  Real k_mix = _fp_mix->k_from_p_T(p, T, x);
  REL_TEST(rho_mix, 0.88183704292782583, REL_TOL_CONSISTENCY);
  REL_TEST(v_mix, 1.1339963636363655, REL_TOL_CONSISTENCY);
  REL_TEST(e_mix, 523068.96363636368, REL_TOL_CONSISTENCY);
  REL_TEST(c_mix, 418.49693534182865, REL_TOL_CONSISTENCY);
  REL_TEST(cp_mix, 1083.6715000000002, REL_TOL_CONSISTENCY);
  REL_TEST(cv_mix, 771.82250000000022, REL_TOL_CONSISTENCY);
  REL_TEST(mu_mix, 0.000013317970680742846, REL_TOL_CONSISTENCY);
  REL_TEST(k_mix, 0.026852020459600251, REL_TOL_CONSISTENCY);

  // check inverse functions of (v,e)
  Real p_mix = _fp_mix->p_from_v_e(v_mix, e_mix, x);
  Real T_mix = _fp_mix->T_from_v_e(v_mix, e_mix, x);
  REL_TEST(p_mix, p, REL_TOL_CONSISTENCY);
  REL_TEST(T_mix, T, REL_TOL_CONSISTENCY);

  //////////////////////////////////////////////////////////////////////////////
  // note that the VAPOR_MIX_DERIV_TEST works for binary mixtures only (for now)
  //////////////////////////////////////////////////////////////////////////////

  // check analytical derivatives from (p,T)
  VAPOR_MIX_DERIV_TEST(_fp_mix->rho_from_p_T, p, T, x, REL_TOL_DERIVATIVE);
  VAPOR_MIX_DERIV_TEST(_fp_mix->v_from_p_T, p, T, x, REL_TOL_DERIVATIVE);
  // the following test fails since the pertubation in VAPOR_MIX_DERIV_TEST
  // is too small if v(p,T) is iterated within e_from_p_T
  // VAPOR_MIX_DERIV_TEST(_fp_mix->e_from_p_T, p, T, x, REL_TOL_DERIVATIVE);
  Real e, de_dp, de_dT;
  std::vector<Real> de_dx;
  de_dx.resize(_fp_mix->getNumberOfSecondaryVapors());
  _fp_mix->e_from_p_T(p, T, x, e, de_dp, de_dT, de_dx);
  Real dp = p * 1.e-5;
  Real p1 = _fp_mix->e_from_p_T(p - dp, T, x);
  Real p2 = _fp_mix->e_from_p_T(p + dp, T, x);
  Real de_dp_num = (p2 - p1) / (2.0 * dp);
  REL_TEST(de_dp, de_dp_num, REL_TOL_DERIVATIVE);

  // check analytical derivatives from (v,e)
  VAPOR_MIX_DERIV_TEST(_fp_mix->p_from_v_e, v_mix, e_mix, x, REL_TOL_DERIVATIVE);
  VAPOR_MIX_DERIV_TEST(_fp_mix->T_from_v_e, v_mix, e_mix, x, REL_TOL_DERIVATIVE);

  // check analytical derivatives from (T,v)
  VAPOR_MIX_DERIV_TEST(_fp_mix->p_from_T_v, T, v_mix, x, REL_TOL_DERIVATIVE);
  VAPOR_MIX_DERIV_TEST(_fp_mix->e_from_T_v, T, v_mix, x, REL_TOL_DERIVATIVE);

  // state-of-the-art mixture model comparison
  T = 360.;
  p = 100000.;
  x[0] = 0.5;
  rho_mix = _fp_mix->rho_from_p_T(p, T, x); // 0.7362935
  v_mix = _fp_mix->v_from_p_T(p, T, x);     // 1.3581540
  e_mix = _fp_mix->e_from_p_T(p, T, x);     // 1380586.9
  c_mix = _fp_mix->c_from_p_T(p, T, x);     // 428.1928
  cp_mix = _fp_mix->cp_from_p_T(p, T, x);   // 1479.7114
  cv_mix = _fp_mix->cv_from_p_T(p, T, x);   // 1090.5912
  // these quantities cannot be calculated with the state-of-the-art mixture model
  // mu_mix = _fp_mix->mu_from_p_T(p, T, x);
  // k_mix = _fp_mix->k_from_p_T(p, T, x);

  REL_TEST(rho_mix, 0.7362935, 0.115554);
  REL_TEST(v_mix, 1.3581540, 0.103585);
  REL_TEST(e_mix, 1380586.9, 0.023648);
  REL_TEST(c_mix, 428.1928, 0.017535);
  REL_TEST(cp_mix, 1479.7114, 0.146444);
  REL_TEST(cv_mix, 1090.5912, 0.183001);
}
예제 #26
0
/*
 * Verify calculation of liquid density, viscosity, enthalpy, and derivatives
 */
TEST_F(PorousFlowBrineCO2Test, liquidProperties)
{
  const Real p = 1.0e6;
  const Real T = 350.0;
  const Real Xnacl = 0.1;

  FluidStatePhaseEnum phase_state;
  const unsigned int np = _fp->numPhases();
  const unsigned int nc = _fp->numComponents();
  std::vector<FluidStateProperties> fsp(np, FluidStateProperties(nc));

  // Liquid region
  Real Z = 0.0001;
  _fp->massFractions(p, T, Xnacl, Z, phase_state, fsp);
  EXPECT_EQ(phase_state, FluidStatePhaseEnum::LIQUID);

  // Verify fluid density and viscosity
  _fp->liquidProperties(p, T, Xnacl, fsp);

  Real liquid_density = fsp[0].density;
  Real liquid_viscosity = fsp[0].viscosity;
  Real liquid_enthalpy = fsp[0].enthalpy;

  Real co2_partial_density, dco2_partial_density_dT;
  _fp->partialDensityCO2(T, co2_partial_density, dco2_partial_density_dT);
  Real brine_density = _brine_fp->rho(p, T, Xnacl);

  Real density = 1.0 / (Z / co2_partial_density + (1.0 - Z) / brine_density);

  Real viscosity = _brine_fp->mu(p, T, Xnacl);

  Real brine_enthalpy = _brine_fp->h(p, T, Xnacl);
  Real hdis, dhdis_dT;
  _fp->enthalpyOfDissolution(T, hdis, dhdis_dT);
  Real co2_enthalpy = _co2_fp->h(p, T);
  Real enthalpy = (1.0 - Z) * brine_enthalpy + Z * (co2_enthalpy + hdis);

  ABS_TEST(liquid_density, density, 1.0e-12);
  ABS_TEST(liquid_viscosity, viscosity, 1.0e-12);
  ABS_TEST(liquid_enthalpy, enthalpy, 1.0e-12);

  // Verify fluid density and viscosity derivatives
  Real ddensity_dp = fsp[0].ddensity_dp;
  Real ddensity_dT = fsp[0].ddensity_dT;
  Real ddensity_dZ = fsp[0].ddensity_dZ;
  Real ddensity_dX = fsp[0].ddensity_dX;
  Real dviscosity_dp = fsp[0].dviscosity_dp;
  Real dviscosity_dT = fsp[0].dviscosity_dT;
  Real dviscosity_dZ = fsp[0].dviscosity_dZ;
  Real dviscosity_dX = fsp[0].dviscosity_dX;
  Real denthalpy_dp = fsp[0].denthalpy_dp;
  Real denthalpy_dT = fsp[0].denthalpy_dT;
  Real denthalpy_dZ = fsp[0].denthalpy_dZ;
  Real denthalpy_dX = fsp[0].denthalpy_dX;

  // Derivatives wrt pressure
  const Real dp = 1.0;
  _fp->liquidProperties(p + dp, T, Xnacl, fsp);
  Real rho1 = fsp[0].density;
  Real mu1 = fsp[0].viscosity;
  Real h1 = fsp[0].enthalpy;

  _fp->liquidProperties(p - dp, T, Xnacl, fsp);
  Real rho2 = fsp[0].density;
  Real mu2 = fsp[0].viscosity;
  Real h2 = fsp[0].enthalpy;

  REL_TEST(ddensity_dp, (rho1 - rho2) / (2.0 * dp), 1.0e-4);
  REL_TEST(dviscosity_dp, (mu1 - mu2) / (2.0 * dp), 1.0e-5);
  REL_TEST(denthalpy_dp, (h1 - h2) / (2.0 * dp), 1.0e-4);

  // Derivatives wrt temperature
  const Real dT = 1.0e-4;
  _fp->liquidProperties(p, T + dT, Xnacl, fsp);
  rho1 = fsp[0].density;
  mu1 = fsp[0].viscosity;
  h1 = fsp[0].enthalpy;

  _fp->liquidProperties(p, T - dT, Xnacl, fsp);
  rho2 = fsp[0].density;
  mu2 = fsp[0].viscosity;
  h2 = fsp[0].enthalpy;

  REL_TEST(ddensity_dT, (rho1 - rho2) / (2.0 * dT), 1.0e-6);
  REL_TEST(dviscosity_dT, (mu1 - mu2) / (2.0 * dT), 1.0e-6);
  REL_TEST(denthalpy_dT, (h1 - h2) / (2.0 * dT), 1.0e-6);

  // Derivatives wrt Xnacl
  const Real dx = 1.0e-8;
  _fp->liquidProperties(p, T, Xnacl + dx, fsp);
  rho1 = fsp[0].density;
  mu1 = fsp[0].viscosity;
  h1 = fsp[0].enthalpy;

  _fp->liquidProperties(p, T, Xnacl - dx, fsp);
  rho2 = fsp[0].density;
  mu2 = fsp[0].viscosity;
  h2 = fsp[0].enthalpy;

  REL_TEST(ddensity_dX, (rho1 - rho2) / (2.0 * dx), 1.0e-6);
  REL_TEST(dviscosity_dX, (mu1 - mu2) / (2.0 * dx), 1.0e-6);
  REL_TEST(denthalpy_dX, (h1 - h2) / (2.0 * dx), 1.0e-6);

  // Derivatives wrt Z
  const Real dZ = 1.0e-8;
  _fp->massFractions(p, T, Xnacl, Z + dZ, phase_state, fsp);
  _fp->liquidProperties(p, T, Xnacl, fsp);
  rho1 = fsp[0].density;
  mu1 = fsp[0].viscosity;
  h1 = fsp[0].enthalpy;

  _fp->massFractions(p, T, Xnacl, Z - dZ, phase_state, fsp);
  _fp->liquidProperties(p, T, Xnacl, fsp);
  rho2 = fsp[0].density;
  mu2 = fsp[0].viscosity;
  h2 = fsp[0].enthalpy;

  REL_TEST(ddensity_dZ, (rho1 - rho2) / (2.0 * dZ), 1.0e-6);
  ABS_TEST(dviscosity_dZ, (mu1 - mu2) / (2.0 * dZ), 1.0e-6);
  REL_TEST(denthalpy_dZ, (h1 - h2) / (2.0 * dZ), 1.0e-6);

  // Two-phase region
  Z = 0.045;
  _fp->massFractions(p, T, Xnacl, Z, phase_state, fsp);
  EXPECT_EQ(phase_state, FluidStatePhaseEnum::TWOPHASE);

  // Verify fluid density and viscosity derivatives
  _fp->liquidProperties(p, T, Xnacl, fsp);

  ddensity_dp = fsp[0].ddensity_dp;
  ddensity_dT = fsp[0].ddensity_dT;
  ddensity_dX = fsp[0].ddensity_dX;
  ddensity_dZ = fsp[0].ddensity_dZ;
  dviscosity_dp = fsp[0].dviscosity_dp;
  dviscosity_dT = fsp[0].dviscosity_dT;
  dviscosity_dX = fsp[0].dviscosity_dX;
  dviscosity_dZ = fsp[0].dviscosity_dZ;
  denthalpy_dp = fsp[0].denthalpy_dp;
  denthalpy_dT = fsp[0].denthalpy_dT;
  denthalpy_dZ = fsp[0].denthalpy_dZ;
  denthalpy_dX = fsp[0].denthalpy_dX;

  // Derivatives wrt pressure
  _fp->massFractions(p + dp, T, Xnacl, Z, phase_state, fsp);
  _fp->liquidProperties(p + dp, T, Xnacl, fsp);
  rho1 = fsp[0].density;
  mu1 = fsp[0].viscosity;
  h1 = fsp[0].enthalpy;

  _fp->massFractions(p - dp, T, Xnacl, Z, phase_state, fsp);
  _fp->liquidProperties(p - dp, T, Xnacl, fsp);
  rho2 = fsp[0].density;
  mu2 = fsp[0].viscosity;
  h2 = fsp[0].enthalpy;

  REL_TEST(ddensity_dp, (rho1 - rho2) / (2.0 * dp), 1.0e-4);
  REL_TEST(dviscosity_dp, (mu1 - mu2) / (2.0 * dp), 1.0e-5);
  REL_TEST(denthalpy_dp, (h1 - h2) / (2.0 * dp), 1.0e-4);

  // Derivatives wrt temperature
  _fp->massFractions(p, T + dT, Xnacl, Z, phase_state, fsp);
  _fp->liquidProperties(p, T + dT, Xnacl, fsp);
  rho1 = fsp[0].density;
  mu1 = fsp[0].viscosity;
  h1 = fsp[0].enthalpy;

  _fp->massFractions(p, T - dT, Xnacl, Z, phase_state, fsp);
  _fp->liquidProperties(p, T - dT, Xnacl, fsp);
  rho2 = fsp[0].density;
  mu2 = fsp[0].viscosity;
  h2 = fsp[0].enthalpy;

  REL_TEST(ddensity_dT, (rho1 - rho2) / (2.0 * dT), 1.0e-6);
  REL_TEST(dviscosity_dT, (mu1 - mu2) / (2.0 * dT), 1.0e-6);
  REL_TEST(denthalpy_dT, (h1 - h2) / (2.0 * dT), 1.0e-6);

  // Derivatives wrt Xnacl
  _fp->massFractions(p, T, Xnacl + dx, Z, phase_state, fsp);
  _fp->liquidProperties(p, T, Xnacl + dx, fsp);
  rho1 = fsp[0].density;
  mu1 = fsp[0].viscosity;
  h1 = fsp[0].enthalpy;

  _fp->massFractions(p, T, Xnacl - dx, Z, phase_state, fsp);
  _fp->liquidProperties(p, T, Xnacl - dx, fsp);
  rho2 = fsp[0].density;
  mu2 = fsp[0].viscosity;
  h2 = fsp[0].enthalpy;

  REL_TEST(ddensity_dX, (rho1 - rho2) / (2.0 * dx), 1.0e-6);
  REL_TEST(dviscosity_dX, (mu1 - mu2) / (2.0 * dx), 1.0e-6);
  REL_TEST(denthalpy_dX, (h1 - h2) / (2.0 * dx), 1.0e-6);

  // Derivatives wrt Z
  _fp->massFractions(p, T, Xnacl, Z + dZ, phase_state, fsp);
  _fp->liquidProperties(p, T, Xnacl, fsp);
  rho1 = fsp[0].density;
  mu1 = fsp[0].viscosity;
  h1 = fsp[0].enthalpy;

  _fp->massFractions(p, T, Xnacl, Z - dZ, phase_state, fsp);
  _fp->liquidProperties(p, T, Xnacl, fsp);
  rho2 = fsp[0].density;
  mu2 = fsp[0].viscosity;
  h2 = fsp[0].enthalpy;

  ABS_TEST(ddensity_dZ, (rho1 - rho2) / (2.0 * dZ), 1.0e-6);
  ABS_TEST(dviscosity_dZ, (mu1 - mu2) / (2.0 * dZ), 1.0e-6);
  ABS_TEST(denthalpy_dZ, (h1 - h2) / (2.0 * dZ), 1.0e-6);
}
예제 #27
0
/*
 * Verify calculation of gas saturation and derivatives in the two-phase region
 */
TEST_F(PorousFlowWaterNCGTest, twoPhase)
{
  const Real p = 1.0e6;
  const Real T = 350.0;

  FluidStatePhaseEnum phase_state;
  std::vector<FluidStateProperties> fsp(2, FluidStateProperties(2));

  // In the two-phase region, the mass fractions are the equilibrium values, so
  // a temporary value of Z can be used (as long as it corresponds to the two-phase
  // region)
  Real Z = 0.45;
  _fp->massFractions(p, T, Z, phase_state, fsp);
  EXPECT_EQ(phase_state, FluidStatePhaseEnum::TWOPHASE);

  // Calculate Z that gives a saturation of 0.25
  Real gas_saturation = 0.25;
  Real liquid_pressure = p + _pc->capillaryPressure(1.0 - gas_saturation);
  // Calculate gas density and liquid density
  _fp->gasProperties(p, T, fsp);
  _fp->liquidProperties(liquid_pressure, T, fsp);

  // The mass fraction that corresponds to a gas_saturation = 0.25
  Z = (gas_saturation * fsp[1].density * fsp[1].mass_fraction[1] +
       (1.0 - gas_saturation) * fsp[0].density * fsp[0].mass_fraction[1]) /
      (gas_saturation * fsp[1].density + (1.0 - gas_saturation) * fsp[0].density);

  // Calculate the gas saturation and derivatives
  _fp->saturationTwoPhase(p, T, Z, fsp);

  ABS_TEST(fsp[1].saturation, gas_saturation, 1.0e-8);

  // Test the derivatives
  const Real dp = 1.0e-1;
  gas_saturation = fsp[1].saturation;
  Real dgas_saturation_dp = fsp[1].dsaturation_dp;
  Real dgas_saturation_dT = fsp[1].dsaturation_dT;
  Real dgas_saturation_dZ = fsp[1].dsaturation_dZ;

  _fp->massFractions(p + dp, T, Z, phase_state, fsp);
  _fp->gasProperties(p + dp, T, fsp);
  _fp->saturationTwoPhase(p + dp, T, Z, fsp);
  Real gsat1 = fsp[1].saturation;

  _fp->massFractions(p - dp, T, Z, phase_state, fsp);
  _fp->gasProperties(p - dp, T, fsp);
  _fp->saturationTwoPhase(p - dp, T, Z, fsp);
  Real gsat2 = fsp[1].saturation;

  REL_TEST(dgas_saturation_dp, (gsat1 - gsat2) / (2.0 * dp), 1.0e-6);

  // Derivative wrt T
  const Real dT = 1.0e-4;
  _fp->massFractions(p, T + dT, Z, phase_state, fsp);
  _fp->gasProperties(p, T + dT, fsp);
  _fp->saturationTwoPhase(p, T + dT, Z, fsp);
  gsat1 = fsp[1].saturation;

  _fp->massFractions(p, T - dT, Z, phase_state, fsp);
  _fp->gasProperties(p, T - dT, fsp);
  _fp->saturationTwoPhase(p, T - dT, Z, fsp);
  gsat2 = fsp[1].saturation;

  REL_TEST(dgas_saturation_dT, (gsat1 - gsat2) / (2.0 * dT), 1.0e-6);

  // Derivative wrt Z
  const Real dZ = 1.0e-8;

  _fp->massFractions(p, T, Z, phase_state, fsp);
  _fp->gasProperties(p, T, fsp);
  _fp->saturationTwoPhase(p, T, Z + dZ, fsp);
  gsat1 = fsp[1].saturation;

  _fp->saturationTwoPhase(p, T, Z - dZ, fsp);
  gsat2 = fsp[1].saturation;

  REL_TEST(dgas_saturation_dZ, (gsat1 - gsat2) / (2.0 * dZ), 1.0e-6);
}
예제 #28
0
/*
 * Verify calculation of liquid density, viscosity, enthalpy and derivatives. Note that as
 * density and viscosity don't depend on mass fraction, only the liquid region needs to be
 * tested (the calculations are identical in the two phase region). The enthalpy does depend
 * on mass fraction, so should be tested in the two phase region as well as the liquid region
 */
TEST_F(PorousFlowWaterNCGTest, liquidProperties)
{
  const Real p = 1.0e6;
  const Real T = 350.0;
  std::vector<FluidStateProperties> fsp(2, FluidStateProperties(2));

  // Verify fluid density and viscosity
  _fp->liquidProperties(p, T, fsp);
  Real liquid_density = fsp[0].density;
  Real liquid_viscosity = fsp[0].viscosity;
  Real density = _water_fp->rho_from_p_T(p, T);
  Real viscosity = _water_fp->mu(p, T);

  ABS_TEST(liquid_density, density, 1.0e-12);
  ABS_TEST(liquid_viscosity, viscosity, 1.0e-12);

  // Verify derivatives
  Real ddensity_dp = fsp[0].ddensity_dp;
  Real ddensity_dT = fsp[0].ddensity_dT;
  Real ddensity_dZ = fsp[0].ddensity_dZ;
  Real dviscosity_dp = fsp[0].dviscosity_dp;
  Real dviscosity_dT = fsp[0].dviscosity_dT;
  Real dviscosity_dZ = fsp[0].dviscosity_dZ;
  Real denthalpy_dp = fsp[0].denthalpy_dp;
  Real denthalpy_dT = fsp[0].denthalpy_dT;
  Real denthalpy_dZ = fsp[0].denthalpy_dZ;

  const Real dp = 1.0;
  _fp->liquidProperties(p + dp, T, fsp);
  Real rho1 = fsp[0].density;
  Real mu1 = fsp[0].viscosity;
  Real h1 = fsp[0].enthalpy;

  _fp->liquidProperties(p - dp, T, fsp);
  Real rho2 = fsp[0].density;
  Real mu2 = fsp[0].viscosity;
  Real h2 = fsp[0].enthalpy;

  REL_TEST(ddensity_dp, (rho1 - rho2) / (2.0 * dp), 1.0e-6);
  REL_TEST(dviscosity_dp, (mu1 - mu2) / (2.0 * dp), 1.0e-5);
  REL_TEST(denthalpy_dp, (h1 - h2) / (2.0 * dp), 1.0e-5);

  const Real dT = 1.0e-4;
  _fp->liquidProperties(p, T + dT, fsp);
  rho1 = fsp[0].density;
  mu1 = fsp[0].viscosity;
  h1 = fsp[0].enthalpy;

  _fp->liquidProperties(p, T - dT, fsp);
  rho2 = fsp[0].density;
  mu2 = fsp[0].viscosity;
  h2 = fsp[0].enthalpy;

  REL_TEST(ddensity_dT, (rho1 - rho2) / (2.0 * dT), 1.0e-6);
  REL_TEST(dviscosity_dT, (mu1 - mu2) / (2.0 * dT), 1.0e-6);
  REL_TEST(denthalpy_dT, (h1 - h2) / (2.0 * dT), 1.0e-5);

  Real Z = 0.0001;
  const Real dZ = 1.0e-8;
  FluidStatePhaseEnum phase_state;

  _fp->massFractions(p, T, Z, phase_state, fsp);
  _fp->liquidProperties(p, T, fsp);
  denthalpy_dp = fsp[0].denthalpy_dp;
  denthalpy_dT = fsp[0].denthalpy_dT;
  denthalpy_dZ = fsp[0].denthalpy_dZ;

  _fp->massFractions(p, T, Z + dZ, phase_state, fsp);
  _fp->liquidProperties(p, T, fsp);
  h1 = fsp[0].enthalpy;

  _fp->massFractions(p, T, Z - dZ, phase_state, fsp);
  _fp->liquidProperties(p, T, fsp);
  h2 = fsp[0].enthalpy;

  REL_TEST(denthalpy_dZ, (h1 - h2) / (2.0 * dZ), 1.0e-6);

  // Density and viscosity don't depend on Z, so derivatives should be 0
  ABS_TEST(ddensity_dZ, 0.0, 1.0e-12);
  ABS_TEST(dviscosity_dZ, 0.0, 1.0e-12);

  // Check enthalpy calculations in the two phase region as well. Note that the mass fractions
  // vary with pressure and temperature in this region
  Z = 0.45;
  _fp->massFractions(p, T, Z, phase_state, fsp);
  _fp->liquidProperties(p, T, fsp);
  denthalpy_dp = fsp[0].denthalpy_dp;
  denthalpy_dT = fsp[0].denthalpy_dT;
  denthalpy_dZ = fsp[0].denthalpy_dZ;

  _fp->massFractions(p + dp, T, Z, phase_state, fsp);
  _fp->liquidProperties(p + dp, T, fsp);
  h1 = fsp[0].enthalpy;

  _fp->massFractions(p - dp, T, Z, phase_state, fsp);
  _fp->liquidProperties(p - dp, T, fsp);
  h2 = fsp[0].enthalpy;

  REL_TEST(denthalpy_dp, (h1 - h2) / (2.0 * dp), 1.0e-5);

  _fp->massFractions(p, T + dT, Z, phase_state, fsp);
  _fp->liquidProperties(p, T + dT, fsp);
  h1 = fsp[0].enthalpy;

  _fp->massFractions(p, T - dT, Z, phase_state, fsp);
  _fp->liquidProperties(p, T - dT, fsp);
  h2 = fsp[0].enthalpy;

  REL_TEST(denthalpy_dT, (h1 - h2) / (2.0 * dT), 1.0e-5);

  _fp->massFractions(p, T, Z + dZ, phase_state, fsp);
  _fp->liquidProperties(p, T, fsp);
  h1 = fsp[0].enthalpy;

  _fp->massFractions(p, T, Z - dZ, phase_state, fsp);
  _fp->liquidProperties(p, T, fsp);
  h2 = fsp[0].enthalpy;

  ABS_TEST(denthalpy_dZ, (h1 - h2) / (2.0 * dZ), 1.0e-5);
}
TEST_F(StiffenedGasFluidPropertiesTest, testAll)
{
  const Real T = 20. + 273.15; // K
  const Real p = 101325;       // Pa

  const Real rho = _fp->rho_from_p_T(p, T);
  const Real v = 1 / rho;
  const Real e = _fp->e_from_p_rho(p, rho);
  const Real s = _fp->s_from_v_e(v, e);
  const Real h = _fp->h_from_p_T(p, T);

  Real e_inv = _fp->e_from_T_v(T, v);
  REL_TEST(e_inv, e, 10.0 * REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->e_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  Real p_inv = _fp->p_from_T_v(T, v);
  REL_TEST(p_inv, p, 10.0 * REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->p_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  REL_TEST(_fp->h_from_T_v(T, v), h, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->h_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  REL_TEST(_fp->s_from_T_v(T, v), s, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->s_from_T_v, T, v, 10.0 * REL_TOL_DERIVATIVE);
  REL_TEST(_fp->cv_from_T_v(T, v), _fp->cv_from_v_e(v, e), REL_TOL_CONSISTENCY);

  REL_TEST(_fp->p_from_h_s(h, s), p, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->p_from_h_s, h, s, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->rho_from_p_s(p, s), rho, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->rho_from_p_s, p, s, 1e-5);

  REL_TEST(_fp->p_from_v_e(v, e), p, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->p_from_v_e, v, e, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->T_from_v_e(v, e), T, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->T_from_v_e, v, e, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->c_from_v_e(v, e), 1.299581997797754e3, REL_TOL_SAVED_VALUE);
  REL_TEST(_fp->cp_from_v_e(v, e), 4267.6, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->cp_from_v_e, v, e, REL_TOL_DERIVATIVE);
  REL_TEST(_fp->cv_from_v_e(v, e), 1816, REL_TOL_SAVED_VALUE);
  REL_TEST(_fp->mu_from_v_e(v, e), 0.001, 1e-15);
  REL_TEST(_fp->k_from_v_e(v, e), 0.6, 1e-15);

  REL_TEST(_fp->beta_from_p_T(p, T), 3.411222923418045e-3, REL_TOL_SAVED_VALUE);

  REL_TEST(_fp->s_from_v_e(v, e), -2.656251807629821e4, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->s_from_v_e, v, e, 1e-5);

  ABS_TEST(_fp->rho_from_p_T(p, T), 1.391568186319449e3, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->rho_from_p_T, p, T, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->v_from_p_T(p, T), 1.0 / 1.391568186319449e3, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->v_from_p_T, p, T, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->e_from_p_rho(p, rho), 8.397412646416598e4, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->e_from_p_rho, p, rho, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->h_from_p_T(p, T), 8.404693999999994e4, 1e-10);
  DERIV_TEST(_fp->h_from_p_T, p, T, REL_TOL_DERIVATIVE);

  ABS_TEST(_fp->s_from_p_T(p, T), -2.6562518076298216e4, 4 * REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->s_from_p_T, p, T, REL_TOL_DERIVATIVE);
  ABS_TEST(_fp->s_from_h_p(h, p), -2.6562518076298216e4, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->s_from_h_p, h, p, 1e-5);

  ABS_TEST(_fp->e_from_p_T(p, T), 8.397412646416575e4, 1e-10);
  DERIV_TEST(_fp->e_from_p_T, p, T, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->T_from_p_h(p, h), T, REL_TOL_CONSISTENCY);

  REL_TEST(_fp->mu_from_p_T(p, T), 0.001, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->mu_from_p_T, p, T, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->k_from_p_T(p, T), 0.6, REL_TOL_CONSISTENCY);
  DERIV_TEST(_fp->k_from_p_T, p, T, REL_TOL_DERIVATIVE);

  REL_TEST(_fp->cv_from_p_T(p, T), 1816, REL_TOL_SAVED_VALUE);
  REL_TEST(_fp->cp_from_p_T(p, T), 4267.6, REL_TOL_SAVED_VALUE);
  DERIV_TEST(_fp->cp_from_p_T, p, T, REL_TOL_DERIVATIVE);
}
예제 #30
0
/*
 * Verify calculation of gas density, viscosity, enthalpy and derivatives
 */
TEST_F(PorousFlowWaterNCGTest, gasProperties)
{
  const Real p = 1.0e6;
  const Real T = 350.0;
  FluidStatePhaseEnum phase_state;
  std::vector<FluidStateProperties> fsp(2, FluidStateProperties(2));

  // Gas region
  Real Z = 0.995;
  _fp->massFractions(p, T, Z, phase_state, fsp);
  EXPECT_EQ(phase_state, FluidStatePhaseEnum::GAS);

  // Verify fluid density, viscosity and enthalpy
  _fp->gasProperties(p, T, fsp);
  Real gas_density = fsp[1].density;
  Real gas_viscosity = fsp[1].viscosity;
  Real gas_enthalpy = fsp[1].enthalpy;

  Real density =
      _ncg_fp->rho_from_p_T(Z * p, T) + _water_fp->rho_from_p_T(_water_fp->vaporPressure(T), T);
  Real viscosity =
      Z * _ncg_fp->mu(Z * p, T) + (1.0 - Z) * _water_fp->mu(_water_fp->vaporPressure(T), T);
  Real enthalpy =
      Z * _ncg_fp->h(Z * p, T) + (1.0 - Z) * _water_fp->h(_water_fp->vaporPressure(T), T);

  ABS_TEST(gas_density, density, 1.0e-8);
  ABS_TEST(gas_viscosity, viscosity, 1.0e-8);
  ABS_TEST(gas_enthalpy, enthalpy, 1.0e-8);

  // Verify derivatives
  Real ddensity_dp = fsp[1].ddensity_dp;
  Real ddensity_dT = fsp[1].ddensity_dT;
  Real ddensity_dZ = fsp[1].ddensity_dZ;
  Real dviscosity_dp = fsp[1].dviscosity_dp;
  Real dviscosity_dT = fsp[1].dviscosity_dT;
  Real dviscosity_dZ = fsp[1].dviscosity_dZ;
  Real denthalpy_dp = fsp[1].denthalpy_dp;
  Real denthalpy_dT = fsp[1].denthalpy_dT;
  Real denthalpy_dZ = fsp[1].denthalpy_dZ;

  const Real dp = 1.0e-1;
  _fp->gasProperties(p + dp, T, fsp);
  Real rho1 = fsp[1].density;
  Real mu1 = fsp[1].viscosity;
  Real h1 = fsp[1].enthalpy;

  _fp->gasProperties(p - dp, T, fsp);
  Real rho2 = fsp[1].density;
  Real mu2 = fsp[1].viscosity;
  Real h2 = fsp[1].enthalpy;

  REL_TEST(ddensity_dp, (rho1 - rho2) / (2.0 * dp), 1.0e-6);
  REL_TEST(dviscosity_dp, (mu1 - mu2) / (2.0 * dp), 1.0e-6);
  REL_TEST(denthalpy_dp, (h1 - h2) / (2.0 * dp), 1.0e-6);

  const Real dT = 1.0e-3;
  _fp->gasProperties(p, T + dT, fsp);
  rho1 = fsp[1].density;
  mu1 = fsp[1].viscosity;
  h1 = fsp[1].enthalpy;

  _fp->gasProperties(p, T - dT, fsp);
  rho2 = fsp[1].density;
  mu2 = fsp[1].viscosity;
  h2 = fsp[1].enthalpy;

  REL_TEST(ddensity_dT, (rho1 - rho2) / (2.0 * dT), 1.0e-6);
  REL_TEST(dviscosity_dT, (mu1 - mu2) / (2.0 * dT), 1.0e-6);
  REL_TEST(denthalpy_dT, (h1 - h2) / (2.0 * dT), 1.0e-6);

  // Note: mass fraction changes with Z
  const Real dZ = 1.0e-8;
  _fp->massFractions(p, T, Z + dZ, phase_state, fsp);
  _fp->gasProperties(p, T, fsp);
  rho1 = fsp[1].density;
  mu1 = fsp[1].viscosity;
  h1 = fsp[1].enthalpy;

  _fp->massFractions(p, T, Z - dZ, phase_state, fsp);
  _fp->gasProperties(p, T, fsp);
  rho2 = fsp[1].density;
  mu2 = fsp[1].viscosity;
  h2 = fsp[1].enthalpy;

  REL_TEST(ddensity_dZ, (rho1 - rho2) / (2.0 * dZ), 1.0e-6);
  REL_TEST(dviscosity_dZ, (mu1 - mu2) / (2.0 * dZ), 1.0e-6);
  REL_TEST(denthalpy_dZ, (h1 - h2) / (2.0 * dZ), 1.0e-6);

  // Check derivatives in the two phase region as well. Note that the mass fractions
  // vary with pressure and temperature in this region
  Z = 0.45;
  _fp->massFractions(p, T, Z, phase_state, fsp);
  EXPECT_EQ(phase_state, FluidStatePhaseEnum::TWOPHASE);

  _fp->gasProperties(p, T, fsp);
  ddensity_dp = fsp[1].ddensity_dp;
  ddensity_dT = fsp[1].ddensity_dT;
  ddensity_dZ = fsp[1].ddensity_dZ;
  dviscosity_dp = fsp[1].dviscosity_dp;
  dviscosity_dT = fsp[1].dviscosity_dT;
  dviscosity_dZ = fsp[1].dviscosity_dZ;
  denthalpy_dp = fsp[1].denthalpy_dp;
  denthalpy_dT = fsp[1].denthalpy_dT;
  denthalpy_dZ = fsp[1].denthalpy_dZ;

  _fp->massFractions(p + dp, T, Z, phase_state, fsp);
  _fp->gasProperties(p + dp, T, fsp);
  rho1 = fsp[1].density;
  mu1 = fsp[1].viscosity;
  h1 = fsp[1].enthalpy;

  _fp->massFractions(p - dp, T, Z, phase_state, fsp);
  _fp->gasProperties(p - dp, T, fsp);
  rho2 = fsp[1].density;
  mu2 = fsp[1].viscosity;
  h2 = fsp[1].enthalpy;

  REL_TEST(ddensity_dp, (rho1 - rho2) / (2.0 * dp), 1.0e-6);
  REL_TEST(dviscosity_dp, (mu1 - mu2) / (2.0 * dp), 1.0e-6);
  REL_TEST(denthalpy_dp, (h1 - h2) / (2.0 * dp), 1.0e-6);

  _fp->massFractions(p, T + dT, Z, phase_state, fsp);
  _fp->gasProperties(p, T + dT, fsp);
  rho1 = fsp[1].density;
  mu1 = fsp[1].viscosity;
  h1 = fsp[1].enthalpy;

  _fp->massFractions(p, T - dT, Z, phase_state, fsp);
  _fp->gasProperties(p, T - dT, fsp);
  rho2 = fsp[1].density;
  mu2 = fsp[1].viscosity;
  h2 = fsp[1].enthalpy;

  REL_TEST(ddensity_dT, (rho1 - rho2) / (2.0 * dT), 1.0e-6);
  REL_TEST(dviscosity_dT, (mu1 - mu2) / (2.0 * dT), 1.0e-6);
  REL_TEST(denthalpy_dT, (h1 - h2) / (2.0 * dT), 1.0e-6);

  _fp->massFractions(p, T, Z + dZ, phase_state, fsp);
  _fp->gasProperties(p, T, fsp);
  rho1 = fsp[1].density;
  mu1 = fsp[1].viscosity;
  h1 = fsp[1].enthalpy;

  _fp->massFractions(p, T, Z - dZ, phase_state, fsp);
  _fp->gasProperties(p, T, fsp);
  rho2 = fsp[1].density;
  mu2 = fsp[1].viscosity;
  h2 = fsp[1].enthalpy;

  ABS_TEST(ddensity_dZ, (rho1 - rho2) / (2.0 * dZ), 1.0e-6);
  ABS_TEST(dviscosity_dT, (mu1 - mu2) / (2.0 * dZ), 1.0e-6);
  ABS_TEST(denthalpy_dZ, (h1 - h2) / (2.0 * dZ), 1.0e-6);
}