21 "Base class for assembling the path-integrated incompressible momentum equation.");
24 "Fluid temperature in each segment of this component. Takes a "
25 "list of scalar variable names");
29 "Whether an explicit (previous value calculation) or implicit (current value) is used");
30 params.
addRequiredParam<MooseFunctorName>(
"reference_pressure",
"system reference pressure [Pa]");
33 "Fluid properties user object(s). Supply either one (applied to all segments) "
34 "or one per segment.");
35 params.
addParam<UserObjectName>(
"reference_fp",
36 "Fluid properties of the liquid phase for draining problems.");
37 params.
addParam<std::vector<MooseFunctorName>>(
39 std::vector<MooseFunctorName>({}),
40 "Component flow areas per segment. Takes a vector of functors.");
41 params.
addParam<std::vector<MooseFunctorName>>(
43 std::vector<MooseFunctorName>({}),
44 "Component flow perimeters per segment. Takes a vector of functors.");
45 params.
addParam<std::vector<MooseFunctorName>>(
47 std::vector<MooseFunctorName>({}),
48 "Component flow lengths per segment. Takes a vector of functors.");
49 params.
addParam<std::vector<MooseFunctorName>>(
51 std::vector<MooseFunctorName>({}),
52 "Height change from inlet to outlet of each segment. Takes a vector of functors.");
53 params.
addParam<std::vector<MooseFunctorName>>(
55 std::vector<MooseFunctorName>({}),
56 "Forms loss coefficients per segment. Takes a vector of functors.");
57 params.
addParam<std::vector<MooseFunctorName>>(
59 std::vector<MooseFunctorName>({}),
60 "Pump pressure gains per segment [Pa]. Takes a vector of functors.");
61 params.
addParam<std::vector<MooseFunctorName>>(
63 std::vector<MooseFunctorName>({}),
64 "Component wall roughnesses per segment [m]. Takes a vector of functors.");
75 _is_implicit(this->template getParam<bool>(
"is_implicit")),
76 _Pref(this->template getFunctor<
ADReal>(
"reference_pressure")),
77 _n_fp(this->template getParam<
std::vector<UserObjectName>>(
"fp").size()),
78 _n_segments(this->template getParam<
std::vector<MooseFunctorName>>(
"areas").size()),
81 getParam<UserObjectName>(
"reference_fp"))
83 _areas(this->template getParam<
std::vector<MooseFunctorName>>(
"areas").size()),
84 _perimeters(this->template getParam<
std::vector<MooseFunctorName>>(
"perimeters").size()),
85 _lengths(this->template getParam<
std::vector<MooseFunctorName>>(
"lengths").size()),
86 _dZs(this->template getParam<
std::vector<MooseFunctorName>>(
"height_changes").size()),
87 _forms_losses(this->template getParam<
std::vector<MooseFunctorName>>(
"forms_losses").size()),
88 _dPps(this->template getParam<
std::vector<MooseFunctorName>>(
"pump_pressures").size()),
89 _roughnesses(this->template getParam<
std::vector<MooseFunctorName>>(
"roughnesses").size()),
90 _gravity(this->template getFunctor<
ADReal>(
"g"))
92 const auto & area_names = MooseBase::getParam<std::vector<MooseFunctorName>>(
"areas");
93 const auto & perimeter_names = MooseBase::getParam<std::vector<MooseFunctorName>>(
"perimeters");
94 const auto & length_names = MooseBase::getParam<std::vector<MooseFunctorName>>(
"lengths");
95 const auto & dZ_names = MooseBase::getParam<std::vector<MooseFunctorName>>(
"height_changes");
96 const auto & forms_loss_names =
97 MooseBase::getParam<std::vector<MooseFunctorName>>(
"forms_losses");
98 const auto & dPp_names = MooseBase::getParam<std::vector<MooseFunctorName>>(
"pump_pressures");
99 const auto & roughness_names = MooseBase::getParam<std::vector<MooseFunctorName>>(
"roughnesses");
106 "Must provide consistent number of segments for each parameter! Including temperatures!");
111 _areas[j] = &(this->
template getFunctor<ADReal>(area_names[j]));
112 _perimeters[j] = &(this->
template getFunctor<ADReal>(perimeter_names[j]));
113 _lengths[j] = &(this->
template getFunctor<ADReal>(length_names[j]));
114 _dZs[j] = &(this->
template getFunctor<ADReal>(dZ_names[j]));
115 _forms_losses[j] = &(this->
template getFunctor<ADReal>(forms_loss_names[j]));
116 _dPps[j] = &(this->
template getFunctor<ADReal>(dPp_names[j]));
117 _roughnesses[j] = &(this->
template getFunctor<ADReal>(roughness_names[j]));
119 const auto & fp_names = MooseBase::getParam<std::vector<UserObjectName>>(
"fp");
122 "fp",
"Provide either one fluid properties object or one per segment (",
_n_segments,
").");
126 const auto &
name = (
_n_fp == 1) ? fp_names[0] : fp_names[j];
127 _fp[j] = &getUserObjectByName<SinglePhaseFluidProperties>(
name);
134 ADReal momentum_residual = 0;
138 const auto P =
_Pref(arg, state);
145 const auto Tj = (*(
_T[j]))[i];
146 const auto rho_j =
_fp[j]->rho_from_p_T(
P, Tj);
149 max(rho_j / rho_ref, 1e-6) * (*(
_lengths[j]))(arg, state) / (*(
_areas[j]))(arg, state);
151 const auto inv_L_over_A_sum = 1.0 / L_over_A_sum;
155 const auto Tj = (*(
_T[j]))[i];
156 const auto A = (*(
_areas[j]))(arg, state);
157 const auto Dh = 4.0 *
A / (*(
_perimeters[j]))(arg, state);
159 const auto mu =
_fp[j]->mu_from_p_T(
P, Tj);
160 const auto rho_j =
_fp[j]->rho_from_p_T(
P, Tj);
165 const auto Gj = rho_j *
v;
168 momentum_residual += fd * (*(
_lengths[j]))(arg, state) / Dh * Gj * abs(Gj) / 2.0 / rho_j;
169 momentum_residual += (*(
_forms_losses[j]))(arg, state) * Gj * abs(Gj) / 2.0 / rho_j;
171 momentum_residual += rho_j *
_gravity(arg, state) * (*(
_dZs[j]))(arg, state);
173 momentum_residual -= (*(
_dPps[j]))(arg, state);
176 return momentum_residual * inv_L_over_A_sum;
182 mooseError(
"Internal error, calling computeQpJacobian in AD class.");
190 const unsigned int j)
194 const auto Re = max(abs(G) * Dh /
mu, 1.0e-03);
197 else if (
Re > 4000.0)
202 const auto f_lam_2300 = 64.0 / 2300.0;
203 const auto f_turb_4000 =
205 pow(log10((*(
_roughnesses[j]))(arg, state) / (Dh * 3.7) + 5.74 /
pow(4000.0, 0.9)), 2);
206 return f_lam_2300 + (f_turb_4000 - f_lam_2300) * (
Re - 2300.0) / 1700.0;
DualNumber< Real, DNDerivativeType, true > ADReal
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const size_t _n_segments
Number of geometrically/thermally unique segments.
const unsigned int _n_fp
Number of fluid property user objects supplied.
const bool _is_implicit
Property state integration flag.
std::vector< const Moose::Functor< ADReal > * > _dZs
Height change inlet to outlet of each segment.
ADIncompressibleMomentumSPBase(const InputParameters ¶meters)
virtual ADReal pressureDrop() const =0
const size_t _n_temps
Number of coupled temperature variables.
virtual ADReal computeFrictionFactor(const ADReal &mu, const ADReal &G, const ADReal &Dh, const unsigned int j)
std::vector< const Moose::Functor< ADReal > * > _perimeters
Wetted perimeter of each segment.
const Moose::Functor< ADReal > & _Pref
System reference pressure.
std::vector< const Moose::Functor< ADReal > * > _roughnesses
Wall roughness of each segment.
std::vector< const Moose::Functor< ADReal > * > _areas
Flow area of each segment.
const Moose::Functor< ADReal > & _gravity
Gravitational acceleration in the vertical downward direction.
std::vector< const Moose::Functor< ADReal > * > _forms_losses
Forms loss coefficients of each segment.
const SinglePhaseFluidProperties * _fp_ref
Pure liquid fluid properties reference (for draining problems, not for multiphase flow)
virtual ADReal computeQpResidual() override
virtual Real computeQpJacobian() override
std::vector< const SinglePhaseFluidProperties * > _fp
Fluid properties per segment (non-owning pointers)
std::vector< const ADVariableValue * > _T
Coupled temperature variables.
std::vector< const Moose::Functor< ADReal > * > _dPps
Pump pressure gains of each segment.
virtual ADReal massFlowRate() const =0
static InputParameters validParams()
std::vector< const Moose::Functor< ADReal > * > _lengths
Length of each segment.
static InputParameters validParams()
const std::string & name() const
void paramError(const std::string ¶m, Args... args) const
void mooseError(Args &&... args) const
const ADVariableValue & adCoupledScalarValue(const std::string &var_name, unsigned int comp=0) const
Common class for single phase fluid properties.
const auto acceleration_of_gravity