Final Projects Math104 C 1 Prof. Hector Ceniceros
Instructions: Choose one of the problems and write a jupyter notebook to integrate all the parts of the problem solution; this includes any analytic calculations and theory, code, results and analysis of the results.
1. The cellar. Neglecting the curvature of the Earth and the diurnal (daily) variation of temperature, the distribution of temperature T (x, t) at a depth x and a time t is given by the Heat equation:
∂T =κ∂2T. (1) ∂t ∂x2
Here κ is thermometric diffusivity of soil whose value is approximately κ = 2 × 10−3cm2/sec (the fundamental time scale is a year, 3.15 × 107sec). Assume that the temperature f(t) at the surface of the Earth (x = 0) has only two values, a “summer” value for half of the year and a “winter” value for the other half, and that this pattern is repeated every year (i.e. at x = 0 the temperature is periodic with a period of a year). The temperature T should decay to zero as x → ∞.
a) Show that the backward (implicit Euler) difference scheme for (1) is consistent and unconditionally stable. What is the order of the scheme?
b) Implement the backward difference scheme to find a numerical approximation to (1). Consider the initial condition u0(x) = f(t)e−q1x, where q1 = 0.71m−1. For your computational spatial domain take a sufficiently long interval so that the right-end boundary condition u = 0 can be used. Select k and h small enough to resolve well the numerical solution. Plot the numerical solution at several times.
c) From your numerical solution, find the depth xc at which the temperature is opposite in phase to the surface temperature, i.e, it is summer at xc when is winter at the surface. Note that the temperature variation at xc is much smaller than that at the surface. This makes the depth xc ideal for a wine cellar or vegetable storage.
2. A simple model for air quality control. An air pollutant gets advected by the wind and at the same time diffuses as it travels. The time evolution of the concentration u(x,y,t) of the pollutant at position (x,y) and at time t can be modelled by the advection diffusion equation
ut + Uwux + Vwuy = D(uxx + uyy), (2)
1All course materials (class lectures and discussions, handouts, homework assignments, examinations, web materials) and the intellectual content of the course itself are protected by United States Federal Copyright Law, the California Civil Code. The UC Policy 102.23 expressly prohibits students (and all other persons) from recording lectures or discussions and from distributing or selling lectures notes and all other course materials without the prior written permission of the instructor.
1
where (Uw,Vw) are the components of the wind velocity and D > 0 is the diffusivity coefficient (assumed small) of the pollutant in the air.
a) The one-dimensional case of (2) is
ut + Uwux = Duxx. (3)
(If D = 0, this is the simple one-way wave equation (also called advection equa- tion) we have seen in class). Assuming Uw < 0 (and constant) find the stability condition for the scheme
un+1 −un un −un un+1 −2un+1 +un+1
m m+U m+1 m=Dm+1 m m−1. (4)
kwh h2
b) If D = 0, one gets an “upwind” scheme for the one-way way equation. Find the modified (model) equation for the “upwind” scheme and show that the scheme is dissipative. How do you have to take your numerical parameters to guarantee that your numerical diffusion is much less than the “real” diffusion when D ̸= 0?. Explain
c) Write a code to implement (4) with homogeneous boundary conditions (u = 0 at the boundary) and use it to solve (3) in [−5, 1] with initial condition
1 for0≤x≤1/2
u0(x) = 0 otherwise (5)
Take Uw = −1 and D = 0.1 and select k and h small enough to resolve well the numerical solution. Plot the solution at t = 1, 2, 3.
3. Acoustic waves. The air pressure p(x,t) in an organ pipe is governed by the wave equation
∂2p =c2∂2p 0
where l is the length of the pipe and c is a constant. If the pipe is open, the boundary cinditions are given by
p(0,t) = p0 and p(l,t) = p0. (7) If the pipe is closed at the end x = l the boundary conditions are
p(0,t) = p0 and ∂p(l,t) = 0. (8) ∂x
Assume that c = 1, l = 1, and the initial conditions are
p(x,0) = p0 cos2πx, and ∂p(x,0) = 0 0 ≤ x ≤ 1. (9)
∂t
a) Write down an explicit finite difference method for (5) and give stability conditions and the order of the method.
2
b) Implement your method given in a) for the open pipe with p0 = 0.9, and with step sizes k = h = 0.05. Plot your numerical solution at t = 0.5 and t = 1.0.
c) Implement your method given in a) for the closed pipe at x = l with p0 = 0.9, and with step sizes k = h = 0.05. Plot your numerical solution at t = 0.5 and t = 1.0.
d) Repeat b) for k = h = 0.025. Construct a higher order approximation by extrapo- lating your numerical solutions corresponding to k = h = 0.05 and k = h = 0.025. What’s the order of the new approximation.
3