https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ADDittusBoelterHTCFunctorMaterial.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
11
12#include "Numerics.h"
14
16
19{
22 "Computes the wall heat transfer coefficient of a path-integrated flow segment using "
23 "the Dittus-Boelter correlation, as a functor material property.");
24 params.addParam<MooseFunctorName>(
25 "htc_name",
26 "Name of the heat transfer coefficient functor property. Defaults to the name of this "
27 "object.");
28 params.addCoupledVar(
29 "mass_flow_rate", {}, "Mass flow rate through the segment. Takes a scalar variable name");
30 params.addCoupledVar(
31 "T_fluid", {}, "Fluid temperature of the segment. Takes a scalar variable name");
32 params.addCoupledVar(
33 "T_fluid_inlet",
34 {},
35 "Fluid temperature of the nominal inlet segment/component. Takes a scalar variable name");
36 params.addCoupledVar(
37 "T_fluid_outlet",
38 {},
39 "Fluid temperature of the nominal outlet segment/component. Takes a scalar variable name");
40 params.addRequiredParam<UserObjectName>("fluid_properties",
41 "The name of the user object for fluid properties");
42 params.addParam<UserObjectName>("reference_fp",
43 "Liquid-phase fluid properties; see momentum kernel.");
44 params.addRequiredParam<MooseFunctorName>("reference_pressure", "System reference pressure [Pa]");
45 params.addRequiredParam<MooseFunctorName>("flow_area",
46 "Cross-sectional area of the fluid flow channel [m^2]");
47 params.addRequiredParam<MooseFunctorName>("wetted_perimeter",
48 "Wetted perimeter of the fluid flow channel [m]");
49
50 return params;
51}
52
54 const InputParameters & parameters)
55 : FunctorMaterial(parameters),
56 _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties")),
57 _fp_ref(isParamValid("reference_fp") ? &getUserObjectByName<SinglePhaseFluidProperties>(
58 getParam<UserObjectName>("reference_fp"))
59 : nullptr),
60 _m(ScalarCoupleable::adCoupledScalarValue("mass_flow_rate")),
61 _T_fluid(ScalarCoupleable::adCoupledScalarValue("T_fluid")),
62 _T_fluid_inlet(ScalarCoupleable::adCoupledScalarValue("T_fluid_inlet")),
63 _T_fluid_outlet(ScalarCoupleable::adCoupledScalarValue("T_fluid_outlet")),
64 _P_ref(getFunctor<ADReal>("reference_pressure")),
65 _flow_area(getFunctor<ADReal>("flow_area")),
66 _wetted_perimeter(getFunctor<ADReal>("wetted_perimeter"))
67{
68 const MooseFunctorName htc_name =
69 isParamValid("htc_name") ? getParam<MooseFunctorName>("htc_name") : MooseFunctorName(name());
70 const std::set<ExecFlagType> clearance_schedule(_execute_enum.begin(), _execute_enum.end());
71
72 addFunctorProperty<ADReal>(
73 htc_name,
74 [this](const auto & r, const auto & t) -> ADReal
75 {
76 using std::abs, std::pow;
77
78 // Scalar variables have a single component
79 const unsigned int i = 0;
80
81 // Upwind the segment inlet temperature on the flow direction
82 const auto T_in =
83 1.0 / 2.0 * (1 - _m[i] / sqrt(_m[i] * _m[i] + 1.0e-08)) * _T_fluid_outlet[i] +
84 1.0 / 2.0 * (1 + _m[i] / sqrt(_m[i] * _m[i] + 1.0e-08)) * _T_fluid_inlet[i];
85
86 // Properties at the bulk film temperature of the segment
87 const auto T_film = (_T_fluid[i] + T_in) / 2;
88 const auto P_ref = _P_ref(r, t);
89 const auto mu = _fp.mu_from_p_T(P_ref, T_film);
90 const auto cp = _fp.cp_from_p_T(P_ref, T_film);
91 const auto k = _fp.k_from_p_T(P_ref, T_film);
92 const auto rho = _fp.rho_from_p_T(P_ref, T_film);
93 const auto rho_ref = _fp_ref ? _fp_ref->rho_from_p_T(P_ref, T_film) : rho;
94
95 const auto A = _flow_area(r, t);
96 const auto D_h = 4.0 * A / _wetted_perimeter(r, t);
97 // Formed from the mass flux G = rho * vel, which the segment's mass flow rate gives
98 // directly, so no density evaluation is needed
99 const auto G = abs(_m[i]) / A * rho / rho_ref;
100 const auto Re = max(G * D_h / mu, 1.0e-03);
101 const auto Pr = THM::Prandtl(cp, mu, k);
102 const auto Nu = max(0.023 * pow(Re, 0.8) * pow(Pr, 0.4), 4.0);
103
104 return THM::wallHeatTransferCoefficient(Nu, k, D_h);
105 },
106 clearance_schedule);
107}
registerMooseObject("ThermalHydraulicsApp", ADDittusBoelterHTCFunctorMaterial)
DualNumber< Real, DNDerivativeType, true > ADReal
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const double mu
const double Re
const double rho
Computes a Dittus-Boelter wall heat transfer coefficient functor material property for the lumped pat...
const SinglePhaseFluidProperties * _fp_ref
Fluid properties of the pure liquid.
const ADVariableValue & _T_fluid_inlet
Fluid temperature at the nominal inlet neighbor.
const Moose::Functor< ADReal > & _wetted_perimeter
Wetted perimeter of the flow channel.
const ADVariableValue & _m
Mass flow rate through the segment.
const SinglePhaseFluidProperties & _fp
Fluid properties of the flowing fluid.
const Moose::Functor< ADReal > & _P_ref
System reference pressure.
ADDittusBoelterHTCFunctorMaterial(const InputParameters &parameters)
const ADVariableValue & _T_fluid_outlet
Fluid temperature at the nominal outlet neighbor.
const ADVariableValue & _T_fluid
Fluid temperature of the segment.
const Moose::Functor< ADReal > & _flow_area
Cross-sectional area of the flow channel.
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
const std::string & name() const
bool isParamValid(const std::string &name) const
MooseEnumIterator end() const
MooseEnumIterator begin() const
const ExecFlagEnum & _execute_enum
Common class for single phase fluid properties.
auto Prandtl(const T1 &cp, const T2 &mu, const T3 &k)
Compute Prandtl number.
Definition Numerics.h:131