Step 3 - Adding additional terms to the heat equation
In the previous step, we modified boundary conditions to solve a meaningful problem that provided the steady-state solution to the heat equation by neglecting time-dependent terms. In this step, we will add terms to the heat equation by adding kernels. The heat equation with the full set of terms typically used for heat transfer within a solid or stationary fluid is:
(1)
where is temperature, is time, is the vector of spatial coordinates, is the density, is the specific heat capacity, is the thermal conductivity, is a heat source, and is the solution domain.
The first step will be to add the time derivative term to this equation, and then in a subsequent step, a volumetric heating term will be added.
#
# Single block thermal input with time derivative term
# https://mooseframework.inl.gov/modules/heat_transfer/tutorials/introduction/therm_step03.html
#
[Mesh<<<{"href": "../../../../syntax/Mesh/index.html"}>>>]
[generated]
type = GeneratedMeshGenerator<<<{"description": "Create a line, square, or cube mesh with uniformly spaced or biased elements.", "href": "../../../../source/meshgenerators/GeneratedMeshGenerator.html"}>>>
dim<<<{"description": "The dimension of the mesh to be generated"}>>> = 2
nx<<<{"description": "Number of elements in the X direction"}>>> = 10
ny<<<{"description": "Number of elements in the Y direction"}>>> = 10
xmax<<<{"description": "Upper X Coordinate of the generated mesh"}>>> = 2
ymax<<<{"description": "Upper Y Coordinate of the generated mesh"}>>> = 1
[]
[]
[Variables<<<{"href": "../../../../syntax/Variables/index.html"}>>>]
[T]
initial_condition<<<{"description": "Specifies a constant initial condition for this variable"}>>> = 300.0
[]
[]
[Kernels<<<{"href": "../../../../syntax/Kernels/index.html"}>>>]
[heat_conduction]
type = HeatConduction<<<{"description": "Diffusive heat conduction term $-\\nabla\\cdot(k\\nabla T)$ of the thermal energy conservation equation", "href": "../../../../source/kernels/HeatConduction.html"}>>>
variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = T
[]
[time_derivative]
type = HeatConductionTimeDerivative<<<{"description": "Time derivative term $\\rho c_p \\frac{\\partial T}{\\partial t}$ of the thermal energy conservation equation.", "href": "../../../../source/kernels/HeatConductionTimeDerivative.html"}>>>
variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = T
[]
[]
[Materials<<<{"href": "../../../../syntax/Materials/index.html"}>>>]
[thermal]
type = HeatConductionMaterial<<<{"description": "General-purpose material model for heat conduction", "href": "../../../../source/materials/HeatConductionMaterial.html"}>>>
thermal_conductivity<<<{"description": "The thermal conductivity value"}>>> = 45.0
specific_heat<<<{"description": "The specific heat value"}>>> = 0.5
[]
[density]
type = GenericConstantMaterial<<<{"description": "Declares material properties based on names and values prescribed by input parameters.", "href": "../../../../source/materials/GenericConstantMaterial.html"}>>>
prop_names<<<{"description": "The names of the properties this material will have"}>>> = 'density'
prop_values<<<{"description": "The values associated with the named properties"}>>> = 8000.0
[]
[]
[BCs<<<{"href": "../../../../syntax/BCs/index.html"}>>>]
[t_left]
type = DirichletBC<<<{"description": "Imposes the essential boundary condition $u=g$, where $g$ is a constant, controllable value.", "href": "../../../../source/bcs/DirichletBC.html"}>>>
variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = T
value<<<{"description": "Value of the BC"}>>> = 300
boundary<<<{"description": "The list of boundary IDs from the mesh where this object applies"}>>> = 'left'
[]
[t_right]
type = FunctionDirichletBC<<<{"description": "Imposes the essential boundary condition $u=g(t,\\vec{x})$, where $g$ is a (possibly) time and space-dependent MOOSE Function.", "href": "../../../../source/bcs/FunctionDirichletBC.html"}>>>
variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = T
function<<<{"description": "The forcing function."}>>> = '300+5*t'
boundary<<<{"description": "The list of boundary IDs from the mesh where this object applies"}>>> = 'right'
[]
[]
[Executioner<<<{"href": "../../../../syntax/Executioner/index.html"}>>>]
type = Transient
end_time = 5
dt = 1
[]
[VectorPostprocessors<<<{"href": "../../../../syntax/VectorPostprocessors/index.html"}>>>]
[t_sampler]
type = LineValueSampler<<<{"description": "Samples variable(s) along a specified line", "href": "../../../../source/vectorpostprocessors/LineValueSampler.html"}>>>
variable<<<{"description": "The names of the variables that this VectorPostprocessor operates on"}>>> = T
start_point<<<{"description": "The beginning of the line"}>>> = '0 0.5 0'
end_point<<<{"description": "The ending of the line"}>>> = '2 0.5 0'
num_points<<<{"description": "The number of points to sample along the line"}>>> = 20
sort_by<<<{"description": "What to sort the samples by"}>>> = x
[]
[]
[Outputs<<<{"href": "../../../../syntax/Outputs/index.html"}>>>]
exodus<<<{"description": "Output the results using the default settings for Exodus output."}>>> = true
[csv]
type = CSV<<<{"description": "Output for postprocessors, vector postprocessors, and scalar variables using comma seperated values (CSV).", "href": "../../../../source/outputs/CSV.html"}>>>
file_base<<<{"description": "The desired solution output name without an extension. If not provided, MOOSE sets it with Outputs/file_base when available. Otherwise, MOOSE uses input file name and this object name for a master input or uses master file_base, the subapp name and this object name for a subapp input to set it."}>>> = therm_step03_out
execute_on<<<{"description": "The list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html."}>>> = final
[]
[]
(moose/modules/heat_transfer/tutorials/introduction/therm_step03.i)Input file
Variables
The first change necessary to convert this from a quasi-steady-state problem to a transient problem is to define a reasonable initial condition for the temperature variable. The default initial value of variables is 0, which did not affect the steady-state solution in the previous step, but has a significant effect on the transient solution. The initial_condition
parameter is set for the T
variable to 300. Units of Kelvin are used here, and this is close to room temperature.
[Variables<<<{"href": "../../../../syntax/Variables/index.html"}>>>]
[T]
initial_condition<<<{"description": "Specifies a constant initial condition for this variable"}>>> = 300.0
[]
[]
(moose/modules/heat_transfer/tutorials/introduction/therm_step03.i)Kernels
An additional block is added under the Kernels
top level block to include the time dependent term in the heat equation. The Kernel that provides this term is named HeatConductionTimeDerivative
because this term has a dependence on the time derivative of the temperature.
[Kernels<<<{"href": "../../../../syntax/Kernels/index.html"}>>>]
[heat_conduction]
type = HeatConduction<<<{"description": "Diffusive heat conduction term $-\\nabla\\cdot(k\\nabla T)$ of the thermal energy conservation equation", "href": "../../../../source/kernels/HeatConduction.html"}>>>
variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = T
[]
[time_derivative]
type = HeatConductionTimeDerivative<<<{"description": "Time derivative term $\\rho c_p \\frac{\\partial T}{\\partial t}$ of the thermal energy conservation equation.", "href": "../../../../source/kernels/HeatConductionTimeDerivative.html"}>>>
variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = T
[]
[]
(moose/modules/heat_transfer/tutorials/introduction/therm_step03.i)Materials
The HeatConductionTimeDerivative
Kernel depends on two additional material properties: density
and specific_heat
, which must be provided by material models. The specific heat can be provided by adding an additional parameter to the HeatConductionMaterial
Material block.
The density is not provided by HeatConductionMaterial
because that is a property that is used by other physics models, in particular by the models for solid mechanics. There is a specialized model to compute the density of a deforming material that is commonly used in those calculations, but there is no deformation in the present simulation, so a constant property can be used. The GenericConstantMaterial
is a material model that can be used to define one or more properties by providing the name of the property and the constant value. This is used here as a simple way to define the density.
[Materials<<<{"href": "../../../../syntax/Materials/index.html"}>>>]
[thermal]
type = HeatConductionMaterial<<<{"description": "General-purpose material model for heat conduction", "href": "../../../../source/materials/HeatConductionMaterial.html"}>>>
thermal_conductivity<<<{"description": "The thermal conductivity value"}>>> = 45.0
specific_heat<<<{"description": "The specific heat value"}>>> = 0.5
[]
[density]
type = GenericConstantMaterial<<<{"description": "Declares material properties based on names and values prescribed by input parameters.", "href": "../../../../source/materials/GenericConstantMaterial.html"}>>>
prop_names<<<{"description": "The names of the properties this material will have"}>>> = 'density'
prop_values<<<{"description": "The values associated with the named properties"}>>> = 8000.0
[]
[]
(moose/modules/heat_transfer/tutorials/introduction/therm_step03.i)Questions
Before running the model, consider the initial conditions and boundary conditions, and estimate what expected solution should be when the time-dependent term is included.
Now go ahead and run the input and visualize the result to see if it matches the behavior you would expect.
Exploring parameters
Which parameters would you expect to be able to change to give a solution that matches more closely with the steady-state solution? Try changing those parameters to see if they have the expected effect after re-running the model.
Sidebar:
Some problems also have volumetric heating, which can be included by adding another Kernel.
Comparison of results
A Python script called therm_soln_compare.py
in this directory is set up to plot the results of the problems from steps 2a, 3, and 3a to show a side-by-side comparison of the temperature profiles at the end of the analysis for these cases. This script depends on having the matplotlib
and pandas
libraries available in your Python installation. It is executed by typing:
./therm_soln_compare.py
from the directory where the problems are run. It will generate an image called therm_soln_compare.png
with line plots for these three cases.