代写 matlab Problem solving in Engineering with MATLAB EG-228

Problem solving in Engineering with MATLAB EG-228
Coursework 2 (25 marks) Deadline: Friday 12th April, 5pm
Problem description
For uniform flow at a given discharge Q in a rectangular open channel of breath B, Manning’s equation may be expressed in the form
1 A5/3 Q= n S1/2
nP2/3 0 n
where An = Byn is the cross sectional area defined by the normal water depth yn and the channel shape, Pn = B + 2yn is the wetted perimeter, S0 is the channel slope and n is a constant.
For a gradually varied flow at a given discharge Q, the water depth y changes from the value y1 to the value y2 over a distance x, where
􏰀 y2
x= f(y)dy
y1
and the function f(y) is defined to be
f(y)= 1−Fr2
S0 − Sf
Here, the friction slope Sf and the Froude number Fr are defined, in terms of y, as
n2Q2P 4/3 2 Q2B Sf = A10/3 Fr = gA3
with A(y) = By, P (y) = B + 2y and g is the acceleration due to gravity. Tasks
Consider a flow in a rectangular open channel for which B = 50m, S0 = 0.002, n = 0.04, g = 9.81ms−2 and the discharge Q, expressed in m3s−1.
(a) Assume that the flow is uniform. Write a Matlab function that given the discharge Q, outputs the normal depth yn with an error of less than 10−3.
• The Matlab header must be:
• The name of the Matlab file must be:
• If you create other functions that will be called by the main function uniform, you can decide the name of these auxiliary functions.
function yn = uniform(Q)
uniform.m
Swansea University – EG228

• Note that the problem is very sensitive to the choice of the initial guess for the root finding. Make sure that your program works for a value of Q between 500m3s−1 and 1000m3s−1.
(b) Assume that the flow is gradually varying, and the water depth at x = 0 is ya = 1.01yn. Write a Matlab function that given the normal depth yn, outputs the value (xb) of x such that the water depth is yb = 2yn. The result must be computed with the trapezoidal rule and must be provided with an error of less than 10−2.
• The Matlab header must be:
• The name of the Matlab file must be:
• If you create other functions that will be called by the main function varying, you can decide the name of the auxiliary functions.
Marking process
Matlab programs will be marked according to the:
• Quality of the Matlab programs (40% marks). Follow the tips for designing good programs given in the lecture notes and check the model answers in Blackboard. Uncommented Matlab programs will not receive marks for quality.
• Accuracy of the results (60% marks). Matlab is just a tool for undertaking engi- neering tasks, therefore the results must be accurate for these programs to be useful. A program is only correct when it returns the correct answer for any set of inputs provided.
Checklist
Before you submit your programs, make sure that you are able to answer YES to ALL the questions below:
􏰁 Have you tested that the programs do not return an error?
􏰁 Have you tested that the programs return the correct result? You can do this by com- paring the Matlab results to the results you will get using the calculator for some cases involving a reasonable number of computations.
􏰁 Have you named the Matlab files as specified? Remember that lower-case and upper- case is different in Matlab.
􏰁 Have you checked that your files do not contain warnings? Remember that warnings are highlighted in orange by Matlab (see lecture notes).
􏰁 Have you checked that only Matlab concepts covered in EG-228 are used? Avoid us- ing Matlab programming concepts not covered in the module as the objective of the coursework is to test that you have achieve the learning outcomes.
function xb = varying(yn)
varying.m
Swansea University – EG228

Submission of the Matlab programs
Follow the steps below to avoid losing marks due to an incorrect submission: • Create a folder named with your group number. For example, if your group is G72,
the name of the folder must be G72.
• Copy all the Matlab files inside this folder. Make sure that the Matlab files are named exactly as specified, otherwise an error will be produced when I try to execute these files and ZERO marks will be awarded.
• Do not create subfolders, just one folder with all the Matlab files inside.
• Compress the folder as a ZIP file and submit the compressed file through Blackboard.
IMPORTANT REMARK
The files submitted should be the result of the work performed by your group only. Any potential case of Academic Misconduct will be thoroughly investigated. If there are doubts about the authenticity of the work, your group can be interviewed by the lecturer of the module in the presence of another academic from the College of Engineering. This interview can be used to decide the final mark to be awarded.
Swansea University – EG228