CS计算机代考程序代写 scheme Final Projects Math104 C 1

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 (t, x) at a depth x and a time t is given
by the Heat equation:

∂T

∂t
= κ

∂2T

∂x2
. (1)

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(t0)e

−q1x, where q1 = 0.71m
−1 and t0

is your initial time. For your computational spatial domain take a sufficiently long
interval so that the right-end boundary condition u = 0 can be used. Select ∆t
and ∆x small enough to resolve well the numerical solution. Plot the numerical
solution at several times.

c) From your numerical solution, find the depth x∗ at which the temperature is
opposite in phase to the surface temperature, i.e, it is summer at x∗ when is
winter at the surface. Note that the temperature variation at x∗ is much smaller
than that at the surface. This makes the depth x∗ 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(t, x, y) of the pollutant at position (x, y) and at time t can be modeled 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+1j − u n j ∆t + Uw unj+1 − unj ∆x = D un+1j+1 − 2u n+1 j + u n+1 j−1 (∆x)2 . (4) b) If D = 0, one gets an “upwind” scheme for the one-way way equation. Show that this scheme satisfies an equation of the form ut + Uwux = σuxx to second order accuracy, where σ ≥ 0 (obtain the explicit expression of σ in terms of ∆x and λ). Therefore the numerical approximation using this upwind scheme will have some numerical diffusion or dissipation. How do you have to take your numerical parameters to guarantee that your numerical diffusion is much less than the “real” diffusion when D 6= 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 u0(x) = { 1 for 0 ≤ x ≤ 1/2 0 otherwise (5) Take Uw = −1 and D = 0.1 and select ∆t and ∆x small enough to resolve well the numerical solution. Plot the solution at t = 1, 2, 3. 3. Acoustic waves. The air pressure p(t, x) in an organ pipe is governed by the wave equation ∂2p ∂t2 = a2 ∂2p ∂x2 0 < x < l, t > 0, (6)

where l is the length of the pipe and a is a constant. If the pipe is open, the boundary
conditions are given by

p(t, 0) = p0 and p(t, l) = p0. (7)

If the pipe is closed at the end x = l the boundary conditions are

p(t, 0) = p0 and
∂p

∂x
(t, l) = 0. (8)

Assume that a = 1, l = 1, and the initial conditions are

p(0, x) = p0 cos 2πx, and
∂p

∂t
(0, x) = 0 0 ≤ x ≤ 1. (9)

2

a) Write down an explicit finite difference method for (6) and give stability conditions
and the order of the method.

b) Implement your method given in a) for the open pipe with p0 = 0.9, and with
step sizes ∆t = ∆x = 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 ∆t = ∆x = 0.05. Plot your numerical solution at t = 0.5 and
t = 1.0.

d) Repeat b) for ∆t = ∆x = 0.025. Construct a higher order approximation by
extrapolating your numerical solutions corresponding to ∆t = ∆x = 0.05 and
∆t = ∆x = 0.025. What’s the order of the new approximation?

3