namespace JSBSim {
-static const char *IdSrc = "$Id: FGPiston.cpp,v 1.52 2010/06/05 12:12:34 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;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
: 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)
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
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"))
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"))
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
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;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGPiston::Calculate(void)
+void FGPiston::Calculate(void)
{
+ RunPreFunctions();
+
if (FuelFlow_gph > 0.0) ConsumeFuel();
Throttle = FCS->GetThrottlePos(EngineNumber);
Mixture = FCS->GetMixturePos(EngineNumber);
- //
// Input values.
- //
p_amb = Atmosphere->GetPressure() * psftopa;
double p = Auxiliary->GetTotalPressure() * psftopa;
//Assume lean limit at 22 AFR for now - thats a thi of 0.668
//This might be a bit generous, but since there's currently no audiable warning of impending
//cutout in the form of misfiring and/or rough running its probably reasonable for now.
-// if (equivalence_ratio < 0.668)
-// Running = false;
+
+ // if (equivalence_ratio < 0.668)
+ // Running = false;
doEnginePower();
if (IndicatedHorsePower < 0.1250) Running = false;
((FGPropeller*)Thruster)->SetFeather(FCS->GetPropFeather(EngineNumber));
}
- PowerAvailable = (HP * hptoftlbssec) - Thruster->GetPowerRequired();
+ Thruster->Calculate(HP * hptoftlbssec);
- return Thruster->Calculate(PowerAvailable);
+ RunPostFunctions();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// 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;
// (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;
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;
* 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
*/
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;
{
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
{
std::ostringstream buf;
- buf << PowerAvailable << delimiter << HP << delimiter
+ buf << (HP * hptoftlbssec) << delimiter << HP << delimiter
<< equivalence_ratio << delimiter << ManifoldPressure_inHg << delimiter
<< Thruster->GetThrusterValues(EngineNumber, delimiter);
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;