https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
IncompressibleEnergySPScalarKernelTempl< is_ad > Class Template Reference

Path-integrated incompressible energy kernel. More...

#include <IncompressibleEnergySPScalarKernel.h>

Inheritance diagram for IncompressibleEnergySPScalarKernelTempl< is_ad >:
[legend]

Public Member Functions

 IncompressibleEnergySPScalarKernelTempl (const InputParameters &parameters)
 
virtual bool isADObject () const override
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Member Functions

virtual GenericReal< is_ad > computeQpResidual () override
 
virtual Real computeQpJacobian () override
 
Real computeQpJacobian ()
 

Protected Attributes

const SinglePhaseFluidProperties & _fp
 Fluid properties object.
 
const GenericVariableValue< is_ad > & _m
 Coupled mass flow rate through the segment.
 
const GenericVariableValue< is_ad > & _Tup
 Coupled temperature of the upstream segment.
 
const GenericVariableValue< is_ad > & _Tdown
 Coupled temperature of the downstream segment.
 
const GenericVariableValue< is_ad > & _Tw
 Coupled temperature of the component wall.
 
const bool _is_implicit
 Property state integration flag.
 
const Moose::Functor< GenericReal< is_ad > > & _Pref
 System reference pressure.
 
const Moose::Functor< GenericReal< is_ad > > & _area
 Flow area of the segment.
 
const Moose::Functor< GenericReal< is_ad > > & _perimeter
 Wetted perimeter of the segment.
 
const Moose::Functor< GenericReal< is_ad > > & _length
 Length of the segment.
 

Private Types

using Base = typename std::conditional< is_ad, ADScalarKernel, ScalarKernel >::type
 

Detailed Description

template<bool is_ad>
class IncompressibleEnergySPScalarKernelTempl< is_ad >

Path-integrated incompressible energy kernel.

Definition at line 21 of file IncompressibleEnergySPScalarKernel.h.

Member Typedef Documentation

◆ Base

template<bool is_ad>
using IncompressibleEnergySPScalarKernelTempl< is_ad >::Base = typename std::conditional<is_ad, ADScalarKernel, ScalarKernel>::type
private

Definition at line 24 of file IncompressibleEnergySPScalarKernel.h.

Constructor & Destructor Documentation

◆ IncompressibleEnergySPScalarKernelTempl()

Definition at line 54 of file IncompressibleEnergySPScalarKernel.C.

56 : Base(parameters),
57 _fp(this->template getUserObject<SinglePhaseFluidProperties>("fp")),
58 _m(ScalarCoupleable::coupledGenericScalarValue<is_ad>("mass_flow_rate")),
59 _Tup(ScalarCoupleable::coupledGenericScalarValue<is_ad>("inlet_temperature")),
60 _Tdown(ScalarCoupleable::coupledGenericScalarValue<is_ad>("outlet_temperature")),
61 _Tw(ScalarCoupleable::coupledGenericScalarValue<is_ad>("wall_temperature")),
62 _is_implicit(this->template getParam<bool>("is_implicit")),
63 _Pref(this->template getFunctor<GenericReal<is_ad>>("reference_pressure")),
64 _area(this->template getFunctor<GenericReal<is_ad>>("area")),
65 _perimeter(this->template getFunctor<GenericReal<is_ad>>("perimeter")),
66 _length(this->template getFunctor<GenericReal<is_ad>>("length"))
67{
68}
Moose::GenericType< Real, is_ad > GenericReal
const GenericVariableValue< is_ad > & _Tdown
Coupled temperature of the downstream segment.
const GenericVariableValue< is_ad > & _m
Coupled mass flow rate through the segment.
const GenericVariableValue< is_ad > & _Tw
Coupled temperature of the component wall.
const Moose::Functor< GenericReal< is_ad > > & _perimeter
Wetted perimeter of the segment.
const Moose::Functor< GenericReal< is_ad > > & _area
Flow area of the segment.
const Moose::Functor< GenericReal< is_ad > > & _length
Length of the segment.
const GenericVariableValue< is_ad > & _Tup
Coupled temperature of the upstream segment.
const bool _is_implicit
Property state integration flag.
const SinglePhaseFluidProperties & _fp
Fluid properties object.
typename std::conditional< is_ad, ADScalarKernel, ScalarKernel >::type Base
const Moose::Functor< GenericReal< is_ad > > & _Pref
System reference pressure.

Member Function Documentation

◆ computeQpJacobian() [1/2]

Real IncompressibleEnergySPScalarKernelTempl< true >::computeQpJacobian ( )
protected

