程序代写代做代考 Final Projects 1

Final Projects 1
Instructions: Choose two 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 =κ∂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(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+1 −un un −un un+1 −2un+1 +un+1 j j+U j+1 ∆t w ∆x j=Dj+1 j j−1. (4) (∆x)2 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 ̸= 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 ∆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 =a2∂2p 00, (6) ∂t2 ∂x2
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(t,l) = 0. ∂x
Assume that a = 1, l = 1, and the initial conditions are p(0,x) = p0 cos2πx, and ∂p(0,x) = 0
∂t
(8)
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