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