Lecture 17 Solving the Diffusion equation Only 5 lectures left • Come to see me before the end of term • I’ve put more sample questions and answers in Phils Problems • Past exam papers • Complete solution from last lecture • Have a look at homework 2 (due in on 12/12/08) 1 u u 2 h t 2 Remember Phils Problems and your notes = everything http://www.hep.shef.ac.uk/Phil/PHY226.htm Introduction to PDEs In many physical situations we encounter quantities which depend on two or more variables, for example the displacement of a string varies with space and time: y(x, t). Handing such functions mathematically involves partial differentiation and partial differential equations (PDEs). 2 1 u 2 u 2 2 c t Wave equation Elastic waves, sound waves, electromagnetic waves, etc. 2 2 u u Vu i 2m t 1 u 2u 2 h t Schrödinger’s equation Quantum mechanics Diffusion equation Heat flow, chemical diffusion, etc. u0 Laplace’s equation Electromagnetism, gravitation, hydrodynamics, heat flow. 2 u 0 Poisson’s equation As (4) in regions containing mass, charge, sources of heat, etc. 2 The Diffusion equation In classical physics, almost all time dependent phenomena may be described by the wave equation or the diffusion equation. Smaller than the micrometer scale, diffusion is often the dominant phenomenon. 2 d f ( x, t ) 1 f ( x, t ) The 1D diffusion equation has the form 2 2 dx h t f(x, t) is the quantity that diffuses. It usually describes a chemical or heat diffusing through a region where h2 is the diffusion constant typically 1×10-4 m 2s -1 for metals. Introduction to PDEs 2 d x(t ) 2 Unstable equilibrium x(t ) 2 dt 2 dx d x mt mt So Step 1: Let the trial solution be me mx and 2 m 2e mt m 2 x xe dt dt Step 2: The auxiliary is then m x x 2 Step 3: General solution for real roots Step 4: Boundary conditions could then be applied to find A and B Thing to notice is that x(t) only tends towards x=0 in one direction of t, increasing exponentially in the other 2 and so roots are m m is x(t ) Ae t Be t x(t ) Aet t Introduction to PDEs d 2 x(t ) 2 Harmonic oscillator 0 x (t ) 2 dt Step 1: Let the trial solution be Step 2: The auxiliary is then x d 2x mt So dx mt me mx and 2 m 2e mt m 2 x e dt dt m x x 2 Step 3: General solution for complex where = 0 and b = so 2 and so roots are m i m ib is x e t (C sin b t D cos b t ) x C sin t D cos t Step 4: Boundary conditions could then be applied to find C and D Thing to notice is that x(t) passes through the equilibrium position (x=0) more than once !!!! x C sin t SUMMARY of the procedure used to solve PDEs 2 y ( x , t ) 1 2 y ( x, t ) 1. We have an equation 2 x 2 c t 2 with supplied boundary conditions 2. We look for a solution of the form y ( x, t ) X ( x)T (t ) 3. We find that the variables ‘separate’ 1 d 2 X ( x) 1 d 2T (t ) 2 N X ( x) dx 2 c T (t ) dt 2 4. We use the boundary conditions to deduce the polarity of N. e.g. N k 2 5. We use the boundary conditions further to find allowed values of k and hence X(x). X ( x) A cos kx B sin kx so X n ( x) Bn sin nx L 6. We find the corresponding solution of the equation for T(t). nct T ( t ) E cos n T (t ) C cos kct D sin kct n L 7. We hence write down the special solutions. Yn ( x, t ) Bn sin nx cos nct n L L 8. By the principle of superposition, the general solution is the sum of all special nx nct solutions.. y ( x, t ) B sin cos n 1 n L L n www.falstad.com/mathphysics.html 9. The Fourier series can be used to find the particular solution at all times. y ( x, t ) 8d x ct 1 3x 3ct 1 5x 5ct 1 7x 7ct sin cos sin cos sin cos sin cos L L 9 L L 25 L L 49 L L 2 Before we do anything let’s think about hot stuff Consider a metal bar heated along it’s length. The ends are placed in ice water and so are held at 0ºC and the middle section is heated by a gas burner. After a while we reach an equilibrium or steady state temperature distribution along the rod which, let’s say is given by f(x), the temperature distribution plot below. f ( x) x for 0 x L 2 f ( x) x L for L 2 x L x=0 x=L Is there a way of describing the shape of the temperature distribution in terms of an infinite series of sine terms ??????? Yes, it’s called the Half range sine series !!!! Before we do anything let’s think about hot stuff f ( x) x for 0 x L 2 f ( x) x L for L 2 x L Half-range sine series: f ( x) nx 2 d nx where b sin b f ( x ) sin dx n n 0 d d d n 1 2 L nx 2 So bn f ( x) sin dx 0 L L L L2 0 nx 2 nx x sin dx ( L x) sin dx L L L. 2 L L Full solution is given in the notes, but we don’t want to waste time doing number crunching so let’s go straight to the answer…. 4L n nx nx 4L n f ( x ) sin sin f ( x ) b sin b sin Find n So since then n 2 2 2 L d n 1 n 2 n 1 n 2 2 This describes the temperature distribution f(x) along the bar in equilibrium Solving the diffusion equation for relaxation Consider a metal bar heated along it’s length. The ends are placed in ice water and so are held at 0ºC and the middle section is heated by a gas burner. After a while we reach an equilibrium or steady state temperature distribution along the rod which, let’s say is given by f(x), the temperature distribution plot below. At t = 0 we switch off the burner and allow the rod to cool. What is the function f(x,t) that describes the temperature of the rod at any point along its length at any time as it cools? Heat flow is governed by the diffusion equation, (f is the temperature and x is position and t is time) d 2 f ( x, t ) 1 f ( x, t ) 2 2 dx h t Solving the diffusion equation for relaxation Heat flow is governed by the diffusion equation, (f is the temperature and x is position and t is time) We are looking for solutions of the form d 2 f ( x, t ) 1 f ( x, t ) 2 2 dx h t f ( x, t ) X ( x)T (t ) Where X(x) is temperature purely as a function of x and T(t) is temperature purely as a function of time Step 1: Rewrite using new variables 2 d X ( x) 1 dT (t ) Substitute f(x,t) back into the Diffusion equation: T ( t ) X ( x ) dx 2 h2 dt Step 2: Rearrange the equation Separating variables: 1 d 2 X ( x) 1 1 dT (t ) 2 2 X ( x) dx h T (t ) dt Solving the diffusion equation for relaxation 1 d 2 X ( x) 1 1 dT (t ) 2 2 X ( x) dx h T (t ) dt Step 3: Equate to a constant Now we have separated the variables. The above equation can only be true for all x, t if both sides are equal to a constant. 1 d 2 X ( x) 1 d 2 X ( x) So constant X ( x) (i) constant which rearranges to 2 2 X ( x) dx X ( x) dx 1 1 dT (t ) dT (t ) 2 constant which rearranges to constant h T (t ) 2 h T (t ) dt dt (ii) Solving the diffusion equation for relaxation d 2 X ( x) constant X ( x) 2 dx (i) dT (t ) constant h 2T (t ) dt (ii) Step 4: Decide based on the boundary conditions whether constant is +ve or -ve We are told in the boundary conditions that both ends of the rod are held at 0°C at all times. We therefore choose a negative constant, –k2, to give LHO type solutions that will allow X(x) to be zero at more than one value of x, and rearrange to get two ODEs: d 2 X ( x) k 2 X 2 dx which has general solution X ( x) A cos kx B sin kx dT (t ) k 2 h 2T (t ) dt which has general solution k 2 h 2t T (t ) Ce (iv) (iii) Solving the diffusion equation for relaxation X ( x) A cos kx B sin kx (iii) T (t ) Ce k 2 h 2t (iv) Step 5: Solve for the boundary conditions for X(x) We know that X(0) = X(L) = 0 meaning that the temperature is zero at the ends Solution to (iii) is X ( x) A cos kx B sin kx We know that X(0) = 0 so A = 0. Also since X ( L) 0 B sin kL then kL n so we can say X ( x) B sin 1.5 total amplitude X(x)1 0.5 0 -0.5 x nx L Solving the diffusion equation for relaxation X n ( x) Bn sin kn x Tn (t ) Cn e Step 6: Write down the special solution for fn (x, t) i.e. nx f n ( x, t ) X ( x)T (t ) BnCn sin e L So t n k n 2 h 2t f n ( x, t ) X n ( x)Tn (t ) 1 L where n 2 2 h k nh nx f n ( x, t ) X ( x)T (t ) Pn sin e L t n where Pn = BnCn is a special solution of the diffusion equation at one value of n 2 Solving the diffusion equation for relaxation So nx f n ( x, t ) X ( x)T (t ) Pn sin e L t n is a special solution of the diffusion equation at one value of n Step 7: Constructing the general solution for f ( x, t ) X n 1 n ( x)Tn (t ) . The general solution of our equation is the sum of all special solutions: The general solution therefore is f ( x, t ) n nx f n ( x, t ) Pn sin e L n t n Solving the diffusion equation for relaxation nx n f ( x, t ) Pn sin e L n t The general solution is Step 8: Use Fourier series to find values of Pn The general solution is the solution to the diffusion equation for all values of n summed from 1 to infinity. For our specific example we only want our solution to contain those harmonics required to fulfil the boundary conditions. All that remains is calculate the required values of Pn and the harmonics required. We can do this by relating the Fourier series found at t = 0 to the general solution. Remember earlier we showed that in equilibrium the temperature profile along the rod is given by: 4L n nx sin sin 2 2 2 L n 1 n f ( x,0) By comparing this with the general solution at the top of the page when t = 0 we can assign values to Pn . Solving the diffusion equation for relaxation nx n f ( x, t ) Pn sin e L n t The general solution is Step 8 continued: Use Fourier series to find values of Pn 4L n nx sin sin 2 2 2 L n 1 n Fourier series at t = 0 is f ( x,0) The general solution at t = 0 is f ( x,0) Pn sin n By comparing we can see that Pn nx L 4L n sin 2 2 n 2 Step 9: Write down full solution of problem 4L n nx f ( x, t ) 2 2 sin sin e 2 L n n t n 1 L where n 2 2 h k nh 2 Solving the diffusion equation for relaxation A metal bar is heated along it’s length. The ends are placed in ice water and so are held at 0ºC and the middle section is heated by a gas burner. At t=0 heating stops. 4L n nx n f ( x, t ) 2 2 sin sin e 2 L n n t Let’s check that this fulfils all boundary conditions f ( x,0) X ( x)T (0) f ( x, t ) n f (0, t ) X (0)T (t ) f ( L, t ) X ( L)T (t ) f ( x, t ) 0e f ( x, t ) n 4L n nx sin sin n 2 2 2 L This is just the Fourier series at start t n 0 4L n sin n e sin 2 2 n 2 t n 0 Solving the diffusion equation for relaxation A metal bar is heated along it’s length. The ends are placed in ice water and so are held at 0ºC and the middle section is heated by a gas burner. At t=0 heating stops. 4L n nx f ( x, t ) 2 2 sin sin e 2 L n n t n 1 L where n 2 2 h k nh 2 Now we can stick in appropriate values of h and find how the temperature profile changes over time. It can be shown that f(x, t) with increasing time looks like this: h t 9 h t 25 h t 4 L 1 x L2 1 3x L2 1 5x L2 f ( x, t ) 2 sin e sin e sin e ..... 1 L 9 L 25 L 2 2 2 2 2 2 Solving the diffusion equation for relaxation h t 9 h t 25 h t 4 L 1 x L2 1 3x L2 1 5x L2 f ( x, t ) 2 sin e sin e sin e ..... 1 L 9 L 25 L 2 2 2 2 2 2 Remember how we said earlier that temperature as a function of time was written: Tn (t ) e t n 1 where n 2 2 h k The time constant of temperature decay is defined as n , the time for temperature to drop to e 1 0.37 of its initial value. Points of interest The temperature distribution decays exponentially with time. 1 L n 2 2 h k nh 2 The time constant of the decay is proportional to k -2, and therefore also L2. So the longest wavelengths (such as the fundamental) last longest. To know exactly how the temperature profile changes with time then we need all the terms. But usually a very good approximation can be obtained by considering just the first term. Our experiment A good approximation can be obtained by considering just the first term. f ( x, t ) 4L 2 sin x L e 2 h 2t L2 At a fixed x, the temperature drop from t = 0 is: 2 2 f (t ) e h t L2 We know , L = 0.5m , and h2 = 3×10-5m2s-1 for stainless steel. So 1 π 2h2 2 1.2103 1 L L2 and therefore 1 2 2 844 s So h f (t ) e t 844 We must record temperature at a fixed location on the rod at regular intervals, then plotting it as a function of time and fitting an exponential to find the decay time constant Remember that now in the full equation x is fixed constant 4L n nx n f ( x, t ) 2 2 sin sin e 2 L n n t Our experiment We recorded temperature at a fixed location on the rod at regular intervals, then plotted it as a function of time and fitted an exponential to find the decay time constant Theory tells us that at a fixed x, the temperature drop from t = 0 should be: f (t ) e t 844 since 1 π 2h2 2 1.2103 1 L 400 350 y = 333.75e-0.0012x Temperature (degC) 300 Data collected during the lecture has a decay constant of 1.2x10-3 as expected!!!! 250 200 150 100 50 0 0 200 400 600 800 Time (seconds) 1000 1200 1400 Revision for the exam http://www.shef.ac.uk/physics/exampapers/2007-08/phy226-07-08.pdf Above is a sample exam paper for this course There are 5 questions. You have to answer Q1 but then choose any 2 others Previous years maths question papers are up on Phils Problems very soon Q1: Basic questions to test elementary concepts. Looking at previous years you can expect complex number manipulation, integration, solving ODEs, applying boundary conditions, plotting functions, showing ‘x’ is solution of PDE. Easy stuff. Q2-5: More detailed questions usually centred about specific topics: InhomoODE, damped SHM equation, Fourier series, Half range Fourier series, Fourier transforms, convolution, partial differential equation solving (including applying an initial condition to general solution for a specific case), Cartesian 3D systems, Spherical polar 3D systems, Spherical harmonics The notes are the source of examinable material – NOT the lecture presentations I wont be asking specific questions about Quantum mechanics outside of the notes Revision for the exam The notes are the source of examinable material – NOT the lecture presentations Things to do now Read through the notes using the lecture presentations to help where required. At the end of each section in the notes try Phils problem questions, then try the tutorial questions, then look at your problem and homework questions. If you can do these questions (they’re fun) then you’re in excellent shape for getting over 80% in the exam. Look at the past exam papers for the style of questions and the depth to which you need to know stuff. You’ll have the standard maths formulae and physical constants sheets (I’ll put a copy of it up on Phils Problems so you are sure what’s on it). You don’t need to know any equations e.g. Fourier series or transforms, wave equation, polars. Any problems – see me in my office or email me Same applies over holidays. I’ll be in the department most days but email a question or tell me you want to meet up and I’ll make sure I’m in. Concerned about what you need to know? Look through previous exam questions. 2008/2009 exam will be of very similar style. You don’t need to remember any proofs or solutions (e.g. Parseval, Fourier series, Complex Fourier series) apart from damped SHM which you should be able to do. You don’t need to remember any equations or trial solutions, eg. Fourier and InhomoODE particular solutions. You don’t need to remember solutions to any PDE or for example the Fourier transform of a Gaussian and its key widths, etc. However you should understand how to solve any PDE from start to finish and how to generate a Fourier transform. Things you need to be able to do: Everything with complex numbers; solve ODEs and InhomoODEs, apply boundary conditions; integrate and differentiate general stuff; know even and odd functions; understand damped SHM, how to derive its solutions depending on damping coefficient and how to draw them; how to represent an infinitely repeating pattern as a Fourier series, how to represent a pulse as a sine or cosine half range Fourier series; how to calculate a Fourier transform; how to (de)convolve two functions; the steps needed to solve any PDE and apply boundary conditions and initial conditions (usually using Fourier series); how to integrate and manipulate equations in 3D cartesian coordinates; how to do the same in spherical polar coordinates; how to prove an expression is a solution of a spherical polar equation; explain in general terms what spherical harmonics are.