Skip to content
Permalink
Browse files

Merge pull request #12967 from cpgr/adbrine

AD BrineFluidProperties
  • Loading branch information...
andrsd committed Feb 26, 2019
2 parents 6442a85 + 70266ab commit 45e781387adb16e65ef5fded3caf3483d55298cf
@@ -10,14 +10,17 @@
#ifndef BRINEFLUIDPROPERTIES_H
#define BRINEFLUIDPROPERTIES_H

#include "MultiComponentFluidPropertiesPT.h"
#include "MultiComponentFluidProperties.h"
#include "Water97FluidProperties.h"

class BrineFluidProperties;

template <>
InputParameters validParams<BrineFluidProperties>();

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"

/**
* Brine (NaCl in H2O) fluid properties as a function of pressure (Pa),
* temperature (K) and NaCl mass fraction
@@ -33,7 +36,7 @@ InputParameters validParams<BrineFluidProperties>();
* Note: uses water thermal conductivity from IAPWS rather than the correlation
* given by Phillips et al.
*/
class BrineFluidProperties : public MultiComponentFluidPropertiesPT
class BrineFluidProperties : public MultiComponentFluidProperties
{
public:
BrineFluidProperties(const InputParameters & parameters);
@@ -51,6 +54,7 @@ class BrineFluidProperties : public MultiComponentFluidPropertiesPT
* @return average molar mass (kg/mol)
*/
Real molarMass(Real xnacl) const;
FPDualReal molarMass(const FPDualReal & xnacl) const;

/**
* NaCl molar mass
@@ -64,64 +68,61 @@ class BrineFluidProperties : public MultiComponentFluidPropertiesPT
*/
Real molarMassH2O() const;

virtual Real rho(Real pressure, Real temperature, Real xnacl) const override;

virtual void rho_dpTx(Real pressure,
Real temperature,
Real xnacl,
Real & rho,
Real & drho_dp,
Real & drho_dT,
Real & drho_dx) const override;

virtual Real mu(Real pressure, Real temperature, Real xnacl) const override;

virtual void mu_dpTx(Real pressure,
Real temperature,
Real xnacl,
Real & mu,
Real & dmu_dp,
Real & dmu_dT,
Real & dmu_dx) const override;

virtual void
rho_mu(Real pressure, Real temperature, Real xnacl, Real & rho, Real & mu) const override;

virtual void rho_mu_dpTx(Real pressure,
Real temperature,
Real xnacl,
Real & rho,
Real & drho_dp,
Real & drho_dT,
Real & drho_dx,
Real & mu,
Real & dmu_dp,
Real & dmu_dT,
Real & dmu_dx) const override;

virtual Real h(Real pressure, Real temperature, Real xnacl) const override;

virtual void h_dpTx(Real pressure,
Real temperature,
Real xnacl,
Real & h,
Real & dh_dp,
Real & dh_dT,
Real & dh_dx) const override;

virtual Real cp(Real pressure, Real temperature, Real xnacl) const override;

virtual Real e(Real pressure, Real temperature, Real xnacl) const override;

virtual void e_dpTx(Real pressure,
Real temperature,
Real xnacl,
Real & e,
Real & de_dp,
Real & de_dT,
Real & de_dx) const override;

virtual Real k(Real pressure, Real temperature, Real xnacl) const override;
virtual Real rho_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override;

FPDualReal rho_from_p_T_X(const FPDualReal & pressure,
const FPDualReal & temperature,
const FPDualReal & xnacl) const override;

virtual void rho_from_p_T_X(Real pressure,
Real temperature,
Real xnacl,
Real & rho,
Real & drho_dp,
Real & drho_dT,
Real & drho_dx) const override;

virtual Real mu_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override;

virtual void mu_from_p_T_X(Real pressure,
Real temperature,
Real xnacl,
Real & mu,
Real & dmu_dp,
Real & dmu_dT,
Real & dmu_dx) const override;

FPDualReal h_from_p_T_X(const FPDualReal & pressure,
const FPDualReal & temperature,
const FPDualReal & xnacl) const override;

virtual Real h_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override;

virtual void h_from_p_T_X(Real pressure,
Real temperature,
Real xnacl,
Real & h,
Real & dh_dp,
Real & dh_dT,
Real & dh_dx) const override;

virtual Real cp_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override;

FPDualReal e_from_p_T_X(const FPDualReal & pressure,
const FPDualReal & temperature,
const FPDualReal & xnacl) const override;

virtual Real e_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override;

virtual void e_from_p_T_X(Real pressure,
Real temperature,
Real xnacl,
Real & e,
Real & de_dp,
Real & de_dT,
Real & de_dx) const override;

virtual Real k_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override;

/**
* Brine vapour pressure
@@ -171,6 +172,7 @@ class BrineFluidProperties : public MultiComponentFluidPropertiesPT
* @return mole fraction (mol/mol)
*/
Real massFractionToMoleFraction(Real xnacl) const;
FPDualReal massFractionToMoleFraction(const FPDualReal & xnacl) const;

/// Water97FluidProperties UserObject
const SinglePhaseFluidProperties * _water_fp;
@@ -181,6 +183,10 @@ class BrineFluidProperties : public MultiComponentFluidPropertiesPT
Real _Mnacl;
/// Molar mass of water (H2O) (kg/mol)
Real _Mh2o;
/// Flag to indicate whether to calculate derivatives in water_fp
mutable bool _water_fp_derivs;
};

#pragma GCC diagnostic pop

#endif /* BRINEFLUIDPROPERTIES_H */
@@ -15,6 +15,14 @@
// Forward Declarations
class FluidProperties;

// The default DualReal size allows functions of many more variables than
// common in the FluidProperties module. This makes the computations much
// slower than necessary, so use a smaller definition in the FluidProperties
// module, FPDualReal, which is suitable for up to five variables.
// This is useful for the cases where we wish to use AD to compute the derivatives
// rather than hand-coding them in derived classes.
typedef DualNumber<Real, NumberArray<5, Real>> FPDualReal;

template <>
InputParameters validParams<FluidProperties>();

@@ -30,6 +38,12 @@ class FluidProperties : public ThreadedGeneralUserObject

virtual void threadJoin(const UserObject &) final {}
virtual void subdomainSetup() final {}

protected:
/// Conversion of temperature from Celsius to Kelvin
const Real _T_c2k;
/// Flag to set unimplemented Jacobian entries to zero
const bool _allow_imperfect_jacobians;
};

#endif /* FLUIDPROPERTIES_H */
Oops, something went wrong.

0 comments on commit 45e7813

Please sign in to comment.
You can’t perform that action at this time.