]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/atmosphere/FGMSIS.h
Merge branch 'work4' into next
[flightgear.git] / src / FDM / JSBSim / models / atmosphere / FGMSIS.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2  
3  Header:       FGMSIS.h
4  Description:  MSIS-00 Atmosphere
5  Author:       David Culp
6  Date started: 12/14/03
7  
8  ------------- Copyright (C) 2003  David P. Culp (davidculp2@comcast.net) ------
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 HISTORY
28 --------------------------------------------------------------------------------
29 12/14/03   DPC   Created
30 01/11/04   DPC   Derive from FGAtmosphere
31  
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 SENTRY
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
35
36 #ifndef FGMSIS_H
37 #define FGMSIS_H
38
39 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 INCLUDES
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42
43 #include "models/FGAtmosphere.h"
44 #include "FGFDMExec.h"
45
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 DEFINITIONS
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49
50 #define ID_MSIS "$Id: FGMSIS.h,v 1.7 2010/02/25 05:21:36 jberndt Exp $"
51
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 FORWARD DECLARATIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
56 namespace JSBSim {
57
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62 /** Models the MSIS-00 atmosphere.
63     This is a wrapper for the NRL-MSIS-00 model 2001:
64
65     This C++ format model wraps the NRLMSISE-00 C source code package - release
66     20020503
67  
68     The NRLMSISE-00 model was developed by Mike Picone, Alan Hedin, and
69     Doug Drob. They also wrote a NRLMSISE-00 distribution package in 
70     FORTRAN which is available at
71     http://uap-www.nrl.navy.mil/models_web/msis/msis_home.htm
72  
73     Dominik Brodowski implemented and maintains this C version. You can
74     reach him at devel@brodo.de. See the file "DOCUMENTATION" for details,
75     and check http://www.brodo.de/english/pub/nrlmsise/index.html for
76     updated releases of this package.
77     @author David Culp
78     @version $Id: FGMSIS.h,v 1.7 2010/02/25 05:21:36 jberndt Exp $
79 */
80
81 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 STRUCT DECLARATIONS
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
84
85 struct nrlmsise_flags {
86   int switches[24];
87   double sw[24];
88   double swc[24];
89 };
90
91 struct ap_array {
92   double a[7];   
93 };
94
95 struct nrlmsise_input {
96   int year;      /* year, currently ignored                           */
97   int doy;       /* day of year                                       */
98   double sec;    /* seconds in day (UT)                               */
99   double alt;    /* altitude in kilometers                            */
100   double g_lat;  /* geodetic latitude                                 */
101   double g_long; /* geodetic longitude                                */
102   double lst;    /* local apparent solar time (hours), see note below */
103   double f107A;  /* 81 day average of F10.7 flux (centered on DOY)    */
104   double f107;   /* daily F10.7 flux for previous day                 */
105   double ap;     /* magnetic index(daily)                             */
106   struct ap_array *ap_a; /* see above */
107 };
108
109 struct nrlmsise_output {
110   double d[9];   /* densities    */
111   double t[2];   /* temperatures */
112 };
113
114
115 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 CLASS DECLARATION
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
118
119 class MSIS : public FGAtmosphere
120 {
121 public:
122
123   /// Constructor
124   MSIS(FGFDMExec*);
125   /// Destructor
126   ~MSIS();
127   /** Runs the MSIS-00 atmosphere model; called by the Executive
128       @return false if no error */
129   bool Run(void);
130
131   bool InitModel(void);
132
133   /// Does nothing. External control is not allowed.
134   void UseExternal(void);
135
136 private:
137
138   void Calculate(int day,      // day of year (1 to 366) 
139                  double sec,   // seconds in day (0.0 to 86400.0)
140                  double alt,   // altitude, feet
141                  double lat,   // geodetic latitude, degrees
142                  double lon    // geodetic longitude, degrees
143                 );
144
145   void Debug(int from);
146
147   nrlmsise_flags flags;
148   nrlmsise_input input;
149   nrlmsise_output output;
150   ap_array aph;
151
152   /* PARMB */
153   double gsurf;
154   double re;
155
156   /* GTS3C */
157   double dd;
158
159   /* DMIX */
160   double dm04, dm16, dm28, dm32, dm40, dm01, dm14;
161
162   /* MESO7 */
163   double meso_tn1[5];
164   double meso_tn2[4];
165   double meso_tn3[5];
166   double meso_tgn1[2];
167   double meso_tgn2[2];
168   double meso_tgn3[2];
169
170   /* LPOLY */
171   double dfa;
172   double plg[4][9];
173   double ctloc, stloc;
174   double c2tloc, s2tloc;
175   double s3tloc, c3tloc;
176   double apdf, apt[4];
177
178   void tselec(struct nrlmsise_flags *flags);
179   void glatf(double lat, double *gv, double *reff);
180   double ccor(double alt, double r, double h1, double zh);
181   double ccor2(double alt, double r, double h1, double zh, double h2);
182   double scalh(double alt, double xm, double temp);
183   double dnet(double dd, double dm, double zhm, double xmm, double xm);
184   void splini(double *xa, double *ya, double *y2a, int n, double x, double *y);
185   void splint(double *xa, double *ya, double *y2a, int n, double x, double *y);
186   void spline(double *x, double *y, int n, double yp1, double ypn, double *y2);
187   double zeta(double zz, double zl);
188   double densm(double alt, double d0, double xm, double *tz, int mn3, double *zn3,
189                double *tn3, double *tgn3, int mn2, double *zn2, double *tn2,
190                double *tgn2);
191   double densu(double alt, double dlb, double tinf, double tlb, double xm, 
192                double alpha, double *tz, double zlb, double s2, int mn1, 
193                double *zn1, double *tn1, double *tgn1);
194   double g0(double a, double *p);
195   double sumex(double ex);
196   double sg0(double ex, double *p, double *ap);
197   double globe7(double *p, nrlmsise_input *input, nrlmsise_flags *flags);
198   double glob7s(double *p, nrlmsise_input *input, nrlmsise_flags *flags);
199   void gtd7(nrlmsise_input *input, nrlmsise_flags *flags, nrlmsise_output *output);
200   void gtd7d(nrlmsise_input *input, nrlmsise_flags *flags, nrlmsise_output *output); 
201   void ghp7(nrlmsise_input *input, nrlmsise_flags *flags, nrlmsise_output *output, double press);
202   void gts7(nrlmsise_input *input, nrlmsise_flags *flags, nrlmsise_output *output); 
203
204 };
205
206 } // namespace JSBSim
207
208 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209 #endif
210