1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 Description: MSIS-00 Atmosphere
8 ------------- Copyright (C) 2003 David P. Culp (davidculp2@comcast.net) ------
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
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
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.
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.
28 --------------------------------------------------------------------------------
30 01/11/04 DPC Derive from FGAtmosphere
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 #include "models/FGAtmosphere.h"
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49 #define ID_MSIS "$Id$"
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 /** Models the MSIS-00 atmosphere.
62 This is a wrapper for the NRL-MSIS-00 model 2001:
64 This C++ format model wraps the NRLMSISE-00 C source code package - release
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
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.
80 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
84 struct nrlmsise_flags {
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 */
108 struct nrlmsise_output {
109 double d[9]; /* densities */
110 double t[2]; /* temperatures */
114 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
118 class MSIS : public FGAtmosphere
126 /** Runs the MSIS-00 atmosphere model; called by the Executive
127 @return false if no error */
130 bool InitModel(void);
132 /// Does nothing. External control is not allowed.
133 void UseExternal(void);
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
144 void Debug(int from);
146 nrlmsise_flags flags;
147 nrlmsise_input input;
148 nrlmsise_output output;
159 double dm04, dm16, dm28, dm32, dm40, dm01, dm14;
173 double c2tloc, s2tloc;
174 double s3tloc, c3tloc;
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,
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);
205 } // namespace JSBSim
207 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%