]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGAerodynamics.cpp
Andreas Gaeb: fix #222 (JSBSIm reset problems)
[flightgear.git] / src / FDM / JSBSim / models / FGAerodynamics.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGAerodynamics.cpp
4  Author:       Jon S. Berndt
5  Date started: 09/13/00
6  Purpose:      Encapsulates the aerodynamic forces
7
8  ------------- Copyright (C) 2000  Jon S. Berndt (jon@jsbsim.org) -------------
9
10  This program is free software; you can redistribute it and/or modify it under
11  the terms of the GNU Lesser General Public License as published by the Free Software
12  Foundation; either version 2 of the License, or (at your option) any later
13  version.
14
15  This program is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
18  details.
19
20  You should have received a copy of the GNU Lesser General Public License along with
21  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  Place - Suite 330, Boston, MA  02111-1307, USA.
23
24  Further information about the GNU Lesser General Public License can also be found on
25  the world wide web at http://www.gnu.org.
26
27 FUNCTIONAL DESCRIPTION
28 --------------------------------------------------------------------------------
29
30 HISTORY
31 --------------------------------------------------------------------------------
32 09/13/00   JSB   Created
33 04/22/01   JSB   Moved code into here from FGAircraft
34
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 INCLUDES
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
38
39 #include <iostream>
40 #include <sstream>
41 #include <iomanip>
42 #include <cstdlib>
43 #include <FGFDMExec.h>
44 #include "FGAerodynamics.h"
45 #include "FGPropagate.h"
46 #include "FGAircraft.h"
47 #include "FGAuxiliary.h"
48 #include "FGMassBalance.h"
49 #include "input_output/FGPropertyManager.h"
50
51 using namespace std;
52
53 namespace JSBSim {
54
55 static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.35 2010/11/18 12:38:06 jberndt Exp $";
56 static const char *IdHdr = ID_AERODYNAMICS;
57
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS IMPLEMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62
63 FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec)
64 {
65   Name = "FGAerodynamics";
66
67   AxisIdx["DRAG"]   = 0;
68   AxisIdx["SIDE"]   = 1;
69   AxisIdx["LIFT"]   = 2;
70   AxisIdx["ROLL"]   = 3;
71   AxisIdx["PITCH"]  = 4;
72   AxisIdx["YAW"]    = 5;
73
74   AxisIdx["AXIAL"]  = 0;
75   AxisIdx["NORMAL"] = 2;
76
77   AxisIdx["X"] = 0;
78   AxisIdx["Y"] = 1;
79   AxisIdx["Z"] = 2;
80
81   axisType = atNone;
82
83   Coeff = new CoeffArray[6];
84
85   impending_stall = stall_hyst = 0.0;
86   alphaclmin = alphaclmax = 0.0;
87   alphahystmin = alphahystmax = 0.0;
88   clsq = lod = 0.0;
89   alphaw = 0.0;
90   bi2vel = ci2vel = 0.0;
91   AeroRPShift = 0;
92   vDeltaRP.InitMatrix();
93
94   bind();
95
96   Debug(0);
97 }
98
99 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100
101 FGAerodynamics::~FGAerodynamics()
102 {
103   unsigned int i,j;
104
105   for (i=0; i<6; i++)
106     for (j=0; j<Coeff[i].size(); j++)
107       delete Coeff[i][j];
108
109   delete[] Coeff;
110
111   delete AeroRPShift;
112
113   Debug(1);
114 }
115
116 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117
118 bool FGAerodynamics::InitModel(void)
119 {
120   if (!FGModel::InitModel()) return false;
121
122   impending_stall = stall_hyst = 0.0;
123   alphaclmin = alphaclmax = 0.0;
124   alphahystmin = alphahystmax = 0.0;
125   clsq = lod = 0.0;
126   alphaw = 0.0;
127   bi2vel = ci2vel = 0.0;
128   AeroRPShift = 0;
129   vDeltaRP.InitMatrix();
130
131   return true;
132 }
133 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134
135 bool FGAerodynamics::Run(void)
136 {
137
138   if (FGModel::Run()) return true;
139   if (FDMExec->Holding()) return false; // if paused don't execute
140
141   unsigned int axis_ctr, ctr;
142   const double alpha=FDMExec->GetAuxiliary()->Getalpha();
143   const double twovel=2*FDMExec->GetAuxiliary()->GetVt();
144   const double qbar = FDMExec->GetAuxiliary()->Getqbar();
145   const double wingarea = FDMExec->GetAircraft()->GetWingArea();
146   const double wingspan = FDMExec->GetAircraft()->GetWingSpan();
147   const double wingchord = FDMExec->GetAircraft()->Getcbar();
148   const double wingincidence = FDMExec->GetAircraft()->GetWingIncidence();
149   RunPreFunctions();
150
151   // calculate some oft-used quantities for speed
152
153   if (twovel != 0) {
154     bi2vel = wingspan / twovel;
155     ci2vel = wingchord / twovel;
156   }
157   alphaw = alpha + wingincidence;
158   qbar_area = wingarea * qbar;
159
160   if (alphaclmax != 0) {
161     if (alpha > 0.85*alphaclmax) {
162       impending_stall = 10*(alpha/alphaclmax - 0.85);
163     } else {
164       impending_stall = 0;
165     }
166   }
167
168   if (alphahystmax != 0.0 && alphahystmin != 0.0) {
169     if (alpha > alphahystmax) {
170        stall_hyst = 1;
171     } else if (alpha < alphahystmin) {
172        stall_hyst = 0;
173     }
174   }
175
176   vFw.InitMatrix();
177   vFnative.InitMatrix();
178
179   for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
180     for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) {
181       vFnative(axis_ctr+1) += Coeff[axis_ctr][ctr]->GetValue();
182     }
183   }
184
185   // Note that we still need to convert to wind axes here, because it is
186   // used in the L/D calculation, and we still may want to look at Lift
187   // and Drag.
188
189   switch (axisType) {
190     case atBodyXYZ:       // Forces already in body axes; no manipulation needed
191       vFw = GetTb2w()*vFnative;
192       vForces = vFnative;
193       break;
194     case atLiftDrag:      // Copy forces into wind axes
195       vFw = vFnative;
196       vFw(eDrag)*=-1; vFw(eLift)*=-1;
197       vForces = GetTw2b()*vFw;
198       break;
199     case atAxialNormal:   // Convert native forces into Axial|Normal|Side system
200       vFw = GetTb2w()*vFnative;
201       vFnative(eX)*=-1; vFnative(eZ)*=-1;
202       vForces = vFnative;
203       break;
204     default:
205       cerr << endl << "  A proper axis type has NOT been selected. Check "
206                    << "your aerodynamics definition." << endl;
207       exit(-1);
208   }
209
210   // Calculate aerodynamic reference point shift, if any
211   if (AeroRPShift) vDeltaRP(eX) = AeroRPShift->GetValue()*wingchord*12.0;
212
213   // Calculate lift coefficient squared
214   if ( qbar > 0) {
215     clsq = vFw(eLift) / (wingarea*qbar);
216     clsq *= clsq;
217   }
218
219   // Calculate lift Lift over Drag
220   if ( fabs(vFw(eDrag)) > 0.0) lod = fabs( vFw(eLift) / vFw(eDrag) );
221
222   vDXYZcg = FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZrp() + vDeltaRP);
223
224   vMoments = vDXYZcg*vForces; // M = r X F
225
226   for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
227     for (ctr = 0; ctr < Coeff[axis_ctr+3].size(); ctr++) {
228       vMoments(axis_ctr+1) += Coeff[axis_ctr+3][ctr]->GetValue();
229     }
230   }
231
232   RunPostFunctions();
233
234   return false;
235 }
236
237 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238 //
239 // From Stevens and Lewis, "Aircraft Control and Simulation", 3rd Ed., the
240 // transformation from body to wind axes is defined (where "a" is alpha and "B"
241 // is beta):
242 //
243 //   cos(a)*cos(B)     sin(B)    sin(a)*cos(B)
244 //  -cos(a)*sin(B)     cos(B)   -sin(a)*sin(B)
245 //  -sin(a)              0       cos(a)
246 //
247 // The transform from wind to body axes is then,
248 //
249 //   cos(a)*cos(B)  -cos(a)*sin(B)  -sin(a)
250 //          sin(B)          cos(B)     0
251 //   sin(a)*cos(B)  -sin(a)*sin(B)   cos(a)
252
253 FGMatrix33& FGAerodynamics::GetTw2b(void)
254 {
255   double ca, cb, sa, sb;
256
257   double alpha = FDMExec->GetAuxiliary()->Getalpha();
258   double beta  = FDMExec->GetAuxiliary()->Getbeta();
259
260   ca = cos(alpha);
261   sa = sin(alpha);
262   cb = cos(beta);
263   sb = sin(beta);
264
265   mTw2b(1,1) =  ca*cb;
266   mTw2b(1,2) = -ca*sb;
267   mTw2b(1,3) = -sa;
268   mTw2b(2,1) =  sb;
269   mTw2b(2,2) =  cb;
270   mTw2b(2,3) =  0.0;
271   mTw2b(3,1) =  sa*cb;
272   mTw2b(3,2) = -sa*sb;
273   mTw2b(3,3) =  ca;
274
275   return mTw2b;
276 }
277
278 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
279
280 FGMatrix33& FGAerodynamics::GetTb2w(void)
281 {
282   double alpha,beta;
283   double ca, cb, sa, sb;
284
285   alpha = FDMExec->GetAuxiliary()->Getalpha();
286   beta  = FDMExec->GetAuxiliary()->Getbeta();
287
288   ca = cos(alpha);
289   sa = sin(alpha);
290   cb = cos(beta);
291   sb = sin(beta);
292
293   mTb2w(1,1) = ca*cb;
294   mTb2w(1,2) = sb;
295   mTb2w(1,3) = sa*cb;
296   mTb2w(2,1) = -ca*sb;
297   mTb2w(2,2) = cb;
298   mTb2w(2,3) = -sa*sb;
299   mTb2w(3,1) = -sa;
300   mTb2w(3,2) = 0.0;
301   mTb2w(3,3) = ca;
302
303   return mTb2w;
304 }
305
306 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
307
308 bool FGAerodynamics::Load(Element *element)
309 {
310   string parameter, axis, scratch;
311   string scratch_unit="";
312   string fname="", file="";
313   Element *temp_element, *axis_element, *function_element;
314
315   string separator = "/";
316
317   fname = element->GetAttributeValue("file");
318   if (!fname.empty()) {
319     file = FDMExec->GetFullAircraftPath() + separator + fname;
320     document = LoadXMLDocument(file);
321   } else {
322     document = element;
323   }
324
325   FGModel::Load(document); // Perform base class Pre-Load
326
327   DetermineAxisSystem(); // Detemine if Lift/Side/Drag, etc. is used.
328
329   Debug(2);
330
331   if ((temp_element = document->FindElement("alphalimits"))) {
332     scratch_unit = temp_element->GetAttributeValue("unit");
333     if (scratch_unit.empty()) scratch_unit = "RAD";
334     alphaclmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD");
335     alphaclmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD");
336   }
337
338   if ((temp_element = document->FindElement("hysteresis_limits"))) {
339     scratch_unit = temp_element->GetAttributeValue("unit");
340     if (scratch_unit.empty()) scratch_unit = "RAD";
341     alphahystmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD");
342     alphahystmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD");
343   }
344
345   if ((temp_element = document->FindElement("aero_ref_pt_shift_x"))) {
346     function_element = temp_element->FindElement("function");
347     AeroRPShift = new FGFunction(PropertyManager, function_element);
348   }
349
350   axis_element = document->FindElement("axis");
351   while (axis_element) {
352     CoeffArray ca;
353     axis = axis_element->GetAttributeValue("name");
354     function_element = axis_element->FindElement("function");
355     while (function_element) {
356       string current_func_name = function_element->GetAttributeValue("name");
357       try {
358         ca.push_back( new FGFunction(PropertyManager, function_element) );
359       } catch (string const str) {
360         cerr << endl << fgred << "Error loading aerodynamic function in " 
361              << current_func_name << ":" << str << " Aborting." << reset << endl;
362         return false;
363       }
364       function_element = axis_element->FindNextElement("function");
365     }
366     Coeff[AxisIdx[axis]] = ca;
367     axis_element = document->FindNextElement("axis");
368   }
369
370   PostLoad(document, PropertyManager); // Perform base class Post-Load
371
372   return true;
373 }
374
375 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376 //
377 // This private class function checks to verify consistency in the choice of
378 // aerodynamic axes used in the config file. One set of LIFT|DRAG|SIDE, or 
379 // X|Y|Z, or AXIAL|NORMAL|SIDE must be chosen; mixed system axes are not allowed.
380 // Note that if the "SIDE" axis specifier is entered first in a config file, 
381 // a warning message will be given IF the AXIAL|NORMAL specifiers are also given.
382 // This is OK, and the warning is due to the SIDE specifier used for both
383 // the Lift/Drag and Axial/Normal axis systems.
384
385 void FGAerodynamics::DetermineAxisSystem()
386 {
387   Element* axis_element = document->FindElement("axis");
388   string axis;
389   while (axis_element) {
390     axis = axis_element->GetAttributeValue("name");
391     if (axis == "LIFT" || axis == "DRAG" || axis == "SIDE") {
392       if (axisType == atNone) axisType = atLiftDrag;
393       else if (axisType != atLiftDrag) {
394         cerr << endl << "  Mixed aerodynamic axis systems have been used in the"
395                      << " aircraft config file." << endl;
396       }
397     } else if (axis == "AXIAL" || axis == "NORMAL") {
398       if (axisType == atNone) axisType = atAxialNormal;
399       else if (axisType != atAxialNormal) {
400         cerr << endl << "  Mixed aerodynamic axis systems have been used in the"
401                      << " aircraft config file." << endl;
402       }
403     } else if (axis == "X" || axis == "Y" || axis == "Z") {
404       if (axisType == atNone) axisType = atBodyXYZ;
405       else if (axisType != atBodyXYZ) {
406         cerr << endl << "  Mixed aerodynamic axis systems have been used in the"
407                      << " aircraft config file." << endl;
408       }
409     } else if (axis != "ROLL" && axis != "PITCH" && axis != "YAW") { // error
410       cerr << endl << "  An unknown axis type, " << axis << " has been specified"
411                    << " in the aircraft configuration file." << endl;
412       exit(-1);
413     }
414     axis_element = document->FindNextElement("axis");
415   }
416   if (axisType == atNone) {
417     axisType = atLiftDrag;
418     cerr << endl << "  The aerodynamic axis system has been set by default"
419                  << " to the Lift/Side/Drag system." << endl;
420   }
421 }
422
423 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
424
425 string FGAerodynamics::GetCoefficientStrings(const string& delimeter) const
426 {
427   string CoeffStrings = "";
428   bool firstime = true;
429   unsigned int axis, sd;
430
431   for (axis = 0; axis < 6; axis++) {
432     for (sd = 0; sd < Coeff[axis].size(); sd++) {
433       if (firstime) {
434         firstime = false;
435       } else {
436         CoeffStrings += delimeter;
437       }
438       CoeffStrings += Coeff[axis][sd]->GetName();
439     }
440   }
441   return CoeffStrings;
442 }
443
444 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
445
446 string FGAerodynamics::GetCoefficientValues(const string& delimeter) const
447 {
448   ostringstream buf;
449
450   for (unsigned int axis = 0; axis < 6; axis++) {
451     for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
452       if (buf.tellp() > 0) buf << delimeter;
453       buf << setw(9) << Coeff[axis][sd]->GetValue();
454     }
455   }
456
457   return buf.str();
458 }
459
460 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
461
462 void FGAerodynamics::bind(void)
463 {
464   typedef double (FGAerodynamics::*PMF)(int) const;
465
466   PropertyManager->Tie("forces/fbx-aero-lbs", this,1,
467                        (PMF)&FGAerodynamics::GetForces);
468   PropertyManager->Tie("forces/fby-aero-lbs", this,2,
469                        (PMF)&FGAerodynamics::GetForces);
470   PropertyManager->Tie("forces/fbz-aero-lbs", this,3,
471                        (PMF)&FGAerodynamics::GetForces);
472   PropertyManager->Tie("moments/l-aero-lbsft", this,1,
473                        (PMF)&FGAerodynamics::GetMoments);
474   PropertyManager->Tie("moments/m-aero-lbsft", this,2,
475                        (PMF)&FGAerodynamics::GetMoments);
476   PropertyManager->Tie("moments/n-aero-lbsft", this,3,
477                        (PMF)&FGAerodynamics::GetMoments);
478   PropertyManager->Tie("forces/fwx-aero-lbs", this,1,
479                        (PMF)&FGAerodynamics::GetvFw);
480   PropertyManager->Tie("forces/fwy-aero-lbs", this,2,
481                        (PMF)&FGAerodynamics::GetvFw);
482   PropertyManager->Tie("forces/fwz-aero-lbs", this,3,
483                        (PMF)&FGAerodynamics::GetvFw);
484   PropertyManager->Tie("forces/lod-norm", this,
485                        &FGAerodynamics::GetLoD);
486   PropertyManager->Tie("aero/cl-squared", this,
487                        &FGAerodynamics::GetClSquared);
488   PropertyManager->Tie("aero/qbar-area", &qbar_area);
489   PropertyManager->Tie("aero/alpha-max-rad", this,
490                        &FGAerodynamics::GetAlphaCLMax,
491                        &FGAerodynamics::SetAlphaCLMax,
492                        true);
493   PropertyManager->Tie("aero/alpha-min-rad", this,
494                        &FGAerodynamics::GetAlphaCLMin,
495                        &FGAerodynamics::SetAlphaCLMin,
496                        true);
497   PropertyManager->Tie("aero/bi2vel", this,
498                        &FGAerodynamics::GetBI2Vel);
499   PropertyManager->Tie("aero/ci2vel", this,
500                        &FGAerodynamics::GetCI2Vel);
501   PropertyManager->Tie("aero/alpha-wing-rad", this,
502                        &FGAerodynamics::GetAlphaW);
503   PropertyManager->Tie("systems/stall-warn-norm", this,
504                         &FGAerodynamics::GetStallWarn);
505   PropertyManager->Tie("aero/stall-hyst-norm", this,
506                         &FGAerodynamics::GetHysteresisParm);
507 }
508
509 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
510 //    The bitmasked value choices are as follows:
511 //    unset: In this case (the default) JSBSim would only print
512 //       out the normally expected messages, essentially echoing
513 //       the config files as they are read. If the environment
514 //       variable is not set, debug_lvl is set to 1 internally
515 //    0: This requests JSBSim not to output any messages
516 //       whatsoever.
517 //    1: This value explicity requests the normal JSBSim
518 //       startup messages
519 //    2: This value asks for a message to be printed out when
520 //       a class is instantiated
521 //    4: When this value is set, a message is displayed when a
522 //       FGModel object executes its Run() method
523 //    8: When this value is set, various runtime state variables
524 //       are printed out periodically
525 //    16: When set various parameters are sanity checked and
526 //       a message is printed out when they go out of bounds
527
528 void FGAerodynamics::Debug(int from)
529 {
530   if (debug_lvl <= 0) return;
531
532   if (debug_lvl & 1) { // Standard console startup message output
533     if (from == 2) { // Loader
534       switch (axisType) {
535         case (atLiftDrag):
536           cout << endl << "  Aerodynamics (Lift|Side|Drag axes):" << endl << endl;
537           break;
538         case (atAxialNormal):
539           cout << endl << "  Aerodynamics (Axial|Side|Normal axes):" << endl << endl;
540           break;
541         case (atBodyXYZ):
542           cout << endl << "  Aerodynamics (X|Y|Z axes):" << endl << endl;
543           break;
544       case (atNone):
545           cout << endl << "  Aerodynamics (undefined axes):" << endl << endl;
546           break;
547       }
548     }
549   }
550   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
551     if (from == 0) cout << "Instantiated: FGAerodynamics" << endl;
552     if (from == 1) cout << "Destroyed:    FGAerodynamics" << endl;
553   }
554   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
555   }
556   if (debug_lvl & 8 ) { // Runtime state variables
557   }
558   if (debug_lvl & 16) { // Sanity checking
559   }
560   if (debug_lvl & 64) {
561     if (from == 0) { // Constructor
562       cout << IdSrc << endl;
563       cout << IdHdr << endl;
564     }
565   }
566 }
567
568 } // namespace JSBSim