Piston engine oil temperature model from David Luff:
Attached is a patch to add oil temperature to the YASim piston engine model. This brings to life one of the pa28-161's otherwise 'dead' guages. It's a pretty simple 'model' based on temperatures and warmup times I've observed in the labs on auto engines and run through my dodgy-memory filter. It does the job of populating the guage with something plausible though.
This commit is contained in:
parent
37b9a23122
commit
76f4bc1cef
4 changed files with 47 additions and 5 deletions
|
@ -529,6 +529,8 @@ void FGFDM::setOutputProperties(float dt)
|
||||||
node->setFloatValue("mp-inhg", pe->getMP() * (1/INHG2PA));
|
node->setFloatValue("mp-inhg", pe->getMP() * (1/INHG2PA));
|
||||||
node->setFloatValue("egt-degf",
|
node->setFloatValue("egt-degf",
|
||||||
pe->getEGT() * K2DEGF + K2DEGFOFFSET);
|
pe->getEGT() * K2DEGF + K2DEGFOFFSET);
|
||||||
|
node->setFloatValue("oil-temperature-degf",
|
||||||
|
pe->getOilTemp() * K2DEGF + K2DEGFOFFSET);
|
||||||
node->setFloatValue("boost-gauge-inhg",
|
node->setFloatValue("boost-gauge-inhg",
|
||||||
pe->getBoost() * (1/INHG2PA));
|
pe->getBoost() * (1/INHG2PA));
|
||||||
} else if(p->getEngine()->isTurbineEngine()) {
|
} else if(p->getEngine()->isTurbineEngine()) {
|
||||||
|
|
|
@ -13,6 +13,10 @@ PistonEngine::PistonEngine(float power, float speed)
|
||||||
_running = false;
|
_running = false;
|
||||||
_fuel = true;
|
_fuel = true;
|
||||||
_boostPressure = 0;
|
_boostPressure = 0;
|
||||||
|
|
||||||
|
_oilTemp = Atmosphere::getStdTemperature(0);
|
||||||
|
_oilTempTarget = _oilTemp;
|
||||||
|
_dOilTempdt = 0;
|
||||||
|
|
||||||
// Presume a BSFC (in lb/hour per HP) of 0.45. In SI that becomes
|
// Presume a BSFC (in lb/hour per HP) of 0.45. In SI that becomes
|
||||||
// (2.2 lb/kg, 745.7 W/hp, 3600 sec/hour) 7.62e-08 kg/Ws.
|
// (2.2 lb/kg, 745.7 W/hp, 3600 sec/hour) 7.62e-08 kg/Ws.
|
||||||
|
@ -93,6 +97,16 @@ float PistonEngine::getEGT()
|
||||||
return _egt;
|
return _egt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PistonEngine::stabilize()
|
||||||
|
{
|
||||||
|
_oilTemp = _oilTempTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PistonEngine::integrate(float dt)
|
||||||
|
{
|
||||||
|
_oilTemp += (_dOilTempdt * dt);
|
||||||
|
}
|
||||||
|
|
||||||
void PistonEngine::calc(float pressure, float temp, float speed)
|
void PistonEngine::calc(float pressure, float temp, float speed)
|
||||||
{
|
{
|
||||||
if(_magnetos == 0 || speed < 60*RPM2RADPS)
|
if(_magnetos == 0 || speed < 60*RPM2RADPS)
|
||||||
|
@ -208,12 +222,31 @@ void PistonEngine::calc(float pressure, float temp, float speed)
|
||||||
// what we'd expect. And diddle the work done by the gas a bit to
|
// what we'd expect. And diddle the work done by the gas a bit to
|
||||||
// account for non-thermodynamic losses like internal friction;
|
// account for non-thermodynamic losses like internal friction;
|
||||||
// 10% should do it.
|
// 10% should do it.
|
||||||
|
|
||||||
float massFlow = _fuelFlow + (rho * 0.5f * _displacement * speed);
|
float massFlow = _fuelFlow + (rho * 0.5f * _displacement * speed);
|
||||||
float specHeat = 1300;
|
float specHeat = 1300;
|
||||||
float corr = 1.0f/(Math::pow(_compression, 0.4f) - 1.0f);
|
float corr = 1.0f/(Math::pow(_compression, 0.4f) - 1.0f);
|
||||||
_egt = corr * (power * 1.1f) / (massFlow * specHeat);
|
_egt = corr * (power * 1.1f) / (massFlow * specHeat);
|
||||||
if(_egt < temp) _egt = temp;
|
if(_egt < temp) _egt = temp;
|
||||||
|
|
||||||
|
|
||||||
|
// Oil temperature.
|
||||||
|
// Assume a linear variation between ~90degC at idle and ~120degC
|
||||||
|
// at full power. No attempt to correct for airflow over the
|
||||||
|
// engine is made. Make the time constant to attain target steady-
|
||||||
|
// state oil temp greater at engine off than on to reflect no
|
||||||
|
// circulation. Nothing fancy, but populates the guage with a
|
||||||
|
// plausible value.
|
||||||
|
float tau; // secs
|
||||||
|
if(_running) {
|
||||||
|
_oilTempTarget = 363.0f + (30.0f * (power/_power0));
|
||||||
|
tau = 600;
|
||||||
|
// Reduce tau linearly to 300 at max power
|
||||||
|
tau -= (power/_power0) * 300.0f;
|
||||||
|
} else {
|
||||||
|
_oilTempTarget = temp;
|
||||||
|
tau = 1500;
|
||||||
|
}
|
||||||
|
_dOilTempdt = (_oilTempTarget - _oilTemp) / tau;
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace yasim
|
}; // namespace yasim
|
||||||
|
|
|
@ -20,8 +20,11 @@ public:
|
||||||
float getEGT();
|
float getEGT();
|
||||||
float getMaxPower(); // max sea-level power
|
float getMaxPower(); // max sea-level power
|
||||||
float getBoost() { return _boostPressure; }
|
float getBoost() { return _boostPressure; }
|
||||||
|
float getOilTemp() { return _oilTemp; }
|
||||||
|
|
||||||
virtual void calc(float pressure, float temp, float speed);
|
virtual void calc(float pressure, float temp, float speed);
|
||||||
|
virtual void stabilize();
|
||||||
|
virtual void integrate(float dt);
|
||||||
virtual float getTorque();
|
virtual float getTorque();
|
||||||
virtual float getFuelFlow();
|
virtual float getFuelFlow();
|
||||||
|
|
||||||
|
@ -43,6 +46,9 @@ private:
|
||||||
float _fuelFlow;
|
float _fuelFlow;
|
||||||
float _egt;
|
float _egt;
|
||||||
float _boostPressure;
|
float _boostPressure;
|
||||||
|
float _oilTemp;
|
||||||
|
float _oilTempTarget;
|
||||||
|
float _dOilTempdt;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace yasim
|
}; // namespace yasim
|
||||||
|
|
|
@ -91,10 +91,11 @@ void YASim::bind()
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
for(int i=0; i<_fdm->getAirplane()->getModel()->numThrusters(); i++) {
|
for(int i=0; i<_fdm->getAirplane()->getModel()->numThrusters(); i++) {
|
||||||
sprintf(buf, "/engines/engine[%d]/fuel-flow-gph", i); fgUntie(buf);
|
sprintf(buf, "/engines/engine[%d]/fuel-flow-gph", i); fgUntie(buf);
|
||||||
sprintf(buf, "/engines/engine[%d]/rpm", i); fgUntie(buf);
|
sprintf(buf, "/engines/engine[%d]/rpm", i); fgUntie(buf);
|
||||||
sprintf(buf, "/engines/engine[%d]/mp-osi", i); fgUntie(buf);
|
sprintf(buf, "/engines/engine[%d]/mp-osi", i); fgUntie(buf);
|
||||||
sprintf(buf, "/engines/engine[%d]/egt-degf", i); fgUntie(buf);
|
sprintf(buf, "/engines/engine[%d]/egt-degf", i); fgUntie(buf);
|
||||||
|
sprintf(buf, "/engines/engine[%d]/oil-temperature-degf", i); fgUntie(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue