Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NAME: a new script file and save it as HW2P2 ubitname.m. Add the required comments at the top. You are free to use an old
NAME: a new script file and save it as HW2P2 ubitname.m. Add the required comments at the top. You are free to use an old HW m file or the template from UBlearns. HW2P2 Script file (18 points) The frictional head loss h, in pipes can be determined from the following equation where is the mean flow velocity in m/s, L is the pipe length in m, D is the pipe diameter in m and g is the acceleration of gravity = 9.81 m/s2 LV2 hu=fD2g f is the friction coefficient and can be determined from the following empirical formula (Zigrang and Sylvester (1982)) where log is base 10, is the pipe roughness in m, and vis the kinematic viscosity in m2/s. f={-2log 4D 5,02108 ( 5:02 10g ( +3) Re Re is the dimensionless Reynolds number calculated as follows where V, D, and v are defined as above. VD Re =- In your script file, calculate the frictional head loss using the above equations given the parameters defined in the table below. Units are provided only to verify the use of consistent units across all values. The answers for the first set of parameters have been provided to check your solution. Store your results in variables named Re_x, fx, and hL x where x is 1, 2, and 3 corresponding to the case number. Case V[m/s] [m] 1 L D [m] 26.667 15.5 30.0 2.065 1.567 3.075 2 3 E h [m] [m/s] [m] 0.00036 1.02 x 10-6 0.967352381049705 0.00045 1.05 x 10-6 0.00025 0.95 x 10-6 0.15 0.10 0.20 Create a new function file and save it as Frictional Head Loss.m. Add in the recommended H1 line and help text lines using comments. Function File (12 points) in your function file, convert the calculation from above into a function. Your function should have the following inputs: V.L.D. & , and vand outputs Re,f, and hl. Note, your function definition line should appear as follows: [Re, f, hL] = FrictionalHeadLoss( V, L, D, e, nu ) At the bottom of your HW2P2_ubitname.m file, call your function 3 times to compare your results calculated within your script file versus your function file. Use the same parameters defined in the table. NOTE: Your function should return the same results as your calculations from within your script file given the same parameters. Your final script file must contain 10 variables; 3 per row in the table, i.e. for the first set of parameters: Re_1, f_1, and hL 1. Your final script must also contain 3 function calls. You may use, and are encouraged to use any other variables you create. Script file grading rubric: For each required variable: o 1 point for correct variable names o 1 point for the correct answer Function file grading rubric: 2 points for correct function name 2 points for correct inputs 2 points for correct outputs 6 points for correct calculations NOTE: 0 points are given if your code does not run Save and submit both ALL files (HW2P1_ubitname.m, FrustumSAV.m, HW2P2_ubitname.m, and FrictionalHead Loss.m) to a single submission on Unlearns under Assignments > HW1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started