63#include "input_output/FGLog.h"
78 for(
unsigned int i=0; i<24; ++i)
79 flags.switches[i] = 1;
100 FGStandardAtmosphere::InitModel();
111 if (!
Upload(el,
true))
return false;
129 Compute(0.0, SLpressure, SLtemperature, SLdensity, SLRair);
130 Compute(altitude, Pressure, Temperature, Density, Reng);
132 SLsoundspeed = sqrt(SHRatio*SLRair*SLtemperature);
133 Soundspeed = sqrt(SHRatio*Reng*Temperature);
137 Viscosity = Beta * pow(Temperature, 1.5) / (SutherlandConstant + Temperature);
138 KinematicViscosity = Viscosity / Density;
145void FGMSIS::Compute(
double altitude,
double& pressure,
double& temperature,
146 double& density,
double &Rair)
const
148 constexpr double fttokm = fttom / 1000.;
149 constexpr double kgm3_to_slugft3 = kgtoslug / m3toft3;
150 constexpr double gtoslug = kgtoslug / 1000.;
153 const double species_mmol[8] {28.0134, 31.9988, 31.9988/2.0, 4.0, 1.0, 39.948,
154 28.0134/2.0, 31.9988/2.0};
156 double dn[10] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
157 double h = altitude*fttokm;
158 double lat = in.GeodLatitudeDeg;
159 double lon = in.LongitudeDeg;
162 double utc_seconds = seconds_in_day + FDMExec->
GetSimTime();
163 unsigned int days = utc_seconds / 86400.;
164 utc_seconds -= days * 86400.;
165 double today = day_of_year + days;
166 unsigned int year = today / 365.;
167 today -= year * 365.;
169 struct nrlmsise_output output;
172 input.sec = utc_seconds;
176 input.lst = utc_seconds/3600 + lon/15;
177 assert(flags.switches[9] != -1);
179 gtd7(&input, &flags, &output);
182 density = output.d[5] * kgm3_to_slugft3;
196 double qty_mol = 0.0;
198 for (
unsigned int i=1; i<9; ++i) {
199 mmol += dn[i]*species_mmol[i-1];
202 double mair = mmol * gtoslug / qty_mol;
205 pressure = density * Rair * temperature;
227void FGMSIS::Debug(
int from)
229 if (debug_lvl <= 0)
return;
234 FGLogging log(LogLevel::DEBUG);
235 log <<
" NRLMSIS atmosphere model\n" << fixed;
236 log <<
" day: " << day_of_year <<
"\n";
237 log <<
" UTC: " << seconds_in_day <<
"\n\n";
240 if (debug_lvl & 2 ) {
241 FGLogging log(LogLevel::DEBUG);
242 if (from == 0) log <<
"Instantiated: MSIS\n";
243 if (from == 1) log <<
"Destroyed: MSIS\n";
245 if (debug_lvl & 4 ) {
247 if (debug_lvl & 8 ) {
249 if (debug_lvl & 16) {
251 if (debug_lvl & 128) {
253 if (debug_lvl & 64) {
Element * FindElement(const std::string &el="")
Searches for a specified element.
double FindElementValueAsNumber(const std::string &el="")
Searches for the named element and returns the data belonging to it as a number.
static constexpr double Rstar
Universal gas constant - ft*lbf/R/mol.
Encapsulates the JSBSim simulation executive.
double GetSimTime(void) const
Returns the cumulative simulation time in seconds.
static constexpr double KelvinToRankine(double kelvin)
Converts from degrees Kelvin to degrees Rankine.
void Calculate(double altitude) override
Calculate the atmosphere for the given altitude.
bool InitModel(void) override
Runs the MSIS-00 atmosphere model; called by the Executive Can pass in a value indicating if the exec...
FGMSIS(FGFDMExec *)
Constructor.
bool Upload(Element *el, bool preLoad)
Uploads this model in memory.
double CalculateDensityAltitude(double density, double geometricAlt) override
Calculates the density altitude given any temperature or pressure bias.
double CalculatePressureAltitude(double pressure, double geometricAlt) override
Calculates the pressure altitude given any temperature or pressure bias.
Main namespace for the JSBSim Flight Dynamics Model.