Engr30003 - write your c program such that it uses the


Learning Outcomes

In this assignment you will demonstrate your understanding of solving engineering problems using numerical computations and assessing particular algorithms. The objectives of this assignment are to program algorithms for root-finding, solving systems of linear algebraic equations, performing least-squares approximations and interpolations, regressing solutions and solving a transport equation using finite-difference discretization schemes.

Rootfinding

Imagine a wedge-shaped object flying through air at supersonic speeds (see Fig. 1). In compressible flow theory (covered in MCEN90008 Fluid Dynamics), it is known that an oblique shock wave forms at the front tip of this object under certain conditions

2.1 Analytical solution for θ = 0°

For θ = 0, i.e. the object would be a flat plate, show that two possible solutions for β are

βL = arcsin (1/M), βU = 90°.

βU and βL are usually called the strong shock and weak shock solutions, respectively. Even though we can mathematically obtain two possible solutions, in reality, or physically, only the weak shock solution occurs.

Graphical solution

Plot f(β) vs β for

a. M =1.5 and θ = 5°, 10° and 15°

b. M = 5.0 and θ =20°, 30° and 45°

Indicate how βU and βL change with θ and M. Can you identify from your plots the approximate value of θmax?

C program to solve shock-wave equation

Your task is to write a C code that solves Eq. (2) using the Newton-Raphson method to find the root of f (β), regarding θ and M as parameters and solving for β.

(a) Write your C program such that it uses the Newton-Raphson method to solve f (β) = 0. What values of βL and βU do you think might be appropriate to use as an initial guess? For M = 5.0 and θ =20°, you should find that βL =  29.80092...° , and βU =  84.55625...°

(b) Extend your C program to find βU and βL values for M = 5.0 and 0 ≤ θ ≤ θmax. Remember that for θ = 0, βL = arcsin(1) and βU= 90°. Plot values of θ on the horizontal axis and M corresponding values of β on the vertical axis. Your solution to this part of the assignment should look like Fig. 2. Note that you can plot your results obtained from your C code with your program of choice, e.g. Matlab, Excel, etc.

(c) Use your computer program to solve f (β) = 0 for M = 1.5, 3.0, 4.0, 5.0, 7.0, 8.0. Plot β vs θ for all the M's. This plot is called the θ-β- M diagram and you will find it very useful if you decide to do MCEN90008 Fluid Dynamics in the future.

Linear Algebraic Systems

Write a C code using the Thomas algorithm to solve the tri-diagonal system shown in Eq. 4. Since the tri-diagonal system is a banded matrix, you need not store all the zeros!

Regression

Write C code that uses both second-order Lagrange interpolating polynomials and cubic splines in order to estimate f (x). Estimate the value of f (x= 5) using both methods. You will implement both methods in interp0, reading in from the file in_interp.csv the values of x and f (x) and outputting the values of the interpolated value to out_interp.csv in the following format (up to 6 decimal places).

Differentiation, differential equations

Tasks

Run your code until a time of t =2.0 for different resolutions Δx, i.e. different number of grid points Nx. Your time steps need to satisfy the so-called Diffusion number, specifying that µΔt/(Δx)2 ≤ 1. You should investigate the effect of

- spatial resolution, i.e. Δx, determined by the number of points Nx used
- temporal resolution Δt (or, for a given Δx, variations of the Diffusion number µΔt/(Δx)2

- effect of time integration type (explicit vs implicit) on the maximum time step permitted on the accuracy of the solution. In particular, assess the error made in amplitude of the numerical solution compared with the solution obtained with Nx = 1,000 and Diffusion number 0.1, called grid-independent reference solution.

Project Report

Your project report need not be a full technical report but should state all approximations made and use figures of results to back up any conclusions. Be sure to include enough detail (using appendices as necessary) so that your results could be reproduced by another researcher (or yourself at a future date!) wishing to check or extend your findings. Your report will be primarily assessed on the completeness of the results, and the visual/logical effectiveness of the manner in which they are presented.

Attachment:- codes.zip

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Engr30003 - write your c program such that it uses the
Reference No:- TGS02482999

Expected delivery within 24 Hours