1
0
Fork 0

Vivian Meazza:

The value of rho (air density) varies with height. (Including the upper
stratosphere, ust in case someone wants to model ICBMs.) The standard
atmosphere is used (based on a sea-level temperature of 15 deg C.).


Erik Hofman:
I moved this code over the AIBase::update() so all AIModels can make
use of rho, temperature, pressure, etc.
This commit is contained in:
ehofman 2004-09-22 19:11:36 +00:00
parent 82dfd908b7
commit e0e5b325cb
6 changed files with 35 additions and 12 deletions

View file

@ -27,7 +27,6 @@
#include "AIBallistic.hxx"
FGAIBallistic::FGAIBallistic(FGAIManager* mgr) {
manager = mgr;
_type_str = "ballistic";
@ -122,6 +121,7 @@ void FGAIBallistic::setWeight(double w) {
}
void FGAIBallistic::Run(double dt) {
life_timer += dt;
if (life_timer > life) setDie(true);
@ -130,7 +130,7 @@ void FGAIBallistic::Run(double dt) {
double wind_speed_from_north_deg_sec;
double wind_speed_from_east_deg_sec;
double mass;
// the drag calculations below assume sea-level density,
// rho = 0.023780 slugs/ft3
// calculate mass
@ -153,7 +153,7 @@ void FGAIBallistic::Run(double dt) {
speed_east_deg_sec = sin(hdg / SG_RADIANS_TO_DEGREES) * hs / ft_per_deg_lon;
// if wind not required, set to zero
if (!wind){
if (!wind) {
wind_from_north = 0;
wind_from_east = 0;
}

View file

@ -44,7 +44,7 @@
#include "AIManager.hxx"
const double FGAIBase::rho = 0.023780; // sea level air density slugs/ft3
const double FGAIBase::e = 2.71828183;
const double FGAIBase::lbs_to_slugs = 0.031080950172; //conversion factor
@ -80,6 +80,24 @@ FGAIBase::~FGAIBase() {
void FGAIBase::update(double dt) {
ft_per_deg_lat = 366468.96 - 3717.12 * cos(pos.lat()/SG_RADIANS_TO_DEGREES);
ft_per_deg_lon = 365228.16 * cos(pos.lat() / SG_RADIANS_TO_DEGREES);
// Calculate rho at altitude, using standard atmosphere
// For the temperature T and the pressure p,
if (altitude < 36152) { // curve fits for the troposphere
T = 59 - 0.00356 * altitude;
p = 2116 * pow( ((T + 459.7) / 518.6) , 5.256);
} else if ( 36152 < altitude < 82345 ) { // lower stratosphere
T = -70;
p = 473.1 * pow( e , 1.73 - (0.000048 * altitude) );
} else { // upper stratosphere
T = -205.05 + (0.00164 * altitude);
p = 51.97 * pow( ((T + 459.7) / 389.98) , -11.388);
}
rho = p / (1718 * (T + 459.7));
}

View file

@ -179,7 +179,10 @@ public:
double _getY_shift() const;
double _getRotation() const;
static const double rho;
double rho;
double T; // temperature, degs farenheit
double p; // pressure lbs/sq ft
static const double e;
static const double lbs_to_slugs;
int _getID() const;

View file

@ -90,7 +90,7 @@ void FGAIManager::update(double dt) {
if (!enabled)
return;
_dt = dt;
_dt = dt;
ai_list_itr = ai_list.begin();
while(ai_list_itr != ai_list.end()) {
@ -203,8 +203,8 @@ FGAIManager::createBallistic( FGAIModelEntity *entity ) {
ai_ballistic->setWind_from_north(entity->wind_from_north);
ai_ballistic->setWind(entity->wind);
ai_ballistic->setRoll(entity->roll);
ai_ballistic->setCd(entity->cd);
ai_ballistic->setWeight(entity->weight);
ai_ballistic->setCd(entity->cd);
ai_ballistic->setWeight(entity->weight);
ai_ballistic->init();
ai_ballistic->bind();
return ai_ballistic;
@ -214,7 +214,6 @@ void*
FGAIManager::createStorm( FGAIModelEntity *entity ) {
FGAIStorm* ai_storm = new FGAIStorm(this);
ai_list.push_back(ai_storm);
++numObjects[0];
++numObjects[FGAIBase::otStorm];
ai_storm->setHeading(entity->heading);
@ -225,6 +224,7 @@ FGAIManager::createStorm( FGAIModelEntity *entity ) {
ai_storm->setLatitude(entity->latitude);
ai_storm->init();
ai_storm->bind();
ai_list.push_back(ai_storm);
return ai_storm;
}
@ -232,7 +232,6 @@ void*
FGAIManager::createThermal( FGAIModelEntity *entity ) {
FGAIThermal* ai_thermal = new FGAIThermal(this);
ai_list.push_back(ai_thermal);
++numObjects[0];
++numObjects[FGAIBase::otThermal];
ai_thermal->setLongitude(entity->longitude);
@ -241,6 +240,7 @@ FGAIManager::createThermal( FGAIModelEntity *entity ) {
ai_thermal->setDiameter(entity->diameter / 6076.11549);
ai_thermal->init();
ai_thermal->bind();
ai_list.push_back(ai_thermal);
return ai_thermal;
}

View file

@ -78,7 +78,9 @@ public:
inline double get_user_yaw() { return user_yaw; }
inline double get_user_speed() {return user_speed; }
inline int getNum( FGAIBase::object_type ot ) { return numObjects[ot]; }
inline int getNum( FGAIBase::object_type ot ) {
return (0 < ot < FGAIBase::MAX_OBJECTS) ? numObjects[ot] : numObjects[0];
}
void processScenario( string filename );

View file

@ -36,7 +36,7 @@ SG_USING_STD(string);
FGAIStorm::FGAIStorm(FGAIManager* mgr) {
manager = mgr;
_type_str = "thunderstorm";
_type_str = "storm";
_otype = otStorm;
}