-
Notifications
You must be signed in to change notification settings - Fork 6
/
torques.asv
executable file
·379 lines (265 loc) · 11.7 KB
/
torques.asv
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
function [boat_torque] = torques(v_water,v_wind,sail_angle,rudder_angle,water_angle,apparant_wind_angle)
%Calculates torque on boat generated by sail, centreboard and rudder
% sail/rudder angle relative to boat
% water angle relative to hull
% aparent wind angle relative to hull
% +ve torque anti clockwise
% wind + air speeds = component perpendicular to surface
% Call command:
%torques(5,20,25,0,0,0)
%%%%%%%%%%%%%%%%%%%%%%%% Define sail geometry %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Le=5.570; %sail leach (m)
ch1=0.965; %sail chord length at point 1 (m)
ch2=1.720; %sail chord length at point 2 (m)
ch3=2.330; %sail chord length at point 3 (m)
ch4=2.740; %sail chord length at point 4 (m)
ex1=ch2-ch1;
ex2=ch3-ch2;
ex3=ch4-ch3;
h1=(((0.25*Le)^2)-((ch1)^2))^0.5; %sail section 1 height (m)
h2=(((0.25*Le)^2)-((ex1)^2))^0.5; %sail section 2 height (m)
h3=(((0.25*Le)^2)-((ex2)^2))^0.5; %sail section 3 height (m)
h4=(((0.25*Le)^2)-((ex3)^2))^0.5; %sail section 4 height (m)
hT=h1+h2+h3+h4; %total sail height (m)
sail_height=0; %height of base of sail above axis of rotation
r_z_offset=0; %offset of centreboard front wetted point from axis of rotation (m)
r_y_offset=0; %offset of centreboard top wetted line from axis of rotation (m)
c_z_offset=0; %offset of centreboard front wetted point from axis of rotation (m)
c_y_offset=0; %offset of centreboard top wetted line from axis of rotation (m)
ro_water=1000; %define density of water (kgm^-3)
ro_air=1; %define density of air (kgm^-3)
%%%%%%%%%%%%%%%%%%%%%% Calculating coefficients %%%%%%%%%%%%%%%%%%%%%%%%%%
t_r_a=water_angle+(rudder_angle); %angle of rudder with respect to water (degrees)
angle_of_attack=apparant_wind_angle+sail_angle; %angle of attack (degrees)
%changing sign to give better fit
if t_r_a<0
t_r_a_new=-t_r_a;
else t_r_a_new=t_r_a;
end
if angle_of_attack<0
a_o_a=-angle_of_attack;
else a_o_a=angle_of_attack;
end
if water_angle<0
water_angle_c=-water_angle;
else water_angle_c=water_angle;
end
z_s=(a_o_a-90)/56.3; %defining correction factors to give better conditioning
z=(water_angle_c-90)/56.3;
z_2=(water_angle_c-90)/56;
z_r=(t_r_a_new-90)/56.273;
Cl=-0.0746*(z_s^10)+0.0975*(z_s^9)+0.713*(z_s^8)-0.625*(z_s^7)-1.96*(z_s^6)+1.58*(z_s^5)+1.81*(z_s^4)-1.23*(z_s^3)-0.714*(z_s^2)-0.903*z_s+0.439;
Cd=-0.00156*(z_s^10)-0.00571*(z_s^9)+0.000313*(z_s^8)+0.0426*(z_s^7)-0.0129*(z_s^6)-0.199*(z_s^5)+0.0911*(z_s^4)+0.188*(z_s^3)-0.55*(z_s^2)+0.354*z_s+1.183;
if angle_of_attack<0 %changing sign back
Cl=-Cl;
Cd=-Cd;
end
Cl_r=0.0811*(z_r^10)-0.139*(z_r^9)-0.457*(z_r^8)+1.08*(z_r^7)+0.822*(z_r^6)-2.72*(z_r^5)-0.491*(z_r^4)+2.83*(z_r^3)+0.0326*(z_r^2)-1.55*z_r+0.0275;
Cd_r=0.0509*(z_r^10)-0.0199*(z_r^9)-0.286*(z_r^8)+0.0728*(z_r^7)+0.544*(z_r^6)-0.0885*(z_r^5)-0.519*(z_r^4)+0.0825*(z_r^3)-0.089*(z_r^2)-0.000146*z_r+1.185;
if t_r_a<0 %changing sign back
Cl_r=-Cl_r;
Cd_r=-Cd_r;
end
Cl_c=0.0902*(z^10)-0.137*(z^9)-0.524*(z^8)+1.06*(z^7)+0.996*(z^6)-2.66*(z^5)-0.673*(z^4)+2.79*(z^3)+0.0997*(z^2)-1.55*z+0.12691;
Cd_c=0.0209*(z_2^10)-0.0354*(z_2^9)-0.131*(z_2^8)+0.164*(z_2^7)+0.301*(z_2^6)-0.272*(z_2^5)-0.427*(z_2^4)+0.223*(z_2^3)-0.0552*(z_2^2)-0.0216*z_2+1.21;
if water_angle<0
Cl_c=-Cl_c;
Cd_c=-Cd_c;
end
%%%%%%%%%%%%%%%%%%%%%%% Calculating T round mast + z %%%%%%%%%%%%%%%%%%%%%%
% For sail section 1
area_old=0; %set starting conditions
lift_old=0;
drag_old=0;
torque_x_old=0;
torque_y_old=0;
torque_z_old=0;
for i=1:h1;
area=i*1*(ch1/h1); %calculate strip area
lift=Cl*(0.5*ro_air*(v_wind^2))*area; %calculate lift force on strip
torque_y=lift*(0.25*(i*(ch1/h1))); %calculate associated torque
torque_z=lift*((hT-i)+sail_height); %calculate associated torque
drag=Cd*ro_air*((v_wind^2)/2)*area; %calculate drag force on strip
torque_x=drag*((hT-i)+sail_height);
section1_lift=lift_old+lift; %add up total lift
section1_torque_y=torque_y_old+torque_y; %add up total torque
section1_drag=drag_old+drag; %add up total drag
section1_torque_z=torque_z_old+torque_z; %add up total torque
section1_torque_x=torque_x_old+torque_x;
torque_y_old=section1_torque_y;
lift_old=section1_lift;
torque_z_old=section1_torque_z;
drag_old=section1_drag;
torque_x_old=section1_torque_x;
area_1=area;
end
% For section 2
area_old=0; %set starting conditions
lift_old=0;
drag_old=0;
torque_x_old=0;
torque_y_old=0;
torque_z_old=0;
for i=1:h2;
area=ch1+(i*1*(ex1/h2)); %calculate strip area
lift=Cl*(0.5*ro_air*(v_wind^2))*area; %calculate lift force on strip
torque_y=lift*(0.25*(ch1+(i*(ex1/h2)))); %calculate associated torque
torque_z=lift*((hT-h1-i)+sail_height); %calculate associated torque
drag=Cd*ro_air*((v_wind^2)/2)*area; %calculate drag force on strip
torque_x=drag*((hT-h1-i)+sail_height);
section2_lift=lift_old+lift; %add up total lift
section2_torque_y=torque_y_old+torque_y; %add up total torque
section2_drag=drag_old+drag; %add up total drag
section2_torque_z=torque_z_old+torque_z; %add up total torque
section2_torque_x=torque_x_old+torque_x;
torque_y_old=section2_torque_y;
lift_old=section2_lift;
torque_z_old=section2_torque_z;
drag_old=section2_drag;
torque_x_old=section2_torque_x;
area_2=area;
end
% For section 3
area_old=0; %set starting conditions
lift_old=0;
drag_old=0;
torque_x_old=0;
torque_y_old=0;
torque_z_old=0;
for i=1:h3;
area=ch2+(i*1*(ex2/h3)); %calculate strip area
lift=Cl*(0.5*ro_air*(v_wind^2))*area; %calculate lift force on strip
torque_y=lift*(0.25*(ch2+(i*(ex2/h3)))); %calculate associated torque
torque_z=lift*((hT-h2-h1-i)+sail_height); %calculate associated torque
drag=Cd*ro_air*((v_wind^2)/2)*area; %calculate drag force on strip
torque_x=drag*((hT-h2-h1-i)+sail_height);
section3_lift=lift_old+lift; %add up total lift
section3_torque_y=torque_y_old+torque_y; %add up total torque
section3_drag=drag_old+drag; %add up total drag
section3_torque_z=torque_z_old+torque_z; %add up total torque
section3_torque_x=torque_x_old+torque_x;
torque_y_old=section3_torque_y;
lift_old=section3_lift;
torque_z_old=section3_torque_z;
drag_old=section3_drag;
torque_x_old=section3_torque_x;
area_3=area;
end
% For section 4
area_old=0; %set starting conditions
lift_old=0;
drag_old=0;
torque_x_old=0;
torque_y_old=0;
torque_z_old=0;
for i=1:h4;
area=ch3+(i*1*(ex3/h4)); %calculate strip area
lift=Cl*(0.5*ro_air*(v_wind^2))*area; %calculate lift force on strip
torque_y=lift*(0.25*(ch3+(i*(ex3/h4)))); %calculate associated torque
torque_z=lift*((h4-i)+sail_height); %calculate associated torque
drag=Cd*ro_air*((v_wind^2)/2)*area; %calculate drag force on strip
torque_x=drag*((h4-i)+sail_height);
section4_lift=lift_old+lift; %add up total lift
section4_torque_y=torque_y_old+torque_y; %add up total torque
section4_drag=drag_old+drag; %add up total drag
section4_torque_z=torque_z_old+torque_z; %add up total torque
section4_torque_x=torque_x_old+torque_x;
torque_y_old=section4_torque_y;
lift_old=section4_lift;
torque_z_old=section4_torque_z;
drag_old=section4_drag;
torque_x_old=section4_torque_x;
area_4=area;
end
%%%%%%%%%%%%%%%%%%% Rotating into global co-odinates %%%%%%%%%%%%%%%%%%%%%%
if sail_angle<0
sail_angle=-sail_angle;
end
rotation_s=[cosd(sail_angle) 0 -sind(sail_angle); 0 1 0; sind(sail_angle) 0 cosd(sail_angle)];
sail_area=area_1+area_2+area_3+area_4;
total_lift_s = section4_lift+section3_lift+section2_lift+section1_lift;
total_drag_s = section4_drag+section3_drag+section2_drag+section1_drag;
total_torque_x = section4_torque_x+section3_torque_x+section2_torque_x+section1_torque_x;
total_torque_y = section4_torque_y+section3_torque_y+section2_torque_y+section1_torque_y;
total_torque_z = section4_torque_z+section3_torque_z+section2_torque_z+section1_torque_z;
local_torque_s_vector=[total_torque_x;total_torque_y;total_torque_z];
global_torque_s_vector=rotation_s*local_torque_s_vector;
%%%%%%%%%%%%%%%%%%%%%%%%%% Calculating rudder T %%%%%%%%%%%%%%%%%%%%%%%%%%%
torque_r_y_old=0;
torque_r_z_old=0;
torque_r_x_old=0;
lift_r_old=0;
drag_r_old=0;
for i=1:515
lift_r=Cl_r*(0.5*ro_water*(v_water^2))*(1.77*(10^-4)) ; %calculating lift
torque_r_y=lift_r*(0.04425+r_z_offset+(i*(109.6/515)*(10^-3))); %calculating torque
torque_r_z=lift_r*(r_y_offset+(i*(10^-3))-0.0005);
drag_r=Cd_r*ro_water*((v_water^2)/2)*(1.77*(10^-4)); %calculating drag
torque_r_x=drag_r*(r_y_offset+(i*(10^-3))-0.0005);
total_torque_r_x=torque_r_x_old+torque_r_x;
total_torque_r_y=torque_r_y_old+torque_r_y; %calculating total torque
total_torque_r_z=torque_r_z_old+torque_r_z;
total_lift_r=lift_r_old+lift_r;
total_drag_r=drag_r_old+drag_r;
torque_r_x_old=total_torque_r_x;
torque_r_y_old=total_torque_r_y; %storing torque value for use in loop
torque_r_z_old=total_torque_r_z;
drag_r_old=total_drag_r;
lift_r_old=total_lift_r;
end
%%%%%%%%%%%%%%%%%%% Rotating into global co-odinates %%%%%%%%%%%%%%%%%%%%%%
if rudder_angle<0
rudder_angle=-rudder_angle;
end
rotation_r=[cosd(rudder_angle) 0 -sind(rudder_angle); 0 1 0; sind(rudder_angle) 0 cosd(rudder_angle)];
local_torque_r_vector=[total_torque_r_x;total_torque_r_y;total_torque_r_z];
global_torque_r_vector=rotation_r*local_torque_r_vector;
%%%%%%%%%%%%%%%%%%%%%%% Calculating centreboard T %%%%%%%%%%%%%%%%%%%%%%%%%
torque_c_y_old=0;
torque_c_z_old=0;
torque_c_x_old=0;
lift_c_old=0;
drag_c_old=0;
for i=1:632
lift_c=Cl_c*(0.5*ro_water*(v_water^2))*(3.67*(10^-4)) ; %calculating lift
torque_c_y=lift_c*(0.09175+c_z_offset+(i*(251/632)*(10^-3))); %calculating torque
torque_c_z=lift_c*(c_y_offset+(i*(10^-3))-0.0005);
drag_c=Cd_c*ro_water*((v_water^2)/2)*(3.67*(10^-4)); %calculating drag
torque_c_x=drag_c*(c_y_offset+(i*(10^-3))-0.0005);
total_torque_c_x=torque_c_x_old+torque_c_x;
total_torque_c_y=torque_c_y_old+torque_c_y; %calculating total torque
total_torque_c_z=torque_c_z_old+torque_c_z;
total_lift_c=lift_c_old+lift_c;
total_drag_c=drag_c_old+drag_c;
torque_c_x_old=total_torque_c_x;
torque_c_y_old=total_torque_c_y; %storing torque value for use in loop
torque_c_z_old=total_torque_c_z;
drag_c_old=total_drag_c;
lift_c_old=total_lift_c;
end
global_torque_c_vector=[total_torque_c_x;total_torque_c_y;total_torque_c_z];
%%%%%%%%%%%%%%%%%%%%%%%%% Calculating total T %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
boat_torque=global_torque_c_vector+global_torque_r_vector+global_torque_s_vector;
%%%%%%%%%%%%%%%%%%%%%%%%% Displaying Values %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Cl
Cd
Cl_r
Cd_r
Cl_c
Cd_c
total_drag_s;
total_drag_r;
total_drag_c;
total_lift_s;
total_lift_r;
total_lift_c;
Fx = -abs(total_drag_s*cos(sail_angle) - abs(total_drag_r*cos(rudder_angle)) - abs(total_drag_c)...
+ abs(total_lift_s*sin(sail_angle)) + abs(total_lift_r*sin(rudder_angle));
Fy = abs(total_drag_s*sin(sail_angle)) + abs(total_drag_r*sin(rudder_angle)) ...
+ abs(total_lift_s*
global_torque_s_vector;
global_torque_c_vector;
global_torque_r_vector;
rotation_r;
rotation_s;
end