Sync. w. JSBSim CVS
This commit is contained in:
parent
71c9cb9f48
commit
720b6fa3f6
9 changed files with 321 additions and 153 deletions
|
@ -514,56 +514,170 @@ bool FGFDMExec::LoadModel(string model, bool addModelToPath)
|
||||||
document = LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
|
document = LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
|
||||||
if (document) {
|
if (document) {
|
||||||
ReadPrologue(document);
|
ReadPrologue(document);
|
||||||
element = document->GetElement();
|
|
||||||
|
|
||||||
result = true;
|
// Process the fileheader element in the aircraft config file. This element is OPTIONAL.
|
||||||
while (element && result) {
|
element = document->FindElement("fileheader");
|
||||||
string element_name = element->GetName();
|
if (element) {
|
||||||
if (element_name == "fileheader" ) result = ReadFileHeader(element);
|
result = ReadFileHeader(element);
|
||||||
else if (element_name == "slave") result = ReadSlave(element);
|
if (!result) {
|
||||||
else if (element_name == "metrics") result = Aircraft->Load(element);
|
cerr << endl << "Aircraft fileheader element has problems in file " << aircraftCfgFileName << endl;
|
||||||
else if (element_name == "mass_balance") result = MassBalance->Load(element);
|
return result;
|
||||||
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);
|
// Process the metrics element. This element is REQUIRED.
|
||||||
else if (element_name == "system") result = FCS->Load(element,
|
element = document->FindElement("metrics");
|
||||||
FGFCS::stSystem);
|
if (element) {
|
||||||
else if (element_name == "autopilot") result = FCS->Load(element,
|
result = Aircraft->Load(element);
|
||||||
FGFCS::stAutoPilot);
|
if (!result) {
|
||||||
else if (element_name == "flight_control") result = FCS->Load(element,
|
cerr << endl << "Aircraft metrics element has problems in file " << aircraftCfgFileName << endl;
|
||||||
FGFCS::stFCS);
|
return result;
|
||||||
else if (element_name == "aerodynamics") result = Aerodynamics->Load(element);
|
}
|
||||||
else if (element_name == "input") result = Input->Load(element);
|
} else {
|
||||||
else if (element_name == "output") {
|
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);
|
FGOutput* Output = new FGOutput(this);
|
||||||
Output->InitModel();
|
Output->InitModel();
|
||||||
Schedule(Output, 1);
|
Schedule(Output, 1);
|
||||||
result = Output->Load(element);
|
result = Output->Load(element);
|
||||||
Outputs.push_back(Output);
|
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;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
cerr << "Found unexpected subsystem: " << element_name << ", exiting." << endl;
|
|
||||||
result = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
element = document->GetNextElement();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cerr << fgred
|
|
||||||
<< " JSBSim failed to load aircraft model."
|
|
||||||
<< fgdef << endl;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
|
||||||
modelLoaded = true;
|
modelLoaded = true;
|
||||||
Debug(3);
|
|
||||||
} else {
|
} else {
|
||||||
cerr << fgred
|
cerr << fgred
|
||||||
<< " JSBSim failed to load properly."
|
<< " JSBSim failed to open the configuration file: " << aircraftCfgFileName
|
||||||
<< fgdef << endl;
|
<< fgdef << endl;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PropertyCatalogStructure masterPCS;
|
struct PropertyCatalogStructure masterPCS;
|
||||||
|
|
|
@ -150,9 +150,6 @@ FGJSBsim::FGJSBsim( double dt )
|
||||||
// file on each FlightGear reset.
|
// file on each FlightGear reset.
|
||||||
fgGetNode("/fdm/jsbsim/simulation/write-state-file")->untie();
|
fgGetNode("/fdm/jsbsim/simulation/write-state-file")->untie();
|
||||||
fgGetNode("/fdm/jsbsim/simulation")->removeChild("write-state-file", false);
|
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
|
// end ugly hack
|
||||||
|
|
||||||
// Register ground callback.
|
// Register ground callback.
|
||||||
|
@ -328,9 +325,9 @@ void FGJSBsim::init()
|
||||||
Atmosphere->UseInternal();
|
Atmosphere->UseInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
fgic->SetVNorthFpsIC( wind_from_north->getDoubleValue() );
|
fgic->SetVNorthFpsIC( -wind_from_north->getDoubleValue() );
|
||||||
fgic->SetVEastFpsIC( wind_from_east->getDoubleValue() );
|
fgic->SetVEastFpsIC( -wind_from_east->getDoubleValue() );
|
||||||
fgic->SetVDownFpsIC( wind_from_down->getDoubleValue() );
|
fgic->SetVDownFpsIC( -wind_from_down->getDoubleValue() );
|
||||||
|
|
||||||
//Atmosphere->SetExTemperature(get_Static_temperature());
|
//Atmosphere->SetExTemperature(get_Static_temperature());
|
||||||
//Atmosphere->SetExPressure(get_Static_pressure());
|
//Atmosphere->SetExPressure(get_Static_pressure());
|
||||||
|
@ -625,9 +622,9 @@ bool FGJSBsim::copy_to_JSBsim()
|
||||||
tmp = turbulence_rate->getDoubleValue();
|
tmp = turbulence_rate->getDoubleValue();
|
||||||
//Atmosphere->SetTurbRate(tmp);
|
//Atmosphere->SetTurbRate(tmp);
|
||||||
|
|
||||||
Atmosphere->SetWindNED( wind_from_north->getDoubleValue(),
|
Atmosphere->SetWindNED( -wind_from_north->getDoubleValue(),
|
||||||
wind_from_east->getDoubleValue(),
|
-wind_from_east->getDoubleValue(),
|
||||||
wind_from_down->getDoubleValue() );
|
-wind_from_down->getDoubleValue() );
|
||||||
// SG_LOG(SG_FLIGHT,SG_INFO, "Wind NED: "
|
// SG_LOG(SG_FLIGHT,SG_INFO, "Wind NED: "
|
||||||
// << get_V_north_airmass() << ", "
|
// << get_V_north_airmass() << ", "
|
||||||
// << get_V_east_airmass() << ", "
|
// << get_V_east_airmass() << ", "
|
||||||
|
@ -1100,6 +1097,7 @@ void FGJSBsim::init_gear(void )
|
||||||
node->setDoubleValue("yoffset-in", gear->GetBodyLocation()(2));
|
node->setDoubleValue("yoffset-in", gear->GetBodyLocation()(2));
|
||||||
node->setDoubleValue("zoffset-in", gear->GetBodyLocation()(3));
|
node->setDoubleValue("zoffset-in", gear->GetBodyLocation()(3));
|
||||||
node->setBoolValue("wow", gear->GetWOW());
|
node->setBoolValue("wow", gear->GetWOW());
|
||||||
|
node->setDoubleValue("rollspeed-ms", gear->GetWheelRollVel()*0.3043);
|
||||||
node->setBoolValue("has-brake", gear->GetBrakeGroup() > 0);
|
node->setBoolValue("has-brake", gear->GetBrakeGroup() > 0);
|
||||||
node->setDoubleValue("position-norm", gear->GetGearUnitPos());
|
node->setDoubleValue("position-norm", gear->GetGearUnitPos());
|
||||||
node->setDoubleValue("tire-pressure-norm", gear->GetTirePressure());
|
node->setDoubleValue("tire-pressure-norm", gear->GetTirePressure());
|
||||||
|
@ -1118,6 +1116,7 @@ void FGJSBsim::update_gear(void)
|
||||||
FGLGear *gear = gr->GetGearUnit(i);
|
FGLGear *gear = gr->GetGearUnit(i);
|
||||||
SGPropertyNode * node = fgGetNode("gear/gear", i, true);
|
SGPropertyNode * node = fgGetNode("gear/gear", i, true);
|
||||||
node->getChild("wow", 0, true)->setBoolValue( gear->GetWOW());
|
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());
|
node->getChild("position-norm", 0, true)->setDoubleValue(gear->GetGearUnitPos());
|
||||||
gear->SetTirePressure(node->getDoubleValue("tire-pressure-norm"));
|
gear->SetTirePressure(node->getDoubleValue("tire-pressure-norm"));
|
||||||
node->setDoubleValue("compression-norm", gear->GetCompLen());
|
node->setDoubleValue("compression-norm", gear->GetCompLen());
|
||||||
|
|
|
@ -69,7 +69,9 @@ FGInitialCondition::FGInitialCondition(FGFDMExec *FDMExec) : fdmex(FDMExec)
|
||||||
fdmex->GetPropagate()->Seth(altitude);
|
fdmex->GetPropagate()->Seth(altitude);
|
||||||
fdmex->GetAtmosphere()->Run();
|
fdmex->GetAtmosphere()->Run();
|
||||||
PropertyManager=fdmex->GetPropertyManager();
|
PropertyManager=fdmex->GetPropertyManager();
|
||||||
|
Constructing = true;
|
||||||
bind();
|
bind();
|
||||||
|
Constructing = false;
|
||||||
} else {
|
} else {
|
||||||
cout << "FGInitialCondition: This class requires a pointer to a valid FGFDMExec object" << endl;
|
cout << "FGInitialCondition: This class requires a pointer to a valid FGFDMExec object" << endl;
|
||||||
}
|
}
|
||||||
|
@ -156,6 +158,8 @@ void FGInitialCondition::InitializeIC(void)
|
||||||
|
|
||||||
void FGInitialCondition::WriteStateFile(int num)
|
void FGInitialCondition::WriteStateFile(int num)
|
||||||
{
|
{
|
||||||
|
if (Constructing) return;
|
||||||
|
|
||||||
string filename = fdmex->GetFullAircraftPath();
|
string filename = fdmex->GetFullAircraftPath();
|
||||||
|
|
||||||
if (filename.empty())
|
if (filename.empty())
|
||||||
|
|
|
@ -644,6 +644,7 @@ private:
|
||||||
FGFDMExec *fdmex;
|
FGFDMExec *fdmex;
|
||||||
FGPropertyManager *PropertyManager;
|
FGPropertyManager *PropertyManager;
|
||||||
|
|
||||||
|
bool Constructing;
|
||||||
bool getAlpha(void);
|
bool getAlpha(void);
|
||||||
bool getTheta(void);
|
bool getTheta(void);
|
||||||
bool getMachFromVcas(double *Mach,double vcas);
|
bool getMachFromVcas(double *Mach,double vcas);
|
||||||
|
|
|
@ -340,6 +340,9 @@ FGColumnVector3& FGLGear::Force(void)
|
||||||
WOW = false;
|
WOW = false;
|
||||||
compressLength = 0.0;
|
compressLength = 0.0;
|
||||||
|
|
||||||
|
// No wheel conditons
|
||||||
|
RollingWhlVel = SideWhlVel = WheelSlip = 0.0;
|
||||||
|
|
||||||
// Return to neutral position between 1.0 and 0.8 gear pos.
|
// Return to neutral position between 1.0 and 0.8 gear pos.
|
||||||
SteerAngle *= max(GetGearUnitPos()-0.8, 0.0)/0.2;
|
SteerAngle *= max(GetGearUnitPos()-0.8, 0.0)/0.2;
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,9 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
|
||||||
dt = State->Getdt();
|
dt = State->Getdt();
|
||||||
|
|
||||||
// These items are read from the configuration file
|
// These items are read from the configuration file
|
||||||
|
// Defaults are from a Lycoming O-360, more or less
|
||||||
|
|
||||||
Cycles = 2;
|
Cycles = 4;
|
||||||
IdleRPM = 600;
|
IdleRPM = 600;
|
||||||
MaxRPM = 2800;
|
MaxRPM = 2800;
|
||||||
Displacement = 360;
|
Displacement = 360;
|
||||||
|
@ -80,10 +81,12 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
|
||||||
MaxHP = 200;
|
MaxHP = 200;
|
||||||
MinManifoldPressure_inHg = 6.5;
|
MinManifoldPressure_inHg = 6.5;
|
||||||
MaxManifoldPressure_inHg = 28.5;
|
MaxManifoldPressure_inHg = 28.5;
|
||||||
BSFC = -1;
|
ISFC = -1;
|
||||||
|
volumetric_efficiency = -0.1;
|
||||||
// Initialisation
|
Bore = 5.125;
|
||||||
volumetric_efficiency = 0.8; // Actually f(speed, load) but this will get us running
|
Stroke = 4.375;
|
||||||
|
Cylinders = 4;
|
||||||
|
CompressionRatio = 8.5;
|
||||||
|
|
||||||
// These are internal program variables
|
// These are internal program variables
|
||||||
|
|
||||||
|
@ -173,9 +176,17 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
|
||||||
if (el->FindElement("minthrottle"))
|
if (el->FindElement("minthrottle"))
|
||||||
MinThrottle = el->FindElementValueAsNumber("minthrottle");
|
MinThrottle = el->FindElementValueAsNumber("minthrottle");
|
||||||
if (el->FindElement("bsfc"))
|
if (el->FindElement("bsfc"))
|
||||||
BSFC = el->FindElementValueAsNumberConvertTo("bsfc", "LBS/HP*HR");
|
ISFC = el->FindElementValueAsNumberConvertTo("bsfc", "LBS/HP*HR");
|
||||||
if (el->FindElement("volumetric-efficiency"))
|
if (el->FindElement("volumetric-efficiency"))
|
||||||
volumetric_efficiency = el->FindElementValueAsNumber("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
|
if (el->FindElement("numboostspeeds")) { // Turbo- and super-charging parameters
|
||||||
BoostSpeeds = (int)el->FindElementValueAsNumber("numboostspeeds");
|
BoostSpeeds = (int)el->FindElementValueAsNumber("numboostspeeds");
|
||||||
if (el->FindElement("boostoverride"))
|
if (el->FindElement("boostoverride"))
|
||||||
|
@ -208,30 +219,42 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
|
||||||
RatedAltitude[2] = el->FindElementValueAsNumberConvertTo("ratedaltitude3", "FT");
|
RatedAltitude[2] = el->FindElementValueAsNumberConvertTo("ratedaltitude3", "FT");
|
||||||
}
|
}
|
||||||
|
|
||||||
MaxManifoldPressure_Percent = MaxManifoldPressure_inHg / 29.92;
|
StarterHP = sqrt(MaxHP) * 0.4;
|
||||||
// Create a BSFC to match the engine if not provided
|
displacement_SI = Displacement * in3tom3;
|
||||||
if (BSFC < 0) {
|
|
||||||
BSFC = ( Displacement * MaxRPM * volumetric_efficiency ) / (9411 * MaxHP);
|
// Create IFSC and VE to match the engine if not provided
|
||||||
BSFC *= (MaxManifoldPressure_Percent * MaxManifoldPressure_Percent * MaxManifoldPressure_Percent);
|
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
|
if ( MaxManifoldPressure_inHg > 29.9 ) { // Don't allow boosting with a bogus number
|
||||||
MaxManifoldPressure_inHg = 29.9;
|
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;
|
string property_name, base_property_name;
|
||||||
base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
|
base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
|
||||||
property_name = base_property_name + "/power-hp";
|
property_name = base_property_name + "/power-hp";
|
||||||
PropertyManager->Tie(property_name, &HP);
|
PropertyManager->Tie(property_name, &HP);
|
||||||
property_name = base_property_name + "/bsfc-lbs_hphr";
|
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";
|
property_name = base_property_name + "/volumetric-efficiency";
|
||||||
PropertyManager->Tie(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";
|
property_name = base_property_name + "/map-inhg";
|
||||||
PropertyManager->Tie(property_name, &ManifoldPressure_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.
|
// Set up and sanity-check the turbo/supercharging configuration based on the input values.
|
||||||
if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true;
|
if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true;
|
||||||
|
@ -279,9 +302,6 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
|
||||||
BoostSpeed = 0;
|
BoostSpeed = 0;
|
||||||
}
|
}
|
||||||
bBoostOverride = (BoostOverride == 1 ? true : false);
|
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
|
Debug(0); // Call Debug() routine from constructor if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +339,7 @@ double FGPiston::Calculate(void)
|
||||||
if (FuelFlow_gph > 0.0) ConsumeFuel();
|
if (FuelFlow_gph > 0.0) ConsumeFuel();
|
||||||
|
|
||||||
Throttle = FCS->GetThrottlePos(EngineNumber);
|
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 );
|
ThrottleAngle = MinThrottle+((MaxThrottle-MinThrottle)*Throttle );
|
||||||
Mixture = FCS->GetMixturePos(EngineNumber);
|
Mixture = FCS->GetMixturePos(EngineNumber);
|
||||||
|
|
||||||
|
@ -328,10 +348,10 @@ double FGPiston::Calculate(void)
|
||||||
//
|
//
|
||||||
|
|
||||||
p_amb = Atmosphere->GetPressure() * psftopa;
|
p_amb = Atmosphere->GetPressure() * psftopa;
|
||||||
p_amb_sea_level = Atmosphere->GetPressureSL() * psftopa;
|
|
||||||
T_amb = RankineToKelvin(Atmosphere->GetTemperature());
|
T_amb = RankineToKelvin(Atmosphere->GetTemperature());
|
||||||
|
|
||||||
RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
|
RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
|
||||||
|
MeanPistonSpeed_fps = ( RPM * Stroke) / (360); // AKA 2 * (RPM/60) * ( Stroke / 12) or 2NS
|
||||||
|
|
||||||
IAS = Auxiliary->GetVcalibratedKTS();
|
IAS = Auxiliary->GetVcalibratedKTS();
|
||||||
|
|
||||||
|
@ -349,7 +369,7 @@ double FGPiston::Calculate(void)
|
||||||
// Running = false;
|
// Running = false;
|
||||||
|
|
||||||
doEnginePower();
|
doEnginePower();
|
||||||
if (HP < 0.1250) Running = false;
|
if (IndicatedHorsePower < 0.1250) Running = false;
|
||||||
|
|
||||||
doEGT();
|
doEGT();
|
||||||
doCHT();
|
doCHT();
|
||||||
|
@ -489,20 +509,33 @@ void FGPiston::doBoostControl(void)
|
||||||
* from the throttle position, turbo/supercharger boost control
|
* from the throttle position, turbo/supercharger boost control
|
||||||
* system, engine speed and local ambient air density.
|
* system, engine speed and local ambient air density.
|
||||||
*
|
*
|
||||||
* Inputs: p_amb, Throttle, MaxManifoldPressure_Percent, ThrottleAngle
|
* Inputs: p_amb, Throttle, ThrottleAngle,
|
||||||
* RPM, MaxRPM
|
* MeanPistonSpeed_fps, dt
|
||||||
*
|
*
|
||||||
* Outputs: MAP, ManifoldPressure_inHg
|
* Outputs: MAP, ManifoldPressure_inHg
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void FGPiston::doMAP(void)
|
void FGPiston::doMAP(void)
|
||||||
{
|
{
|
||||||
// estimate throttle plate area. This maps 0.2 -> 0.1 for historical performance reasons
|
// estimate throttle plate area.
|
||||||
double throttle_area = ThrottleAngle * 1.125 - 0.125;
|
double throttle_area = ThrottleAngle*ThrottleAngle;
|
||||||
map_coefficient = pow ((throttle_area * MaxManifoldPressure_Percent),RPM/MaxRPM);
|
// Internal Combustion Engine in Theory and Practice, Volume 2. Charles Fayette Taylor. Revised Edition, 1985 fig 6-13
|
||||||
MAP = p_amb * map_coefficient;
|
double map_coefficient = 1-((MeanPistonSpeed_fps*MeanPistonSpeed_fps)/(24978*throttle_area));
|
||||||
|
|
||||||
if(Boosted) {
|
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:
|
// If takeoff boost is fitted, we currently assume the following throttle map:
|
||||||
// (In throttle % - actual input is 0 -> 1)
|
// (In throttle % - actual input is 0 -> 1)
|
||||||
// 99 / 100 - Takeoff boost
|
// 99 / 100 - Takeoff boost
|
||||||
|
@ -510,19 +543,15 @@ void FGPiston::doMAP(void)
|
||||||
// 0 - 95 - Idle to Rated boost (MinManifoldPressure to MaxManifoldPressure)
|
// 0 - 95 - Idle to Rated boost (MinManifoldPressure to MaxManifoldPressure)
|
||||||
// In real life, most planes would be fitted with a mechanical 'gate' between
|
// In real life, most planes would be fitted with a mechanical 'gate' between
|
||||||
// the rated boost and takeoff boost positions.
|
// the rated boost and takeoff boost positions.
|
||||||
double T = Throttle; // processed throttle value.
|
|
||||||
bool bTakeoffPos = false;
|
bool bTakeoffPos = false;
|
||||||
if(bTakeoffBoost) {
|
if (bTakeoffBoost) {
|
||||||
if(Throttle > 0.98) {
|
if (Throttle > 0.98) {
|
||||||
//cout << "Takeoff Boost!!!!\n";
|
|
||||||
bTakeoffPos = true;
|
bTakeoffPos = true;
|
||||||
} else if(Throttle <= 0.95) {
|
} else if(Throttle <= 0.95) {
|
||||||
bTakeoffPos = false;
|
bTakeoffPos = false;
|
||||||
T *= 1.0 / 0.95;
|
|
||||||
} else {
|
} else {
|
||||||
bTakeoffPos = false;
|
bTakeoffPos = false;
|
||||||
//cout << "Rated Boost!!\n";
|
|
||||||
T = 1.0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Boost the manifold pressure.
|
// Boost the manifold pressure.
|
||||||
|
@ -530,14 +559,10 @@ void FGPiston::doMAP(void)
|
||||||
if (boost_factor < 1.0) boost_factor = 1.0; // boost will never reduce the MAP
|
if (boost_factor < 1.0) boost_factor = 1.0; // boost will never reduce the MAP
|
||||||
MAP *= boost_factor;
|
MAP *= boost_factor;
|
||||||
// Now clip the manifold pressure to BCV or Wastegate setting.
|
// Now clip the manifold pressure to BCV or Wastegate setting.
|
||||||
if(bTakeoffPos) {
|
if (bTakeoffPos) {
|
||||||
if(MAP > TakeoffMAP[BoostSpeed]) {
|
if (MAP > TakeoffMAP[BoostSpeed]) MAP = TakeoffMAP[BoostSpeed];
|
||||||
MAP = TakeoffMAP[BoostSpeed];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if(MAP > RatedMAP[BoostSpeed]) {
|
if (MAP > RatedMAP[BoostSpeed]) MAP = RatedMAP[BoostSpeed];
|
||||||
MAP = RatedMAP[BoostSpeed];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,20 +586,24 @@ void FGPiston::doMAP(void)
|
||||||
|
|
||||||
void FGPiston::doAirFlow(void)
|
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);
|
rho_air = p_amb / (R_air * T_amb);
|
||||||
double displacement_SI = Displacement * in3tom3;
|
|
||||||
double swept_volume = (displacement_SI * (RPM/60)) / 2;
|
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);
|
double rho_air_manifold = MAP / (R_air * T_amb);
|
||||||
m_dot_air = v_dot_air * rho_air_manifold;
|
m_dot_air = v_dot_air * rho_air_manifold;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
/**
|
/**
|
||||||
* Calculate the fuel flow into the engine.
|
* 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
|
* Outputs: equivalence_ratio, m_dot_fuel
|
||||||
*/
|
*/
|
||||||
|
@ -601,49 +630,53 @@ void FGPiston::doFuelFlow(void)
|
||||||
* 200HP.
|
* 200HP.
|
||||||
*
|
*
|
||||||
* Inputs: ManifoldPressure_inHg, p_amb, RPM, T_amb,
|
* 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)
|
void FGPiston::doEnginePower(void)
|
||||||
{
|
{
|
||||||
|
IndicatedHorsePower = 0;
|
||||||
|
FMEP = 0;
|
||||||
if (Running) {
|
if (Running) {
|
||||||
// FIXME: this needs to be generalized
|
// 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);
|
ME = Mixture_Efficiency_Correlation->GetValue(m_dot_fuel/m_dot_air);
|
||||||
|
|
||||||
percent_RPM = RPM/MaxRPM;
|
percent_RPM = RPM/MaxRPM;
|
||||||
friction = 1 - (percent_RPM * percent_RPM * percent_RPM * percent_RPM/10);
|
// Guestimate engine friction as a percentage of rated HP + a percentage of rpm + a percentage of Indicted HP
|
||||||
if (friction < 0 ) friction = 0;
|
// friction = 1 - (percent_RPM * percent_RPM * percent_RPM/10);
|
||||||
power = friction;
|
FMEP = (-18400 * MeanPistonSpeed_fps * fttom - 46500);
|
||||||
|
|
||||||
|
power = 1;
|
||||||
|
|
||||||
if ( Magnetos != 3 ) power *= SparkFailDrop;
|
if ( Magnetos != 3 ) power *= SparkFailDrop;
|
||||||
|
|
||||||
|
|
||||||
HP = (FuelFlow_gph * 6.0 / BSFC )* ME * map_coefficient * power;
|
IndicatedHorsePower = (FuelFlow_pph / ISFC )* ME * power;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Power output when the engine is not running
|
// Power output when the engine is not running
|
||||||
if (Cranking) {
|
if (Cranking) {
|
||||||
if (RPM < 10) {
|
if (RPM < 10) {
|
||||||
HP = StarterHP;
|
IndicatedHorsePower = StarterHP;
|
||||||
} else if (RPM < IdleRPM*0.8) {
|
} 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
|
// This is a guess - would be nice to find a proper starter moter torque curve
|
||||||
} else {
|
} 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;
|
// cout << "Power = " << HP << " RPM = " << RPM << " Running = " << Running << " Cranking = " << Cranking << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,7 +685,7 @@ void FGPiston::doEnginePower(void)
|
||||||
* Calculate the exhaust gas temperature.
|
* Calculate the exhaust gas temperature.
|
||||||
*
|
*
|
||||||
* Inputs: equivalence_ratio, m_dot_fuel, calorific_value_fuel,
|
* 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
|
* Outputs: combustion_efficiency, ExhaustGasTemp_degK
|
||||||
*/
|
*/
|
||||||
|
@ -671,7 +704,7 @@ void FGPiston::doEGT(void)
|
||||||
heat_capacity_exhaust = (Cp_air * m_dot_air) + (Cp_fuel * m_dot_fuel);
|
heat_capacity_exhaust = (Cp_air * m_dot_air) + (Cp_fuel * m_dot_fuel);
|
||||||
delta_T_exhaust = enthalpy_exhaust / heat_capacity_exhaust;
|
delta_T_exhaust = enthalpy_exhaust / heat_capacity_exhaust;
|
||||||
ExhaustGasTemp_degK = T_amb + delta_T_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
|
} else { // Drop towards ambient - guess an appropriate time constant for now
|
||||||
combustion_efficiency = 0;
|
combustion_efficiency = 0;
|
||||||
dEGTdt = (RankineToKelvin(Atmosphere->GetTemperature()) - ExhaustGasTemp_degK) / 100.0;
|
dEGTdt = (RankineToKelvin(Atmosphere->GetTemperature()) - ExhaustGasTemp_degK) / 100.0;
|
||||||
|
@ -837,12 +870,17 @@ void FGPiston::Debug(int from)
|
||||||
cout << " MinMaP (Pa): " << minMAP << endl;
|
cout << " MinMaP (Pa): " << minMAP << endl;
|
||||||
cout << " MaxMaP (Pa): " << maxMAP << endl;
|
cout << " MaxMaP (Pa): " << maxMAP << endl;
|
||||||
cout << " Displacement: " << Displacement << 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 << " MaxHP: " << MaxHP << endl;
|
||||||
cout << " Cycles: " << Cycles << endl;
|
cout << " Cycles: " << Cycles << endl;
|
||||||
cout << " IdleRPM: " << IdleRPM << endl;
|
cout << " IdleRPM: " << IdleRPM << endl;
|
||||||
cout << " MaxThrottle: " << MaxThrottle << endl;
|
cout << " MaxThrottle: " << MaxThrottle << endl;
|
||||||
cout << " MinThrottle: " << MinThrottle << endl;
|
cout << " MinThrottle: " << MinThrottle << endl;
|
||||||
cout << " BSFC: " << BSFC << endl;
|
cout << " ISFC: " << ISFC << endl;
|
||||||
|
cout << " Volumentric Efficiency: " << volumetric_efficiency << endl;
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
cout << " Combustion Efficiency table:" << endl;
|
cout << " Combustion Efficiency table:" << endl;
|
||||||
|
|
|
@ -67,8 +67,12 @@ CLASS DOCUMENTATION
|
||||||
@code
|
@code
|
||||||
<piston_engine name="{string}">
|
<piston_engine name="{string}">
|
||||||
<minmp unit="{INHG | PA | ATM}"> {number} </minmp> <!-- Depricated -->
|
<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>
|
<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>
|
<sparkfaildrop> {number} </sparkfaildrop>
|
||||||
<maxhp unit="{HP | WATTS}"> {number} </maxhp>
|
<maxhp unit="{HP | WATTS}"> {number} </maxhp>
|
||||||
<cycles> {number} </cycles>
|
<cycles> {number} </cycles>
|
||||||
|
@ -76,9 +80,9 @@ CLASS DOCUMENTATION
|
||||||
<maxrpm> {number} </maxrpm>
|
<maxrpm> {number} </maxrpm>
|
||||||
<maxthrottle> {number} </maxthrottle>
|
<maxthrottle> {number} </maxthrottle>
|
||||||
<minthrottle> {number} </minthrottle>
|
<minthrottle> {number} </minthrottle>
|
||||||
<numboostspeeds> {number} </numboostspeeds>
|
|
||||||
<bsfc unit="{LBS/HP*HR | "KG/KW*HR"}"> {number} </bsft>
|
<bsfc unit="{LBS/HP*HR | "KG/KW*HR"}"> {number} </bsft>
|
||||||
<volumetric_efficiency> {number} </volumetric_efficiency>
|
<volumetric_efficiency> {number} </volumetric_efficiency>
|
||||||
|
<numboostspeeds> {number} </numboostspeeds>
|
||||||
<boostoverride> {0 | 1} </boostoverride>
|
<boostoverride> {0 | 1} </boostoverride>
|
||||||
<ratedboost1 unit="{INHG | PA | ATM}"> {number} </ratedboost1>
|
<ratedboost1 unit="{INHG | PA | ATM}"> {number} </ratedboost1>
|
||||||
<ratedpower1 unit="{HP | WATTS}"> {number} </ratedpower1>
|
<ratedpower1 unit="{HP | WATTS}"> {number} </ratedpower1>
|
||||||
|
@ -210,7 +214,9 @@ protected:
|
||||||
private:
|
private:
|
||||||
int crank_counter;
|
int crank_counter;
|
||||||
|
|
||||||
double BrakeHorsePower;
|
double IndicatedHorsePower;
|
||||||
|
double PMEP;
|
||||||
|
double FMEP;
|
||||||
double SpeedSlope;
|
double SpeedSlope;
|
||||||
double SpeedIntercept;
|
double SpeedIntercept;
|
||||||
double AltitudeSlope;
|
double AltitudeSlope;
|
||||||
|
@ -243,7 +249,6 @@ private:
|
||||||
const double Cp_fuel; // J/KgK
|
const double Cp_fuel; // J/KgK
|
||||||
|
|
||||||
FGTable *Lookup_Combustion_Efficiency;
|
FGTable *Lookup_Combustion_Efficiency;
|
||||||
FGTable *Power_Mixture_Correlation;
|
|
||||||
FGTable *Mixture_Efficiency_Correlation;
|
FGTable *Mixture_Efficiency_Correlation;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -253,11 +258,17 @@ private:
|
||||||
double MaxManifoldPressure_inHg; // Inches Hg
|
double MaxManifoldPressure_inHg; // Inches Hg
|
||||||
double MaxManifoldPressure_Percent; // MaxManifoldPressure / 29.92
|
double MaxManifoldPressure_Percent; // MaxManifoldPressure / 29.92
|
||||||
double Displacement; // cubic inches
|
double Displacement; // cubic inches
|
||||||
|
double displacement_SI; // cubic meters
|
||||||
double MaxHP; // horsepower
|
double MaxHP; // horsepower
|
||||||
double SparkFailDrop; // drop of power due to spark failure
|
double SparkFailDrop; // drop of power due to spark failure
|
||||||
double Cycles; // cycles/power stroke
|
double Cycles; // cycles/power stroke
|
||||||
double IdleRPM; // revolutions per minute
|
double IdleRPM; // revolutions per minute
|
||||||
double MaxRPM; // 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
|
double StarterHP; // initial horsepower of starter motor
|
||||||
int BoostSpeeds; // Number of super/turbocharger boost speeds - zero implies no turbo/supercharging.
|
int BoostSpeeds; // Number of super/turbocharger boost speeds - zero implies no turbo/supercharging.
|
||||||
int BoostSpeed; // The current boost-speed (zero-based).
|
int BoostSpeed; // The current boost-speed (zero-based).
|
||||||
|
@ -284,13 +295,12 @@ private:
|
||||||
double minMAP; // Pa
|
double minMAP; // Pa
|
||||||
double maxMAP; // Pa
|
double maxMAP; // Pa
|
||||||
double MAP; // 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).
|
// Inputs (in addition to those in FGEngine).
|
||||||
//
|
//
|
||||||
double p_amb; // Pascals
|
double p_amb; // Pascals
|
||||||
double p_amb_sea_level; // Pascals
|
|
||||||
double T_amb; // degrees Kelvin
|
double T_amb; // degrees Kelvin
|
||||||
double RPM; // revolutions per minute
|
double RPM; // revolutions per minute
|
||||||
double IAS; // knots
|
double IAS; // knots
|
||||||
|
@ -298,7 +308,6 @@ private:
|
||||||
bool Magneto_Right;
|
bool Magneto_Right;
|
||||||
int Magnetos;
|
int Magnetos;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Outputs (in addition to those in FGEngine).
|
// Outputs (in addition to those in FGEngine).
|
||||||
//
|
//
|
||||||
|
@ -308,7 +317,6 @@ private:
|
||||||
double m_dot_air;
|
double m_dot_air;
|
||||||
double equivalence_ratio;
|
double equivalence_ratio;
|
||||||
double m_dot_fuel;
|
double m_dot_fuel;
|
||||||
double Percentage_Power;
|
|
||||||
double HP;
|
double HP;
|
||||||
double combustion_efficiency;
|
double combustion_efficiency;
|
||||||
double ExhaustGasTemp_degK;
|
double ExhaustGasTemp_degK;
|
||||||
|
@ -317,6 +325,7 @@ private:
|
||||||
double CylinderHeadTemp_degK;
|
double CylinderHeadTemp_degK;
|
||||||
double OilPressure_psi;
|
double OilPressure_psi;
|
||||||
double OilTemp_degK;
|
double OilTemp_degK;
|
||||||
|
double MeanPistonSpeed_fps;
|
||||||
|
|
||||||
void Debug(int from);
|
void Debug(int from);
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,6 +37,7 @@ INCLUDES
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
#include "FGTank.h"
|
#include "FGTank.h"
|
||||||
|
#include <models/FGAuxiliary.h>
|
||||||
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
@ -52,7 +53,7 @@ CLASS IMPLEMENTATION
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number)
|
FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number)
|
||||||
: TankNumber(tank_number)
|
: TankNumber(tank_number), Exec(exec)
|
||||||
{
|
{
|
||||||
string token;
|
string token;
|
||||||
Element* element;
|
Element* element;
|
||||||
|
@ -60,9 +61,8 @@ FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number)
|
||||||
Area = 1.0;
|
Area = 1.0;
|
||||||
Temperature = -9999.0;
|
Temperature = -9999.0;
|
||||||
Ixx = Iyy = Izz = 0.0;
|
Ixx = Iyy = Izz = 0.0;
|
||||||
Auxiliary = exec->GetAuxiliary();
|
|
||||||
Radius = Capacity = Contents = Standpipe = Length = InnerRadius = 0.0;
|
Radius = Capacity = Contents = Standpipe = Length = InnerRadius = 0.0;
|
||||||
PropertyManager = exec->GetPropertyManager();
|
PropertyManager = Exec->GetPropertyManager();
|
||||||
vXYZ.InitMatrix();
|
vXYZ.InitMatrix();
|
||||||
vXYZ_drain.InitMatrix();
|
vXYZ_drain.InitMatrix();
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ double FGTank::Calculate(double dt)
|
||||||
if (Temperature == -9999.0) return 0.0;
|
if (Temperature == -9999.0) return 0.0;
|
||||||
double HeatCapacity = 900.0; // Joules/lbm/C
|
double HeatCapacity = 900.0; // Joules/lbm/C
|
||||||
double TempFlowFactor = 1.115; // Watts/sqft/C
|
double TempFlowFactor = 1.115; // Watts/sqft/C
|
||||||
double TAT = Auxiliary->GetTAT_C();
|
double TAT = Exec->GetAuxiliary()->GetTAT_C();
|
||||||
double Tdiff = TAT - Temperature;
|
double Tdiff = TAT - Temperature;
|
||||||
double dTemp = 0.0; // Temp change due to one surface
|
double dTemp = 0.0; // Temp change due to one surface
|
||||||
if (fabs(Tdiff) > 0.1) {
|
if (fabs(Tdiff) > 0.1) {
|
||||||
|
|
|
@ -44,10 +44,10 @@ SENTRY
|
||||||
INCLUDES
|
INCLUDES
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
|
||||||
|
|
||||||
|
#include "FGFDMExec.h"
|
||||||
#include <FGJSBBase.h>
|
#include <FGJSBBase.h>
|
||||||
#include <input_output/FGXMLElement.h>
|
#include <input_output/FGXMLElement.h>
|
||||||
#include <math/FGColumnVector3.h>
|
#include <math/FGColumnVector3.h>
|
||||||
#include <models/FGAuxiliary.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
@ -281,7 +281,7 @@ private:
|
||||||
double Temperature, InitialTemperature;
|
double Temperature, InitialTemperature;
|
||||||
double Standpipe, InitialStandpipe;
|
double Standpipe, InitialStandpipe;
|
||||||
bool Selected;
|
bool Selected;
|
||||||
FGAuxiliary* Auxiliary;
|
FGFDMExec* Exec;
|
||||||
FGPropertyManager* PropertyManager;
|
FGPropertyManager* PropertyManager;
|
||||||
void CalculateInertias(void);
|
void CalculateInertias(void);
|
||||||
void Debug(int from);
|
void Debug(int from);
|
||||||
|
|
Loading…
Reference in a new issue