For the fifirst part of this assignment, you will write codes to accurately plot pathlines – which for steady flflows are the same as streamlines – from given starting positions. Make sure you get this question right.
For the later parts of this assignment you will build on the computer program which you have written here to study much more complex flflows.
- (Total marks for question = 27) In order to write a computer code to sketch streamlines, it is best to fifirst start by writing a computer program to solve a simple problem.
(a) Write down the analytical solution to the following ordinary difffferential equation (ODE) dxdt= 5x
(1)with the initial condition x = 1 att = 0 (2)(1 Mark)
(b) Write a computer program to solve Eq. (1) using Euler’s (EU) and the 4th order Runge Kutta (RK-4) method (see the appendix for more information on EU and RK-4). Solve the equation from 0 ≤ t ≤ tf where tf = 0.2, 0.4, 0.6, 0.8 and 1.0. Perform your computations with various step sizes, (h = 0.1, 0.01, 0.001), and tabulate your results in the table shown below (show 4 decimal places).
The output from your computer program must approach the analytical answer as h gets smaller. Plot the analytical solution (x vs t) along with the EU and the RK4 solution for h = 0.01 and 0 < t < 1. Use the axis limits axis([0 1 0 150]) and daspect([1 150 1]).
Which is the more accurate numerical method? EU or RK-4?
(c) Write down the analytical solution (write them as equations of the form x = f(t) and y = f(t)) to the following set of coupled ODE dxdt= x − 2y
(3)dydt= x − y
(4)You are given that at time, t = 0 xy = −03 .
(d) Extend your program from part (1b) so that it can solve the set of equations given by Eq.
(4) for 0 ≤ t ≤ tf . Check your program by completing the table below for both x and y for various tf and time-steps h. To save time in future questions, you should try to write your program such that you can easily change the set of equations f(x, y) and g(x, y) as defifined in the Appendix.
Which is the more accurate numerical method? Use the more accurate numerical method in ALL subsequent parts of this assignment.
(e) Plot y vs x for h = 0.1, h = 0.01 and h = 0.001 for both EU and RK-4 with tf = 2π. Plot the EU and RK4 calculations on separate fifigures. Should the lines join up? Do the lines join up?(4 Marks)
(f) Use your computer program to plot the streamline pattern for the flflow described by Eq. (4)i.e. plot y vs x for a set of initial conditions, where tf = 10 and h = 0.01. You should modify your program such that you can pass it a number of starting positions xs and ys, the time step h and total time of integration tf . In matlab, this could be achieved by writing your program as a function where you pass the variables xs and ys (which could be vectors) and tf and h.
This function would then be used as follows,
[xr yr] = my_streamline_function(xs, ys, tf, h)
where xr and yr are the returned coordinates (matrices) of the streamline and xs and ys are the start locations,
xs = [-1 -2 -3];
ys = [0 0 0];
For non-Matlabers, your program could read an input fifile where the fifirst line contains the number of streamlines, Nl , the time of integration tf and the time step h. The subsequent Nl lines in the input fifile should contain the location of the initial points of the streamlines, (x0i y0i). For example, the input fifile to draw three solution trajectories that start from (0, −1),(0, −2) and (0, −3) with h = 0.01 and 0 < t < 10 will look something like,
3 10 0.01
- (Total marks for question = 23) Consider the scenario shown in the fifigure 1 below. Some people are contaminated, and they are stood in a uniform flflow of strength U∞ from right to left.
Containment is attempted via an extraction fan in the location shown. We will model this scenario as a source of strength Qc representing the contaminant release, a sink of strength Qe = RQc,representing the extraction fan, and a uniform flflow from left to right. The ratio of the strength of the contaminant release Qc to the extraction fan strength Qe is given by R(≡ Qe/Qc).
(a) Show that the stagnation points are given by the following equation,