Index: FGFDM.cpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/FGFDM.cpp,v
retrieving revision 1.29
diff -u -w -r1.29 FGFDM.cpp
--- FGFDM.cpp	17 Feb 2005 10:26:15 -0000	1.29
+++ FGFDM.cpp	11 Apr 2005 16:06:59 -0000
@@ -17,6 +17,7 @@
 #include "Rotor.hpp"
 #include "Rotorpart.hpp"
 #include "Rotorblade.hpp"
+#include "AIModel/AIBallistic.hxx"
 
 #include "FGFDM.hpp"
 
@@ -518,6 +519,11 @@
                 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()) {
@@ -668,8 +674,10 @@
     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 +723,7 @@
         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"))
Index: PistonEngine.cpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/PistonEngine.cpp,v
retrieving revision 1.7
diff -u -w -r1.7 PistonEngine.cpp
--- PistonEngine.cpp	1 May 2004 14:30:00 -0000	1.7
+++ PistonEngine.cpp	17 Apr 2005 09:47:24 -0000
@@ -1,6 +1,16 @@
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+
 #include "Atmosphere.hpp"
 #include "Math.hpp"
 #include "PistonEngine.hpp"
+
+#include <math.h>
+
+#include <Main/fg_props.hxx>
+
 namespace yasim {
 
 const static float HP2W = 745.7f;
@@ -13,6 +23,7 @@
     _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;
@@ -44,12 +55,15 @@
     _turbo = turbo;
     _maxMP = maxMP;
 
+    
     // This changes the "sea level" manifold air density
     float P0 = Atmosphere::getStdPressure(0);
     float P = P0 * (1 + _boost * (_turbo - 1));
     if(P > _maxMP) P = _maxMP;
     float T = Atmosphere::getStdTemperature(0) * Math::pow(P/P0, 2./7.);
     _rho0 = P / (287.1f * T);
+    
+    
 }
 
 void PistonEngine::setDisplacement(float d)
@@ -62,6 +76,11 @@
     _compression = c;
 }
 
+void PistonEngine::setEngineSpeed(float engineSpeed)
+{
+   _engineSpeed = engineSpeed; 
+}
+
 float PistonEngine::getMaxPower()
 {
     return _power0;
@@ -87,13 +106,21 @@
     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,10 +136,30 @@
     // 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 turbocharger output for 
+    // rpm. A 3rd order polynomial is used to give a non-linear output.
+    // This provides near-linear output over the normal operating range, with
+    // fall-off in the over-speed situation.
+    float rpm_norm = (speed / _engineSpeed);
+    float rpm_factor = (-0.25 * math::pow(rpm_norm,3)) + (-0.15 * math::pow(rpm_norm,2)) 
+                         + (1.11 * rpm_norm);
+    
+    // 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
+    float mp = _mp * (_minMP + (1 -_minMP) * _throttle); 
+   
+    if(mp > _maxMP) {
+        mp = _maxMP;              // wastegate
+        }
+        
+    _boostPressure = mp;
 
     // Air entering the manifold does so rapidly, and thus the
     // pressure change can be assumed to be adiabatic.  Calculate a
Index: PistonEngine.hpp
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/FDM/YASim/PistonEngine.hpp,v
retrieving revision 1.4
diff -u -w -r1.4 PistonEngine.hpp
--- PistonEngine.hpp	1 May 2004 14:30:00 -0000	1.4
+++ PistonEngine.hpp	17 Apr 2005 09:00:47 -0000
@@ -14,11 +14,13 @@
     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,15 @@
     float _maxMP;    // wastegate setting
     float _displacement; // piston stroke volume
     float _compression;  // compression ratio (>1)
+    float _engineSpeed; //
 
     // Runtime state/output:
+    float _boostPressure;
     float _mp;
     float _torque;
     float _fuelFlow;
     float _egt;
+    
 };
 
 }; // namespace yasim



