]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAuxiliary.cpp
Updates from Jon and Tony.
[flightgear.git] / src / FDM / JSBSim / FGAuxiliary.cpp
1 /*******************************************************************************
2
3  Module:       FGAuxiliary.cpp
4  Author:       Jon Berndt
5  Date started: 01/26/99
6  Purpose:      Calculates additional parameters needed by the visual system, etc.
7  Called by:    FGSimExec
8
9  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
10
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  details.
20
21  You should have received a copy of the GNU General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24
25  Further information about the GNU General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This class calculates various auxiliary parameters, mostly used by the visual
31 system
32
33 REFERENCES
34         Anderson, John D. "Introduction to Flight", 3rd Edition, McGraw-Hill, 1989
35                           pgs. 112-126
36 HISTORY
37 --------------------------------------------------------------------------------
38 01/26/99   JSB   Created
39
40 ********************************************************************************
41 INCLUDES
42 *******************************************************************************/
43
44 #include "FGAuxiliary.h"
45 #include "FGTranslation.h"
46 #include "FGRotation.h"
47 #include "FGAtmosphere.h"
48 #include "FGState.h"
49 #include "FGFDMExec.h"
50 #include "FGFCS.h"
51 #include "FGAircraft.h"
52 #include "FGPosition.h"
53 #include "FGOutput.h"
54
55 /*******************************************************************************
56 ************************************ CODE **************************************
57 *******************************************************************************/
58
59 FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
60 {
61   Name = "FGAuxiliary";
62   vcas=veas=mach=qbar=pt=0;
63   psl=rhosl=1;
64 }
65
66
67 FGAuxiliary::~FGAuxiliary()
68 {
69 }
70
71
72 bool FGAuxiliary::Run()
73 {
74   float A,B,D;
75   if (!FGModel::Run()) {
76         GetState();
77         if(mach < 1)
78             //calculate total pressure assuming isentropic flow
79                 pt=p*pow((1 + 0.2*mach*mach),3.5); 
80         else
81         {
82             // shock in front of pitot tube, we'll assume its normal and use
83                 // the Rayleigh Pitot Tube Formula, i.e. the ratio of total 
84                 // pressure behind the shock to the static pressure in front
85                 B=5.76*mach*mach/(5.6*mach*mach - 0.8); 
86                 // The denominator above is zero for Mach ~ 0.38, for which 
87                 // we'll never be here, so we're safe
88                 D=(2.8*mach*mach-0.4)*0.4167;
89                 pt=p*pow(B,3.5)*D;
90         }       
91         A=pow(((pt-p)/psl+1),0.28571);
92         vcas=sqrt(7*psl/rhosl*(A-1)); 
93         veas=sqrt(2*qbar/rhosl);
94   } else {
95   }
96   return false;
97 }
98
99 void FGAuxiliary::GetState(void)
100 {
101         qbar=State->Getqbar();
102         mach=State->GetMach();
103         p=Atmosphere->GetPressure();
104         rhosl=Atmosphere->GetDensity(0);
105         psl=Atmosphere->GetPressure(0);
106 }       
107
108 void FGAuxiliary::PutState(void){}