-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsolverloop5.m
1106 lines (886 loc) · 36.2 KB
/
solverloop5.m
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function []=solverloop5(results,quest,JID,lattice,state,geo,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: []=solverloop(results,quest,JID,lattice,state,geo,ref);
%
% This is the main computational function of Tornado. It computes allf of
% the results in the RESULTS struct. QUEST is a switch for which type of
% computation is to be performed. JID is the Job IDentifier, which is used
% to name the resultfiles. LATTICE, STATE, GEO and REF are all input
% structures defined in inpt and statesetup.
%
% Example:
%
% []=solverloop(results,quest,JID,lattice,state,geo,ref);
%
% Calls:
% solver8
% coeff_create
% spanload6
% terror
% solver_svl
% solver_sym
% fLattice_setup
%
%
% Author: Tomas Melin <melin@kth.se>
% Keywords: Tornado core function
%
% Revision History:
% Bristol, 2007 06 27: Addition of new header. TM.
% Bristol, 2007 06 25: Subsidary functions moved inline, TM
% Spånga, 2021 08 13: Changes to trim function to allow allmoving surface
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
settings=config('startup');
resetstate=state;
%%%%%%%%%%%%%%%%%%
%determine flap settings on flapped partitions
rudder_index=find(geo.flapped);
flap_setting=geo.flap_vector(rudder_index);
tdisp(' ')
tdisp('Solution started, please wait. ')
tdisp(' ')
switch(quest)
case 1 %Simple Solver
[results]=solver9(results,state,geo,lattice,ref);
[results]=coeff_create3(results,lattice,state,ref,geo);
fname=strcat(JID,'-Cx');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
tdisp(' ')
tdisp(strcat(' Solution available in output/',fname))
tdisp(' ')
case 2
lock(4)=0;
a1=input(' From alfa [deg]: ')*pi/180;
b1=input(' Increment [deg]: ')*pi/180;
c1=input(' To alpha [deg]: ')*pi/180;
j=0;
results.matrix=ones(9,6,1);
for alpha=a1:b1:c1
state.alpha=alpha;
j=j+1;
%The lattice type was hardcoded to type 0 in version 135...
[lattice,ref]=fLattice_setup2(geo,state,1);
[results]=solver9(results,state,geo,lattice,ref);
[results]=coeff_create3(results,lattice,state,ref,geo);
results.alpha_sweep(j)=state.alpha;
results.matrix(:,:,j)=[results.CL results.CL_a results.CL_b results.CL_P results.CL_Q results.CL_R
results.CD results.CD_a results.CD_b results.CD_P results.CD_Q results.CD_R
results.CC results.CC_a results.CC_b results.CC_P results.CC_Q results.CC_R
results.Cl results.Cl_a results.Cl_b results.Cl_P results.Cl_Q results.Cl_R
results.Cm results.Cm_a results.Cm_b results.Cm_P results.Cm_Q results.Cm_R
results.Cn results.Cn_a results.Cn_b results.Cn_P results.Cn_Q results.Cn_R
results.CX results.CX_a results.CX_b results.CX_P results.CX_Q results.CX_R
results.CY results.CY_a results.CY_b results.CY_P results.CY_Q results.CY_R
results.CZ results.CZ_a results.CZ_b results.CZ_P results.CZ_Q results.CZ_R];
end
state=resetstate;
fname=strcat(JID,'-Cx_alpha');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
disp(' ')
disp(strcat(' Solution available in output/',fname))
disp(' ')
case 3
lock(5)=0;
a=input(' From beta [deg]: ')*pi/180;
b=input(' Increment [deg]: ')*pi/180;
c=input(' To beta [deg]: ')*pi/180;
i=0;
results.matrix=ones(9,6,1);
for angle=a:b:c
i=i+1;
state.betha=angle;
[lattice,ref]=fLattice_setup2(geo,state,0);
[results]=solver9(results,state,geo,lattice,ref);
[results]=coeff_create3(results,lattice,state,ref,geo);
results.betha_sweep(i)=angle;
results.matrix(:,:,i)=[results.CL results.CL_a results.CL_b results.CL_P results.CL_Q results.CL_R
results.CD results.CD_a results.CD_b results.CD_P results.CD_Q results.CD_R
results.CC results.CC_a results.CC_b results.CC_P results.CC_Q results.CC_R
results.Cl results.Cl_a results.Cl_b results.Cl_P results.Cl_Q results.Cl_R
results.Cm results.Cm_a results.Cm_b results.Cm_P results.Cm_Q results.Cm_R
results.Cn results.Cn_a results.Cn_b results.Cn_P results.Cn_Q results.Cn_R
results.CX results.CX_a results.CX_b results.CX_P results.CX_Q results.CX_R
results.CY results.CY_a results.CY_b results.CY_P results.CY_Q results.CY_R
results.CZ results.CZ_a results.CZ_b results.CZ_P results.CZ_Q results.CZ_R];
end
state=resetstate;
fname=strcat(JID,'-Cx_beta');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
disp(' ')
disp(strcat(' Solution available in output/',fname))
disp(' ')
case 5
lock(7)=0;
a=input(' From P [deg/s]: ')*pi/180;
b=input(' Increment [deg/s]: ')*pi/180;
c=input(' To P [deg/s]: ')*pi/180;
i=0;
results.matrix=ones(9,6,1);
for angle=a:b:c
i=i+1;
state.P=angle;
[lattice,ref]=fLattice_setup2(geo,state,0);
[results]=solver9(results,state,geo,lattice,ref);
[results]=coeff_create3(results,lattice,state,ref,geo);
results.P_sweep(i)=angle;
results.matrix(:,:,i)=[results.CL results.CL_a results.CL_b results.CL_P results.CL_Q results.CL_R
results.CD results.CD_a results.CD_b results.CD_P results.CD_Q results.CD_R
results.CC results.CC_a results.CC_b results.CC_P results.CC_Q results.CC_R
results.Cl results.Cl_a results.Cl_b results.Cl_P results.Cl_Q results.Cl_R
results.Cm results.Cm_a results.Cm_b results.Cm_P results.Cm_Q results.Cm_R
results.Cn results.Cn_a results.Cn_b results.Cn_P results.Cn_Q results.Cn_R
results.CX results.CX_a results.CX_b results.CX_P results.CX_Q results.CX_R
results.CY results.CY_a results.CY_b results.CY_P results.CY_Q results.CY_R
results.CZ results.CZ_a results.CZ_b results.CZ_P results.CZ_Q results.CZ_R];
end
state=resetstate;
fname=strcat(JID,'-Cx_P');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
disp(' ')
disp(strcat(' Solution available in output/',fname))
disp(' ')
case 6
lock(8)=0;
a=input(' From Q [deg/s]: ')*pi/180;
b=input(' Increment [deg/s]: ')*pi/180;
c=input(' To Q [deg/s]: ')*pi/180;
i=0;
results.matrix=ones(9,6,1);
for angle=a:b:c
i=i+1;
state.Q=angle;
[lattice,ref]=fLattice_setup2(geo,state,0);
[results]=solver9(results,state,geo,lattice,ref);
[results]=coeff_create3(results,lattice,state,ref,geo);
results.Q_sweep(i)=angle;
results.matrix(:,:,i)=[results.CL results.CL_a results.CL_b results.CL_P results.CL_Q results.CL_R
results.CD results.CD_a results.CD_b results.CD_P results.CD_Q results.CD_R
results.CC results.CC_a results.CC_b results.CC_P results.CC_Q results.CC_R
results.Cl results.Cl_a results.Cl_b results.Cl_P results.Cl_Q results.Cl_R
results.Cm results.Cm_a results.Cm_b results.Cm_P results.Cm_Q results.Cm_R
results.Cn results.Cn_a results.Cn_b results.Cn_P results.Cn_Q results.Cn_R
results.CX results.CX_a results.CX_b results.CX_P results.CX_Q results.CX_R
results.CY results.CY_a results.CY_b results.CY_P results.CY_Q results.CY_R
results.CZ results.CZ_a results.CZ_b results.CZ_P results.CZ_Q results.CZ_R];
end
state=resetstate;
fname=strcat(JID,'-Cx_Q');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
disp(' ')
disp(strcat(' Solution available in output/',fname))
disp(' ')
case 7
lock(9)=0;
a=input(' From R [deg/s]: ')*pi/180;
b=input(' Increment [deg/s]: ')*pi/180;
c=input(' To R [deg/s]: ')*pi/180;
i=0;
results.matrix=ones(9,6,1);
for angle=a:b:c
i=i+1;
disp('****************')
state.R=angle
[lattice,ref]=fLattice_setup2(geo,state,0);
[results]=solver9(results,state,geo,lattice,ref);
[results]=coeff_create3(results,lattice,state,ref,geo);
results.R_sweep(i)=angle;
roll =results.Cl
rollq =results.Cl_R
figure(1)
subplot(1,2,1)
plot(state.R,roll,'*')
hold on
subplot(1,2,2)
plot(state.R,rollq,'o')
hold on
pause
results.matrix(:,:,i)=[results.CL results.CL_a results.CL_b results.CL_P results.CL_Q results.CL_R
results.CD results.CD_a results.CD_b results.CD_P results.CD_Q results.CD_R
results.CC results.CC_a results.CC_b results.CC_P results.CC_Q results.CC_R
results.Cl results.Cl_a results.Cl_b results.Cl_P results.Cl_Q results.Cl_R
results.Cm results.Cm_a results.Cm_b results.Cm_P results.Cm_Q results.Cm_R
results.Cn results.Cn_a results.Cn_b results.Cn_P results.Cn_Q results.Cn_R
results.CX results.CX_a results.CX_b results.CX_P results.CX_Q results.CX_R
results.CY results.CY_a results.CY_b results.CY_P results.CY_Q results.CY_R
results.CZ results.CZ_a results.CZ_b results.CZ_P results.CZ_Q results.CZ_R];
end
state=resetstate;
fname=strcat(JID,'-Cx_R');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
disp(' ')
disp(strcat(' Solution available in output/',fname))
disp(' ')
case 4
lock(6)=0;
disp('__________________________________________')
disp(' ')
disp(strcat(' The current geometry has ',032, num2str(sum(sum(geo.flapped))), ' trailing edge control surfaces'))
disp(strcat(' and ',032, num2str(sum(geo.allmove)), ' all moving control surfaces'))
disp(' ')
disp('Sweeping either: ')
disp('[1] Trailing edge control effector ')
disp('[2] Allmoving wing effector ')
disp(' ')
disp('[0] Exit/upmenu ')
disp(' ')
q=input('Selection [1..]: ');
if q==1
if sum(sum(geo.flapped))>0
rudder=input('Sweep TE effector number: [1..]: ');
[n,m]=find(geo.flapped');
else
disp(' No trailing edge control surfaces in the current geometry.')
return
end
resetdelta=geo.flap_vector;
elseif q ==2
if sum(sum(geo.allmove))>0
rudder=input('Sweep allmoving wing number: [1..]: ');
[n,m]=find(geo.flapped');
else
disp(' No allmoving wing in the current geometry.')
return
end
resetdelta=geo.allmove_def;
else
return
end
a=input(' From delta [deg]: ')*pi/180;
b=input(' Increment [deg]: ')*pi/180;
c=input(' To delta [deg]: ')*pi/180;
i=0;
def=a;
results.matrix=ones(9,6,1);
for angle=a:b:c
i=i+1;
if q==1
geo.flap_vector(m(rudder),n(rudder))=angle;
else
geo.allmove_def(rudder)=angle;
end
[lattice,ref]=fLattice_setup2(geo,state,0);
[results]=solver9(results,state,geo,lattice,ref);
[results]=coeff_create3(results,lattice,state,ref,geo);
results.delta_sweep(i)=angle;
results.matrix(:,:,i)=[results.CL results.CL_a results.CL_b results.CL_P results.CL_Q results.CL_R
results.CD results.CD_a results.CD_b results.CD_P results.CD_Q results.CD_R
results.CC results.CC_a results.CC_b results.CC_P results.CC_Q results.CC_R
results.Cl results.Cl_a results.Cl_b results.Cl_P results.Cl_Q results.Cl_R
results.Cm results.Cm_a results.Cm_b results.Cm_P results.Cm_Q results.Cm_R
results.Cn results.Cn_a results.Cn_b results.Cn_P results.Cn_Q results.Cn_R
results.CX results.CX_a results.CX_b results.CX_P results.CX_Q results.CX_R
results.CY results.CY_a results.CY_b results.CY_P results.CY_Q results.CY_R
results.CZ results.CZ_a results.CZ_b results.CZ_P results.CZ_Q results.CZ_R];
end
if q==1
geo.flap_vector=resetdelta;
else
geo.allmove_def=resetdelta;
end
fname=strcat(JID,'-Cx_d');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
disp(' ')
disp(strcat(' Solution available in output/',fname))
disp(' ')
%Resetting control surfaces to zero deflection
geo.flap_vector(n(rudder),m(rudder))=0;
[lattice,ref]=fLattice_setup2(geo,state,0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 8
disp(' Option removed')
case 10
%Estimated Zero Lift Drag, Eckerts equation.
tdisp('Friction drag estimation.')
[rho a p mu]=ISAtmosphere(state.ALT); %Calling International Standard atmosphere.
Mach=state.AS/a; %Computing local TAS
[results.CD0 results.Re results.Swet results.Vol]=zeroliftdragpred(Mach,state.ALT,geo,ref);
fname=strcat(JID,'-Cnull');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
case 11
disp(' Option removed')
case 12
disp(' Option removed')
case 13
disp('--------------------- ')
disp(' ');
disp(' Trim aircraft around:')
disp(' [1] Roll axis.')
disp(' [2] Pitch axis.')
disp(' [3] Yaw axis.')
trimaxis=input(' Axis [1 2 3]: ');
disp(' ')
disp(' Trim aircraft by:')
disp(' [1] Changing wing incidence.')
disp(' [2] Changing control effector setting.')
disp(' [3] Changing allmoving control effector setting')
disp(' ');
choice=input(' Please enter option frome above please: ');
disp(' ')
if choice==1;
trimwing=input(' Which wingnumber to incidence trim with: ');
trimrudder=0;
trimallmove=0;
elseif choice==2
trimrudder=input(' Which control effector number to trim with: ');
trimwing=0;
trimallmove=0;
elseif choice==3
trimrudder=0;
trimwing=0;
trimallmove=input(' Which allmoving effector number to trim with: ');
else
disp('Bad input.')
return
end
disp(' ')
disp(' State:')
disp(' [1] Keep angle of attack constant.')
disp(' [2] Keep lift coefficient constant.')
disp(' ');
choice2=input(' Please enter option from above please: ');
disp(' ')
solvertype=1;
if choice2==1
[results,rudderangle,geo,state]=fTrimAconst(geo,state,trimaxis,trimwing,trimrudder,trimallmove,solvertype);
disp(' ')
elseif choice2==2
[results,rudderangle,geo,state]=fTrimCLconst(geo,state,trimaxis,trimwing,trimrudder,trimallmove,solvertype);
disp(' ')
else
disp(' Bad input, no computation made.')
end
if choice==1;
disp(('Aircraft will be in trim with an additional'));
disp(strcat(('wing incidence setting of degrees: '),num2str(rudderangle*180/pi)));
disp(strcat(('At a body reference angle of attack of degrees: '),num2str(state.alpha*180/pi)));
end
if choice==2;
disp(strcat(('Aircraft will be in trim with a control effector setting of degrees: '),num2str(rudderangle*180/pi)));
disp(strcat(('At an angle of attack of: '),num2str(state.alpha*180/pi)));
end
disp(' ');
fname=strcat(JID,'-Cx');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
tdisp(' ')
tdisp(strcat(' Trimmed solution available in output/',fname))
tdisp(' ')
return
case 14
disp(' ')
disp('**********')
disp(' ')
wing=input('Check grid convergence on wing number: ');
disp(' ')
disp('Check convergence in direction: ')
disp(' [1]. Chord wise.')
disp(' [2]. Span wise.')
disp(' ')
direction=input('Direction [1 2]: ');
disp(' ')
criterion=input('Convergence criterion (recommend 0.01): ');
converge=zgridconverge2(geo,state,wing,direction,criterion);
if converge.converged
% update=input('Do you wish to update current geometry, [0 1]:');
% if update
geo.nx=converge.nx
geo.ny=converge.ny
lattice=[];
figure(200)
subplot(3,1,1)
title('Convergence history')
plot(converge.panels,converge.CL,'-o')
xlabel('Number of Panels')
ylabel('Lift coefficient, C_L, [-]')
subplot(3,1,2)
plot(converge.panels,converge.CD,'-o')
xlabel('Number of Panels')
ylabel('Drag coefficient, C_{Di}, [-]')
subplot(3,1,3)
plot(converge.panels,converge.Cm,'-o')
xlabel('Number of Panels')
ylabel('Pitching moment coefficient, C_m, [-]')
% end
end
case 15
disp(' ')
disp('**********')
disp(' ')
CLmax=input('Main wing profile maximum CL: ');
[results state]=zfindstall(geo,state,ref,results,CLmax);
disp(' ')
disp(strcat('Stall angle of attack [deg]: ',num2str(state.alpha*180/pi)));
disp(' ')
fname=strcat(JID,'-Cx');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
tdisp(' ')
tdisp(strcat(' Solution available in output/',fname))
tdisp(' ')
case 16
%% Functionallity removed due to copyright issues in core.
% Method based on a TSaGI code for which I couldnt get a License.
tdisp(' ')
tdisp('**********')
tdisp(' ')
tdisp('CAUTION: Function not fully validated yet.')
tdisp(' ')
% [rho a p mu]=ISAtmosphere(state.ALT); %Calling International Standard atmosphere.
% Mach=state.AS/a; %Computing local TAS
%
% A=funsteady(lattice,geo,ref,Mach);
%
% results.CZ_a_dot=A(1);
% results.Cm_a_dot=A(2);
%
% lattice.COLLOC=[lattice.COLLOC(:,1) lattice.COLLOC(:,3) lattice.COLLOC(:,2)];
% lattice.N=[lattice.N(:,1) lattice.N(:,3) lattice.N(:,2)];
%
% lattice.VORTEX2(:,:,1)=lattice.VORTEX(:,:,1);
% lattice.VORTEX2(:,:,3)=lattice.VORTEX(:,:,2);
% lattice.VORTEX2(:,:,2)=lattice.VORTEX(:,:,3);
% lattice.VORTEX=lattice.VORTEX2;
%
% lattice.XYZ2(:,:,1)=lattice.XYZ(:,:,1);
% lattice.XYZ2(:,:,3)=lattice.XYZ(:,:,2);
% lattice.XYZ2(:,:,2)=lattice.XYZ(:,:,3);
% lattice.XYZ=lattice.XYZ2;
%
% A=funsteady(lattice,geo,ref,Mach);
%
% results.CY_b_dot=A(1);
% results.Cn_b_dot=A(2);
%
% fname=strcat(JID,'-Cx_dot');
% save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
%
% tdisp(' ')
% tdisp(strcat(' Solution available in output/',fname))
% tdisp(' ')
case 17
%% Functionallity removed due to copyright issues in core.
% Method based on a TSaGI code for which I couldnt get a License.
%%%%%%%%%
% Unsteady, acceleration free, all coefficients.
%%%%%%%%%
% Part one, STATIC COEFFICIENTS
%
%%%%%%%%%
% [results]=solver9(results,state,geo,lattice,ref);
% [results]=coeff_create3(results,lattice,state,ref,geo);
%
% %%%%%%%%%
% % Part two, UNSTEADY COEFFICIENTS
% %
% %%%%%%%%%
%
% tdisp(' ')
% tdisp('**********')
% tdisp(' ')
%
% tdisp('All inviscous coefficients.')
% tdisp('CAUTION: Function not fully validated yet.')
% tdisp(' ')
%
% [rho a p mu]=ISAtmosphere(state.ALT); %Calling International Standard atmosphere.
% Mach=state.AS/a; %Computing local TAS
%
% A=funsteady(lattice,geo,ref,Mach);
%
% results.CZ_a_dot=-A(1);
% results.Cm_a_dot=-A(2);
%
% %Flipping the lattice to get the sideslip solved.
% lattice.COLLOC=[lattice.COLLOC(:,1) lattice.COLLOC(:,3) lattice.COLLOC(:,2)];
% lattice.N=[lattice.N(:,1) lattice.N(:,3) lattice.N(:,2)];
%
% lattice.VORTEX2(:,:,1)=lattice.VORTEX(:,:,1);
% lattice.VORTEX2(:,:,3)=lattice.VORTEX(:,:,2);
% lattice.VORTEX2(:,:,2)=lattice.VORTEX(:,:,3);
% lattice.VORTEX=lattice.VORTEX2;
%
% lattice.XYZ2(:,:,1)=lattice.XYZ(:,:,1);
% lattice.XYZ2(:,:,3)=lattice.XYZ(:,:,2);
% lattice.XYZ2(:,:,2)=lattice.XYZ(:,:,3);
% lattice.XYZ=lattice.XYZ2;
%
% A=funsteady(lattice,geo,ref,Mach);
%
% results.CY_b_dot=-A(1);
% results.Cn_b_dot=-A(2);
%
% warning off
% factor1=results.CL/results.CZ; %L scaling factor
% if isnan(factor1)
% factor1=1;
% end
%
% factor2=results.CD/results.CZ; %D scaling factor
% if isnan(factor2)
% factor2=0;
% end
%
% results.CL_a_dot=results.CZ_a_dot*factor1;
% results.CD_a_dot=results.CZ_a_dot*factor2;
% results.CC_a_dot=results.CY_b_dot;
%
% %Fixing all other coefficients
%
% CZchange=(state.adot*results.CZ_a_dot+results.CZ)./results.CZ;
% if isnan(CZchange)
% CZchange=1;
% end
% CYchange=(state.bdot*results.CY_b_dot+results.CY)./results.CY;
% if isnan(CYchange)
% CYchange=1;
% end
% Cmchange=(state.adot*results.Cm_a_dot+results.Cm)./results.Cm;
% if isnan(Cmchange)
% Cmchange=1;
% end
% Cnchange=(state.bdot*results.Cn_b_dot+results.Cn)./results.Cn;
% if isnan(Cnchange)
% Cnchange=1;
% end
% warning on
%
% results.F(:,1)=results.F(:,1).*CZchange;
% results.F(:,2)=results.F(:,2).*CYchange;
% results.F(:,3)=results.F(:,3).*CZchange;
% results.FORCE(1)=results.FORCE(1).*CZchange;
% results.FORCE(2)=results.FORCE(2).*CYchange;
% results.FORCE(3)=results.FORCE(3).*CZchange;
%
% results.M(:,1)=results.M(:,1);
% results.M(:,2)=results.M(:,2).*Cmchange;
% results.M(:,3)=results.M(:,3).*Cnchange;
% results.MOMENTS(1)=results.MOMENTS(1);
% results.MOMENTS(2)=results.MOMENTS(2).*Cmchange;
% results.MOMENTS(3)=results.MOMENTS(3).*Cnchange;
%
% results.CX=results.CX*CZchange;
% results.CY=results.CY*CYchange;
% results.CZ=results.CZ*CZchange;
% results.CL=results.CL*CZchange;
% results.CD=results.CD*CZchange;
% results.CC=results.CC*CYchange;
% results.Cl=results.Cl;
% results.Cm=results.Cm+state.adot*results.Cm_a_dot;
% results.Cn=results.Cn+state.bdot*results.Cn_b_dot;
%
% results.CL_a=results.CL_a*CZchange;
% results.CD_a=results.CD_a*CZchange;
% results.CC_a=results.CC_a*CYchange;
% results.CX_a=results.CX_a*CZchange;
% results.CY_a=results.CY_a*CYchange;
% results.CZ_a=results.CZ_a*CZchange;
% results.Cl_a=results.Cl_a ;
% results.Cm_a=results.Cm_a*Cmchange;
% results.Cn_a=results.Cn_a*Cnchange;
%
% results.CL_b=results.CL_b*CZchange;
% results.CD_b=results.CD_b*CZchange;
% results.CC_b=results.CC_b*CYchange;
% results.CX_b=results.CX_b*CZchange;
% results.CY_b=results.CY_b*CYchange;
% results.CZ_b=results.CZ_b*CZchange;
% results.Cl_b=results.Cl_b ;
% results.Cm_b=results.Cm_b*Cmchange;
% results.Cn_b=results.Cn_b*Cnchange;
%
% results.CL_P=results.CL_P*CZchange;
% results.CD_P=results.CD_P*CZchange;
% results.CC_P=results.CC_P*CYchange;
% results.CX_P=results.CX_P*CZchange;
% results.CY_P=results.CY_P*CYchange;
% results.CZ_P=results.CZ_P*CZchange;
% results.Cl_P=results.Cl_P ;
% results.Cm_P=results.Cm_P*Cmchange;
% results.Cn_P=results.Cn_P*Cnchange;
%
% results.CL_Q=results.CL_Q*CZchange;
% results.CD_Q=results.CD_Q*CZchange;
% results.CC_Q=results.CC_Q*CYchange;
% results.CX_Q=results.CX_Q*CZchange;
% results.CY_Q=results.CY_Q*CYchange;
% results.CZ_Q=results.CZ_Q*CZchange;
% results.Cl_Q=results.Cl_Q ;
% results.Cm_Q=results.Cm_Q*Cmchange;
% results.Cn_Q=results.Cn_Q*Cnchange;
%
% results.CL_R=results.CL_R*CZchange;
% results.CD_R=results.CD_R*CZchange;
% results.CC_R=results.CC_R*CYchange;
% results.CX_R=results.CX_R*CZchange;
% results.CY_R=results.CY_R*CYchange;
% results.CZ_R=results.CZ_R*CZchange;
% results.Cl_R=results.Cl_R ;
% results.Cm_R=results.Cm_R*Cmchange;
% results.Cn_R=results.Cn_R*Cnchange;
%
% results.CL_d=results.CL_d*CZchange;
% results.CD_d=results.CD_d*CZchange;
% results.CC_d=results.CC_d*CYchange;
% results.CX_d=results.CX_d*CZchange;
% results.CY_d=results.CY_d*CYchange;
% results.CZ_d=results.CZ_d*CZchange;
% results.Cl_d=results.Cl_d ;
% results.Cm_d=results.Cm_d*Cmchange;
% results.Cn_d=results.Cn_d*Cnchange;
%
% results.ForcePerMeter=results.ForcePerMeter*CZchange;
% results.CL_local=results.CL_local*CZchange;
%
%
% fname=strcat(JID,'-Cxunst');
% save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
%
% tdisp(' ')
% tdisp(strcat(' Solution available in output/',fname))
% tdisp(' ')
%
case 18
tdisp('Strip theory drag estimation')
tdisp('Function not fully validated yet. Proceed with caution.')
latticetype=1; %Standard VLM to start with.
test=fCheckThickness(geo);
if test==0;
terror(22)
return
end
[lattice,ref]=fLattice_setup2(geo,state,latticetype); %Setting up the lattice
[results]=solver9(results,state,geo,lattice,ref);
[results]=coeff_create3(results,lattice,state,ref,geo);
A=fViscCorr2(geo,state,lattice,results,ref); %Strip theory viscous drag.
results.CDv=A.totalvdragcoeff; %
results.BLparam=A; %just send everything to file.
fname=strcat(JID,'-viscous');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
tdisp(' ')
tdisp(strcat(' Solution available in output/',fname))
tdisp(' ')
tdisp(strcat('**********',' Alpha = ',num2str(state.alpha*57.2958),' *****************'))
tdisp(strcat('CL = ',num2str(results.CL),' CDv = ',num2str(results.CDv),' CDi = ',num2str(results.CD)))
tdisp(strcat('Cl = ',num2str(results.Cl),' Cn = ',num2str(results.Cn),' Cm = ',num2str(results.Cm)))
tdisp(strcat('Cl_p = ',num2str(results.Cl_P),' Cn_p = ',num2str(results.Cn_P)))
tdisp(strcat('Cl_r = ',num2str(results.Cl_R),' Cn_r = ',num2str(results.Cn_R)))
tdisp('**************************************************************************')
case 19
tdisp(' ')
tdisp('Tsagi strip theory implementation')
tdisp(' ')
tdisp('CAUTION: Function not implemented.')
tdisp(' ')
return
%result=visc_corr(state,geo,lattice,ref);
%
% fname=strcat(JID,'-viscous');
% cd(settings.odir)
% save(fname,'results','geo','lattice','state','ref')
% cd(settings.hdir)
% tdisp(' ')
% tdisp(strcat(' Solution available in output/',fname))
% tdisp(' ')
%tdisp(strcat('**********',' Alpha = ',num2str(state.alpha*57.2958),' *****************'))
%tdisp(strcat('CN = ',num2str(result.CN),' CA = ',num2str(result.CA),' CS = ',num2str(result.CS)))
%tdisp(strcat('Cl = ',num2str(result.Cl),' Cn = ',num2str(result.Cn),' Cm = ',num2str(result.Cm)))
%tdisp(strcat('Cl_p = ',num2str(result.Cl_p),' Cn_p = ',num2str(result.Cn_p)))
%tdisp(strcat('Cl_r = ',num2str(result.Cl_r),' Cn_r = ',num2str(result.Cn_r)))
%tdisp('*********************************************************************************')
case 20
disp(' ')
solvertype=1; %Hardcoded fixed wake so far
CL_target=input(' What is the target CL:');
[results,alpha]=fFindAlphaAtCL(geo,state,solvertype,CL_target);
disp(' ')
disp(strcat('Target CL of :',num2str(CL_target)));
disp(strcat(strcat('at an alpha of :',num2str(alpha)),' [rad]'));
disp(strcat(strcat('or : ',num2str(alpha*180/pi)),' [deg]'));
case 21
disp(' ')
out=fFindstaticmargin(geo,state);
if isempty(out.h)
disp('Static margin not found')
else
disp('****************************************************')
disp(strcat('Aerodynamic center located at :',num2str(out.ac)));
disp(strcat('Static margin :',num2str(out.h(1))));
disp('****************************************************')
end
%% =====================Trimmed Alpha Sweep Polar============================
case 22
lock(4)=0;
a1=input(' From alpha [deg]: ')*pi/180;
b1=input(' Increment [deg]: ')*pi/180;
c1=input(' To alpha [deg]: ')*pi/180;
j=0;
trimaxis=2; % trim arount pitch axis
disp(' ')
disp(' Trim aircraft by:')
disp(' [1] Changing wing incidence.')
disp(' [2] Changing control effector setting.')
disp(' [3] Changing allmoving wing effector setting.')
choice=input(' Please enter option from above please: ');
disp(' ')
if choice==1;
trimwing=input(' Which number is the wing to trim with: ');
trimrudder=0;
trimallmove=0;
elseif choice==2
trimrudder=input(' Which number is the control effector to trim with: ');
trimwing=0;
trimallmove=0;
elseif choise==3
trimallmove=input(' Which number is the control effector to trim with: ');
trimwing=0;
trimrudder=0;
else
disp('Bad input.')
return
end
choice2=1; %Keep angle of attack constant.
% d1 = Number of Alphas
d1=(c1-a1)/b1+1;
results.matrix=ones(9,6,d1); %initializing the results matrix;
solvertype=1; %For now, always use fixed wake.
for alpha=a1:b1:c1
state.alpha=alpha;
disp(' ')
disp('Alpha = ')
disp(alpha*180/pi());
j=j+1;
if choice2==1;
[lemma_results,rudderangle]=fTrimAconst(geo,state,trimaxis,trimwing,trimrudder,trimallmove,solvertype);
elseif choice2==2;
[lemma_results,rudderangle]=fTrimCLconst(geo,state,trimaxis,trimwing,trimrudder,trimallmove,solvertype);
else
disp(' Bad input, no computation made.')
end
%if choice==1;
% disp(('Aircraft will be in trim with an additional'));
% disp(strcat(('wing incidence setting of degrees: '),num2str(rudderangle*180/pi)));
%end
%if choice==2;
% disp(strcat(('Aircraft will be in trim with a control effector setting of degrees: '),num2str(rudderangle*pi/180)));
%end
results.alpha_sweep(j)=state.alpha;
results.rudderangle(j)=rudderangle;
try
results.matrix(:,:,j)=lemma_results.matrix;
catch
end
end
state=resetstate;
fname=strcat(JID,'-Cx_alpha');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
disp(' ')
disp(strcat(' Trimmed solution available in output/',fname))
disp(' ')
case 23
[rho a p mu]=ISAtmosphere(state.ALT); %Calling International Standard atmosphere.
Mach=state.AS/a; %Computing local TAS
results.CD0_blunt=zldpblunt(Mach,state.ALT,geo.body,ref);
fname=strcat(JID,'-blunt');
save([settings.odir,'/',fname],'results','geo','lattice','state','ref')
disp(' ')
disp(strcat(' Blunt body solution available in output/',fname));
disp(' ')