0% found this document useful (0 votes)
2 views6 pages

week7_solutions

The document describes a numerical approach to solving a partial differential equation for temperature using an implicit finite difference scheme. It includes exercises that involve discretizing coordinates and time, implementing boundary conditions, and analyzing temperature oscillations at various depths. Additionally, it discusses the effects of varying diffusivity in materials and provides code references for implementation.

Uploaded by

Anglo-Saxon NO.1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

week7_solutions

The document describes a numerical approach to solving a partial differential equation for temperature using an implicit finite difference scheme. It includes exercises that involve discretizing coordinates and time, implementing boundary conditions, and analyzing temperature oscillations at various depths. Additionally, it discusses the effects of varying diffusivity in materials and provides code references for implementation.

Uploaded by

Anglo-Saxon NO.1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Practical 7: Correction

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,

where s = α∆t/∆y 2 , and the boundary conditions become

TIn = T0 and T0n = T0 + A sin(2πtn /τ ).

In matrix form, the numerical scheme is equivalent to AX = B where


 
1 0 0 0 ··· 0 0
 −s (1 + 2s) −s 0 ··· 0 0 
 
 0
 −s (1 + 2s) −s · · · 0 0 

 .. . .. . .. . .. ..
A= . ,

 . 
 0
 · · · 0 −s (1 + 2s) −s 0 

 0 ··· 0 0 −s (1 + 2s) −s 
0 ··· 0 0 0 0 1

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)

Figure 1: Temperature evolution as a function of time at four different depths.

and  
T0 + A sin(2πtn+1 /τ )

 T1n 

 T2n 
B= .
 
..

 . 

 n
TI−1 
T0

Question 2. See code in file question2.m.

Question 3. See code in file question3.m and figure 1.

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̃ = t/τ, ỹ = y/`, T̃ = (T − T0 )/A,

so that the governing equation is expressed as

∂ T̃ ∂ 2 T̃
= ,
∂ t̃ ∂ ỹ 2

2
1

oscillation amplitude (Tmax−Tmin)/A


0.8

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.

with boundary conditions:


T̃ (ỹ = L/`) = 0, T̃ (ỹ = 0) = sin(2π t̃),
and initial condition T̃ (x̃, 0) = 0.
The code given in file question5.m solves the nondimensional problem.

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

Figure 3: Temperature evolution as a function of time at four different depths.

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,

where si±1/2 = αi±1/2 ∆t/∆y 2 , where


αi±1/2 = α(yi ± ∆y/2).
The boundary conditions are the same as in exercise 1:

TIn = T0 and T0n = T0 + A sin(2πtn /τ ).

In matrix form, the numerical scheme is equivalent to AX = B where A is given by

···
 
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 2. See code in file question2b.m.

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)

Figure 5: Temperature evolution as a function of time at four different depths.

You might also like