// McCormick lists 299.16/101325/1.22500, but those don't agree with
// R=287. I chose to correct the temperature to 288.20, since 79F is
// pretty hot for a "standard" atmosphere.
-// meters kelvin kPa kg/m^3
+// meters kelvin Pa kg/m^3
float Atmosphere::data[][4] = {{ 0, 288.20, 101325, 1.22500 },
{ 900, 282.31, 90971, 1.12260 },
{ 1800, 276.46, 81494, 1.02690 },
{ 18000, 216.66, 7565, 0.12165 },
{ 18900, 216.66, 6570, 0.10564 }};
+// Universal gas constant for air, in SI units. P = R * rho * T.
+// P in pascals (N/m^2), rho is kg/m^3, T in kelvin.
+const float R = 287.1;
+
+// Specific heat ratio for air, at "low" temperatures.
+const float GAMMA = 1.4;
+
float Atmosphere::getStdTemperature(float alt)
{
return getRecord(alt, 1);
float Atmosphere::calcVEAS(float spd, float pressure, float temp)
{
- return 0; //FIXME
+ static float rho0 = getStdDensity(0);
+ float densityRatio = calcDensity(pressure, temp) / rho0;
+ return spd * Math::sqrt(densityRatio);
}
float Atmosphere::calcVCAS(float spd, float pressure, float temp)
float Atmosphere::calcDensity(float pressure, float temp)
{
- // P = rho*R*T, R == 287 kPa*m^3 per kg*kelvin for air
- return pressure / (287 * temp);
+ return pressure / (R * temp);
}
float Atmosphere::calcMach(float spd, float temp)
{
- return spd / Math::sqrt(1.4 * 287 * temp);
+ return spd / Math::sqrt(GAMMA * R * temp);
+}
+
+void Atmosphere::calcStaticAir(float p0, float t0, float d0, float v,
+ float* pOut, float* tOut, float* dOut)
+{
+ const static float C0 = ((GAMMA-1)/(2*R*GAMMA));
+ const static float C1 = 1/(GAMMA-1);
+
+ *tOut = t0 + (v*v) * C0;
+ *dOut = d0 * Math::pow(*tOut / t0, C1);
+ *pOut = (*dOut) * R * (*tOut);
}
float Atmosphere::getRecord(float alt, int recNum)