namespace JSBSim {
-static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.50 2011/08/03 03:21:06 jberndt Exp $";
+static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.61 2012/04/14 18:10:44 bcoconni Exp $";
static const char *IdHdr = ID_PROPULSION;
extern short debug_lvl;
unsigned int TanksWithOxidizer=0, CurrentOxidizerTankPriority=1;
vector <int> FeedListFuel, FeedListOxi;
bool Starved = true; // Initially set Starved to true. Set to false in code below.
-// bool hasOxTanks = false;
+ bool hasOxTanks = false;
// For this engine,
// 1) Count how many fuel tanks with the current priority level have fuel
if (TanksWithFuel == 0) CurrentFuelTankPriority++; // No tanks at this priority, try next priority
}
+ bool FuelStarved = Starved;
+ Starved = true;
+
// Process Oxidizer tanks, if any
if (engine->GetType() == FGEngine::etRocket) {
while ((TanksWithOxidizer == 0) && (CurrentOxidizerTankPriority <= numTanks)) {
// Skip this here (done above)
break;
case FGTank::ttOXIDIZER:
-// hasOxTanks = true;
+ hasOxTanks = true;
if (Tank->GetContents() > 0.0 && Tank->GetSelected() && TankPriority == CurrentOxidizerTankPriority) {
TanksWithOxidizer++;
if (TanksWithFuel > 0) Starved = false;
}
}
- engine->SetStarved(Starved); // Tanks can be refilled, so be sure to reset engine Starved flag here.
+ bool OxiStarved = Starved;
+
+ engine->SetStarved(FuelStarved || (hasOxTanks && OxiStarved)); // Tanks can be refilled, so be sure to reset engine Starved flag here.
// No fuel or fuel/oxidizer found at any priority!
- if (Starved) return;
+// if (Starved) return;
+ if (FuelStarved || (hasOxTanks && OxiStarved)) return;
double FuelToBurn = engine->CalcFuelNeed(); // How much fuel does this engine need?
double FuelNeededPerTank = FuelToBurn / TanksWithFuel; // Determine fuel needed per tank.
bool FGPropulsion::Load(Element* el)
{
string type, engine_filename;
- bool ThrottleAdded = false;
Debug(2);
fullpath = enginePath + separator;
localpath = aircraftPath + separator + "Engines" + separator;
- engine_file.open(string(fullpath + engine_filename + ".xml").c_str());
+ engine_file.open(string(localpath + engine_filename + ".xml").c_str());
if ( !engine_file.is_open()) {
- engine_file.open(string(localpath + engine_filename + ".xml").c_str());
+ engine_file.open(string(fullpath + engine_filename + ".xml").c_str());
if ( !engine_file.is_open()) {
cerr << " Could not open engine file: " << engine_filename << " in path "
<< fullpath << " or " << localpath << endl;
return string("");
} else {
- return string(localpath + engine_filename + ".xml");
+ return string(fullpath + engine_filename + ".xml");
}
}
- return string(fullpath + engine_filename + ".xml");
+ return string(localpath + engine_filename + ".xml");
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fullpath = enginePath + separator;
localpath = aircraftPath + separator + "Engines" + separator;
- engine_file->open(string(fullpath + engine_filename + ".xml").c_str());
+ engine_file->open(string(localpath + engine_filename + ".xml").c_str());
if ( !engine_file->is_open()) {
- engine_file->open(string(localpath + engine_filename + ".xml").c_str());
+ engine_file->open(string(fullpath + engine_filename + ".xml").c_str());
if ( !engine_file->is_open()) {
cerr << " Could not open engine file: " << engine_filename << " in path "
- << fullpath << " or " << localpath << endl;
+ << localpath << " or " << fullpath << endl;
}
}
return engine_file;
else if (Tanks[i]->GetType() == FGTank::ttOXIDIZER) buf << delimiter << "Oxidizer Tank " << i;
}
+ PropulsionStrings += buf.str();
+ buf.str("");
+
return PropulsionStrings;
}
buf << Tanks[i]->GetContents();
}
+ PropulsionValues += buf.str();
+ buf.str("");
+
return PropulsionValues;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3& FGPropulsion::GetTanksMoment(void)
+const FGColumnVector3& FGPropulsion::GetTanksMoment(void)
{
vXYZtank_arm.InitMatrix();
for (unsigned int i=0; i<Tanks.size(); i++) {
- vXYZtank_arm(eX) += Tanks[i]->GetXYZ(eX) * Tanks[i]->GetContents();
- vXYZtank_arm(eY) += Tanks[i]->GetXYZ(eY) * Tanks[i]->GetContents();
- vXYZtank_arm(eZ) += Tanks[i]->GetXYZ(eZ) * Tanks[i]->GetContents();
+ vXYZtank_arm += Tanks[i]->GetXYZ() * Tanks[i]->GetContents();
}
return vXYZtank_arm;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGPropulsion::GetTanksWeight(void)
+double FGPropulsion::GetTanksWeight(void) const
{
double Tw = 0.0;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGMatrix33& FGPropulsion::CalculateTankInertias(void)
+const FGMatrix33& FGPropulsion::CalculateTankInertias(void)
{
+ const FGMatrix33 Ts2b(-inchtoft, 0., 0., 0., inchtoft, 0., 0., 0., -inchtoft);
unsigned int size;
size = Tanks.size();
tankJ = FGMatrix33();
for (unsigned int i=0; i<size; i++) {
+ FGColumnVector3 vTankBodyVec = Ts2b * (in.vXYZcg - Tanks[i]->GetXYZ());
+
tankJ += FDMExec->GetMassBalance()->GetPointmassInertia( lbtoslug * Tanks[i]->GetContents(),
- Tanks[i]->GetXYZ() );
+ vTankBodyVec);
tankJ(1,1) += Tanks[i]->GetIxx();
tankJ(2,2) += Tanks[i]->GetIyy();
tankJ(3,3) += Tanks[i]->GetIzz();