Sync'ed JSBSim
- Now all the sea level properties from the standard atmosphere are updated along with the other atmosphere properties. - The properties propulsion/start_cmd and propulsion/cutoff_cmd are now read/write (they were read only before).
This commit is contained in:
parent
7178b3ef6a
commit
64f3c1d3b6
8 changed files with 104 additions and 39 deletions
|
@ -94,12 +94,7 @@ bool FGAtmosphere::InitModel(void)
|
|||
SLtemperature = Temperature = 518.67;
|
||||
SLpressure = Pressure = 2116.228;
|
||||
SLdensity = Density = Pressure/(Reng*Temperature);
|
||||
SLsoundspeed = Soundspeed = sqrt(SHRatio*Reng*(Temperature));
|
||||
|
||||
rSLtemperature = 1/SLtemperature ;
|
||||
rSLpressure = 1/SLpressure ;
|
||||
rSLdensity = 1/SLdensity ;
|
||||
rSLsoundspeed = 1/SLsoundspeed ;
|
||||
SLsoundspeed = Soundspeed = sqrt(SHRatio*Reng*Temperature);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -137,7 +132,7 @@ void FGAtmosphere::Calculate(double altitude)
|
|||
else
|
||||
Density = node->GetDouble("atmosphere/override/density");
|
||||
|
||||
Soundspeed = sqrt(SHRatio*Reng*(Temperature));
|
||||
Soundspeed = sqrt(SHRatio*Reng*Temperature);
|
||||
PressureAltitude = CalculatePressureAltitude(Pressure, altitude);
|
||||
DensityAltitude = CalculateDensityAltitude(Density, altitude);
|
||||
|
||||
|
|
|
@ -116,15 +116,15 @@ public:
|
|||
|
||||
/// Returns the actual, modeled sea level temperature in degrees Rankine.
|
||||
/// @return The modeled temperature in degrees Rankine at sea level.
|
||||
virtual double GetTemperatureSL() const { return GetTemperature(0.0); }
|
||||
virtual double GetTemperatureSL() const { return SLtemperature; }
|
||||
|
||||
/// Returns the ratio of the at-current-altitude temperature as modeled
|
||||
/// over the sea level value.
|
||||
virtual double GetTemperatureRatio() const { return GetTemperature()*rSLtemperature; }
|
||||
virtual double GetTemperatureRatio() const { return GetTemperature()/SLtemperature; }
|
||||
|
||||
/// Returns the ratio of the temperature as modeled at the supplied altitude
|
||||
/// over the sea level value.
|
||||
virtual double GetTemperatureRatio(double h) const { return GetTemperature(h)*rSLtemperature; }
|
||||
virtual double GetTemperatureRatio(double h) const { return GetTemperature(h)/SLtemperature; }
|
||||
|
||||
/// Sets the Sea Level temperature.
|
||||
/// @param t the temperature value in the unit provided.
|
||||
|
@ -151,7 +151,7 @@ public:
|
|||
virtual double GetPressureSL(ePressure to=ePSF) const { return ConvertFromPSF(SLpressure, to); }
|
||||
|
||||
/// Returns the ratio of at-altitude pressure over the sea level value.
|
||||
virtual double GetPressureRatio(void) const { return Pressure*rSLpressure; }
|
||||
virtual double GetPressureRatio(void) const { return Pressure/SLpressure; }
|
||||
|
||||
/** Sets the sea level pressure for modeling.
|
||||
@param pressure The pressure in the units specified.
|
||||
|
@ -174,7 +174,7 @@ public:
|
|||
virtual double GetDensitySL(void) const { return SLdensity; }
|
||||
|
||||
/// Returns the ratio of at-altitude density over the sea level value.
|
||||
virtual double GetDensityRatio(void) const { return Density*rSLdensity; }
|
||||
virtual double GetDensityRatio(void) const { return Density/SLdensity; }
|
||||
//@}
|
||||
|
||||
// *************************************************************************
|
||||
|
@ -190,7 +190,7 @@ public:
|
|||
virtual double GetSoundSpeedSL(void) const { return SLsoundspeed; }
|
||||
|
||||
/// Returns the ratio of at-altitude sound speed over the sea level value.
|
||||
virtual double GetSoundSpeedRatio(void) const { return Soundspeed*rSLsoundspeed; }
|
||||
virtual double GetSoundSpeedRatio(void) const { return Soundspeed/SLsoundspeed; }
|
||||
//@}
|
||||
|
||||
// *************************************************************************
|
||||
|
@ -214,7 +214,6 @@ public:
|
|||
protected:
|
||||
double SLtemperature, SLdensity, SLpressure, SLsoundspeed; // Sea level conditions
|
||||
double Temperature, Density, Pressure, Soundspeed; // Current actual conditions at altitude
|
||||
double rSLtemperature, rSLdensity, rSLpressure, rSLsoundspeed; // Reciprocal of sea level conditions
|
||||
|
||||
double PressureAltitude;
|
||||
double DensityAltitude;
|
||||
|
|
|
@ -636,6 +636,21 @@ void FGPropulsion::SetStarter(int setting)
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
int FGPropulsion::GetStarter(void) const
|
||||
{
|
||||
if (ActiveEngine < 0) {
|
||||
bool starter = true;
|
||||
|
||||
for (unsigned i=0; i<Engines.size(); i++)
|
||||
starter &= Engines[i]->GetStarter();
|
||||
|
||||
return starter ? 1 : 0;
|
||||
} else
|
||||
return Engines[ActiveEngine]->GetStarter() ? 1: 0;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGPropulsion::SetCutoff(int setting)
|
||||
{
|
||||
bool bsetting = setting == 0 ? false : true;
|
||||
|
@ -669,6 +684,42 @@ void FGPropulsion::SetCutoff(int setting)
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
int FGPropulsion::GetCutoff(void) const
|
||||
{
|
||||
if (ActiveEngine < 0) {
|
||||
bool cutoff = true;
|
||||
|
||||
for (unsigned i=0; i<Engines.size(); i++) {
|
||||
switch (Engines[i]->GetType()) {
|
||||
case FGEngine::etTurbine:
|
||||
cutoff &= ((FGTurbine*)Engines[i])->GetCutoff();
|
||||
break;
|
||||
case FGEngine::etTurboprop:
|
||||
cutoff &= ((FGTurboProp*)Engines[i])->GetCutoff();
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return cutoff ? 1 : 0;
|
||||
} else {
|
||||
switch (Engines[ActiveEngine]->GetType()) {
|
||||
case FGEngine::etTurbine:
|
||||
return ((FGTurbine*)Engines[ActiveEngine])->GetCutoff() ? 1 : 0;
|
||||
case FGEngine::etTurboprop:
|
||||
return ((FGTurboProp*)Engines[ActiveEngine])->GetCutoff() ? 1 : 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGPropulsion::SetActiveEngine(int engine)
|
||||
{
|
||||
if (engine >= (int)Engines.size() || engine < 0)
|
||||
|
@ -760,12 +811,12 @@ void FGPropulsion::bind(void)
|
|||
IsBound = true;
|
||||
PropertyManager->Tie("propulsion/set-running", this, (iPMF)0, &FGPropulsion::InitRunning, false);
|
||||
if (HaveTurbineEngine || HaveTurboPropEngine) {
|
||||
PropertyManager->Tie("propulsion/starter_cmd", this, (iPMF)0, &FGPropulsion::SetStarter, false);
|
||||
PropertyManager->Tie("propulsion/cutoff_cmd", this, (iPMF)0, &FGPropulsion::SetCutoff, false);
|
||||
PropertyManager->Tie("propulsion/starter_cmd", this, &FGPropulsion::GetStarter, &FGPropulsion::SetStarter);
|
||||
PropertyManager->Tie("propulsion/cutoff_cmd", this, &FGPropulsion::GetCutoff, &FGPropulsion::SetCutoff);
|
||||
}
|
||||
|
||||
if (HavePistonEngine) {
|
||||
PropertyManager->Tie("propulsion/starter_cmd", this, (iPMF)0, &FGPropulsion::SetStarter, false);
|
||||
PropertyManager->Tie("propulsion/starter_cmd", this, &FGPropulsion::GetStarter, &FGPropulsion::SetStarter);
|
||||
PropertyManager->Tie("propulsion/magneto_cmd", this, (iPMF)0, &FGPropulsion::SetMagnetos, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,9 @@ public:
|
|||
|
||||
void SetMagnetos(int setting);
|
||||
void SetStarter(int setting);
|
||||
int GetStarter(void) const;
|
||||
void SetCutoff(int setting=0);
|
||||
int GetCutoff(void) const;
|
||||
void SetActiveEngine(int engine);
|
||||
void SetFuelFreeze(bool f);
|
||||
const FGMatrix33& CalculateTankInertias(void);
|
||||
|
|
|
@ -143,10 +143,6 @@ bool MSIS::InitModel(void)
|
|||
// SLpressure = intPressure = 2116.7;
|
||||
// SLdensity = intDensity = 0.002378;
|
||||
// SLsoundspeed = sqrt(2403.0832 * SLtemperature);
|
||||
// rSLtemperature = 1.0/intTemperature;
|
||||
// rSLpressure = 1.0/intPressure;
|
||||
// rSLdensity = 1.0/intDensity;
|
||||
// rSLsoundspeed = 1.0/SLsoundspeed;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -172,10 +168,6 @@ bool MSIS::Run(bool Holding)
|
|||
SLdensity = output.d[5] * 1.940321;
|
||||
SLpressure = 1716.488 * SLdensity * SLtemperature;
|
||||
SLsoundspeed = sqrt(2403.0832 * SLtemperature);
|
||||
rSLtemperature = 1.0/SLtemperature;
|
||||
rSLpressure = 1.0/SLpressure;
|
||||
rSLdensity = 1.0/SLdensity;
|
||||
rSLsoundspeed = 1.0/SLsoundspeed;
|
||||
|
||||
// get at-altitude values
|
||||
Calculate(FDMExec->GetAuxiliary()->GetDayOfYear(),
|
||||
|
|
|
@ -146,11 +146,6 @@ bool FGStandardAtmosphere::InitModel(void)
|
|||
|
||||
StdSLsoundspeed = SLsoundspeed = Soundspeed;
|
||||
|
||||
rSLtemperature = 1/SLtemperature ;
|
||||
rSLpressure = 1/SLpressure ;
|
||||
rSLdensity = 1/SLdensity ;
|
||||
rSLsoundspeed = 1/SLsoundspeed ;
|
||||
|
||||
// PrintStandardAtmosphereTable();
|
||||
|
||||
return true;
|
||||
|
@ -211,11 +206,19 @@ void FGStandardAtmosphere::SetPressureSL(ePressure unit, double pressure)
|
|||
{
|
||||
double press = ConvertToPSF(pressure, unit);
|
||||
|
||||
PressureBreakpoints[0] = press;
|
||||
SLpressure = PressureBreakpoints[0];
|
||||
SLpressure = press;
|
||||
CalculateSLDensity();
|
||||
CalculatePressureBreakpoints();
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGStandardAtmosphere::CalculateSLSoundSpeedAndDensity(void)
|
||||
{
|
||||
SLsoundspeed = sqrt(SHRatio*Reng*SLtemperature);
|
||||
CalculateSLDensity();
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
// Get the modeled temperature at a specified altitude, including any bias or gradient
|
||||
// effects.
|
||||
|
@ -349,6 +352,9 @@ void FGStandardAtmosphere::SetTemperature(double t, double h, eTemperature unit)
|
|||
TemperatureBias -= TemperatureDeltaGradient * (GradientFadeoutAltitude - GeoPotAlt);
|
||||
|
||||
CalculatePressureBreakpoints();
|
||||
|
||||
SLtemperature = GetTemperature(0.0);
|
||||
CalculateSLSoundSpeedAndDensity();
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -360,6 +366,9 @@ void FGStandardAtmosphere::SetTemperatureBias(eTemperature unit, double t)
|
|||
|
||||
TemperatureBias = t;
|
||||
CalculatePressureBreakpoints();
|
||||
|
||||
SLtemperature = GetTemperature(0.0);
|
||||
CalculateSLSoundSpeedAndDensity();
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -396,6 +405,9 @@ void FGStandardAtmosphere::SetTemperatureGradedDelta(double deltemp, double h, e
|
|||
TemperatureDeltaGradient = deltemp/(GradientFadeoutAltitude - GeopotentialAltitude(h));
|
||||
CalculateLapseRates();
|
||||
CalculatePressureBreakpoints();
|
||||
|
||||
SLtemperature = GetTemperature(0.0);
|
||||
CalculateSLSoundSpeedAndDensity();
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -443,6 +455,8 @@ void FGStandardAtmosphere::CalculateLapseRates()
|
|||
|
||||
void FGStandardAtmosphere::CalculatePressureBreakpoints()
|
||||
{
|
||||
PressureBreakpoints[0] = SLpressure;
|
||||
|
||||
for (unsigned int b=0; b<PressureBreakpoints.size()-1; b++) {
|
||||
double BaseTemp = StdAtmosTemperatureTable(b+1,1);
|
||||
double BaseAlt = StdAtmosTemperatureTable(b+1,0);
|
||||
|
@ -469,13 +483,17 @@ void FGStandardAtmosphere::ResetSLTemperature()
|
|||
TemperatureBias = TemperatureDeltaGradient = 0.0;
|
||||
CalculateLapseRates();
|
||||
CalculatePressureBreakpoints();
|
||||
|
||||
SLtemperature = StdSLtemperature;
|
||||
CalculateSLSoundSpeedAndDensity();
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGStandardAtmosphere::ResetSLPressure()
|
||||
{
|
||||
PressureBreakpoints[0] = StdSLpressure; // psf
|
||||
SLpressure = StdSLpressure;
|
||||
CalculateSLDensity();
|
||||
CalculatePressureBreakpoints();
|
||||
}
|
||||
|
||||
|
@ -484,10 +502,9 @@ void FGStandardAtmosphere::ResetSLPressure()
|
|||
void FGStandardAtmosphere::CalculateStdDensityBreakpoints()
|
||||
{
|
||||
StdDensityBreakpoints.clear();
|
||||
for (unsigned int i = 0; i < StdPressureBreakpoints.size(); i++) {
|
||||
for (unsigned int i = 0; i < StdPressureBreakpoints.size(); i++)
|
||||
StdDensityBreakpoints.push_back(StdPressureBreakpoints[i] / (Reng * StdAtmosTemperatureTable(i + 1, 1)));
|
||||
}
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
|
|
@ -125,11 +125,11 @@ public:
|
|||
|
||||
/// Returns the standard sea level temperature in degrees Rankine.
|
||||
/// @return The STANDARD temperature at sea level in degrees Rankine.
|
||||
virtual double GetStdTemperatureSL() const { return GetStdTemperature(0.0); }
|
||||
virtual double GetStdTemperatureSL() const { return StdSLtemperature; }
|
||||
|
||||
/// Returns the ratio of the standard temperature at the supplied altitude
|
||||
/// over the standard sea level temperature.
|
||||
virtual double GetStdTemperatureRatio(double h) const { return GetStdTemperature(h)*rSLtemperature; }
|
||||
virtual double GetStdTemperatureRatio(double h) const { return GetStdTemperature(h)/StdSLtemperature; }
|
||||
|
||||
/// Returns the temperature bias over the sea level value in degrees Rankine.
|
||||
virtual double GetTemperatureBias(eTemperature to) const
|
||||
|
@ -329,6 +329,12 @@ protected:
|
|||
/// Calculate the pressure of water vapor with the Magnus formula.
|
||||
double CalculateVaporPressure(double temperature);
|
||||
|
||||
/// Calculate the SL density
|
||||
void CalculateSLDensity(void) { SLdensity = SLpressure / (Reng * SLtemperature); }
|
||||
|
||||
/// Calculate the SL density and sound speed
|
||||
void CalculateSLSoundSpeedAndDensity(void);
|
||||
|
||||
virtual void bind(void);
|
||||
void Debug(int from);
|
||||
|
||||
|
|
|
@ -255,7 +255,10 @@ double FGPropeller::Calculate(double EnginePower)
|
|||
double tangentialVel = localAeroVel.Magnitude(eV, eW);
|
||||
|
||||
if (tangentialVel > 0.0001) {
|
||||
double angle = atan2(tangentialVel, localAeroVel(eU) + Vinduced);
|
||||
// The angle made locally by the air flow with respect to the propeller
|
||||
// axis is influenced by the induced velocity. This attenuates the
|
||||
// influence of a string cross wind and gives a more realistic behavior.
|
||||
double angle = atan2(tangentialVel, Vel+Vinduced);
|
||||
double factor = Sense * P_Factor * angle / tangentialVel;
|
||||
SetActingLocationY( GetLocationY() + factor * localAeroVel(eW));
|
||||
SetActingLocationZ( GetLocationZ() + factor * localAeroVel(eV));
|
||||
|
|
Loading…
Reference in a new issue