Exemple #1
0
//=========================================================================
//  Update Temperature, pressure and density from altitude
//  NOTE:  Temperature is adjusted with the local conditions
//         if local condition say 20°C, then temperature is adusted 
//         by the delta (20 - 15) because 15°C is the standard temperature
//         at sea level;  We just make a (certainly) wrong supposition by 
//         saying that temperature is 5° higgher at all altitude
//=========================================================================
void CAtmosphereModelJSBSim::TimeSlice(float dt,double altitude)
{  //---Compute temperature and pressure -----------------------
  //  slot.U = slope
  //  slot.V = Temperature in Rankine
  //  slot.W = pressure (psf)
  C3valSlot *slot = stdATMOS.Getfloor(altitude);
  float slp  = slot->GetU();
  float rfT  = slot->GetV();
  float rfP  = slot->GetW();
  float da   = altitude - slot->GetX();
  float tp   = 0;
  float pr   = 0;
  float dn   = 0;
  //---Compute new targets ---------------------
  if (0 == slp)
  { tp = rfT;
    pr = rfP * exp(-pInertial->SLgravity()/(rfT*Reng)* da);
    dn = pr/ (Reng*tp);
  }
  else 
  { tp = rfT + (slp * da);
    pr = rfP * pow(float(tp/rfT),float(-pInertial->SLgravity()/(slp*Reng)));
    dn = pr/(Reng*tp);
  }
  //--- Get final values -----------------------------------------------
  tempR = tVAL.TimeSlice(dt);
  presS = pVAL.TimeSlice(dt);
  densD = dVAL.TimeSlice(dt);
  //--- Set Target value -----------------------------------------------
  tVAL.Set(tp);
  pVAL.Set(pr);
  dVAL.Set(dn);
  //---Update temperature to various units -----------------------------
  tempC   = RankineToCelsius(tempR) + dtaTC;
  tempF   = CelsiusToFahrenheit(tempC);
  //---Update pressure to various units --------------------------------
  presS  += dtaPS;                    // Add local deviation
  presH   = presS * PSF_TO_INHG;
  presB   = presS * PFS_TO_HPA;
  //--- Update sound speed ---------------------------------------------
  soundspeed = sqrt(SHRatio*Reng*(tempR));
  //--------------------------------------------------------------------
  // test others density
  //densD *= 10.0;
  //cout << "Atmosphere:  h=" << altitude << " rho= " << densD << endl;
//  #ifdef _DEBUG	
//	  FILE *fp_debug;
//	  if(!(fp_debug = fopen("__DDEBUG_atmosphere.txt", "a")) == NULL)
//	  {
//		  int test = 0;
//		  fprintf(fp_debug, "TPD = %f %f %f\n", tempR, presS, densD);
//		  fprintf(fp_debug, "TPD = %f %f %f\n",
//                              RankineToCelsius (tempR),
//                              presS * PSF_TO_INHG,
//                              densD);
//		  fclose(fp_debug); 
//	  }
//  #endif
}
Exemple #2
0
//=========================================================================
//  Update Temperature, pressure and density from altitude
//  NOTE:  Temperature is adjusted with the local conditions
//         if local condition say 20°C, then temperature is adusted 
//         by the delta (20 - 15) because 15°C is the standard temperature
//         at sea level;  We just make a (certainly) wrong supposition by 
//         saying that temperature is 5° higgher at all altitude
//=========================================================================
int CAtmosphereModelJSBSim::TimeSlice(float dt,U_INT frame)
{ double altitude = globals->geop.alt;
	//---Compute temperature and pressure -----------------------
  C3valSlot *slot = stdATMOS.Getfloor(altitude);
  float slp  = slot->GetU();
  float rfT  = slot->GetV();
  float rfP  = slot->GetW();
  float da   = altitude - slot->GetX();
  float tp   = 0;
  float pr   = 0;
  float dn   = 0;
  //---Compute new targets ---------------------
  if (0 == slp)
  { tp = rfT;
    pr = rfP * exp(-pInertial->SLgravity()/(rfT*Reng)* da);
    dn = pr/ (Reng*tp);
  }
  else 
  { tp = rfT + (slp * da);
    pr = rfP * pow(float(tp/rfT),float(-pInertial->SLgravity()/(slp*Reng)));
    dn = pr/(Reng*tp);
  }
  //--- Get final values -----------------------------------------------
  tempR = tVAL.TimeSlice(dt);
  presS = pVAL.TimeSlice(dt);
  densD = dVAL.TimeSlice(dt);
  //--- Set Target value -----------------------------------------------
  tVAL.Set(tp);
  pVAL.Set(pr);
  dVAL.Set(dn);
  //---Update temperature to various units -----------------------------
  tempC   = RankineToCelsius(tempR) + dtaTC;
  tempF   = CelsiusToFahrenheit(tempC);
  //---Update pressure to various units --------------------------------
  presS  += dtaPS;                    // Add local deviation
  presH   = presS * PSF_TO_INHG;
  presB   = presS * PFS_TO_HPA;
  //--- Update sound speed ---------------------------------------------
  soundspeed = sqrt(SHRatio*Reng*(tempR));
	return 1;
}