Skip to content

Commit

Permalink
Merge pull request #14607 from bwspenc/conv_flux
Browse files Browse the repository at this point in the history
Add option for temperature-dependent convective heat transfer coefficient
  • Loading branch information
dschwen committed Jan 21, 2020
2 parents 6d07b87 + 634b19f commit 0f6c817
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@

## Description

The `ConvectiveFluxFunction` boundary condition determines the value on a boundary based
upon the heat transfer coefficient of the fluid on the outside of boundary and far-field
temperature.
The `ConvectiveFluxFunction` boundary condition is used to prescribe the following convective flux
$\dot{q}$ to a boundary of a thermal model:
\begin{equation}
\dot{q} = h(T(x) - T_{\text{inf}})
\end{equation}
where $h$ is the heat transfer coefficient, $T(x)$ is the temperature at a location $x$, where $x$ is
the location of a given quadrature point on the surface where this boundary condition is applied, and
$T_{\text{inf}}$ is the far-field temperature of the fluid that the boundary is exposed to.

The far-field temperature is specified using the `T_infinity` parameter, which is a MOOSE Function. This can be provided as the name of a function, using a parsed function, or a constant value. Likewise, the heat transfer coefficient is specified using the `coefficient` parameter, which is also a MOOSE Function, and the same options for how to prescribe `T_infinity` also apply for this parameter. By default, the heat transfer coefficient function is defined in terms of position and time (the standard usage of MOOSE Functions). If the optional `coefficient_function_type` parameter is set to `TEMPERATURE`, the coefficient is instead a function of the temperature. If a Function such as `PiecewiseLinear` were used to define this coefficient, the values on the x-axis of that function would be interpreted as temperature values. If a parsed function were used for this purpose, the `t` variable in a parsed equation would be used for the temperature, rather than for the time.

!syntax parameters /BCs/ConvectiveFluxFunction

Expand Down
21 changes: 18 additions & 3 deletions modules/heat_conduction/include/bcs/ConvectiveFluxFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,26 @@ class ConvectiveFluxFunction : public IntegratedBC
virtual ~ConvectiveFluxFunction() {}

protected:
virtual Real computeQpResidual();
virtual Real computeQpJacobian();
virtual Real computeQpResidual() override;
virtual Real computeQpJacobian() override;

/// Far-field temperature
const Function & _T_infinity;
const Real _coefficient;

/// Heat transfer coefficient
const Function & _coefficient;

/// Enum used to define the type of function used for the heat transfer coefficient
enum class CoefFuncType
{
TIME_AND_POSITION,
TEMPERATURE
};

/// Type of function used for the heat transfer coefficient
const CoefFuncType _coef_func_type;

/// Heat transfer coefficient function (Deprecated -- being replaced by _coefficient)
const Function * const _coef_func;
};

