]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBsim/FGAtmosphere.cpp
source tree reorganization prior to flightgear 0.7
[flightgear.git] / src / FDM / JSBsim / FGAtmosphere.cpp
1 /*******************************************************************************
2
3  Module:       FGAtmosphere.cpp
4  Author:       Jon Berndt
5  Date started: 11/24/98
6  Purpose:      Models the atmosphere
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 Models the atmosphere. The equation used below was determined by a third order
31 curve fit using Excel. The data is from the ICAO atmosphere model.
32
33 HISTORY
34 --------------------------------------------------------------------------------
35 11/24/98   JSB   Created
36
37 ********************************************************************************
38 INCLUDES
39 *******************************************************************************/
40
41 #include "FGAtmosphere.h"
42 #include "FGState.h"
43 #include "FGFDMExec.h"
44 #include "FGFCS.h"
45 #include "FGAircraft.h"
46 #include "FGTranslation.h"
47 #include "FGRotation.h"
48 #include "FGPosition.h"
49 #include "FGAuxiliary.h"
50 #include "FGOutput.h"
51
52 /*******************************************************************************
53 ************************************ CODE **************************************
54 *******************************************************************************/
55
56 FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
57 {
58   Name = "FGAtmosphere";
59 }
60
61
62 FGAtmosphere::~FGAtmosphere()
63 {
64 }
65
66
67 bool FGAtmosphere::Run(void)
68 {
69   if (!FGModel::Run()) {                 // if false then execute this Run()
70     rho = 0.002377 - 7.0E-08*State->Geth()
71         + 7.0E-13*State->Geth()*State->Geth()
72         - 2.0E-18*State->Geth()*State->Geth()*State->Geth();
73
74     State->SetMach(State->GetVt()/State->Geta());
75   } else {                               // skip Run() execution this time
76   }
77   return false;
78 }
79
80 float FGAtmosphere::CalcRho(float altitude)
81 {
82   return (0.002377 - 7.0E-08*altitude
83         + 7.0E-13*altitude*altitude
84         - 2.0E-18*altitude*altitude*altitude);
85
86 }
87