Index: ControlMap.cpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/ControlMap.cpp,v
retrieving revision 1.7
diff -p -u -r1.7 ControlMap.cpp
--- ControlMap.cpp	17 Feb 2005 10:26:15 -0000	1.7
+++ ControlMap.cpp	22 Apr 2005 09:59:59 -0000
@@ -214,6 +214,8 @@ void ControlMap::applyControls(float dt)
 	case REVERSE_THRUST: ((Jet*)obj)->setReverse(lval != 0);   break;
 	case BOOST:
 	    ((PistonEngine*)((Thruster*)obj)->getEngine())->setBoost(lval);
+    case CUTOUT:
+	    ((PistonEngine*)((Thruster*)obj)->getEngine())->setCutout(lval);
 	    break;
 	}
     }
Index: ControlMap.hpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/ControlMap.hpp,v
retrieving revision 1.6
diff -p -u -r1.6 ControlMap.hpp
--- ControlMap.hpp	27 Dec 2004 13:18:29 -0000	1.6
+++ ControlMap.hpp	22 Apr 2005 10:02:01 -0000
@@ -15,7 +15,7 @@ public:
 		      INCIDENCE, FLAP0, FLAP1, SLAT, SPOILER, VECTOR,
                       BOOST, CASTERING, PROPPITCH, PROPFEATHER,
                       COLLECTIVE, CYCLICAIL, CYCLICELE, ROTORENGINEON,
-                      REVERSE_THRUST };
+                      REVERSE_THRUST, CUTOUT };
 
     enum { OPT_SPLIT  = 0x01,
            OPT_INVERT = 0x02,
Index: Engine.hpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/Engine.hpp,v
retrieving revision 1.2
diff -p -u -r1.2 Engine.hpp
--- Engine.hpp	1 May 2004 00:26:33 -0000	1.2
+++ Engine.hpp	22 Apr 2005 10:14:46 -0000
@@ -25,6 +25,7 @@ public:
     void setBoost(float boost) { _boost = boost; }
     void setFuelState(bool hasFuel) { _fuel = hasFuel; }
     void setRunning(bool r) { _running = r; }
+    void setCutout(bool cutout) { _cutout = cutout; }
 
     bool isRunning() { return _running; }
     virtual bool isCranking() { return false; }
@@ -43,6 +44,7 @@ protected:
     float _boost;
     bool _fuel;
     bool _running;
+    bool _cutout;
 };
 
 }; // namespace yasim
