-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfFindstaticmargin.m
59 lines (42 loc) · 1.24 KB
/
fFindstaticmargin.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
function [output]=fFindstaticmargin(geo,state)
%This is only a beta testfunction so far
%It computes the aerodynamic center output.ac
%and the stability margin, output.h
cConvergence_criteria=0.00001;
solvertype=1;
results.matrix=ones(9,6,1);
%% Computing baseline results
[lattice,ref]=fLattice_setup2(geo,state,solvertype);
[results]=solver9(results,state,geo,lattice,ref);
[results]=coeff_create3(results,lattice,state,ref,geo);
CLa0=results.CL_a;
Cma0=results.Cm_a;
var0=CLa0/Cma0;
%% Find Aerodynamic Center
converged=0;
step=0.5;
i=0;
while converged==0
i=i+1;
geo.ref_point(1)=geo.ref_point(1)+step;
[lattice,ref]=fLattice_setup2(geo,state,solvertype);
[results]=solver9(results,state,geo,lattice,ref);
[results]=coeff_create3(results,lattice,state,ref,geo);
CLa1=results.CL_a;
Cma1=results.Cm_a;
var1=Cma1/CLa1;
DvarDstep=(var1-var0)/step;
step=-var1/(DvarDstep);
if abs(var1)<cConvergence_criteria
disp('converged')
output.ac=geo.ref_point;
output.h=-(output.ac-geo.CG)./ref.C_mac;
return
end
if i==10
disp('Max iterations in fFindstaticmargin')
output=[];
return
end
var0=var1;
end