%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGMSIS.h"
-#include "FGState.h"
-#include <math.h> /* maths functions */
-#include <stdlib.h> /* for malloc/free */
-#include <stdio.h> /* for printf */
+#include "models/FGAuxiliary.h"
+#include <cmath> /* maths functions */
#include <iostream> // for cout, endl
+using namespace std;
+
namespace JSBSim {
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGMSIS.cpp,v 1.13 2010/02/25 05:21:36 jberndt Exp $";
static const char *IdHdr = ID_MSIS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MSIS::~MSIS()
{
- unbind();
Debug(1);
}
pressure = &intPressure;
density = &intDensity;
- useExternal=false;
+ UseInternal();
return true;
}
if (FGModel::Run()) return true;
if (FDMExec->Holding()) return false;
+ RunPreFunctions();
+
//do temp, pressure, and density first
if (!useExternal) {
// get sea-level values
// get at-altitude values
Calculate(Auxiliary->GetDayOfYear(),
Auxiliary->GetSecondsInDay(),
- Propagate->Geth(),
+ Propagate->GetAltitudeASL(),
Propagate->GetLocation().GetLatitudeDeg(),
Propagate->GetLocation().GetLongitudeDeg());
intTemperature = output.t[1] * 1.8;
intDensity = output.d[5] * 1.940321;
intPressure = 1716.488 * intDensity * intTemperature;
- soundspeed = sqrt(2403.0832 * intTemperature);
//cout << "T=" << intTemperature << " D=" << intDensity << " P=";
//cout << intPressure << " a=" << soundspeed << endl;
}
- if (turbType != ttNone) {
- Turbulence();
- vWindNED += vTurbulence;
- }
-
- if (vWindNED(1) != 0.0) psiw = atan2( vWindNED(2), vWindNED(1) );
+ CalculateDerived();
- if (psiw < 0) psiw += 2*M_PI;
+ RunPostFunctions();
Debug(2);
double ylog;
a = zhm / (xmm-xm);
if (!((dm>0) && (dd>0))) {
- printf("dnet log error %e %e %e\n",dm,dd,xm);
+ cerr << "dnet log error " << dm << ' ' << dd << ' ' << xm << ' ' << endl;
if ((dd==0) && (dm==0))
dd=1;
if (dm==0)
}
h = xa[khi] - xa[klo];
if (h==0.0)
- printf("bad XA input to splint");
+ cerr << "bad XA input to splint" << endl;
a = (xa[khi] - x)/h;
b = (x - xa[klo])/h;
yi = a * ya[klo] + b * ya[khi] + ((a*a*a - a) * y2a[klo] + (b*b*b - b) * y2a[khi]) * h * h/6.0;
double *u;
double sig, p, qn, un;
int i, k;
- u=(double*)malloc(sizeof(double)*n);
+ u=new double[n];
if (u==NULL) {
- printf("Out Of Memory in spline - ERROR");
+ cerr << "Out Of Memory in spline - ERROR" << endl;
return;
}
if (yp1>0.99E30) {
for (k=n-2;k>=0;k--)
y2[k] = y2[k] * y2[k+1] + u[k];
- free(u);
+ delete u;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (p[99]==0)
p[99]=pset;
if (p[99]!=pset) {
- printf("Wrong parameter set for glob7s\n");
+ cerr << "Wrong parameter set for glob7s" << endl;
return -1;
}
for (j=0;j<14;j++)
if (sqrt(diff*diff)<test)
return;
if (l==ltest) {
- printf("ERROR: ghp7 not converging for press %e, diff %e",press,diff);
+ cerr << "ERROR: ghp7 not converging for press " << press << ", diff " << diff << endl;
return;
}
xm = output->d[5] / xn / 1.66E-24;
}
if (debug_lvl & 32) { // Turbulence
if (first_pass && from == 2) {
- cout << "vTurbulence(X), vTurbulence(Y), vTurbulence(Z), "
+ cout << "vTurbulenceNED(X), vTurbulenceNED(Y), vTurbulenceNED(Z), "
<< "vTurbulenceGrad(X), vTurbulenceGrad(Y), vTurbulenceGrad(Z), "
<< "vDirection(X), vDirection(Y), vDirection(Z), "
<< "Magnitude, "
<< "vTurbPQR(P), vTurbPQR(Q), vTurbPQR(R), " << endl;
}
if (from == 2) {
- cout << vTurbulence << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl;
+ cout << vTurbulenceNED << ", " << vTurbulenceGrad << ", " << vDirection << ", " << Magnitude << ", " << vTurbPQR << endl;
}
}
if (debug_lvl & 64) {