https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ADAverageWallTemperature3EqnMaterial.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
13
16{
18
20 "Weighted average wall temperature from multiple sources for 1-phase flow");
21
22 params.addRequiredCoupledVar("T_wall_sources",
23 "Vector of wall temperatures from individual sources");
24 params.addRequiredParam<std::vector<MaterialPropertyName>>(
25 "Hw_sources", "Vector of wall heat transfer coefficients from individual sources");
26 params.addRequiredCoupledVar("P_hf_sources",
27 "Vector of heated perimeters from individual sources");
28 params.addRequiredCoupledVar("T_fluid", "Fluid temperature");
29 params.addRequiredCoupledVar("P_hf_total", "Total heat flux perimeter from all sources");
30
31 return params;
32}
33
35 const InputParameters & parameters)
36 : Material(parameters),
37 _T_wall(declareADProperty<Real>("T_wall")),
38 _n_values(coupledComponents("T_wall_sources")),
39 _T_fluid(adCoupledValue("T_fluid")),
40 _P_hf_total(adCoupledValue("P_hf_total"))
41{
42 // make sure that numbers of values are consistent
43 if (getParam<std::vector<MaterialPropertyName>>("Hw_sources").size() != _n_values)
45 ": The number of wall heat transfer coefficient values"
46 " must equal the number of wall temperature values");
47 if (coupledComponents("P_hf_sources") != _n_values)
49 ": The number of heated perimeter values"
50 " must equal the number of wall temperature values");
51
52 // get all of the variable values
53 const std::vector<MaterialPropertyName> & Hw_prop_names =
54 getParam<std::vector<MaterialPropertyName>>("Hw_sources");
55 for (unsigned int i = 0; i < _n_values; i++)
56 {
57 _T_wall_sources.push_back(&adCoupledValue("T_wall_sources", i));
58 _Hw_sources.push_back(&getADMaterialProperty<Real>(Hw_prop_names[i]));
59 _P_hf_sources.push_back(&adCoupledValue("P_hf_sources", i));
60 }
61}
62
63void
65{
66 using std::abs;
67
68 ADReal denominator = 0;
69 for (unsigned int i = 0; i < _n_values; i++)
70 denominator += (*(_Hw_sources[i]))[_qp] * (*(_P_hf_sources[i]))[_qp];
71
72 if (abs(denominator) < 1e-15)
73 {
74 // use alternate definition to avoid division by zero: heated-perimeter-weighted average
75 ADReal numerator = 0;
76 for (unsigned int i = 0; i < _n_values; i++)
77 numerator += (*(_T_wall_sources[i]))[_qp] * (*(_P_hf_sources[i]))[_qp];
78 _T_wall[_qp] = numerator / _P_hf_total[_qp];
79 }
80 else
81 {
82 // use normal definition
83 ADReal numerator = 0;
84 for (unsigned int i = 0; i < _n_values; i++)
85 numerator += (*(_Hw_sources[i]))[_qp] * ((*(_T_wall_sources[i]))[_qp] - _T_fluid[_qp]) *
86 (*(_P_hf_sources[i]))[_qp];
87 _T_wall[_qp] = _T_fluid[_qp] + numerator / denominator;
88 }
89}
registerMooseObject("ThermalHydraulicsApp", ADAverageWallTemperature3EqnMaterial)
DualNumber< Real, DNDerivativeType, true > ADReal
Weighted average of wall temperature between multiple heat sources to preserve total wall heat,...
std::vector< const ADVariableValue * > _T_wall_sources
Wall temperature values from the individual sources to average.
ADMaterialProperty< Real > & _T_wall
Average wall temperature.
ADAverageWallTemperature3EqnMaterial(const InputParameters &parameters)
const unsigned int _n_values
Number of values to average.
std::vector< const ADVariableValue * > _P_hf_sources
Heated perimeter values from the individual sources to average.
std::vector< const ADMaterialProperty< Real > * > _Hw_sources
Wall heat transfer coefficient values from the individual sources to average.
const ADVariableValue & _P_hf_total
Total heated perimeter.
const ADVariableValue & _T_fluid
Fluid temperature.
const ADVariableValue & adCoupledValue(const std::string &var_name, unsigned int comp=0) const
unsigned int coupledComponents(const std::string &var_name) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
unsigned int _qp
static InputParameters validParams()
const std::string & name() const
void mooseError(Args &&... args) const
const T & getParam(const std::string &name) const