https://mooseframework.inl.gov
GeneralFluidProps.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "GeneralFluidProps.h"
11 #include "NS.h" // Variable Term Names
12 #include "HeatTransferUtils.h"
13 #include "NavierStokesMethods.h"
15 
16 registerMooseObject("NavierStokesApp", GeneralFluidProps);
17 
20 {
21  auto params = Material::validParams();
22  params.addRequiredParam<UserObjectName>(NS::fluid, "Fluid properties userobject");
23  params.addClassDescription("Computes fluid properties using a (P, T) formulation");
24 
25  params.addRequiredCoupledVar(NS::porosity, "porosity");
26  params.addRequiredRangeCheckedParam<Real>(
27  "characteristic_length",
28  "characteristic_length > 0.0 ",
29  "characteristic length for Reynolds number calculation");
30  return params;
31 }
32 
35  _fluid(UserObjectInterface::getUserObject<SinglePhaseFluidProperties>(NS::fluid)),
36  _eps(coupledValue(NS::porosity)),
37  _d(getParam<Real>("characteristic_length")),
38 
39  _pressure(getADMaterialProperty<Real>(NS::pressure)),
40  _T_fluid(getADMaterialProperty<Real>(NS::T_fluid)),
41  _rho(getADMaterialProperty<Real>(NS::density)),
42  _speed(getADMaterialProperty<Real>(NS::speed)),
43 
44  _drho_dp(declarePropertyDerivative<Real>(NS::density, NS::pressure)),
45  _drho_dT(declarePropertyDerivative<Real>(NS::density, NS::T_fluid)),
46 
47  _cp(declareADProperty<Real>(NS::cp)),
48  _dcp_dp(declarePropertyDerivative<Real>(NS::cp, NS::pressure)),
49  _dcp_dT(declarePropertyDerivative<Real>(NS::cp, NS::T_fluid)),
50 
51  _cv(declareADProperty<Real>(NS::cv)),
52 
53  _mu(declareADProperty<Real>(NS::mu)),
54  _dmu_dp(declarePropertyDerivative<Real>(NS::mu, NS::pressure)),
55  _dmu_dT(declarePropertyDerivative<Real>(NS::mu, NS::T_fluid)),
56 
57  _k(declareADProperty<Real>(NS::k)),
58  _dk_dp(declarePropertyDerivative<Real>(NS::k, NS::pressure)),
59  _dk_dT(declarePropertyDerivative<Real>(NS::k, NS::T_fluid)),
60 
61  _Pr(declareADProperty<Real>(NS::Prandtl)),
62  _dPr_dp(declarePropertyDerivative<Real>(NS::Prandtl, NS::pressure)),
63  _dPr_dT(declarePropertyDerivative<Real>(NS::Prandtl, NS::T_fluid)),
64 
65  _Re(declareADProperty<Real>(NS::Reynolds)),
66  _dRe_dp(declarePropertyDerivative<Real>(NS::Reynolds, NS::pressure)),
67  _dRe_dT(declarePropertyDerivative<Real>(NS::Reynolds, NS::T_fluid)),
68 
69  _Re_h(declareADProperty<Real>(NS::Reynolds_hydraulic)),
70  _Re_i(declareADProperty<Real>(NS::Reynolds_interstitial))
71 {
72 }
73 
74 void
76 {
77  using std::max;
78 
79  auto raw_pressure = MetaPhysicL::raw_value(_pressure[_qp]);
80  auto raw_T_fluid = MetaPhysicL::raw_value(_T_fluid[_qp]);
81 
82  // Density is not a material property because we will calculate it using
83  // FluidDensityAux as needed.
84  Real dummy = 0;
85  _fluid.rho_from_p_T(raw_pressure, raw_T_fluid, dummy, _drho_dp[_qp], _drho_dT[_qp]);
86 
87  _cv[_qp] = _fluid.cv_from_p_T(_pressure[_qp], _T_fluid[_qp]);
88  _cp[_qp] = _fluid.cp_from_p_T(_pressure[_qp], _T_fluid[_qp]);
89  _mu[_qp] = _fluid.mu_from_p_T(_pressure[_qp], _T_fluid[_qp]);
90  _k[_qp] = _fluid.k_from_p_T(_pressure[_qp], _T_fluid[_qp]);
91  _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, _dcp_dp[_qp], _dcp_dT[_qp]);
92  _fluid.mu_from_p_T(raw_pressure, raw_T_fluid, dummy, _dmu_dp[_qp], _dmu_dT[_qp]);
93  _fluid.k_from_p_T(raw_pressure, raw_T_fluid, dummy, _dk_dp[_qp], _dk_dT[_qp]);
94 
95  static constexpr Real small_number = 1e-8;
96 
97  _Pr[_qp] = HeatTransferUtils::prandtl(_cp[_qp], _mu[_qp], max(_k[_qp], small_number));
101  _dmu_dp[_qp],
102  _dcp_dp[_qp],
103  _dk_dp[_qp]);
107  _dmu_dT[_qp],
108  _dcp_dT[_qp],
109  _dk_dT[_qp]);
110 
111  // (pore / particle) Reynolds number based on superficial velocity and
112  // characteristic length. Only call Reynolds() one time to compute all three so that
113  // we don't redundantly check that viscosity is not too close to zero.
115  _rho[_qp], _eps[_qp] * _speed[_qp], _d, max(_mu[_qp], small_number)),
116  1.0);
120  _drho_dp[_qp],
121  _dmu_dp[_qp]);
125  _drho_dT[_qp],
126  _dmu_dT[_qp]);
127 
128  // (hydraulic) Reynolds number
129  _Re_h[_qp] = _Re[_qp] / max(1 - _eps[_qp], small_number);
130 
131  // (interstitial) Reynolds number
132  _Re_i[_qp] = _Re[_qp] / _eps[_qp];
133 }
MaterialProperty< Real > & _dPr_dT
Derivative of Prandtl number with respect to temperature.
static const std::string cv
Definition: NS.h:122
ADMaterialProperty< Real > & _cv
Isochoric specific heat capacity.
static const std::string speed
Definition: NS.h:143
ADMaterialProperty< Real > & _mu
Dynamic viscosity.
static const std::string Reynolds
Definition: NS.h:139
Real prandtlPropertyDerivative(const Real &mu, const Real &cp, const Real &k, const Real &dmu, const Real &dcp, const Real &dk)
Computes the derivative of the Prandtl number, $Pr{ C_p}{k}$, with respect to an arbitrary variale $$...
MaterialProperty< Real > & _dPr_dp
Derivative of Prandtl number with respect to pressure.
const ADMaterialProperty< Real > & _speed
const ADMaterialProperty< Real > & _pressure
variables
ADMaterialProperty< Real > & _cp
Isobaric specific heat capacity.
static const std::string density
Definition: NS.h:33
auto raw_value(const Eigen::Map< T > &in)
ADMaterialProperty< Real > & _Re_h
Hydraulic Reynolds number.
static const std::string fluid
Definition: NS.h:87
MaterialProperty< Real > & _dRe_dT
Derivative of pore Reynolds number with respect to temperature.
ADMaterialProperty< Real > & _Re_i
Interstitial Reynolds number.
MaterialProperty< Real > & _dmu_dp
Derivative of dynamic viscosity with respect to pressure.
auto max(const L &left, const R &right)
static const std::string porosity
Definition: NS.h:104
static const std::string Prandtl
Definition: NS.h:137
static const std::string cp
Definition: NS.h:121
static InputParameters validParams()
static const std::string T_fluid
Definition: NS.h:106
static InputParameters validParams()
GeneralFluidProps(const InputParameters &parameters)
static const std::string mu
Definition: NS.h:123
static const std::string Reynolds_hydraulic
Definition: NS.h:140
MaterialProperty< Real > & _drho_dT
Derivative of density with respect to temperature.
Computes fluid properties in (P, T) formulation.
MaterialProperty< Real > & _dRe_dp
Derivative of pore Reynolds number with respect to pressure.
Common class for single phase fluid properties.
ADMaterialProperty< Real > & _Re
Pore (particle) Reynolds number.
const Real _d
Characteristic length $d$ used in computing the Reynolds number $Re=/$.
const SinglePhaseFluidProperties & _fluid
Real reynoldsPropertyDerivative(const Real &Re, const Real &rho, const Real &mu, const Real &drho, const Real &dmu)
Computes the derivative of the Reynolds number, $Re { Vd}{}$, with respect to an arbitrary variable $...
auto reynolds(const T1 &rho, const T2 &vel, const T3 &L, const T4 &mu)
Compute Reynolds number.
MaterialProperty< Real > & _dcp_dT
Derivative of isobaric specific heat with respect to temperature.
auto prandtl(const T1 &cp, const T2 &mu, const T3 &k)
Compute Prandtl number.
const ADMaterialProperty< Real > & _T_fluid
MaterialProperty< Real > & _dk_dp
Derivative of thermal conductivity with respect to pressure.
MaterialProperty< Real > & _drho_dp
Derivative of density with respect to pressure.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ADMaterialProperty< Real > & _Pr
Prandtl number.
static const std::string pressure
Definition: NS.h:56
const VariableValue & _eps
Porosity.
ADMaterialProperty< Real > & _k
Thermal conductivity.
registerMooseObject("NavierStokesApp", GeneralFluidProps)
MaterialProperty< Real > & _dk_dT
Derivative of thermal conductivity with respect to temperature.
const ADMaterialProperty< Real > & _rho
MaterialProperty< Real > & _dcp_dp
Derivative of isobaric specific heat with respect to pressure.
static const std::string k
Definition: NS.h:130
MaterialProperty< Real > & _dmu_dT
Derivative of dynamic viscosity with respect to temperature.
static const std::string Reynolds_interstitial
Definition: NS.h:141
virtual void computeQpProperties() override