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
|
block Wind6DOF
import Modelica.Math.Matrices.*;
import Modelica.SIunits.*;
import Modelica.Blocks.Interfaces.*;
import Modelica.Math.Vectors.*;
RealInput thrust annotation(
Placement(visible = true, transformation(origin = {-110, 33}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-110, 33}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));//Thrust force
RealInput[3] delta annotation(
Placement(visible = true, transformation(origin = {-110, -33}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-110, -33}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
Modelica.Blocks.Interfaces.RealOutput V annotation(start =39.8858,
Placement(visible = true, transformation(origin = {110, 100}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 100}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); //Linear velocity
Modelica.Blocks.Interfaces.RealOutput alpha annotation(start =0.1,
Placement(visible = true, transformation(origin = {110, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); //Angle of attack
Modelica.Blocks.Interfaces.RealOutput beta annotation(start = 0,
Placement(visible = true, transformation(origin = {110, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); //Angle of sideslip
Modelica.Blocks.Interfaces.RealOutput pos[3]annotation(
Placement(visible = true, transformation(origin = {110, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
//Position (Displacement) //Displacement
Modelica.Blocks.Interfaces.RealOutput omega[3] annotation(
Placement(visible = true, transformation(origin = {110, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); //Angular velocity around the CM
Modelica.Blocks.Interfaces.RealOutput angles[3] annotation(
Placement(visible = true, transformation(origin = {110, -100}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {110, -100}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); //mu, gamma, and chi
parameter Real rho;
parameter Real m;//1.56 for zagi
parameter Real S_ref;//reference area
parameter Real C_bar ;//average chord
parameter Real b ;//span
parameter Real g = 9.81;//gravitational force
//parameter Real b= 1.4224, C_bar = 0.3302,s = 0.2589;
parameter Real CD0;//= 0.01631;for Zagi
parameter Real K_drag ;//for cessna
parameter Real CD_beta;//for cessna
parameter Real CD_alpha;
parameter Real CD_q;
parameter Real CD_delta_e;
//side force
parameter Real Cy_beta;//for cessna
parameter Real Cy_p;//for cessna
parameter Real Cy_r;//for cessna
parameter Real Cy_delta_r; //for cessna
parameter Real Cy_delta_a; //for cessna
// lift
parameter Real CL0 ; //for cessna
parameter Real CL_alpha;//for cessna
parameter Real CL_q;//for cessna
parameter Real CL_delta_e;//for cessna
// rolling moment
parameter Real Cl_beta;//for cessna
parameter Real Cl_p;//for cessna
parameter Real Cl_r;//for cessna
parameter Real Cl_delta_a;//for cessna
parameter Real Cl_delta_r ;//for cessna
// pitching moment
parameter Real Cm0;//for cessna
parameter Real Cm_alpha ;//for cessna
parameter Real Cm_q;//for cessna
parameter Real Cm_delta_e;//for cessna
// yawing moment
parameter Real Cn_beta;//for cessna
parameter Real Cn_p;//for cessna
parameter Real Cn_r;//for cessna
parameter Real Cn_delta_a ;//for cessna
parameter Real Cn_delta_r;//for cessna
//Initial conditions. (delta[2], thrust[1] and the others are straightforward)
parameter Real I_xx;
parameter Real I_yy;
parameter Real I_zz;
Real CL;
Real CD;
Real CY;
Real Cl;
Real Cm;
Real Cn;
Real CX;
Real CZ;
//Params
//parameter Real delta[1] = 0;
//parameter Real delta[3] = 0;
//Modelica.Blocks.Sources.RealExpression delta[2] (y = if time > 100 and time < 105 then -0.15625+3.1412 /180 else -0.15625) annotation( Placement(visible = true, transformation(origin = {-112, 1}, extent = {{-26, -47}, {26, 47}}, rotation = 0)));
//parameter Real delta[2] = -0.15625;
//parameter Real thrust = 1112.82;
Real qbar = 0.5*rho*V^2;
Real Vdot;
Real alphadot;
Real betadot;
Real pdot;
Real qdot;
Real rdot;
Real mudot;
Real gammadot;
Real chidot;
Real xdot;
Real ydot;
Real zdot;
equation
CL = CL0+CL_alpha*alpha+((CL_q*omega[2]*C_bar)/(2*V))+CL_delta_e*delta[2];
//CD = CD0+CD_alpha*alpha+((CD_q*omega[2]*C_bar)/(2*V))+CD_delta_e*abs(delta[2]);// + CDbeta * beta + CDdelta[2] * Elevator;
CD = CD0 + K_drag*CL^2;
CY = Cy_beta * beta + Cy_p * (omega[1]*b)/(2*V) + Cy_r *(omega[3]*b)/(2*V) + Cy_delta_a * delta[1] + Cy_delta_r*delta[3];//Sideslip coeff
Cl = Cl_beta * beta + Cl_p*(omega[1]*b)/(2*V) + Cl_r *(omega[3]*b)/(2*V) + Cl_delta_a * delta[1] + Cl_delta_r * delta[3];//Rolling coeff
Cm = Cm0+Cm_alpha*alpha+((Cm_q*omega[2]*C_bar)/(2*V))+Cm_delta_e*delta[2];//pitching coeff
Cn = Cn_beta * beta + Cn_p * (omega[1]*b)/(2*V) + Cn_r *(omega[3]*b) /(2*V) + Cn_delta_a * delta[1] + Cn_delta_r * delta[3];//Yawing coeff
CX = -CD*cos(alpha) + CL*sin(alpha);
CZ = -CD*sin(alpha) - CL*cos(alpha);
Vdot = der(V);
alphadot = der(alpha);
betadot = der(beta);
pdot = der(omega[1]);
qdot = der(omega[2]);
rdot = der(omega[3]);
xdot = der(pos[1]);
ydot = der(pos[2]);
zdot = der(pos[3]);
mudot = der(angles[1]);
gammadot = der(angles[2]);
chidot = der(angles[3]);
Vdot = 1/m*(thrust*cos(alpha)*cos(beta)-0.5*rho*V^2*S_ref*(CD*cos(beta)-CY*sin(beta))-m*g*sin(angles[2]));
alphadot = omega[2]-1/cos(beta)*((omega[1]*cos(alpha)+omega[3]*sin(alpha))*sin(beta)-g/V*cos(angles[2])*cos(angles[1])+0.5*rho*V^2*S_ref*CL/(m*V)+thrust*sin(alpha)/(m*V));
betadot = (omega[1]*sin(alpha)-omega[3]*cos(alpha))+1/(m*V)*(-thrust*cos(alpha)*sin(beta)+0.5*rho*V^2*S_ref*(CY*cos(beta)+CD*sin(beta))+m*g*cos(angles[2])*sin(angles[1]));
pdot = (I_yy-I_zz)/I_xx*omega[2]*omega[3]+1/(2*I_xx)*rho*V^2*S_ref*b*Cl;
qdot = (I_zz-I_xx)/I_yy*omega[1]*omega[3]+1/(2*I_yy)*rho*V^2*S_ref*C_bar*Cm;
rdot = (I_xx-I_yy)/I_zz*omega[1]*omega[2]+1/(2*I_zz)*rho*V^2*S_ref*b*Cn;
xdot=V*cos(angles[2])*cos(angles[3]);
ydot=V*cos(angles[2])*sin(angles[3]);
zdot=-V*sin(angles[2]);
mudot = omega[1]+tan(angles[2])*sin(angles[1])*omega[2]+tan(angles[2])*cos(angles[1])*omega[3];
gammadot = cos(angles[1])*omega[2]-sin(angles[1])*omega[3];
chidot=(1/cos(angles[2]))*sin(angles[1])*omega[2]+(1/cos(angles[2]))*cos(angles[1])*omega[3];
end Wind6DOF;
|