week7_solutions
week7_solutions
Exercise 1
Question 1. Let us discretise coordinate y into I + 1 nodes denoted yi (i = 0, . . . , I) with uniform spacing
∆y, and time t into N + 1 steps denoted tn (n = 0, . . . , N ) with uniform spacing ∆t. We denote Tin
the numerical approximation of temperature at time tn and position yi . The governing partial differential
equation for temperature is approximated by the following implicit finite difference scheme:
n+1
−sTi+1 + (1 + 2s)Tin+1 − sTi−1
n+1
= Tin , for i = 1, . . . , I,
and
T0n+1
T1n+1
T2n+1
X= ,
..
n+1 .
T
I−1
TIn+1
1
y=0 m
y=0.12 m
y=0.27 m
y=0.57 m
y=1.17 m
30 C
0 2 4 6 8 10
time (day)
and
T0 + A sin(2πtn+1 /τ )
T1n
T2n
B= .
..
.
n
TI−1
T0
Question 4. The code in file question4.m extracts the amplitude of the oscillation as function of depth,
and generates the plot in figure 2. We observe that the depth at which the oscillation becomes less than 5%
of the surface oscillation is of the order of 0.53 m.
Question 5. Here we are asked to repeat the computation and change parameters. This is very easy
to do by just changing values in the code. However, we can gain a lot more insight into the problem
by reformulating the model in terms of dimensionless quantities. Here, a natural choice is to choose the
√
timescale τ and length scale ` = ατ , and to normalise temperature by the amplitude A. Let us write
∂ T̃ ∂ 2 T̃
= ,
∂ t̃ ∂ ỹ 2
2
1
0.6
0.4
0.2
0
0 1 2 3 4 5 6
depth (m)
Figure 2: Relative amplitude of the temperature oscillations as a function of depth. Red line shows the 5%
mark.
Question 6. The code in file question6.m generates the plot shown in figure 3, which shows the nondi-
mensional temperature as a function of time t/τ for a range of depths.
Question 7. The code in file question7.m extracts the amplitude of the oscillation as function of depth,
and generates the plot in figure 4. We observe that the depth at which the oscillation becomes less than 5%
√
of the surface oscillation is of the order of ỹ = 1.8, i.e., y = 1.8 ατ . For τ = 1 year, we would then have a
depth of about 10.1 m.
Question 8. As just seen above, from dimensional considerations we expect that the characteristic depth
√
scales with ` = ατ . Here for the oscillations to become less than 5% of the surface oscillations, we observe
numerically that the depth needs to be greater than 1.8`. While the numerical computation is needed to
get an accurate solution to the problem and extract the numerical factor of 1.8, a basic estimation using `
only (which can be done without any numerical computations) provides the correct order of magnitude for
the critical depth.
Exercise 2
Question 1. Here the simplest option is to consider that we have a heterogeneous material where diffusivity
depends on position. The fact that the variation is just a step function is not that important! We can repeat
steps similar to exercise 1: Let us discretise coordinate y into I + 1 nodes denoted yi (i = 0, . . . , I) with
3
y/l=0
y/l=0.40825
y/l=0.91856
y/l=1.9392
0 2 4 6 8 10
normalised time
0.8
oscillation amplitude
0.6
0.4
0.2
0
0 2 4 6 8 10
depth
Figure 4: Relative amplitude of oscillations as a function of normalised depth. The red line shows the 5%
mark.
4
uniform spacing ∆y, and time t into N + 1 steps denoted tn (n = 0, . . . , N ) with uniform spacing ∆t. We
denote Tin the numerical approximation of temperature at time tn and position yi . The governing partial
differential equation for temperature is approximated by the following implicit finite difference scheme:
n+1
−si+1/2 Ti+1 + (1 + si+1/2 + si−1/2 )Tin+1 − si−1/2 Ti−1
n+1
= Tin , for i = 1, . . . , I,
···
1 0 0 0 0 0
−s1/2 (1 + s3/2 + s1/2 ) −s3/2 0 ··· 0 0
0 −s3/2 (1 + s5/2 + s3/2 ) −s5/2 ··· 0 0
.. .. .. .. ..
,
. . . . .
0 ··· 0 −sI−5/2 (1 + sI−3/2 + sI−5/2 ) −sI−3/2 0
0 ··· 0 0 −sI−3/2 (1 + sI−1/2 + sI−3/2 ) −sI−1/2
0 ··· 0 0 0 0 1
and
T0n+1
T1n+1
T2n+1
X= ,
..
n+1 .
T
I−1
TIn+1
and
T0 + A sin(2πtn+1 /τ )
T1n
T2n
B= .
..
.
n
TI−1
T0
Question 3. See code in file question3b.m and figure 5. We can see that the temperature at a depth of
around 57 cm experiences larger oscillations than in the case where diffusivity is uniform: this is exepcted,
since here we model a material that has a higher diffusivity at depth.
5
y=0 m
y=0.12 m
y=0.27 m
y=0.57 m
y=1.17 m
30 C
0 2 4 6 8 10
time (day)