document = LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
if (document) {
ReadPrologue(document);
- element = document->GetElement();
-
- result = true;
- while (element && result) {
- string element_name = element->GetName();
- if (element_name == "fileheader" ) result = ReadFileHeader(element);
- else if (element_name == "slave") result = ReadSlave(element);
- else if (element_name == "metrics") result = Aircraft->Load(element);
- else if (element_name == "mass_balance") result = MassBalance->Load(element);
- else if (element_name == "ground_reactions") result = GroundReactions->Load(element);
- else if (element_name == "external_reactions") result = ExternalReactions->Load(element);
- else if (element_name == "buoyant_forces") result = BuoyantForces->Load(element);
- else if (element_name == "propulsion") result = Propulsion->Load(element);
- else if (element_name == "system") result = FCS->Load(element,
- FGFCS::stSystem);
- else if (element_name == "autopilot") result = FCS->Load(element,
- FGFCS::stAutoPilot);
- else if (element_name == "flight_control") result = FCS->Load(element,
- FGFCS::stFCS);
- else if (element_name == "aerodynamics") result = Aerodynamics->Load(element);
- else if (element_name == "input") result = Input->Load(element);
- else if (element_name == "output") {
- FGOutput* Output = new FGOutput(this);
- Output->InitModel();
- Schedule(Output, 1);
- result = Output->Load(element);
- Outputs.push_back(Output);
+
+ // Process the fileheader element in the aircraft config file. This element is OPTIONAL.
+ element = document->FindElement("fileheader");
+ if (element) {
+ result = ReadFileHeader(element);
+ if (!result) {
+ cerr << endl << "Aircraft fileheader element has problems in file " << aircraftCfgFileName << endl;
+ return result;
}
- else {
- cerr << "Found unexpected subsystem: " << element_name << ", exiting." << endl;
- result = false;
- break;
+ }
+
+ // Process the metrics element. This element is REQUIRED.
+ element = document->FindElement("metrics");
+ if (element) {
+ result = Aircraft->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft metrics element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ } else {
+ cerr << endl << "No metrics element was found in the aircraft config file." << endl;
+ return false;
+ }
+
+ // Process the mass_balance element. This element is REQUIRED.
+ element = document->FindElement("mass_balance");
+ if (element) {
+ result = MassBalance->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft mass_balance element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ } else {
+ cerr << endl << "No mass_balance element was found in the aircraft config file." << endl;
+ return false;
+ }
+
+ // Process the ground_reactions element. This element is REQUIRED.
+ element = document->FindElement("ground_reactions");
+ if (element) {
+ result = GroundReactions->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft ground_reactions element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ } else {
+ cerr << endl << "No ground_reactions element was found in the aircraft config file." << endl;
+ return false;
+ }
+
+ // Process the external_reactions element. This element is OPTIONAL.
+ element = document->FindElement("external_reactions");
+ if (element) {
+ result = ExternalReactions->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft external_reactions element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the buoyant_forces element. This element is OPTIONAL.
+ element = document->FindElement("buoyant_forces");
+ if (element) {
+ result = BuoyantForces->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft buoyant_forces element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the propulsion element. This element is OPTIONAL.
+ element = document->FindElement("propulsion");
+ if (element) {
+ result = Propulsion->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft propulsion element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the system element[s]. This element is OPTIONAL, and there may be more than one.
+ element = document->FindElement("system");
+ while (element) {
+ result = FCS->Load(element, FGFCS::stSystem);
+ if (!result) {
+ cerr << endl << "Aircraft system element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ element = document->FindNextElement("system");
+ }
+
+ // Process the autopilot element. This element is OPTIONAL.
+ element = document->FindElement("autopilot");
+ if (element) {
+ result = FCS->Load(element, FGFCS::stAutoPilot);
+ if (!result) {
+ cerr << endl << "Aircraft autopilot element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the flight_control element. This element is OPTIONAL.
+ element = document->FindElement("flight_control");
+ if (element) {
+ result = FCS->Load(element, FGFCS::stFCS);
+ if (!result) {
+ cerr << endl << "Aircraft flight_control element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the aerodynamics element. This element is OPTIONAL, but almost always expected.
+ element = document->FindElement("aerodynamics");
+ if (element) {
+ result = Aerodynamics->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft aerodynamics element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ } else {
+ cerr << endl << "No expected aerodynamics element was found in the aircraft config file." << endl;
+ }
+
+ // Process the input element. This element is OPTIONAL.
+ element = document->FindElement("input");
+ if (element) {
+ result = Input->Load(element);
+ if (!result) {
+ cerr << endl << "Aircraft input element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ }
+
+ // Process the output element[s]. This element is OPTIONAL, and there may be more than one.
+ element = document->FindElement("output");
+ while (element) {
+ FGOutput* Output = new FGOutput(this);
+ Output->InitModel();
+ Schedule(Output, 1);
+ result = Output->Load(element);
+ Outputs.push_back(Output);
+ if (!result) {
+ cerr << endl << "Aircraft output element has problems in file " << aircraftCfgFileName << endl;
+ return result;
+ }
+ element = document->FindNextElement("output");
+ }
+
+ // Lastly, process the slave element. This element is OPTIONAL - and NOT YET SUPPORTED.
+ element = document->FindElement("slave");
+ if (element) {
+ result = ReadSlave(element);
+ if (!result) {
+ cerr << endl << "Aircraft slave element has problems in file " << aircraftCfgFileName << endl;
+ return result;
}
- element = document->GetNextElement();
}
- } else {
- cerr << fgred
- << " JSBSim failed to load aircraft model."
- << fgdef << endl;
- return false;
- }
- if (result) {
modelLoaded = true;
- Debug(3);
+
} else {
cerr << fgred
- << " JSBSim failed to load properly."
+ << " JSBSim failed to open the configuration file: " << aircraftCfgFileName
<< fgdef << endl;
- return false;
}
struct PropertyCatalogStructure masterPCS;
// file on each FlightGear reset.
fgGetNode("/fdm/jsbsim/simulation/write-state-file")->untie();
fgGetNode("/fdm/jsbsim/simulation")->removeChild("write-state-file", false);
- // Prevent nuking of the state on JSBSim recreation after FlightGear reset.
- fgGetNode("/fdm/jsbsim/simulation/reset")->untie();
- fgGetNode("/fdm/jsbsim/simulation")->removeChild("reset", false);
// end ugly hack
// Register ground callback.
Atmosphere->UseInternal();
}
- fgic->SetVNorthFpsIC( wind_from_north->getDoubleValue() );
- fgic->SetVEastFpsIC( wind_from_east->getDoubleValue() );
- fgic->SetVDownFpsIC( wind_from_down->getDoubleValue() );
+ fgic->SetVNorthFpsIC( -wind_from_north->getDoubleValue() );
+ fgic->SetVEastFpsIC( -wind_from_east->getDoubleValue() );
+ fgic->SetVDownFpsIC( -wind_from_down->getDoubleValue() );
//Atmosphere->SetExTemperature(get_Static_temperature());
//Atmosphere->SetExPressure(get_Static_pressure());
tmp = turbulence_rate->getDoubleValue();
//Atmosphere->SetTurbRate(tmp);
- Atmosphere->SetWindNED( wind_from_north->getDoubleValue(),
- wind_from_east->getDoubleValue(),
- wind_from_down->getDoubleValue() );
+ Atmosphere->SetWindNED( -wind_from_north->getDoubleValue(),
+ -wind_from_east->getDoubleValue(),
+ -wind_from_down->getDoubleValue() );
// SG_LOG(SG_FLIGHT,SG_INFO, "Wind NED: "
// << get_V_north_airmass() << ", "
// << get_V_east_airmass() << ", "
node->setDoubleValue("yoffset-in", gear->GetBodyLocation()(2));
node->setDoubleValue("zoffset-in", gear->GetBodyLocation()(3));
node->setBoolValue("wow", gear->GetWOW());
+ node->setDoubleValue("rollspeed-ms", gear->GetWheelRollVel()*0.3043);
node->setBoolValue("has-brake", gear->GetBrakeGroup() > 0);
node->setDoubleValue("position-norm", gear->GetGearUnitPos());
node->setDoubleValue("tire-pressure-norm", gear->GetTirePressure());
FGLGear *gear = gr->GetGearUnit(i);
SGPropertyNode * node = fgGetNode("gear/gear", i, true);
node->getChild("wow", 0, true)->setBoolValue( gear->GetWOW());
+ node->getChild("rollspeed-ms", 0, true)->setDoubleValue(gear->GetWheelRollVel()*0.3043);
node->getChild("position-norm", 0, true)->setDoubleValue(gear->GetGearUnitPos());
gear->SetTirePressure(node->getDoubleValue("tire-pressure-norm"));
node->setDoubleValue("compression-norm", gear->GetCompLen());
dt = State->Getdt();
// These items are read from the configuration file
+ // Defaults are from a Lycoming O-360, more or less
- Cycles = 2;
+ Cycles = 4;
IdleRPM = 600;
MaxRPM = 2800;
Displacement = 360;
MaxHP = 200;
MinManifoldPressure_inHg = 6.5;
MaxManifoldPressure_inHg = 28.5;
- BSFC = -1;
-
- // Initialisation
- volumetric_efficiency = 0.8; // Actually f(speed, load) but this will get us running
+ ISFC = -1;
+ volumetric_efficiency = -0.1;
+ Bore = 5.125;
+ Stroke = 4.375;
+ Cylinders = 4;
+ CompressionRatio = 8.5;
// These are internal program variables
if (el->FindElement("minthrottle"))
MinThrottle = el->FindElementValueAsNumber("minthrottle");
if (el->FindElement("bsfc"))
- BSFC = el->FindElementValueAsNumberConvertTo("bsfc", "LBS/HP*HR");
+ ISFC = el->FindElementValueAsNumberConvertTo("bsfc", "LBS/HP*HR");
if (el->FindElement("volumetric-efficiency"))
volumetric_efficiency = el->FindElementValueAsNumber("volumetric-efficiency");
+ if (el->FindElement("compression-ratio"))
+ CompressionRatio = el->FindElementValueAsNumber("compression-ratio");
+ if (el->FindElement("bore"))
+ Bore = el->FindElementValueAsNumberConvertTo("bore","IN");
+ if (el->FindElement("stroke"))
+ Stroke = el->FindElementValueAsNumberConvertTo("stroke","IN");
+ if (el->FindElement("stroke"))
+ Cylinders = el->FindElementValueAsNumber("cylinders");
if (el->FindElement("numboostspeeds")) { // Turbo- and super-charging parameters
BoostSpeeds = (int)el->FindElementValueAsNumber("numboostspeeds");
if (el->FindElement("boostoverride"))
RatedAltitude[2] = el->FindElementValueAsNumberConvertTo("ratedaltitude3", "FT");
}
- MaxManifoldPressure_Percent = MaxManifoldPressure_inHg / 29.92;
- // Create a BSFC to match the engine if not provided
- if (BSFC < 0) {
- BSFC = ( Displacement * MaxRPM * volumetric_efficiency ) / (9411 * MaxHP);
- BSFC *= (MaxManifoldPressure_Percent * MaxManifoldPressure_Percent * MaxManifoldPressure_Percent);
+ StarterHP = sqrt(MaxHP) * 0.4;
+ displacement_SI = Displacement * in3tom3;
+
+ // Create IFSC and VE to match the engine if not provided
+ int calculated_ve=0;
+ if (volumetric_efficiency < 0) {
+ volumetric_efficiency = MaxManifoldPressure_inHg / 29.92;
+ calculated_ve=1;
+ }
+ if (ISFC < 0) {
+ double pmep = MaxManifoldPressure_inHg > 29.92 ? 0 : 29.92 - MaxManifoldPressure_inHg;
+ pmep *= inhgtopa;
+ double fmep = (18400 * (2*(Stroke/12)*(MaxRPM/60)) * fttom + 46500)/2;
+ double hp_loss = ((pmep + fmep) * displacement_SI * MaxRPM)/(Cycles*22371);
+ ISFC = ( Displacement * MaxRPM * volumetric_efficiency ) / (9411 * (MaxHP+hp_loss));
+// cout <<"FMEP: "<< fmep <<" PMEP: "<< pmep << " hp_loss: " <<hp_loss <<endl;
}
if ( MaxManifoldPressure_inHg > 29.9 ) { // Don't allow boosting with a bogus number
MaxManifoldPressure_inHg = 29.9;
- MaxManifoldPressure_Percent = MaxManifoldPressure_inHg / 29.92;
+ if (calculated_ve) volumetric_efficiency = 1.0;
}
+ minMAP = MinManifoldPressure_inHg * inhgtopa; // inHg to Pa
+ maxMAP = MaxManifoldPressure_inHg * inhgtopa;
string property_name, base_property_name;
base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
property_name = base_property_name + "/power-hp";
PropertyManager->Tie(property_name, &HP);
property_name = base_property_name + "/bsfc-lbs_hphr";
- PropertyManager->Tie(property_name, &BSFC);
+ PropertyManager->Tie(property_name, &ISFC);
property_name = base_property_name + "/volumetric-efficiency";
PropertyManager->Tie(property_name, &volumetric_efficiency);
+ property_name = base_property_name + "/map-pa";
+ PropertyManager->Tie(property_name, &MAP);
property_name = base_property_name + "/map-inhg";
PropertyManager->Tie(property_name, &ManifoldPressure_inHg);
- minMAP = MinManifoldPressure_inHg * inhgtopa; // inHg to Pa
- maxMAP = MaxManifoldPressure_inHg * inhgtopa;
- StarterHP = sqrt(MaxHP) * 0.4;
// Set up and sanity-check the turbo/supercharging configuration based on the input values.
if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true;
BoostSpeed = 0;
}
bBoostOverride = (BoostOverride == 1 ? true : false);
- if (MinThrottle < 0.12) MinThrottle = 0.12; //MinThrottle is limited to 0.12 to prevent the
- // throttle area equation from going negative
- // 0.12 is 1% of maximum area
Debug(0); // Call Debug() routine from constructor if needed
}
if (FuelFlow_gph > 0.0) ConsumeFuel();
Throttle = FCS->GetThrottlePos(EngineNumber);
- // calculate the throttle plate angle. 1 unit is pi/2 radians.
+ // calculate the throttle plate angle. 1 unit is approx pi/2 radians.
ThrottleAngle = MinThrottle+((MaxThrottle-MinThrottle)*Throttle );
Mixture = FCS->GetMixturePos(EngineNumber);
//
p_amb = Atmosphere->GetPressure() * psftopa;
- p_amb_sea_level = Atmosphere->GetPressureSL() * psftopa;
T_amb = RankineToKelvin(Atmosphere->GetTemperature());
RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
+ MeanPistonSpeed_fps = ( RPM * Stroke) / (360); // AKA 2 * (RPM/60) * ( Stroke / 12) or 2NS
IAS = Auxiliary->GetVcalibratedKTS();
// Running = false;
doEnginePower();
- if (HP < 0.1250) Running = false;
+ if (IndicatedHorsePower < 0.1250) Running = false;
doEGT();
doCHT();
* from the throttle position, turbo/supercharger boost control
* system, engine speed and local ambient air density.
*
- * Inputs: p_amb, Throttle, MaxManifoldPressure_Percent, ThrottleAngle
- * RPM, MaxRPM
+ * Inputs: p_amb, Throttle, ThrottleAngle,
+ * MeanPistonSpeed_fps, dt
*
* Outputs: MAP, ManifoldPressure_inHg
*/
void FGPiston::doMAP(void)
{
- // estimate throttle plate area. This maps 0.2 -> 0.1 for historical performance reasons
- double throttle_area = ThrottleAngle * 1.125 - 0.125;
- map_coefficient = pow ((throttle_area * MaxManifoldPressure_Percent),RPM/MaxRPM);
- MAP = p_amb * map_coefficient;
-
- if(Boosted) {
- // If takeoff boost is fitted, we currently assume the following throttle map:
- // (In throttle % - actual input is 0 -> 1)
- // 99 / 100 - Takeoff boost
- // 96 / 97 / 98 - Rated boost
- // 0 - 95 - Idle to Rated boost (MinManifoldPressure to MaxManifoldPressure)
- // In real life, most planes would be fitted with a mechanical 'gate' between
- // the rated boost and takeoff boost positions.
- double T = Throttle; // processed throttle value.
- bool bTakeoffPos = false;
- if(bTakeoffBoost) {
- if(Throttle > 0.98) {
- //cout << "Takeoff Boost!!!!\n";
- bTakeoffPos = true;
- } else if(Throttle <= 0.95) {
- bTakeoffPos = false;
- T *= 1.0 / 0.95;
- } else {
- bTakeoffPos = false;
- //cout << "Rated Boost!!\n";
- T = 1.0;
- }
- }
- // Boost the manifold pressure.
- double boost_factor = BoostMul[BoostSpeed] * map_coefficient * RPM/RatedRPM[BoostSpeed];
- if (boost_factor < 1.0) boost_factor = 1.0; // boost will never reduce the MAP
- MAP *= boost_factor;
- // Now clip the manifold pressure to BCV or Wastegate setting.
- if(bTakeoffPos) {
- if(MAP > TakeoffMAP[BoostSpeed]) {
- MAP = TakeoffMAP[BoostSpeed];
- }
+ // estimate throttle plate area.
+ double throttle_area = ThrottleAngle*ThrottleAngle;
+ // Internal Combustion Engine in Theory and Practice, Volume 2. Charles Fayette Taylor. Revised Edition, 1985 fig 6-13
+ double map_coefficient = 1-((MeanPistonSpeed_fps*MeanPistonSpeed_fps)/(24978*throttle_area));
+
+ if ( map_coefficient < 0.1 ) map_coefficient = 0.1;
+
+ // map_coefficient = pow ((throttle_area * MaxManifoldPressure_Percent),RPM/MaxRPM);
+ // Add a one second lag to manifold pressure changes
+ double dMAP = (MAP - p_amb * map_coefficient) * dt;
+ MAP -=dMAP;
+
+ // Find the mean effective pressure required to achieve this manifold pressure
+ // Doing this before boost so boost doesn't add horsepower to the engine.
+ // A better method would be deterimining the HP consumed by the supercharger
+
+ PMEP = MAP - p_amb; // Fixme: p_amb should be exhaust manifold pressure
+
+ if (Boosted) {
+ // If takeoff boost is fitted, we currently assume the following throttle map:
+ // (In throttle % - actual input is 0 -> 1)
+ // 99 / 100 - Takeoff boost
+ // 96 / 97 / 98 - Rated boost
+ // 0 - 95 - Idle to Rated boost (MinManifoldPressure to MaxManifoldPressure)
+ // In real life, most planes would be fitted with a mechanical 'gate' between
+ // the rated boost and takeoff boost positions.
+
+ bool bTakeoffPos = false;
+ if (bTakeoffBoost) {
+ if (Throttle > 0.98) {
+ bTakeoffPos = true;
+ } else if(Throttle <= 0.95) {
+ bTakeoffPos = false;
} else {
- if(MAP > RatedMAP[BoostSpeed]) {
- MAP = RatedMAP[BoostSpeed];
- }
+ bTakeoffPos = false;
}
}
+ // Boost the manifold pressure.
+ double boost_factor = BoostMul[BoostSpeed] * map_coefficient * RPM/RatedRPM[BoostSpeed];
+ if (boost_factor < 1.0) boost_factor = 1.0; // boost will never reduce the MAP
+ MAP *= boost_factor;
+ // Now clip the manifold pressure to BCV or Wastegate setting.
+ if (bTakeoffPos) {
+ if (MAP > TakeoffMAP[BoostSpeed]) MAP = TakeoffMAP[BoostSpeed];
+ } else {
+ if (MAP > RatedMAP[BoostSpeed]) MAP = RatedMAP[BoostSpeed];
+ }
+ }
// And set the value in American units as well
ManifoldPressure_inHg = MAP / inhgtopa;
void FGPiston::doAirFlow(void)
{
+ double gamma = 1.4; // specific heat constants
+// loss of volumentric efficiency due to difference between MAP and exhaust pressure
+ double ve =((gamma-1)/gamma)+( CompressionRatio -(p_amb/MAP))/(gamma*( CompressionRatio - 1));
+
rho_air = p_amb / (R_air * T_amb);
- double displacement_SI = Displacement * in3tom3;
double swept_volume = (displacement_SI * (RPM/60)) / 2;
- double v_dot_air = swept_volume * volumetric_efficiency * map_coefficient;
+ double v_dot_air = swept_volume * volumetric_efficiency *ve;
double rho_air_manifold = MAP / (R_air * T_amb);
m_dot_air = v_dot_air * rho_air_manifold;
+
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/**
* Calculate the fuel flow into the engine.
*
- * Inputs: Mixture, thi_sea_level, p_amb_sea_level, p_amb, m_dot_air
+ * Inputs: Mixture, thi_sea_level, p_amb, m_dot_air
*
* Outputs: equivalence_ratio, m_dot_fuel
*/
* 200HP.
*
* Inputs: ManifoldPressure_inHg, p_amb, RPM, T_amb,
- * Mixture_Efficiency_Correlation, Cycles, MaxHP
+ * Mixture_Efficiency_Correlation, Cycles, MaxHP, PMEP,
*
- * Outputs: Percentage_Power, HP
+ * Outputs: PctPower, HP
*/
void FGPiston::doEnginePower(void)
{
+ IndicatedHorsePower = 0;
+ FMEP = 0;
if (Running) {
// FIXME: this needs to be generalized
- double ME, friction, percent_RPM, power; // Convienience term for use in the calculations
+ double ME, percent_RPM, power; // Convienience term for use in the calculations
ME = Mixture_Efficiency_Correlation->GetValue(m_dot_fuel/m_dot_air);
percent_RPM = RPM/MaxRPM;
- friction = 1 - (percent_RPM * percent_RPM * percent_RPM * percent_RPM/10);
- if (friction < 0 ) friction = 0;
- power = friction;
+// Guestimate engine friction as a percentage of rated HP + a percentage of rpm + a percentage of Indicted HP
+// friction = 1 - (percent_RPM * percent_RPM * percent_RPM/10);
+ FMEP = (-18400 * MeanPistonSpeed_fps * fttom - 46500);
+
+ power = 1;
if ( Magnetos != 3 ) power *= SparkFailDrop;
- HP = (FuelFlow_gph * 6.0 / BSFC )* ME * map_coefficient * power;
+ IndicatedHorsePower = (FuelFlow_pph / ISFC )* ME * power;
} else {
-
// Power output when the engine is not running
if (Cranking) {
if (RPM < 10) {
- HP = StarterHP;
+ IndicatedHorsePower = StarterHP;
} else if (RPM < IdleRPM*0.8) {
- HP = StarterHP + ((IdleRPM*0.8 - RPM) / 8.0);
+ IndicatedHorsePower = StarterHP + ((IdleRPM*0.8 - RPM) / 8.0);
// This is a guess - would be nice to find a proper starter moter torque curve
} else {
- HP = StarterHP;
+ IndicatedHorsePower = StarterHP;
}
- } else {
- // Quick hack until we port the FMEP stuff
- if (RPM > 0.0)
- HP = -1.5;
- else
- HP = 0.0;
}
}
- Percentage_Power = HP / MaxHP ;
+
+ // Constant is (1/2) * 60 * 745.7
+ // (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
+// cout << "pumping_hp " <<pumping_hp << FMEP << PMEP <<endl;
+ PctPower = HP / MaxHP ;
// cout << "Power = " << HP << " RPM = " << RPM << " Running = " << Running << " Cranking = " << Cranking << endl;
}
* Calculate the exhaust gas temperature.
*
* Inputs: equivalence_ratio, m_dot_fuel, calorific_value_fuel,
- * Cp_air, m_dot_air, Cp_fuel, m_dot_fuel, T_amb, Percentage_Power
+ * Cp_air, m_dot_air, Cp_fuel, m_dot_fuel, T_amb, PctPower
*
* Outputs: combustion_efficiency, ExhaustGasTemp_degK
*/
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) * Percentage_Power);
+ 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;
cout << " MinManifoldPressure: " << MinManifoldPressure_inHg << endl;
cout << " MaxManifoldPressure: " << MaxManifoldPressure_inHg << endl;
cout << " MinMaP (Pa): " << minMAP << endl;
- cout << " MaxMaP (Pa): " << maxMAP << endl;
+ cout << " MaxMaP (Pa): " << maxMAP << endl;
cout << " Displacement: " << Displacement << endl;
+ cout << " Bore: " << Bore << endl;
+ cout << " Stroke: " << Stroke << endl;
+ cout << " Cylinders: " << Cylinders << endl;
+ cout << " Compression Ratio: " << CompressionRatio << endl;
cout << " MaxHP: " << MaxHP << endl;
cout << " Cycles: " << Cycles << endl;
cout << " IdleRPM: " << IdleRPM << endl;
cout << " MaxThrottle: " << MaxThrottle << endl;
cout << " MinThrottle: " << MinThrottle << endl;
- cout << " BSFC: " << BSFC << endl;
+ cout << " ISFC: " << ISFC << endl;
+ cout << " Volumentric Efficiency: " << volumetric_efficiency << endl;
cout << endl;
cout << " Combustion Efficiency table:" << endl;
@code
<piston_engine name="{string}">
<minmp unit="{INHG | PA | ATM}"> {number} </minmp> <!-- Depricated -->
- <maxmp unit="{INHG | PA | ATM}"> {number} </maxmp> <!-- Depricated -->
+ <maxmp unit="{INHG | PA | ATM}"> {number} </maxmp>
<displacement unit="{IN3 | LTR | CC}"> {number} </displacement>
+ <bore unit="{IN | M}"> {number} </bore>
+ <stroke unit="{IN | M}"> {number} </stroke>
+ <cylinders> {number} </cylinders>
+ <compression-ratio> {number} </compression-ratio>
<sparkfaildrop> {number} </sparkfaildrop>
<maxhp unit="{HP | WATTS}"> {number} </maxhp>
<cycles> {number} </cycles>
<maxrpm> {number} </maxrpm>
<maxthrottle> {number} </maxthrottle>
<minthrottle> {number} </minthrottle>
- <numboostspeeds> {number} </numboostspeeds>
<bsfc unit="{LBS/HP*HR | "KG/KW*HR"}"> {number} </bsft>
<volumetric_efficiency> {number} </volumetric_efficiency>
+ <numboostspeeds> {number} </numboostspeeds>
<boostoverride> {0 | 1} </boostoverride>
<ratedboost1 unit="{INHG | PA | ATM}"> {number} </ratedboost1>
<ratedpower1 unit="{HP | WATTS}"> {number} </ratedpower1>
private:
int crank_counter;
- double BrakeHorsePower;
+ double IndicatedHorsePower;
+ double PMEP;
+ double FMEP;
double SpeedSlope;
double SpeedIntercept;
double AltitudeSlope;
const double Cp_fuel; // J/KgK
FGTable *Lookup_Combustion_Efficiency;
- FGTable *Power_Mixture_Correlation;
FGTable *Mixture_Efficiency_Correlation;
//
double MaxManifoldPressure_inHg; // Inches Hg
double MaxManifoldPressure_Percent; // MaxManifoldPressure / 29.92
double Displacement; // cubic inches
+ double displacement_SI; // cubic meters
double MaxHP; // horsepower
double SparkFailDrop; // drop of power due to spark failure
double Cycles; // cycles/power stroke
double IdleRPM; // revolutions per minute
double MaxRPM; // revolutions per minute
+ double Bore; // inches
+ double Stroke; // inches
+ double Cylinders; // number
+ double CompressionRatio; // number
+
double StarterHP; // initial horsepower of starter motor
int BoostSpeeds; // Number of super/turbocharger boost speeds - zero implies no turbo/supercharging.
int BoostSpeed; // The current boost-speed (zero-based).
double minMAP; // Pa
double maxMAP; // Pa
double MAP; // Pa
- double BSFC; // brake specific fuel consumption [lbs/horsepower*hour
+ double ISFC; // Indicated specific fuel consumption [lbs/horsepower*hour
//
// Inputs (in addition to those in FGEngine).
//
double p_amb; // Pascals
- double p_amb_sea_level; // Pascals
double T_amb; // degrees Kelvin
double RPM; // revolutions per minute
double IAS; // knots
bool Magneto_Right;
int Magnetos;
-
//
// Outputs (in addition to those in FGEngine).
//
double m_dot_air;
double equivalence_ratio;
double m_dot_fuel;
- double Percentage_Power;
double HP;
double combustion_efficiency;
double ExhaustGasTemp_degK;
double CylinderHeadTemp_degK;
double OilPressure_psi;
double OilTemp_degK;
+ double MeanPistonSpeed_fps;
void Debug(int from);
};