Upload
pinh881
View
224
Download
0
Embed Size (px)
Citation preview
8/10/2019 Simple MATLAB program
1/24
SKAA 3413
COMPUTER PROGRAMMING
GROUP PROJECT
RECTANGULAR CHANNEL CONSTRICTION
STUDENT/
MATRIC NO.
MOHD AZLAN BIN AMIR NORDIN
SX130554KAWS04
MOHD HASNAN BIN HASSAN
SX130580KAWS04
MOHD ZAMY SHAM BIN MOHD ZIN
SX130577KAWS04
MUHAMMAD ASYRAF BIN MASRISX130588KAWS04
NOORSHAFIY BIN AZMEY
SX130600KAWS04
SESI - SEM 2014/2015 1
SECTION 03
LECTURER DR. PONSELVI JEEVARAGAGAM
8/10/2019 Simple MATLAB program
2/24
ii
TABLE OF CONTENTS
CHAPTER TITLE PAGE
1
INTRODUCTION 1
1.1 Background of Problem 1
1.2 Objectives of Program 2
1.3 Benefits of Program 2
2
PROGRAM ALGORITHM 3
2.1 Analysis Method 3
2.2 Pseudo Code 4
2.3 Flow Chart 5
3
PROGRAM STRUCTURE 7
3.1 GUI Setting 7
3.2 Script 8
4 TEST PLAN 11
4.1 Input Validation 11
4.2
Test 1 - Wier 12
4.3 Test 2 - Constriction 14
4.4 Test 3 - Weir & Constriction 15
5
REFERENCES 16
APPENDICES
Appendix 1 - Work Program
Appendix 2 - Test Plan Calculation
8/10/2019 Simple MATLAB program
3/24
1.1 Background
The water wil
the flow. The possi
constriction or both.
Weir is a str
invert level while co
modify the hydraulic
CHAPTER 1
1
INTRODUCTION
of Problem
l flow uniformly in an open channel if there
le obstruction for the flow is either bro
cture that is placed at the channel invert th
striction is the reduction of the channel wid
profile and energy line of the flow.
Figure 1.1 Channel constriction.
is no obstruction to
d crested weir or
at will increase the
th. Obstruction will
8/10/2019 Simple MATLAB program
4/24
1.2
Objectives o
The program
trough the obstructio
1. State
2. Heigh
3. Width
The objective
1. To de
obstru
2. To ill
3. To wr
1.3
Benefits of P
The benefits
1. Quick
downs
2.
Quick3. User f
Figure 1.2 Broad crested weir.
Program
will analyse the flow of water in a rectan
. The hydraulic profile of the flow will depe
f flow before the obstruction (subcritical/su
t of weir, h.
of constriction,B2.
s of the program are:
ermine the water depth at the obstruction (
ction (y1) and downstream of the obstruction
strate the hydraulic profile of the flow.
te the output to text file Result.txt.
ogram
f the program are:
ly calculate values of E, y, and yc from u
tream section.
ly plot the elevation of hydraulic profile of thriendly by application of GUI.
2
ular open channel
nds on:
ercritical).
2), upstream of the
(y3).
pstream section to
e flow.
8/10/2019 Simple MATLAB program
5/24
CHAPTER 2
2
PROGRAM ALGORITHM
2.1 Analysis Method
The program is using the concept of specific energy as a method of analysis
as shown in equation below:
2
22
qE y
gy= +
The values of Eare equal from upstream to downstream of control structure
and must satisfy theEminfor each section. IfE0>Emin2+ h, the value ofE1andE2are
equal to the value ofE0and value ofy1andy3are equal with value of y0. The value
ofE2=E0 handy2to be calculated from equation below:
2
2
2 02
22
q
y E hgy+ =
IfE0
8/10/2019 Simple MATLAB program
6/24
4
2.2 Pseudo Code
The algorithm of the program is listed below:
1. User input Q , 0y , B, 2B and h
2. Validate input until Q , 0y , B, 2 0B > , 2B B< and 0h
3. q Q B= , 23cy q g= , min 1.5 cE y=
4. 2 2q Q B= ,23
2 2cy q g= , min2 21.5 cE y=
5.2
0 0
02
qE y
gy
= +
6. If 0 min2E E h> +
a. 1 3 0E E E= =
b. 1 3 0y y y= =
c. 2 0E E h=
d. Determine 2y by solving equation3 2 2
2 2 2 22 2 0gy gE y q + = where
2 2 0cy y y< < if 0 2cy y> or 0 2 2cy y y< < if 0 2cy y<
7. If 0 min2E E h< +
a. 2 min2E E=
b. 2 2cy y=
c. 1 3 min2E E E h= = +
d. Solving equation 3 2 212 2 0gy gE y q + = to determine 1y and 3y
where 1 0y y> and 3 cy y<
8. Plot graph to display E, y , and cy for section 0 to section 3
9. Write output Result.txt as format below
Location E(m) y(m) yc(m)
--------------------------------------------------
(0)Normal E0 y0 yc0
(1)Upstream E1 y1 yc1
(2)Structure E2 y2 yc2
(3)Downstream E3 y3 yc3
8/10/2019 Simple MATLAB program
7/24
5
2.3 Flow Chart
Main Program (PRJ_Main.m)
Input
0 2, , , ,Q y B B h
Start
q Q B= ,23
cy q g= , min1.5
cE y=
2 2q Q B=
, 232 2cy q g= ,
min 2 21.5 cE y=
2
0 002
q
E y gy= +
2
0 2, , , 0
0
B B
Q y B B
h
>
0 min2E E h> +
0 1 2 3
0 1 2 3
0 1 2 3
, , ,
, , ,
, , ,c c c c
E E E E
y y y y
y y y y
Plot hydraulic profile
Write Result.txt
End
UDF_ControlUDF_Uncontrol
Yes
No
Yes No
8/10/2019 Simple MATLAB program
8/24
6
UDF_Uncontrol.m:
UDF_Control.m:
1 3 0
1 3 0
E E Ey y y
= =
= =
2 0
3 2 2
2 2 2 2Solve 2 2 0
E E h
gy gE y q
=
+ =
2 min2
2 2c
E E
y y
=
=
1 3 min 2
3 2 2
1
1 0
3
Solve 2 2 0
c
E E E h
gy gE y q
y y
y y
= = +
+ =
>
2 2 0cy y y< 0
text(4.5,h,sprintf('h=%.2fm',h),'HorizontalAlignment',...'c','VerticalAlignment','bottom')
end,hold off
%Display resultaxes(handles.FigAns),cla reset,axis off,hold onxlim([0 7])text(0.5,0,sprintf('E_{0}=%.3fm\ny_{0}=%.3fm\ny_{c}=%.3fm' ,...
Out(1).E,Out(1).y,Out(1).yc),'HorizontalAlignment','c',...'VerticalAlignment','bottom')
text(2.5,0,sprintf('E_{1}=%.3fm\ny_{1}=%.3fm\ny_{c}=%.3fm' ,...Out(2).E,Out(2).y,Out(2).yc),'HorizontalAlignment','c',...'VerticalAlignment','bottom')
text(4.5,0,sprintf('E_{2}=%.3fm\ny_{2}=%.3fm\ny_{c2}=%.3fm' ,...Out(3).E,Out(3).y,Out(3).yc),'HorizontalAlignment','c',...'VerticalAlignment','bottom')
text(6.5,0,sprintf('E_{3}=%.3fm\ny_{3}=%.3fm\ny_{c}=%.3fm' ,...
Out(4).E,Out(4).y,Out(4).yc),'HorizontalAlignment','c',...'VerticalAlignment','bottom'),hold off
%Write resultfid=fopen('Results.txt','w');fprintf(fid,'%s%.3fm\n%s%.3fm\n%s%.3fm\n%s%.3fm\n%s%.3fm\n' ,...
'Q = ',Inp.Q,'y0 = ',Inp.y0,'B = ',Inp.B,'B2 = ',...Inp.B2,'h = ',Inp.h)
fprintf(fid,'\n Location E(m) y(m) yc(m)\n')fprintf(fid,'---------------------------------------------\n' )fori=1:4
fprintf(fid,' %s%10.3f%10.3f%10.3f\n',Out(i).Loc,...Out(i).E,Out(i).y,Out(i).yc)
endfclose(fid)end
8/10/2019 Simple MATLAB program
12/24
10
btnCLEAR script
% --- Executes on button press in btnCLEAR.functionbtnCLEAR_Callback(hObject, eventdata, handles)% hObject handle to btnCLEAR (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.txtQ,'string','')set(handles.txty0,'string','')set(handles.txtB,'string','')set(handles.txtB2,'string','')set(handles.txth,'string','')set(handles.txtVal,'string','')axes(handles.FigGraph)cla resetset(handles.FigGraph,'Visible','off')axes(handles.FigAns)cla resetset(handles.FigAns,'Visible','off')
btnEND script
% --- Executes on button press in btnEND.functionbtnEND_Callback(hObject, eventdata, handles)% hObject handle to btnEND (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)delete(handles.PRJ_Main)
8/10/2019 Simple MATLAB program
13/24
CHAPTER 4
4
TEST PLAN
Testing for this program was made using exercise from Hydraulics Lecture
Notes by Mr. Amat Sairin Demun.
4.1 Input Validation
The program requires all inputs are positive number. A notification will
appear if any of the input is not a positive number as shown below.
8/10/2019 Simple MATLAB program
14/24
The program
B. If the value ofB2i
4.2 Test 1 - Wier
2 3AR S
Qn
=
5 3
2 3
A Qn
P S= =
( )( )
5 3
02 3
02By
B y+
also requires the value ofB2is less than or e
s greater thanBa notification will appear as
5 3
2 3
A S
P n=
9.8 0.0155.197
0.0008
=
( )( )
5 3
002 3
0
2.6 5.197 2.2702.6 2
y y my
= =
+
12
qual to the value of
hown below.
8/10/2019 Simple MATLAB program
15/24
13
Location E(m) y(m) yc(m)--------------------------------------------- (0)Normal 2.411 2.270 1.131(1)Upstream 2.411 2.270 1.131(2)Structure 1.911 1.642 1.131(3)Downstream 2.411 2.270 1.131
Location E(m) y(m) yc(m)--------------------------------------------- (0)Normal 2.411 2.270 1.131(1)Upstream 2.617 2.501 1.131
(2)Structure 1.697 1.131 1.131(3)Downstream 2.617 0.599 1.131
8/10/2019 Simple MATLAB program
16/24
4.3 Test 2 - Cons
( )
( )
5 3
0
2 3
0
2.6
2.6 2
y
y+
triction
0
9.8 0.0161.109 0.715
0.02y m
= = =
14
8/10/2019 Simple MATLAB program
17/24
4.4 Test 3 - Weir
Location
-----------------
(0)Normal
(1)Upstream
(2)Structure
(3)Downstream
& Constriction
E(m) y(m) yc(m)----------------------------
2.715 0.450 0.9728.794 8.788 0.9723.794 2.529 2.5298.794 0.231 0.972
15
8/10/2019 Simple MATLAB program
18/24
5
REFERENCES
Amat Sairin Demun (2010).Hydraulics Lecture Notes. (3rd Edition). Skudai: UTM.
Mohamad Hidayat Jamal (2014). Lecture Module for SKAA 2513 Hydraulics.
Unpublished, UTM.
Ponselvi Jeevaragagam (2014). Lecture Module for SKAA 3413 Computer
Programming. Unpublished, UTM.
8/10/2019 Simple MATLAB program
19/24
APPENDIX 1
Work Program
8/10/2019 Simple MATLAB program
20/24
PROGRAM FOR RECTANGULAR CHANNEL CONSTRICTION
Work Program
No. Works Description Action by
November December January
Week
10
Week
11
Week
12
Week
13
Week
14
Week
15
Week
16
Week
17
Week
18
1Choosing the problem:Weir & constriction
Everyone
2Plan the program, pseudocode, flowchart, algorithm
Shafiy/Hasnan
3 Draft the program, GUI Hasnan/Zamy
4 Develop the program, script Asyraf/Azlan
5 Test the program Everyone
6Prepare the report, compile
the programZamy/Shafiy
7 Submission
8/10/2019 Simple MATLAB program
21/24
APPENDIX 2
Test Plan Calculation
8/10/2019 Simple MATLAB program
22/24
8/10/2019 Simple MATLAB program
23/24
8/10/2019 Simple MATLAB program
24/24