Up: Return
EGN 5456 Homework 6 Fall 1997
Numerical Solution of Heat Conduction in a Bar
- Problem Statement
- Find the temperature distribution T in
a bar of length with a heat conduction coefficient .The ends of the bar are kept at zero degrees for all time. However,
initially the center of the bar is at a larger temperature
. You can assume that this initial temperature
decreases linearly from the middle to zero at each end.
Plot the temperature distribution T for times
0, 0.125, 0.25, 0.375, and 0.5
in a single graph against x.
- Analytical Solution
- Solve the problem analytically.
-
Find the separation of variables solution as a Fourier sine series.
Rewrite this solution as a complex Fourier series, just to see
that it can be done.
-
Use the Fourier sine series solution to create a function subprogram
T_ana that takes x, t, , and as
arguments and returns the exact temperature at that point and time.
Some points to consider:
-
The first time this subprogram is used, it should read
the value of from an input file.
But do not keep reading it in.
-
Pay particular attention to the best place to terminate the Fourier
series. Sum as many terms as needed to get the
most accurate solution, but no more than that.
-
Avoid underflow, which may impact performance.
-
Since the series converges slowly for time t=0, you may want to do
this time separately.
-
Use your function in a computer program to plot the exact solution
T(x) in a single graph for times 0, 0.125, 0.25,
0.375, and 0.5. Use a plotting software package of your choice.
Solution
- Numerical Solution
- Solve the problem numerically using a finite difference method.
-
Discretize the bar into J+1 x-locations spaced
apart by defining
-
Similarly, restrict the times to N+1 discrete times spaced apart by defining
Here is the last time you want to compute.
-
You need to determine all (J+1)(N+1) temperature values
and then plot the ones corresponding to the requested times.
Do that by first initializing the initial values T0j as given.
(It is best to do this using your exact solution function;
then you can compute a different initial condition using exactly
the same program).
-
Next compute the values for later times using the formulae
(the left hand side approximates , the
right hand side )This formulae can be used first for n=0 to compute the values
of T1j for all .The end values T10 and T1J can be found from the given
Dirichlet boundary condition. (Again it is neatest to do this using your
exact solution function).
Next, now that all Tnj values are known for n=1,
the values of T2j can be computed
for all values of , and so on.
-
You will need to check at each time level whether it needs to be output.
-
Try a value for J such as 16 or 32.
-
Try 3 different values for N. The first value should
give (as accurately as possible)
,the second
,and the third
.
-
For each of the three cases, make a separate plot of T versus x
for times 0, 0.125, 0.25, 0.375, and 0.5. In these
graphs, present the exact solution by a continuous line and the
computed values Tjn by symbols. (You may want to use more than
J points to plot the exact solution accurately. About 50 points is a
good choice.)
-
Comment on the differences in the results.
-
Follow the recommended programming techniques.
Click here
Up: Return
Author: Leon van Dommelen