DEPARTMENT OF MATHEMATICS The University of Queensland MATH303 Scientific Computation: Algorithmic Design and Implementation Section A Boundary Value Problem in dimension Semester, 00 A simplified problem leading to an ordinary differential equation In the past sections we have considered differential equations whose solutions were dependent on the time variable. The main physical illustration of this was the heat transfer, but we assumed a uniform temperature distribution in the material. This is rarely the case and one can expect to have a varying temperature with respect to space, and this will result in the diffusion of heat. The math model for this is also a differential equation, but at least one of the independent variables must be space. The simplest boundary value problems have the form du κ + cu = f ( x) and boundary conditions u(0), u() given. () u = u(x) represents temperature and is an unknown function of x, and x is in some finite interval, say [0,]. κ is the thermal conductivity, and for small changes in temperature we assume it can be approximated by a constant. If the interval has length other than unity we can scale x and define κ and c accordingly. The function f can have many forms: (i) f = f(x) could be a heat source such as electrical resistance in a wire, (ii) f = c(usur4 - u4) from radiative cooling.
Also, there are types of boundary conditions which reflect how fast heat passes through the boundary. We have derived already set up partial differential equations similar to () based on Fourier's Heat Law: (a) heat flows from hot to cold, (b) the change in heat is proportional to the cross sectional area, change in time, and the gradient of the temperature. The d.e. for heat flow or heat diffusion in a thin wire can be obtained by the following argument Consider a thin wire so that there is diffusion in only one direction, x. Then f has units of (heat)/(volume time). If there is no time dependence for the temperature, then Fourier's heat law for a thin wire when coupled with Newton's law of cooling to the surrounding region takes the form: zero heat change in heat content is approximately equal to (heat from electrical resistance) + (cooling from surrounding region) + (heat from diffusion from the left and right ends). If r is the radius of the wire and A = π r, then the above relation becomes du( x + h) du( x h) 0 f ( xha ) + h πrcu ( ext u) + κ A κ A κ is the constant of proportionality and will depend on the type of material in the wire. Divide both sides of this approximation by ha and let h go to zero to get a variation of (). du c c κ + u = f( x) + u ext () r r Solution of the differential equation by finite differences If κ, c and f are constants, then the closed form solution of () or () is relatively easy to find. However, if they are more complicated or if we have diffusion (or conduction - same thing) in two and three dimensional space, then closed form solutions are harder to find. An alternative is the
finite difference method which is a way of converting continuum problems such as () or () into a finite set of algebraic equations. We approximate the second derivative by approximating it with difference quotients. Thus du du' u'( x+ h) u'( x = h ux ( + h) ux ( ) Now u'( x), so putting this into the previous expression h ux ( + h) ux ( ) ux ( + h) ux ( ) h h = h h du ux ( + h) ux ( + h) ux ( ux ( ) ux ( h) We could equally have used u'( x) then we would have h obtained an expression symmetric about x, thus du ux ( + h) ux ( ) + ux ( h). One reason for preferring this might be h that we don t know whether the values ahead of or behind x are the more important. Here we've assume equal spacing either before or ahead of the current value of x. Effectively we've divided the wire into n equal parts with 0 xi = ih and h=. We denote u(0 + ih) = u( ih) = ui n With u ext = 0 the finite difference method (or discrete model approximation) to () is ui ui + ui c κ + + ui = f i, for 0 < i < n (3) h r ) ) This gives n equations for n unknowns. The end points u l = u(0) and u n = u() are given as is f i = f(x i ).
The discrete system (3) may be written in matrix form. For ease of notation we multiply (3) by h, let B = κ + h c/r, and n = 5 so that there are 4 equations and 4 unknowns. Bu κu = h f + κu 0 u Bu κu3 h f u Bu3 κu4 h f3 u3 Bu4 h f4 κu5 κ + = κ + = κ + = + The matrix form of this is the tridiagonal system AU = F where A is, in general an ( n ) ( n ) tridiagonal matrix and U and F are ( n -) column vectors. a c 0 0 b A = 0 0 (4) cn 0 0 bn a n Solution of the linear system The solution can be obtained by either using the tridiagonal (or Thomas) algorithm, or using a solver that is provided with Matlab or other mathematical software. Let us consider the tridiagonal system Ax = d where A is given in (4) and x and d are column vectors. The following important algorithm computes the LU factorisation of a tridiagonal matrix. It can be found in the book by Atkinson, Introduction to Numerical Analysis. The book is in the list of reference books for the course. If L and U are lower and unit upper bidiagonal matrices
α 0 0 γ 0 0 b 0 0 L and U = = 0 0 γ n 0 0 bn αn 0 0 such that LU =A, then we solve Au = f with the process LUu = f, so solve Ly = f and Uu = y. The tridiagonal LU factorisation algorithm is. c α = a γ = α n n n n ci αi = ai biγi γi =, i=,3,... n α α = a bγ. i We can integrate the solution process with the computation of the LU factors. To see this, consider solving Ly=f. To find y we only need α, and in general, to find y i we only need y i-, b i (which is given) and α. After finding y we can solve Uu = f as a normal back substitution. Matlab code for solution of the thin wire model The following function finds an approximate solution of the boundary value problem du c c κ + u = f( x) + u, (0) 0, () ext u = u u = u. r r It is set up to approximate u at an equally spaced set of points. The values of f(x) are input, computed at a set of equally spaced points and the external temperature u ext has been set to zero. function [u,x] = wire_model(k,c,r,u0,u,f) % Evaluates the numerical solution of an o.d.e
% which models heat conduction in a metal wire % Written by John A. Belward (himself) on August 9th, 00 % Last updated on August 9th 00 % Usage: [u,x] = wire_model(k,c,r,u0,u,f) % where k is the conductivity, c the rate of heat loss due to cooling % r the radius, u0, u end temperatures, f the heat input vector % of length n-. % u and x are n+ vectors of the temperature u at points x n=length(f)+; h = /n; x = 0:h:; rhs=h^*f; rhs() = rhs()+k*u0; rhs(n-)=rhs(n-)+k*u; b=(*k+h^**(c/r)*ones(length(rhs),)); cvec =-k*ones(n-,); a=diag(b); a=a+diag(cvec,); a=a+diag(cvec,-); rhs; u=a\rhs; u(:n)=u; u()=u0; u(n+) = u; The following plots are 5 obtained with the calls: 0 5 [u,x] = wire_model(.00,.0,.3,0,0,f) [u,x] = wire_model(.00,.0,.,0,0,f) [u,x] = wire_model(.00,.0,.,0,0,f) 0 0 0. 0.4 0.6 0.8 f being a 9-vector, all elements equal to unity.