Expand Down
47 changes: 41 additions & 6 deletions modules/heat_conduction/src/bcs/ConvectiveFluxFunction.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@ ConvectiveFluxFunction::validParams()
{
InputParameters params = IntegratedBC::validParams();
params.addRequiredParam<FunctionName>("T_infinity", "Function describing far-field temperature");
params.addRequiredParam<Real>("coefficient", "Heat transfer coefficient");
params.addParam<FunctionName>("coefficient_function", "Heat transfer coefficient function");
params.addRequiredParam<FunctionName>("coefficient",
"Function describing heat transfer coefficient");
MooseEnum coef_func_type("TIME_AND_POSITION TEMPERATURE", "TIME_AND_POSITION");
params.addParam<MooseEnum>(
"coefficient_function_type",
coef_func_type,
"Type of function for heat transfer coefficient provided in 'coefficient' parameter");
params.addDeprecatedParam<FunctionName>(
"coefficient_function",
"Heat transfer coefficient function",
"'coefficient' should be used instead. 'coefficient_function will be removed on March 1, "
"2020.");
params.addClassDescription(
"Determines boundary value by fluid heat transfer coefficient and far-field temperature");

Expand All @@ -31,21 +41,46 @@ ConvectiveFluxFunction::validParams()
ConvectiveFluxFunction::ConvectiveFluxFunction(const InputParameters & parameters)
: IntegratedBC(parameters),
_T_infinity(getFunction("T_infinity")),
_coefficient(getParam<Real>("coefficient")),
_coefficient(getFunction("coefficient")),
_coef_func_type(getParam<MooseEnum>("coefficient_function_type").getEnum<CoefFuncType>()),
_coef_func(isParamValid("coefficient_function") ? &getFunction("coefficient_function") : NULL)
{
if (_coef_func_type == CoefFuncType::TEMPERATURE && _coef_func)
mooseError("Deprecated 'coefficient_function' parameter cannot be used with "
"'coefficient_function_type=TEMPERATURE'");
}

Real
ConvectiveFluxFunction::computeQpResidual()
{
const Real coef(_coefficient * (_coef_func ? _coef_func->value(_t, _q_point[_qp]) : 1));
Real coef;
if (_coef_func_type == CoefFuncType::TIME_AND_POSITION)
{
coef = _coefficient.value(_t, _q_point[_qp]);
if (_coef_func) // Deprecated behavior
coef *= _coef_func->value(_t, _q_point[_qp]);
}
else
coef = _coefficient.value(_u[_qp], Point());

return _test[_i][_qp] * coef * (_u[_qp] - _T_infinity.value(_t, _q_point[_qp]));
}

Real
ConvectiveFluxFunction::computeQpJacobian()
{
const Real coef(_coefficient * (_coef_func ? _coef_func->value(_t, _q_point[_qp]) : 1));
return _test[_i][_qp] * coef * _phi[_j][_qp];
if (_coef_func_type == CoefFuncType::TIME_AND_POSITION)
{
Real coef = _coefficient.value(_t, _q_point[_qp]);
if (_coef_func) // Deprecated behavior
coef *= _coef_func->value(_t, _q_point[_qp]);
return _test[_i][_qp] * coef * _phi[_j][_qp];
}
else
{
const Real coef = _coefficient.value(_u[_qp], Point());
const Real dcoef_dT = _coefficient.timeDerivative(_u[_qp], Point());
return _test[_i][_qp] * (coef + (_u[_qp] - _T_infinity.value(_t, _q_point[_qp])) * dcoef_dT) *
_phi[_j][_qp];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# This is a test of the ConvectiveFluxFunction BC.
# There is a single 1x1 element with a prescribed temperature
# on the left side and a convective flux BC on the right side.
# The temperature on the left is 100, and the far-field temp is 200.
# The conductance of the body (conductivity * length) is 10
#
# If the conductance in the BC is also 10, the temperature on the
# right side of the solid element should be 150 because half of the
# temperature drop should occur over the body and half in the BC.
#
# The integrated flux is deltaT * conductance, or -50 * 10 = -500.
# The negative sign indicates that heat is going into the body.
#
# The conductance is defined multiple ways using this input, and
# as long as it evaluates to 10, the result described above will
# be obtained.

[Mesh]
type = GeneratedMesh
dim = 2
nx = 1
ny = 1
[]

[Problem]
extra_tag_vectors = 'bcs'
[]

[Variables]
[temp]
initial_condition = 100.0
[]
[]

[AuxVariables]
[flux]
[]
[]

[AuxKernels]
[flux]
type = TagVectorAux
variable = flux
v = temp
vector_tag = 'bcs'
execute_on = timestep_end
[]
[]

[Kernels]
[heat_conduction]
type = HeatConduction
variable = temp
[]
[]

[Materials]
[thermal]
type = HeatConductionMaterial
thermal_conductivity = 10.0
[]
[]

[BCs]
[left]
type = DirichletBC
variable = temp
boundary = left
value = 100.0
[]
[right]
type = ConvectiveFluxFunction
variable = temp
boundary = right
T_infinity = 200.0
coefficient = 10.0 #This will behave as described in the header of this file if this evaluates to 10
extra_vector_tags = 'bcs'
[]
[]

[Postprocessors]
[integrated_flux]
type = NodalSum
variable = flux
boundary = right
[]
[]

[Executioner]
type = Transient
start_time = 0.0
end_time = 1.0
dt = 1.0
nl_rel_tol=1e-12
[]

[Outputs]
csv = true
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
time,integrated_flux
0,0
1,-500
26 changes: 26 additions & 0 deletions modules/heat_conduction/test/tests/convective_flux_function/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[Tests]
design = 'ConvectiveFluxFunction.md'
issues = '#14418'
[./constant]
type = 'CSVDiff'
input = 'convective_flux_function.i'
csvdiff = 'convective_flux_function_out.csv'
requirement = 'The system shall allow prescribing a convective flux boundary condition using a constant heat transfer coefficient.'
[../]
[./time_dependent]
prereq = constant
type = 'CSVDiff'
input = 'convective_flux_function.i'
cli_args = "BCs/right/coefficient='t*10.0'"
csvdiff = 'convective_flux_function_out.csv'
requirement = 'The system shall allow prescribing a convective flux boundary condition using a heat transfer coefficient that is a function of position and time.'
[../]
[./temperature_dependent]
prereq = time_dependent
type = 'CSVDiff'
input = 'convective_flux_function.i'
cli_args = "BCs/right/coefficient='t/15.0' BCs/right/coefficient_function_type=TEMPERATURE"
csvdiff = 'convective_flux_function_out.csv'
requirement = 'The system shall allow prescribing a convective flux boundary condition using a heat transfer coefficient that is a function of temperature.'
[../]
[]

0 comments on commit 0f6c817

Please sign in to comment.