MECH 5315M - Engineering Computational Methods
Engineering Computational Methods
MECH 5315M - Engineering Computational Methods
In this assignment we will study a combination of the transport and heat equation
called the advection-diffusion equation
(, ) + 0
(, ) =
2
2
(, ) (1)
For all numerical examples, please use 0 ≤ ≤ 2, a final time of tend=2.0 and a value of
0 = 1.5.
Task 1. (25 marks)
1. (3 x 5 = 15 marks) Derive the initial value problem in spectral space that arises when
solving equation (1) using the pseudo-spectral method. Proceed along the following
steps:
a) How does the equation for the residual R(u(x,t)) look like that comes out of
plugging the truncated Fourier series
(, ) =
1
∑ ̂()
−1
=0
into equation (1)?
b) What are the Nx equations that result from enforcing R(u(xn,t))=0 at Nx equidistant
mesh points
=
2
, = 0, … , − 1? (2)
c) How can those Nx equations be written compactly using the spectral
differentiation matrix ? You do not need to comment on the “trick” we use to
rewrite the second part of and may simply ignore the issue. However, in your
Matlab code, be sure to use the matrix that is defined in the previous
examples.
2. (5 marks for Matlab script plus 5 marks for graphs). Write a Matlab script that solves
the initial value problem coming out of Task 1.1 for = 0.1 using ode45 with
0() = (, 0) = cos (3) and then plots the solution at the end of the simulation in
both physical and spectral space using Nx=64. Modify your code to generate the
corresponding results for 0() = (, 0) = cos(7).
2
Task 2. (30 marks)
1. (5 marks) Apply the continuous Fourier transform in x to equation (1). Write down the
resulting equation in spectral space. Make sure to clearly explain what identities from
Fourier analysis you have used to obtain your result.
2. (5 marks) Write down the general solution of the differential equation arising from
Task 2.1.
3. (5 marks) Find a text book that tells you what the Fourier transform of cos(3x) is.
Write down the result and cite your source.
4. (5 marks) Obtain the solution of the differential equation from Task 2.2 for initial
values (, 0) = cos (3) and (, 0) = cos (7)?
5. (10 marks) Based on your results from 2.4, explain your observations in Task 1.2.
Task 3. (30 marks)
1. (5 marks) Write a Matlab function that solves equation (1) using the pseudo-spectral
method and explicit Euler and returns the approximate solution at the end of the
simulation in physical space. The function should have input variables Nx (number of
Fourier modes), tend (final time), v0 (transport velocity), (viscosity) and u0 (initial
value in physical space). You can use the explicit euler function provided on Minerva,
exp_euler.m:
function u = exp_euler(u0, tend, nsteps, f)
dt = tend/double(nsteps);
u = zeros(length(u0),nsteps+1);
u(:,1) = u0;
for i=1:nsteps
u(:,i+1) = u(:,i) + dt*f(u(:,i));
end
end
When calling the explicit euler function in your code, use 4 x Nx time steps.
2. (5 marks) Write a Matlab function that solves equation (1) using centred finite
differences for both
and
2