Line data Source code
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"
14 : #include "SinglePhaseFluidProperties.h"
15 :
16 : registerMooseObject("NavierStokesApp", GeneralFluidProps);
17 :
18 : InputParameters
19 39 : GeneralFluidProps::validParams()
20 : {
21 39 : auto params = Material::validParams();
22 39 : params.addRequiredParam<UserObjectName>(NS::fluid, "Fluid properties userobject");
23 39 : params.addClassDescription("Computes fluid properties using a (P, T) formulation");
24 :
25 39 : params.addRequiredCoupledVar(NS::porosity, "porosity");
26 78 : params.addRequiredRangeCheckedParam<Real>(
27 : "characteristic_length",
28 : "characteristic_length > 0.0 ",
29 : "characteristic length for Reynolds number calculation");
30 39 : return params;
31 0 : }
32 :
33 30 : GeneralFluidProps::GeneralFluidProps(const InputParameters & parameters)
34 : : DerivativeMaterialInterface<Material>(parameters),
35 60 : _fluid(UserObjectInterface::getUserObject<SinglePhaseFluidProperties>(NS::fluid)),
36 30 : _eps(coupledValue(NS::porosity)),
37 60 : _d(getParam<Real>("characteristic_length")),
38 :
39 30 : _pressure(getADMaterialProperty<Real>(NS::pressure)),
40 30 : _T_fluid(getADMaterialProperty<Real>(NS::T_fluid)),
41 30 : _rho(getADMaterialProperty<Real>(NS::density)),
42 30 : _speed(getADMaterialProperty<Real>(NS::speed)),
43 :
44 30 : _drho_dp(declarePropertyDerivative<Real>(NS::density, NS::pressure)),
45 30 : _drho_dT(declarePropertyDerivative<Real>(NS::density, NS::T_fluid)),
46 :
47 30 : _cp(declareADProperty<Real>(NS::cp)),
48 30 : _dcp_dp(declarePropertyDerivative<Real>(NS::cp, NS::pressure)),
49 30 : _dcp_dT(declarePropertyDerivative<Real>(NS::cp, NS::T_fluid)),
50 :
51 30 : _cv(declareADProperty<Real>(NS::cv)),
52 :
53 30 : _mu(declareADProperty<Real>(NS::mu)),
54 30 : _dmu_dp(declarePropertyDerivative<Real>(NS::mu, NS::pressure)),
55 30 : _dmu_dT(declarePropertyDerivative<Real>(NS::mu, NS::T_fluid)),
56 :
57 30 : _k(declareADProperty<Real>(NS::k)),
58 30 : _dk_dp(declarePropertyDerivative<Real>(NS::k, NS::pressure)),
59 30 : _dk_dT(declarePropertyDerivative<Real>(NS::k, NS::T_fluid)),
60 :
61 30 : _Pr(declareADProperty<Real>(NS::Prandtl)),
62 30 : _dPr_dp(declarePropertyDerivative<Real>(NS::Prandtl, NS::pressure)),
63 30 : _dPr_dT(declarePropertyDerivative<Real>(NS::Prandtl, NS::T_fluid)),
64 :
65 30 : _Re(declareADProperty<Real>(NS::Reynolds)),
66 30 : _dRe_dp(declarePropertyDerivative<Real>(NS::Reynolds, NS::pressure)),
67 30 : _dRe_dT(declarePropertyDerivative<Real>(NS::Reynolds, NS::T_fluid)),
68 :
69 30 : _Re_h(declareADProperty<Real>(NS::Reynolds_hydraulic)),
70 60 : _Re_i(declareADProperty<Real>(NS::Reynolds_interstitial))
71 : {
72 30 : }
73 :
74 : void
75 119097 : GeneralFluidProps::computeQpProperties()
76 : {
77 : using std::max;
78 :
79 119097 : auto raw_pressure = MetaPhysicL::raw_value(_pressure[_qp]);
80 119097 : 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 119097 : Real dummy = 0;
85 119097 : _fluid.rho_from_p_T(raw_pressure, raw_T_fluid, dummy, _drho_dp[_qp], _drho_dT[_qp]);
86 :
87 119097 : _cv[_qp] = _fluid.cv_from_p_T(_pressure[_qp], _T_fluid[_qp]);
88 119097 : _cp[_qp] = _fluid.cp_from_p_T(_pressure[_qp], _T_fluid[_qp]);
89 119097 : _mu[_qp] = _fluid.mu_from_p_T(_pressure[_qp], _T_fluid[_qp]);
90 119097 : _k[_qp] = _fluid.k_from_p_T(_pressure[_qp], _T_fluid[_qp]);
91 119097 : _fluid.cp_from_p_T(raw_pressure, raw_T_fluid, dummy, _dcp_dp[_qp], _dcp_dT[_qp]);
92 119097 : _fluid.mu_from_p_T(raw_pressure, raw_T_fluid, dummy, _dmu_dp[_qp], _dmu_dT[_qp]);
93 119097 : _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 119097 : _Pr[_qp] = HeatTransferUtils::prandtl(_cp[_qp], _mu[_qp], max(_k[_qp], small_number));
98 119097 : _dPr_dp[_qp] = NS::prandtlPropertyDerivative(MetaPhysicL::raw_value(_mu[_qp]),
99 119097 : MetaPhysicL::raw_value(_cp[_qp]),
100 238194 : MetaPhysicL::raw_value(_k[_qp]),
101 119097 : _dmu_dp[_qp],
102 119097 : _dcp_dp[_qp],
103 119097 : _dk_dp[_qp]);
104 119097 : _dPr_dT[_qp] = NS::prandtlPropertyDerivative(MetaPhysicL::raw_value(_mu[_qp]),
105 119097 : MetaPhysicL::raw_value(_cp[_qp]),
106 238194 : MetaPhysicL::raw_value(_k[_qp]),
107 119097 : _dmu_dT[_qp],
108 119097 : _dcp_dT[_qp],
109 119097 : _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.
114 119097 : _Re[_qp] = max(HeatTransferUtils::reynolds(
115 119097 : _rho[_qp], _eps[_qp] * _speed[_qp], _d, max(_mu[_qp], small_number)),
116 238194 : 1.0);
117 119097 : _dRe_dp[_qp] = NS::reynoldsPropertyDerivative(MetaPhysicL::raw_value(_Re[_qp]),
118 119097 : MetaPhysicL::raw_value(_rho[_qp]),
119 238194 : MetaPhysicL::raw_value(_mu[_qp]),
120 119097 : _drho_dp[_qp],
121 119097 : _dmu_dp[_qp]);
122 119097 : _dRe_dT[_qp] = NS::reynoldsPropertyDerivative(MetaPhysicL::raw_value(_Re[_qp]),
123 119097 : MetaPhysicL::raw_value(_rho[_qp]),
124 238194 : MetaPhysicL::raw_value(_mu[_qp]),
125 119097 : _drho_dT[_qp],
126 119097 : _dmu_dT[_qp]);
127 :
128 : // (hydraulic) Reynolds number
129 357291 : _Re_h[_qp] = _Re[_qp] / max(1 - _eps[_qp], small_number);
130 :
131 : // (interstitial) Reynolds number
132 119097 : _Re_i[_qp] = _Re[_qp] / _eps[_qp];
133 119097 : }
|