]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/PistonEngine.cpp
Port over remaining Point3D usage to the more type and unit safe SG* classes.
[flightgear.git] / src / FDM / YASim / PistonEngine.cpp
index 11b04fe7a491ec0c086500c65868678f9d695edc..1ef086b140950b0818ef70abdc112bc0ec4aac5c 100644 (file)
@@ -36,6 +36,7 @@ PistonEngine::PistonEngine(float power, float speed)
     _mixCoeff = realFlow * 1.1f / _omega0;
 
     _turbo = 1;
+    _minthrottle = 0.1;
     _maxMP = 1e6; // No waste gate on non-turbo engines.
     _wastegate = 1;
     _charge = 1;
@@ -72,6 +73,11 @@ void PistonEngine::setCompression(float c)
     _compression = c;
 }
 
+void PistonEngine::setMinThrottle(float m)
+{
+    _minthrottle = m;
+}
+
 float PistonEngine::getMaxPower()
 {
     return _power0;
@@ -147,7 +153,7 @@ void PistonEngine::calc(float pressure, float temp, float speed)
     // We need to adjust the minimum manifold pressure to get a
     // reasonable idle speed (a "closed" throttle doesn't suck a total
     // vacuum in real manifolds).  This is a hack.
-    float _minMP = (-0.008 * _turbo ) + 0.1;
+    float _minMP = (-0.008 * _turbo ) + _minthrottle;
 
     _mp = pressure * _charge;
 
@@ -169,7 +175,7 @@ void PistonEngine::calc(float pressure, float temp, float speed)
     // pressure change can be assumed to be adiabatic.  Calculate a
     // temperature change, and use that to get the density.
     // Note: need to model intercoolers here...
-    float T = temp * Math::pow(_mp/pressure, 2.0/7.0);
+    float T = temp * Math::pow((_mp*_mp)/(pressure*pressure), 1.0/7.0);
     float rho = _mp / (287.1f * T);
 
     // The actual fuel flow is determined only by engine RPM and the