Definition at line 146 of file IncompressibleEnergySPScalarKernel.C.

147{
148 mooseError("Internal error, calling computeQpJacobian in AD class.");
149 return 0.0;
150}
void mooseError(Args &&... args)

◆ computeQpJacobian() [2/2]

template<bool is_ad>
Real IncompressibleEnergySPScalarKernelTempl< is_ad >::computeQpJacobian ( )
overrideprotectedvirtual

Definition at line 106 of file IncompressibleEnergySPScalarKernel.C.

107{
108 if constexpr (!is_ad)
109 {
110 Real energy_jacob = 0;
111 const Moose::ElemArg qp = Moose::ElemArg();
112 const int i = 0;
113 const auto state = _is_implicit ? Moose::currentState() : Moose::oldState();
114 // start by getting fluid properties
115 const auto in = 1.0 / 2.0 * (1 - abs(_m[i]) / _m[i]) * _Tdown[i] +
116 1.0 / 2.0 * (1 + abs(_m[i]) / _m[i]) * _Tup[i];
117 const auto mu = _fp.mu_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
118 const auto rho = _fp.rho_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
119 const auto cp = _fp.cp_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
120 const auto k = _fp.k_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
121
122 // Decide flow regime for HTC
123 const auto Dh = 4.0 * _area(qp, state) / _perimeter(qp, state);
124 const auto G = abs(_m[i]) / _area(qp, state);
125 const auto Re = G * Dh / mu;
126 const auto Pr = mu * cp / k;
127 // Heat transfer to fluid (Dittus-Boelter)
128 const auto h = 0.023 * pow(Re, 0.8) * pow(Pr, 0.4) * k / Dh;
129 const auto q = -h * _perimeter(qp, state) / 2.0;
130 // Advection component
131 energy_jacob += abs(_m[i]) / _length(qp, state) / _area(qp, state) / rho;
132 // Wall heat transfer
133 energy_jacob -= q / _area(qp, state) / rho / cp;
134
135 return energy_jacob;
136 }
137 else
138 {
139 mooseError("computeQpJacobian() should not be called in AD mode");
140 return 0;
141 }
142}
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const double mu
const double Re
const double rho
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
StateArg oldState()
StateArg currentState()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ computeQpResidual()

template<bool is_ad>
GenericReal< is_ad > IncompressibleEnergySPScalarKernelTempl< is_ad >::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 72 of file IncompressibleEnergySPScalarKernel.C.

73{
74 GenericReal<is_ad> energy_residual = 0;
75 const Moose::ElemArg qp = Moose::ElemArg();
76 const int i = 0;
77 const auto state = _is_implicit ? Moose::currentState() : Moose::oldState();
78 // start by getting fluid properties
79 const auto in = 1.0 / 2.0 * (1 - abs(_m[i]) / _m[i]) * _Tdown[i] +
80 1.0 / 2.0 * (1 + abs(_m[i]) / _m[i]) * _Tup[i];
81 const auto mu = _fp.mu_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
82 const auto rho = _fp.rho_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
83 const auto cp = _fp.cp_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
84 const auto k = _fp.k_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
85
86 // Compute HTC quantities
87 const auto Dh = 4.0 * _area(qp, state) / _perimeter(qp, state);
88 const auto G = abs(_m[i]) / _area(qp, state);
89 const auto Re = G * Dh / mu;
90 const auto Pr = mu * cp / k;
91 // Heat transfer to fluid (Dittus-Boelter)
92 const auto h = 0.023 * pow(Re, 0.8) * pow(Pr, 0.4) * k / Dh;
93 const auto q = h * _perimeter(qp, state) / 2.0 * (2.0 * _Tw[i] - Base::_u[i] - in);
94 // Advection component
95 energy_residual += (_m[i] / 2.0 * (1 - abs(_m[i]) / _m[i]) * _Tdown[i] -
96 _m[i] / 2.0 * (1 + abs(_m[i]) / _m[i]) * _Tup[i] + abs(_m[i]) * Base::_u[i]) /
97 _length(qp, state) / _area(qp, state) / rho;
98 // Wall heat transfer
99 energy_residual -= q / _area(qp, state) / rho / cp;
100
101 return energy_residual;
102}

◆ isADObject()

template<bool is_ad>
virtual bool IncompressibleEnergySPScalarKernelTempl< is_ad >::isADObject ( ) const
inlineoverridevirtual

Definition at line 28 of file IncompressibleEnergySPScalarKernel.h.

28{ return is_ad; };

◆ validParams()

template<bool is_ad>
InputParameters IncompressibleEnergySPScalarKernelTempl< is_ad >::validParams ( )
static

Definition at line 20 of file IncompressibleEnergySPScalarKernel.C.

21{
23 params.addClassDescription("Implements a generic energy solve over a 1D flow path segment.");
24 params.addCoupledVar("mass_flow_rate",
25 {},
26 "Mass flow rate in component. Takes a "
27 "scalar variable name");
28 params.addCoupledVar("inlet_temperature",
29 {},
30 "Fluid temperature of nominal inlet segment/component (N-1). Takes a "
31 "scalar variable name");
32 params.addCoupledVar("outlet_temperature",
33 {},
34 "Fluid temperature of nominal outlet segment/component (N+1). Takes a "
35 "scalar variable name");
36 params.addCoupledVar("wall_temperature",
37 {},
38 "Wall temperature adjacent to fluid. Takes a "
39 "scalar variable name");
40 params.addParam<bool>(
41 "is_implicit",
42 false,
43 "Whether an explicit (previous value calculation) or implicit (current value) is used");
44 params.addRequiredParam<MooseFunctorName>("reference_pressure", "system reference pressure [Pa]");
45 params.addRequiredParam<UserObjectName>("fp", "The name of the user object for fluid properties");
46 params.addRequiredParam<MooseFunctorName>("area", "Segment/Component flow area [m^2]");
47 params.addRequiredParam<MooseFunctorName>("perimeter", "Segment/Component wetted perimeter [m]");
48 params.addRequiredParam<MooseFunctorName>("length", "Segment/Component length [m]");
49
50 return params;
51}
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)

Member Data Documentation

◆ _area

template<bool is_ad>
const Moose::Functor<GenericReal<is_ad> >& IncompressibleEnergySPScalarKernelTempl< is_ad >::_area
protected

Flow area of the segment.

Definition at line 49 of file IncompressibleEnergySPScalarKernel.h.

◆ _fp

template<bool is_ad>
const SinglePhaseFluidProperties& IncompressibleEnergySPScalarKernelTempl< is_ad >::_fp
protected

Fluid properties object.

Definition at line 35 of file IncompressibleEnergySPScalarKernel.h.

◆ _is_implicit

template<bool is_ad>
const bool IncompressibleEnergySPScalarKernelTempl< is_ad >::_is_implicit
protected

Property state integration flag.

Definition at line 45 of file IncompressibleEnergySPScalarKernel.h.

◆ _length

template<bool is_ad>
const Moose::Functor<GenericReal<is_ad> >& IncompressibleEnergySPScalarKernelTempl< is_ad >::_length
protected

Length of the segment.

Definition at line 53 of file IncompressibleEnergySPScalarKernel.h.

◆ _m

template<bool is_ad>
const GenericVariableValue<is_ad>& IncompressibleEnergySPScalarKernelTempl< is_ad >::_m
protected

Coupled mass flow rate through the segment.

Definition at line 37 of file IncompressibleEnergySPScalarKernel.h.

◆ _perimeter

template<bool is_ad>
const Moose::Functor<GenericReal<is_ad> >& IncompressibleEnergySPScalarKernelTempl< is_ad >::_perimeter
protected

Wetted perimeter of the segment.

Definition at line 51 of file IncompressibleEnergySPScalarKernel.h.

◆ _Pref

template<bool is_ad>
const Moose::Functor<GenericReal<is_ad> >& IncompressibleEnergySPScalarKernelTempl< is_ad >::_Pref
protected

System reference pressure.

Definition at line 47 of file IncompressibleEnergySPScalarKernel.h.

◆ _Tdown

template<bool is_ad>
const GenericVariableValue<is_ad>& IncompressibleEnergySPScalarKernelTempl< is_ad >::_Tdown
protected

Coupled temperature of the downstream segment.

Definition at line 41 of file IncompressibleEnergySPScalarKernel.h.

◆ _Tup

template<bool is_ad>
const GenericVariableValue<is_ad>& IncompressibleEnergySPScalarKernelTempl< is_ad >::_Tup
protected

Coupled temperature of the upstream segment.

Definition at line 39 of file IncompressibleEnergySPScalarKernel.h.

◆ _Tw

template<bool is_ad>
const GenericVariableValue<is_ad>& IncompressibleEnergySPScalarKernelTempl< is_ad >::_Tw
protected

Coupled temperature of the component wall.

Definition at line 43 of file IncompressibleEnergySPScalarKernel.h.


The documentation for this class was generated from the following files: