1
0
Fork 0

Jan 11, 2000 changes from Jon.

This commit is contained in:
curt 2000-01-11 17:26:43 +00:00
parent 6e14da1e16
commit 0e1c43e8e5
3 changed files with 46 additions and 50 deletions

View file

@ -67,7 +67,11 @@ FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
Name = "FGAtmosphere"; Name = "FGAtmosphere";
h = 0; h = 0;
Calculate(); Calculate(h);
temperature = T;
pressure = p;
density = rho;
soundspeed = a;
} }
@ -80,7 +84,13 @@ bool FGAtmosphere::Run(void)
{ {
if (!FGModel::Run()) { // if false then execute this Run() if (!FGModel::Run()) { // if false then execute this Run()
h = State->Geth(); h = State->Geth();
Calculate();
Calculate(h);
temperature = T;
pressure = p;
density = rhos;
soundspeed = a;
State->Seta(soundspeed); State->Seta(soundspeed);
} else { // skip Run() execution this time } else { // skip Run() execution this time
} }
@ -90,13 +100,14 @@ bool FGAtmosphere::Run(void)
float FGAtmosphere::CalcRho(float altitude) float FGAtmosphere::CalcRho(float altitude)
{ {
return (0.00237 - 7.0E-08*altitude //return (0.00237 - 7.0E-08*altitude
+ 7.0E-13*altitude*altitude // + 7.0E-13*altitude*altitude
- 2.0E-18*altitude*altitude*altitude); // - 2.0E-18*altitude*altitude*altitude);
return GetDensity(altitude);
} }
void FGAtmosphere::Calculate(void) void FGAtmosphere::Calculate(float altitude)
{ {
//see reference [1] //see reference [1]
@ -104,13 +115,13 @@ void FGAtmosphere::Calculate(void)
int i=0; int i=0;
float htab[]={0,36089,82020,154198,173882,259183,295272,344484}; //ft. float htab[]={0,36089,82020,154198,173882,259183,295272,344484}; //ft.
if (h <= htab[0]) { if (altitude <= htab[0]) {
h=0; altitude=0;
} else if (h >= htab[7]){ } else if (altitude >= htab[7]){
i = 7; i = 7;
h = htab[7]; altitude = htab[7];
} else { } else {
while (htab[i+1] < h) { while (htab[i+1] < altitude) {
i++; i++;
} }
} }
@ -168,58 +179,43 @@ void FGAtmosphere::Calculate(void)
if (slope == 0) { if (slope == 0) {
temperature = reftemp; T = reftemp;
pressure = refpress*exp(-GRAVITY/(reftemp*Reng)*(h-htab[i])); p = refpress*exp(-GRAVITY/(reftemp*Reng)*(altitude-htab[i]));
density = refdens*exp(-GRAVITY/(reftemp*Reng)*(h-htab[i])); rhos = refdens*exp(-GRAVITY/(reftemp*Reng)*(altitude-htab[i]));
} else { } else {
temperature = reftemp+slope*(h-htab[i]); T = reftemp+slope*(altitude-htab[i]);
pressure = refpress*pow(temperature/reftemp,-GRAVITY/(slope*Reng)); p = refpress*pow(T/reftemp,-GRAVITY/(slope*Reng));
density = refdens*pow(temperature/reftemp,-(GRAVITY/(slope*Reng)+1)); rhos = refdens*pow(T/reftemp,-(GRAVITY/(slope*Reng)+1));
} }
soundspeed = sqrt(SHRATIO*Reng*temperature); a = sqrt(SHRATIO*Reng*T);
} }
float FGAtmosphere::GetTemperature(float altitude) float FGAtmosphere::GetTemperature(float altitude)
{ {
if (altitude != h) { Calculate(altitude);
h = altitude; return T;
Calculate();
}
return temperature;
} }
float FGAtmosphere::GetPressure(float altitude) float FGAtmosphere::GetPressure(float altitude)
{ {
if (altitude != h) { Calculate(altitude);
h = altitude; return p;
Calculate();
}
return pressure;
} }
float FGAtmosphere::GetDensity(float altitude) float FGAtmosphere::GetDensity(float altitude)
{ {
if (altitude != h) { Calculate(altitude);
h = altitude; return rhos;
Calculate();
}
return density;
} }
float FGAtmosphere::GetSoundSpeed(float altitude) float FGAtmosphere::GetSoundSpeed(float altitude)
{ {
if (altitude != h) { Calculate(altitude);
h = altitude; return a;
Calculate();
}
return soundspeed;
} }

View file

@ -66,7 +66,7 @@ public:
~FGAtmosphere(void); ~FGAtmosphere(void);
bool Run(void); bool Run(void);
inline float Getrho(void) {return rho;} inline float Getrho(void) {return density;}
float CalcRho(float altitude); float CalcRho(float altitude);
inline float GetTemperature(void){return temperature;} inline float GetTemperature(void){return temperature;}
@ -85,11 +85,11 @@ private:
float rho; float rho;
float h; float h;
float temperature; float temperature,T;
float pressure; float pressure,p;
float density; float density,rhos;
float soundspeed; float soundspeed,a;
void Calculate(void); void Calculate(float altitude);
}; };

View file

@ -59,9 +59,9 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
Name = "FGOutput"; Name = "FGOutput";
sFirstPass = dFirstPass = true; sFirstPass = dFirstPass = true;
socket = 0; socket = 0;
//#ifdef FG_WITH_JSBSIM_SOCKET #ifdef FG_WITH_JSBSIM_SOCKET
socket = new FGfdmSocket("localhost",1138); socket = new FGfdmSocket("localhost",1138);
//#endif #endif
} }