-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolver9.asv
286 lines (209 loc) · 7.16 KB
/
solver9.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
function [results]=solver(results,state,geo,lattice,ref)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (C) 1999, 2007 Tomas Melin
%
% This file is part of Tornado
%
% Tornado is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public
% License as published by the Free Software Foundation;
% either version 2, or (at your option) any later version.
%
% Tornado is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied
% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
% PURPOSE. See the GNU General Public License for more
% details.
%
% You should have received a copy of the GNU General Public
% License along with Tornado; see the file GNU GENERAL
% PUBLIC LICENSE.TXT. If not, write to the Free Software
% Foundation, 59 Temple Place -Suite 330, Boston, MA
% 02111-1307, USA.
%
% usage: [RESULTS] = solver8(results,state,geo,lattice,ref)
%
% This function computes forces and moments on each panel.
% Inputs are coordinades for old resluts, collocationpoints,
% vorticies and Normals, reference area and chord
%
% Example:
%
% [results]=solver8(results,state,geo,lattice,ref);
%
% Calls:
% Setboundary
%
% Author: Tomas Melin <[email protected]>
% Keywords: Tornado core function
%
% Revision History:
% Bristol, 2007 06 27: Addition of new header. TM.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%disp('Running solver 8')
[a vor_length void]=size(lattice.VORTEX);%extracting number of sections in
%"horseshoes"
%if vor_length < 8
% terror(1)
% return
%end
%flops(0)
[w2 void]=fastdw(lattice);
results.dwcond=cond(w2);
%disp('dnwash... ok')
%count=flops
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Setting up right hand side %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rhs=(setboundary5(lattice,state,geo))';
%disp('rhs... ok')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Solving for rhs %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
gamma=w2\rhs';
%disp('gauss... ok')
try
if state.pgcorr==1
%tdisp('Trying PG correction')
%Prandtl-Glauert compressibility correction
[state.rho sos p_1]=ISAtmosphere(state.ALT);
M=state.AS/sos;
corr=1/(sqrt(1-M^2));
gamma=gamma*corr;
%Yeah, this part is not validated yet... or even published, but it
%seems to work. Do use it with caution though as the math rigour
%isnt there yet.
elseif state.pgcorr==2
%Küchemann-Weber compressibility correction (ESDU 72025, section4)
tdisp('No, dont do it, for the love of God! This part of the code is experimental!')
[state.rho sos p_1]=ISAtmosphere(state.ALT);
M=state.AS/sos;
corr=(sqrt(1-M^2));
gamma=gamma./sqrt(1-M^2*(1-gamma)) ;
elseif state.pgcorr==3
%Wilby compressibility correction, (ESDU 72025, section4)
%tdisp('No, dont do it, for the love of God! This part of the code is experimental!')
%[state.rho sos p_1]=ISAtmosphere(state.ALT);
%M=state.AS/sos;
%corr=(sqrt(1-M^2));
%gamma=gamma./sqrt(1-M^2(1-M.*gamma)) ;
end
end
b1=vor_length/2;
p1(:,:)=lattice.VORTEX(:,b1,:); %Calculating panel vortex midpoint
p2(:,:)=lattice.VORTEX(:,b1+1,:); %to use as a force locus
lattice.COLLOC(:,:)=(p1+p2)./2; % LOCAL control point, vortex midpoint.
c3=lattice.COLLOC-ones(size(lattice.COLLOC,1),1)*geo.ref_point;
[w3 DW]=fastdw(lattice); %Calculating downwash on vorticies
w4=sum(DW,2); %superpositioning aerodynamic influence
DWX=DW(:,:,1);
DWY=DW(:,:,2);
DWZ=DW(:,:,3);
[void nofderiv]=size(gamma);
le=(p2-p1); %Vortex span vector
%for s=1:a
% Lle(s)=norm(le(s,:)); %length of vortex span vector or panel span
% lehat(s,:)=le(s,:)./Lle(s); %
%end
Lle=sqrt(sum(le.^2,2));
lehat(:,1)=le(:,1)./Lle;
lehat(:,2)=le(:,2)./Lle;
lehat(:,3)=le(:,3)./Lle;
for j=1:nofderiv
IW(:,j,1)=DWX*gamma(:,j);
IW(:,j,2)=DWY*gamma(:,j);
IW(:,j,3)=DWZ*gamma(:,j);
G(:,1)=gamma(:,j).*lehat(:,1); %Aligning vorticity along panel vortex
G(:,2)=gamma(:,j).*lehat(:,2);
G(:,3)=gamma(:,j).*lehat(:,3);
wind1=state.AS*([cos(state.alpha)*cos(state.betha) -cos(state.alpha)*sin(state.betha) sin(state.alpha)]); %Aligning with wind
for i=1:a
Wind(i,:)=wind1-squeeze(IW(i,j,:))';
Rot(i,:)=cross((lattice.COLLOC(i,:)-geo.CG),[state.P state.Q state.R]); %Calculating rotations
end %^^^^^^^---new stuff in T131 %Thanks Luca for pointing out the error here
Wind=Wind+Rot; %Adding rotations
Fprim(:,j,:)=state.rho*cross(Wind,G); %Force per unit length
F(:,j,1)=Fprim(:,j,1).*Lle; %Force per panel
F(:,j,2)=Fprim(:,j,2).*Lle; %Force per panel
F(:,j,3)=Fprim(:,j,3).*Lle; %Force per panel
C3(:,:,1)=c3(:,1)*ones(1,nofderiv);
C3(:,:,2)=c3(:,2)*ones(1,nofderiv);
C3(:,:,3)=c3(:,3)*ones(1,nofderiv);
end
results.F=F;
results.FORCE=sum(F,1); %Total force
M=cross(C3,F,3); %Moments per panel
results.M=M;
results.MOMENTS=sum(M,1); %Summing up moments
results.gamma=gamma;
end%FUNCTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
%
% NEW DOWNWASH FUNCTION
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5five
function[dw,DW]=fastdw(lattice)
one_by_four_pi=1/(4*pi);
[psize vsize void]=size(lattice.VORTEX);
%disp('running right')
%psize=size(lattice.COLLOC,1);
lemma=ones(1,psize);
LDW=zeros(psize,psize,7,3);
mCOLLOC(:,:,1)=lattice.COLLOC(:,1)*lemma;
mCOLLOC(:,:,2)=lattice.COLLOC(:,2)*lemma;
mCOLLOC(:,:,3)=lattice.COLLOC(:,3)*lemma;
mN(:,:,1)=lattice.N(:,1)*lemma;
mN(:,:,2)=lattice.N(:,2)*lemma;
mN(:,:,3)=lattice.N(:,3)*lemma;
for j=1:(vsize-1)
lr1(:,:,1)=(lattice.VORTEX(:,j,1)*lemma)';
lr1(:,:,2)=(lattice.VORTEX(:,j,2)*lemma)';
lr1(:,:,3)=(lattice.VORTEX(:,j,3)*lemma)';
lr2(:,:,1)=(lattice.VORTEX(:,j+1,1)*lemma)';
lr2(:,:,2)=(lattice.VORTEX(:,j+1,2)*lemma)';
lr2(:,:,3)=(lattice.VORTEX(:,j+1,3)*lemma)';
r1=lr1-mCOLLOC;
r2=lr2-mCOLLOC;
warning off
LDW(:,:,j,:)=mega(r1,r2);
warning on
end
LDW(find((isnan(LDW(:,:,:,:)))))=0;
DW=-squeeze(sum(LDW,3))*one_by_four_pi;
dw=sum(DW.*mN,3);
end
function[DW2]=mega(r1,r2)
%% First part
F1=cross(r1,r2,3);
LF1=(sum(F1.^2,3));
F2(:,:,1)=F1(:,:,1)./(LF1);
F2(:,:,2)=F1(:,:,2)./(LF1);
F2(:,:,3)=F1(:,:,3)./(LF1);
%clear('F1')
%% Next part
Lr1=sqrt(sum(r1.^2,3));
Lr2=sqrt(sum(r2.^2,3));
R1(:,:,1)=r1(:,:,1)./Lr1;
R1(:,:,2)=r1(:,:,2)./Lr1;
R1(:,:,3)=r1(:,:,3)./Lr1;
R2(:,:,1)=r2(:,:,1)./Lr2;
R2(:,:,2)=r2(:,:,2)./Lr2;
R2(:,:,3)=r2(:,:,3)./Lr2;
L1=(R2-R1);
%clear('R1','R2')
%% Third part
R0=(r2-r1);
radial_distance=sqrt((LF1./(sum(R0.^2,3))));
%% combinging 2 and 3
L2= R0(:,:,1).*L1(:,:,1)...
+R0(:,:,2).*L1(:,:,2)...
+R0(:,:,3).*L1(:,:,3);
%% Downwash
DW(:,:,1)=F2(:,:,1).*L2;
DW(:,:,2)=F2(:,:,2).*L2;
DW(:,:,3)=F2(:,:,3).*L2;
near=config('near');
DW2(:,:,1)=DW(:,:,1).*(1-(radial_distance<near));
DW2(:,:,2)=DW(:,:,2).*(1-(radial_distance<near));
DW2(:,:,3)=DW(:,:,3).*(1-(radial_distance<near));
end