Repository navigation
Expand file tree
/
Copy pathGUI.m
More file actions
155 lines (127 loc) · 6.17 KB
/
Copy pathGUI.m
File metadata and controls
155 lines (127 loc) · 6.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
classdef FrancisTurbineApp < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = private)
UIFigure matlab.ui.Figure
IntroLabel matlab.ui.control.Label
HeadEditFieldLabel matlab.ui.control.Label
HeadEditField matlab.ui.control.NumericEditField
DischargeEditFieldLabel matlab.ui.control.Label
DischargeEditField matlab.ui.control.NumericEditField
RotationalSpeedEditFieldLabel matlab.ui.control.Label
RotationalSpeedEditField matlab.ui.control.NumericEditField
StreamlinesEditFieldLabel matlab.ui.control.Label
StreamlinesEditField matlab.ui.control.NumericEditField
CalculateButton matlab.ui.control.Button
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: CalculateButton
function CalculateButtonPushed(app, event)
% Get input values
head = app.HeadEditField.Value;
discharge = app.DischargeEditField.Value;
rotationalSpeed = app.RotationalSpeedEditField.Value;
streamlines = app.StreamlinesEditField.Value;
% Call the main calculation script with input values
mainScript(head, discharge, rotationalSpeed, streamlines);
end
end
% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'Francis Turbine Modeling';
% Create IntroLabel
app.IntroLabel = uilabel(app.UIFigure);
app.IntroLabel.FontSize = 20;
app.IntroLabel.Position = [170 380 300 40];
app.IntroLabel.Text = 'Francis Turbine Modeling';
% Create HeadEditFieldLabel
app.HeadEditFieldLabel = uilabel(app.UIFigure);
app.HeadEditFieldLabel.HorizontalAlignment = 'right';
app.HeadEditFieldLabel.Position = [220 290 35 22];
app.HeadEditFieldLabel.Text = 'Head';
% Create HeadEditField
app.HeadEditField = uieditfield(app.UIFigure, 'numeric');
app.HeadEditField.Position = [270 290 100 22];
% Create DischargeEditFieldLabel
app.DischargeEditFieldLabel = uilabel(app.UIFigure);
app.DischargeEditFieldLabel.HorizontalAlignment = 'right';
app.DischargeEditFieldLabel.Position = [190 260 65 22];
app.DischargeEditFieldLabel.Text = 'Discharge';
% Create DischargeEditField
app.DischargeEditField = uieditfield(app.UIFigure, 'numeric');
app.DischargeEditField.Position = [270 260 100 22];
% Create RotationalSpeedEditFieldLabel
app.RotationalSpeedEditFieldLabel = uilabel(app.UIFigure);
app.RotationalSpeedEditFieldLabel.HorizontalAlignment = 'right';
app.RotationalSpeedEditFieldLabel.Position = [155 230 100 22];
app.RotationalSpeedEditFieldLabel.Text = 'Rotational Speed';
% Create RotationalSpeedEditField
app.RotationalSpeedEditField = uieditfield(app.UIFigure, 'numeric');
app.RotationalSpeedEditField.Position = [270 230 100 22];
% Create StreamlinesEditFieldLabel
app.StreamlinesEditFieldLabel = uilabel(app.UIFigure);
app.StreamlinesEditFieldLabel.HorizontalAlignment = 'right';
app.StreamlinesEditFieldLabel.Position = [180 200 70 22];
app.StreamlinesEditFieldLabel.Text = 'Streamlines';
% Create StreamlinesEditField
app.StreamlinesEditField = uieditfield(app.UIFigure, 'numeric');
app.StreamlinesEditField.Position = [270 200 100 22];
% Create CalculateButton
app.CalculateButton = uibutton(app.UIFigure, 'push');
app.CalculateButton.ButtonPushedFcn = createCallbackFcn(app, @CalculateButtonPushed, true);
app.CalculateButton.Position = [265 130 70 22];
app.CalculateButton.Text = 'Calculate';
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = FrancisTurbineApp
% Create UIFigure and components
createComponents(app);
% Register the app with App Designer
registerApp(app, app.UIFigure);
% Run the startup function
runStartupFcn(app, @startupFcn);
if nargout == 0
clear app;
end
end
% Code that executes after component creation
function startupFcn(app)
% Initialize your parameters here
app.HeadEditField.Value = 30;
app.DischargeEditField.Value = 39.9;
app.RotationalSpeedEditField.Value = 400;
app.StreamlinesEditField.Value = 69;
end
end
end
function CalculateButtonPushed(app, event)
try
% Define the parameters
H = 30;
Q = 39.9;
nrpm = 400;
N = 69;
nr = 2 * pi * nrpm / 60;
% Call the functions with the appropriate input arguments
[P, ns, w, r2, d2, r1_new, d1_new, b1, b2, u1, vw1, vf1, beta1, u2, vf2, beta2, alpha1, vr1, v1, vr2, xx, yy, zz, height] = t(H, Q, nr, N);
[P, ns, w, r2, d2, r1_new, ~, b1, b2, u1, vw1, vf1, beta1, u2, vf2, beta2, alpha1, vr1, v1, vr2, xx, yy, zz, height] = axialtry(H, Q, nr, N);
[x1, y1, x2, y2, xl, yl, xt, yt] = meri_lines(Q, H, nr, N);
% [lead_zr, trail_zr, hub_1_zr, hub_2_zr, hub_3_zr, shroud_1_zr, shroud_2_zr, shroud_3_zr] = bladegen(x1, y1, x2, y2, xl, yl, xt, yt);
% Display successful message
app.ErrorMessageLabel.Text = 'Calculation and plotting completed successfully.';
catch exception
% Display any error messages for troubleshooting
errorMessage = ['Error: ', exception.message];
app.ErrorMessageLabel.Text = errorMessage;
end
end