]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/propulsion/FGPiston.cpp
Merge branch 'next' of git://gitorious.org/fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGPiston.cpp
index b225563c2e0a4516da20e9483e2afdd05eb3d193..c687b31e86beb323d6c8162c864046efcd783b18 100644 (file)
@@ -53,7 +53,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGPiston.cpp,v 1.53 2010/08/21 17:13:48 jberndt Exp $";
+static const char *IdSrc = "$Id: FGPiston.cpp,v 1.58 2011/06/13 15:23:09 jentron Exp $";
 static const char *IdHdr = ID_PISTON;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -64,7 +64,7 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
   : FGEngine(exec, el, engine_number),
   R_air(287.3),                  // Gas constant for air J/Kg/K
   rho_fuel(800),                 // estimate
-  calorific_value_fuel(47.3e6),
+  calorific_value_fuel(47.3e6),  // J/Kg
   Cp_air(1005),                  // Specific heat (constant pressure) J/Kg/K
   Cp_fuel(1700),
   standard_pressure(101320.73)
@@ -92,13 +92,15 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
   Bore = 5.125;
   Stroke = 4.375;
   Cylinders = 4;
+  CylinderHeadMass = 2; //kg
   CompressionRatio = 8.5;
   Z_airbox = -999;
   Ram_Air_Factor = 1;
   PeakMeanPistonSpeed_fps = 100;
   FMEPDynamic= 18400;
   FMEPStatic = 46500;
-
+  Cooling_Factor = 0.5144444;
+  StaticFriction_HP = 1.5;
 
   // These are internal program variables
 
@@ -176,6 +178,8 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
     Displacement = el->FindElementValueAsNumberConvertTo("displacement","IN3");
   if (el->FindElement("maxhp"))
     MaxHP = el->FindElementValueAsNumberConvertTo("maxhp","HP");
+  if (el->FindElement("static-friction"))
+    StaticFriction_HP = el->FindElementValueAsNumberConvertTo("static-friction","HP");
   if (el->FindElement("sparkfaildrop"))
     SparkFailDrop = Constrain(0, 1 - el->FindElementValueAsNumber("sparkfaildrop"), 1);
   if (el->FindElement("cycles"))
@@ -200,10 +204,14 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
     Stroke = el->FindElementValueAsNumberConvertTo("stroke","IN");
   if (el->FindElement("cylinders"))
     Cylinders = el->FindElementValueAsNumber("cylinders");
+  if (el->FindElement("cylinder-head-mass"))
+    CylinderHeadMass = el->FindElementValueAsNumberConvertTo("cylinder-head-mass","KG");
   if (el->FindElement("air-intake-impedance-factor"))
     Z_airbox = el->FindElementValueAsNumber("air-intake-impedance-factor");
   if (el->FindElement("ram-air-factor"))
     Ram_Air_Factor  = el->FindElementValueAsNumber("ram-air-factor");
+  if (el->FindElement("cooling-factor"))
+    Cooling_Factor  = el->FindElementValueAsNumber("cooling-factor");
   if (el->FindElement("dynamic-fmep"))
     FMEPDynamic= el->FindElementValueAsNumberConvertTo("dynamic-fmep","PA");
   if (el->FindElement("static-fmep"))
@@ -254,7 +262,7 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
       pmep *= inhgtopa  * volumetric_efficiency;
       double fmep = (FMEPDynamic * RatedMeanPistonSpeed_fps * fttom + FMEPStatic);
       double hp_loss = ((pmep + fmep) * displacement_SI * MaxRPM)/(Cycles*22371);