Index: FGFDM.cpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/FGFDM.cpp,v
retrieving revision 1.29
diff -p -u -r1.29 FGFDM.cpp
--- FGFDM.cpp	17 Feb 2005 10:26:15 -0000	1.29
+++ FGFDM.cpp	18 May 2005 11:11:33 -0000
@@ -518,6 +518,11 @@ void FGFDM::setOutputProperties(float dt
                 PistonEngine* pe = p->getEngine()->isPistonEngine();
                 node->setFloatValue("mp-osi", pe->getMP() * (1/INHG2PA));
                 node->setFloatValue("mp-inhg", pe->getMP() * (1/INHG2PA));
+                node->setFloatValue("mp-pascals", pe->getMP() );
+                node->setFloatValue("boost-pressure-inhg", 
+                                                pe->getBoost() * (1/INHG2PA));
+                node->setFloatValue("boost-pressure-psi-gauge", pe->getBoost() * 0.000145
+                                              - 14.695949);
                 node->setFloatValue("egt-degf",
                                     pe->getEGT() * K2DEGF + K2DEGFOFFSET);
             } else if(p->getEngine()->isTurbineEngine()) {
@@ -667,9 +672,11 @@ void FGFDM::parsePistonEngine(XMLAttribu
 {
     float engP = attrf(a, "eng-power") * HP2W;
     float engS = attrf(a, "eng-rpm") * RPM2RAD;
+    
 
-    PistonEngine* eng = new PistonEngine(engP, engS);
 
+    PistonEngine* eng = new PistonEngine(engP, engS);
+    eng->setEngineSpeed(engS);
     if(a->hasAttribute("displacement"))
         eng->setDisplacement(attrf(a, "displacement") * CIN2CM);
 
@@ -715,6 +722,7 @@ void FGFDM::parsePropeller(XMLAttributes
         float engP = attrf(a, "eng-power") * HP2W;
         float engS = attrf(a, "eng-rpm") * RPM2RAD;
         eng = new PistonEngine(engP, engS);
+        eng->setEngineSpeed(engS);       
         if(a->hasAttribute("displacement"))
             eng->setDisplacement(attrf(a, "displacement") * CIN2CM);
         if(a->hasAttribute("compression"))
@@ -825,6 +833,7 @@ int FGFDM::parseOutput(const char* name)
     if(eq(name, "CYCLICELE")) return ControlMap::CYCLICELE;
     if(eq(name, "ROTORENGINEON")) return ControlMap::ROTORENGINEON;
     if(eq(name, "REVERSE_THRUST")) return ControlMap::REVERSE_THRUST;
+    if(eq(name, "CUTOUT")) return ControlMap::CUTOUT;
     SG_LOG(SG_FLIGHT,SG_ALERT,"Unrecognized control type '"
            << name << "' in YASim aircraft description.");
     exit(1);
Index: PistonEngine.cpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/PistonEngine.cpp,v
retrieving revision 1.7
diff -p -u -r1.7 PistonEngine.cpp
--- PistonEngine.cpp	1 May 2004 14:30:00 -0000	1.7
+++ PistonEngine.cpp	13 Jun 2005 12:25:10 -0000
@@ -1,7 +1,11 @@
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
 #include "Atmosphere.hpp"
 #include "Math.hpp"
 #include "PistonEngine.hpp"
-namespace yasim {
+#include <math.h>
+namespace yasim { 
 
 const static float HP2W = 745.7f;
 const static float CIN2CM = 1.6387064e-5f;
@@ -12,7 +16,7 @@ PistonEngine::PistonEngine(float power, 
     _boost = 1;
     _running = false;
     _fuel = true;
-
+       
     // 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.
     _f0 = power * 7.62e-08f;
@@ -43,7 +47,7 @@ void PistonEngine::setTurboParams(float 
 {
     _turbo = turbo;
     _maxMP = maxMP;
-
+    
     // This changes the "sea level" manifold air density
     float P0 = Atmosphere::getStdPressure(0);
     float P = P0 * (1 + _boost * (_turbo - 1));
@@ -62,6 +66,11 @@ void PistonEngine::setCompression(float 
     _compression = c;
 }
 
+void PistonEngine::setEngineSpeed(float engineSpeed)
+{
+   _engineSpeed = engineSpeed; 
+}
+
 float PistonEngine::getMaxPower()
 {
     return _power0;
@@ -87,13 +96,21 @@ float PistonEngine::getMP()
     return _mp;
 }
 
+float PistonEngine::getBoost()
+{
+    return _boostPressure;
+}
+
 float PistonEngine::getEGT()
 {
     return _egt;
 }
 
+
 void PistonEngine::calc(float pressure, float temp, float speed)
-{
+{   
+    
+     
     if(_magnetos == 0 || speed < 60*RPM2RADPS)
 	_running = false;
     else if(_fuel == false)
@@ -109,11 +126,43 @@ void PistonEngine::calc(float pressure, 
     // power, so use 10% instead!) But we need to produce _zero_
     // thrust at that setting, so hold onto the "output" value
     // separately.  Ick.
-    _mp = pressure * (1 + _boost*(_turbo-1)); // turbocharger
-    float mp = _mp * (0.1f + 0.9f * _throttle); // throttle
-    _mp *= _throttle;
-    if(mp > _maxMP) mp = _maxMP;              // wastegate
 
+    // Calculate the factor required to modify supercharger output for 
+    // rpm. Assume that the normalized supercharger output ~= 1 when
+    // the engine is at the nominated peak-power rpm (normalised).
+    // A power equation of the form  ((A*(B^x))*(x^C)  has been  
+    // derived empirically from some representative supercharger data.
+    // This provides near-linear output over the normal operating range, 
+    // with fall-off in the over-speed situation. 
+    float rpm_norm = (speed / _engineSpeed);
+    float A = 1.795206541;
+    float B = 0.55620178;
+    float C = 1.246708471;   
+    float rpm_factor = (A * (pow(B,rpm_norm))) * (pow(rpm_norm,C));
+    
+    // We need to adjust the minimum manifold pressure to get a 
+    // reasonable idle speed. This is a hack.           
+    float _minMP = (-0.008 * _turbo ) + 0.1;
+    
+    // max turbocharger output modified by rpm
+    _mp = pressure * (1 + (_boost * (_turbo-1) * rpm_factor)); 
+    
+    // manifold pressure modified by throttle: only apply when the 
+    // engine is running, otherwise we get odd results.
+    float mp = 0;
+    if (_running) {
+        mp = _mp * (_minMP + (1 -_minMP) * _throttle);
+    } else {
+        mp = _mp;
+    }       
+    
+    // apply wastegate and boost control cutout
+    if(mp > _maxMP and _cutout == false) {
+        mp = _maxMP;              
+        } 
+ 
+    _boostPressure = mp;
+    
     // Air entering the manifold does so rapidly, and thus the
     // pressure change can be assumed to be adiabatic.  Calculate a
     // temperature change, and use that to get the density.
Index: PistonEngine.hpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/PistonEngine.hpp,v
retrieving revision 1.4
diff -p -u -r1.4 PistonEngine.hpp
--- PistonEngine.hpp	1 May 2004 14:30:00 -0000	1.4
+++ PistonEngine.hpp	25 Apr 2005 09:31:30 -0000
@@ -14,11 +14,13 @@ public:
     void setTurboParams(float mul, float maxMP);
     void setDisplacement(float d);
     void setCompression(float c);
-
+    void setEngineSpeed(float engineSpeed);
+    
     bool isCranking();
     float getMP();
     float getEGT();
     float getMaxPower(); // max sea-level power
+    float getBoost();
 
     virtual void calc(float pressure, float temp, float speed);
     virtual float getTorque();
@@ -35,12 +37,19 @@ private:
     float _maxMP;    // wastegate setting
     float _displacement; // piston stroke volume
     float _compression;  // compression ratio (>1)
-
+    float _engineSpeed;  //
+    float _idleSpeed;   // engine rmp at idle
+    
     // Runtime state/output:
+    float _boostPressure;
     float _mp;
     float _torque;
     float _fuelFlow;
     float _egt;
+    float _adjust;
+    float _step;
+    float _minMP;
+    
 };
 
 }; // namespace yasim



