Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
ENGR30002 Fluid Mechanics
Workshop 09 – Pipe flow (Branches)
Part A: Entering a numerical input and storing the input
Input Use the line num = input(’Enter a numerical input: ’) to prompt the user for a numer-
ical input and store the input in a variable num.
randi(imax) Randi is a MATLAB built function that uniformly distribute pseudorandom integers.
It returns a scalar integer between 1 and imax.
Question 01
Write a function guess my number that randomly picks a ”lucky number”, an integer between 1 and
20, and then keeps prompting the user to input a number until they guess the correct lucky number
and then exits. If a 0 is entered the program should exit immediately.
Question 02
Modify the function in Question 1 to display a message if the number guessed is correct or not.
Part B
Question 01
The three water-filled tanks are located as shown in Figure 1 and are connected by pipes. If the fluid
flows from A to J and distribute to B and C, what are flow rates in each pipe? Neglect minor losses.
Figure 1: Piping system
1
Workshop 09 – Pipe flow (Branches)
Table 1: Physical data for Question 01
Tank A B C
D (m) 0.10 0.08 0.08
L (m) 200 200 400
Z (m) 60 20 0
f 0.015 0.020 0.020
Question 02
The three water-filled tanks are located as shown in Figure 2 and are connected by pipes. If the fluid
flows from both A and B to J, and J to C, what are flow rates in each pipe? Neglect minor losses.
Figure 2: Piping system
Table 2: Physical data for Question 02
Tank A B C
D (m) 0.66 0.66 1
L (m) 2000 1000 2000
Z (m) 100 80 50
(m) 0.004 0.004 0.04
(1) Write MEBs for A to J, B to J, and C to J in terms of a hydraulic grade line of the junction and
head loss.
(2) To determine flow rates, you will guess friction factors and HGL based on given information. Find
expressions of velocities in each pipe.
(3) With what you find in the previous steps, you will write code to take one input of guessed HGL.
You need to save guessed friction factors as guessed f.mat and call these values for your iteration
until your guessed HGL converges. Set a tolerance of 10−2.
Bonus question Once you find a converged HGL, you need to compare friction factors with your
guessed friction factors. If they are different, you will use the new friction factors and repeat the
iteration until friction the factors converge. What are your final friction factors?