-      ISFC = ( 1.1*Displacement * MaxRPM * volumetric_efficiency *(MaxManifoldPressure_inHg / 29.92) ) / (9411 * (MaxHP+hp_loss));
+      ISFC = ( 1.1*Displacement * MaxRPM * volumetric_efficiency *(MaxManifoldPressure_inHg / 29.92) ) / (9411 * (MaxHP+hp_loss-StaticFriction_HP));
 // cout <<"FMEP: "<< fmep <<" PMEP: "<< pmep << " hp_loss: " <<hp_loss <<endl;
   }
   if ( MaxManifoldPressure_inHg > 29.9 ) {   // Don't allow boosting with a bogus number
@@ -303,8 +311,20 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
   PropertyManager->Tie(property_name, &Z_airbox);
   property_name = base_property_name + "/ram-air-factor";
   PropertyManager->Tie(property_name, &Ram_Air_Factor);
+  property_name = base_property_name + "/cooling-factor";
+  PropertyManager->Tie(property_name, &Cooling_Factor);
   property_name = base_property_name + "/boost-speed";
   PropertyManager->Tie(property_name, &BoostSpeed);
+  property_name = base_property_name + "/cht-degF";
+  PropertyManager->Tie(property_name, this, &FGPiston::getCylinderHeadTemp_degF);
+  property_name = base_property_name + "/engine-rpm";
+  PropertyManager->Tie(property_name, this, &FGPiston::getRPM);
+  property_name = base_property_name + "/oil-temperature-degF";
+  PropertyManager->Tie(property_name, this, &FGPiston::getOilTemp_degF);
+  property_name = base_property_name + "/oil-pressure-psi";
+  PropertyManager->Tie(property_name, this, &FGPiston::getOilPressure_psi);
+  property_name = base_property_name + "/egt-degF";
+  PropertyManager->Tie(property_name, this, &FGPiston::getExhaustGasTemp_degF);
 
   // Set up and sanity-check the turbo/supercharging configuration based on the input values.
   if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true;
@@ -433,8 +453,7 @@ void FGPiston::Calculate(void)
     ((FGPropeller*)Thruster)->SetFeather(FCS->GetPropFeather(EngineNumber));
   }
 
-  PowerAvailable = (HP * hptoftlbssec) - Thruster->GetPowerRequired();
-  Thruster->Calculate(PowerAvailable);
+  Thruster->Calculate(HP * hptoftlbssec);
 
   RunPostFunctions();
 }
@@ -642,7 +661,7 @@ void FGPiston::doAirFlow(void)
 // loss of volumentric efficiency due to difference between MAP and exhaust pressure
 // Eq 6-10 from The Internal Combustion Engine - Charles Taylor Vol 1
   double ve =((gamma-1)/gamma) +( CompressionRatio -(p_amb/MAP))/(gamma*( CompressionRatio - 1));
-
+// FGAtmosphere::GetDensity() * FGJSBBase::m3toft3 / FGJSBBase::kgtoslug;
   rho_air = p_amb / (R_air * T_amb);
   double swept_volume = (displacement_SI * (RPM/60)) / 2;
   double v_dot_air = swept_volume * volumetric_efficiency *ve;
@@ -722,7 +741,7 @@ void FGPiston::doEnginePower(void)
   // (1/2) convert cycles, 60 minutes to seconds, 745.7 watts to hp.
   double pumping_hp = ((PMEP + FMEP) * displacement_SI * RPM)/(Cycles*22371);
 
-  HP = IndicatedHorsePower + pumping_hp - 1.5; //FIXME 1.5 static friction should depend on oil temp and configuration
+  HP = IndicatedHorsePower + pumping_hp - StaticFriction_HP; //FIXME static friction should depend on oil temp and configuration
 //  cout << "pumping_hp " <<pumping_hp << FMEP << PMEP <<endl;
   PctPower = HP / MaxHP ;
 //  cout << "Power = " << HP << "  RPM = " << RPM << "  Running = " << Running << "  Cranking = " << Cranking << endl;
@@ -748,11 +767,10 @@ void FGPiston::doEGT(void)
   if ((Running) && (m_dot_air > 0.0)) {  // do the energy balance
     combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio);
     enthalpy_exhaust = m_dot_fuel * calorific_value_fuel *
-                              combustion_efficiency * 0.33;
+                              combustion_efficiency * 0.30;
     heat_capacity_exhaust = (Cp_air * m_dot_air) + (Cp_fuel * m_dot_fuel);
     delta_T_exhaust = enthalpy_exhaust / heat_capacity_exhaust;
     ExhaustGasTemp_degK = T_amb + delta_T_exhaust;
-    ExhaustGasTemp_degK *= 0.444 + ((0.544 - 0.444) * PctPower);
   } else {  // Drop towards ambient - guess an appropriate time constant for now
     combustion_efficiency = 0;
     dEGTdt = (RankineToKelvin(Atmosphere->GetTemperature()) - ExhaustGasTemp_degK) / 100.0;
@@ -766,7 +784,7 @@ void FGPiston::doEGT(void)
  * Calculate the cylinder head temperature.
  *
  * Inputs: T_amb, IAS, rho_air, m_dot_fuel, calorific_value_fuel,
- *   combustion_efficiency, RPM, MaxRPM, Displacement
+ *   combustion_efficiency, RPM, MaxRPM, Displacement, Cylinders
  *
  * Outputs: CylinderHeadTemp_degK
  */
@@ -779,17 +797,17 @@ void FGPiston::doCHT(void)
 
   double arbitary_area = Displacement/360.0;
   double CpCylinderHead = 800.0;
-  double MassCylinderHead = 8.0;
+  double MassCylinderHead = CylinderHeadMass * Cylinders;
 
   double temperature_difference = CylinderHeadTemp_degK - T_amb;
-  double v_apparent = IAS * 0.5144444;
+  double v_apparent = IAS * Cooling_Factor;
   double v_dot_cooling_air = arbitary_area * v_apparent;
   double m_dot_cooling_air = v_dot_cooling_air * rho_air;
   double dqdt_from_combustion =
     m_dot_fuel * calorific_value_fuel * combustion_efficiency * 0.33;
   double dqdt_forced = (h2 * m_dot_cooling_air * temperature_difference) +
     (h3 * RPM * temperature_difference / MaxRPM);
-  double dqdt_free = h1 * temperature_difference;
+  double dqdt_free = h1 * temperature_difference * arbitary_area;
   double dqdt_cylinder_head = dqdt_from_combustion + dqdt_forced + dqdt_free;
 
   double HeatCapacityCylinderHead = CpCylinderHead * MassCylinderHead;
@@ -863,7 +881,7 @@ string FGPiston::GetEngineLabels(const string& delimiter)
 {
   std::ostringstream buf;
 
-  buf << Name << " Power Available (engine " << EngineNumber << " in HP)" << delimiter
+  buf << Name << " Power Available (engine " << EngineNumber << " in ft-lbs/sec)" << delimiter
       << Name << " HP (engine " << EngineNumber << ")" << delimiter
       << Name << " equivalent ratio (engine " << EngineNumber << ")" << delimiter
       << Name << " MAP (engine " << EngineNumber << " in inHg)" << delimiter
@@ -878,7 +896,7 @@ string FGPiston::GetEngineValues(const string& delimiter)
 {
   std::ostringstream buf;
 
-  buf << PowerAvailable << delimiter << HP << delimiter
+  buf << (HP * hptoftlbssec) << delimiter << HP << delimiter
       << equivalence_ratio << delimiter << ManifoldPressure_inHg << delimiter
       << Thruster->GetThrusterValues(EngineNumber, delimiter);
 
@@ -921,6 +939,7 @@ void FGPiston::Debug(int from)
       cout << "      Bore: "                << Bore                     << endl;
       cout << "      Stroke: "              << Stroke                   << endl;
       cout << "      Cylinders: "           << Cylinders                << endl;
+      cout << "      Cylinders Head Mass: " <<CylinderHeadMass          << endl;
       cout << "      Compression Ratio: "   << CompressionRatio         << endl;
       cout << "      MaxHP: "               << MaxHP                    << endl;
       cout << "      Cycles: "              << Cycles                   << endl;