INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#include "FGMassBalance.h"
-#include "FGPropulsion.h"
-#include "propulsion/FGTank.h"
-#include "FGBuoyantForces.h"
-#include "input_output/FGPropertyManager.h"
#include <iostream>
#include <iomanip>
#include <cstdlib>
+#include "FGMassBalance.h"
+#include "FGFDMExec.h"
+#include "input_output/FGPropertyManager.h"
using namespace std;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.33 2010/09/07 00:40:03 jberndt Exp $";
+static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.39 2011/11/09 21:58:26 bcoconni Exp $";
static const char *IdHdr = ID_MASSBALANCE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGMassBalance::InitModel(void)
{
- if (!FGModel::InitModel()) return false;
-
vLastXYZcg.InitMatrix(0.0);
vDeltaXYZcg.InitMatrix(0.0);
if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight();
}
- Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetTotalPointMassWeight()
- + BuoyantForces->GetGasMass()*slugtolb + ChildFDMWeight;
+ Weight = EmptyWeight + in.TanksWeight + GetTotalPointMassWeight()
+ + in.GasMass*slugtolb + ChildFDMWeight;
Mass = lbtoslug*Weight;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-bool FGMassBalance::Run(void)
+bool FGMassBalance::Run(bool Holding)
{
double denom, k1, k2, k3, k4, k5, k6;
double Ixx, Iyy, Izz, Ixy, Ixz, Iyz;
- if (FGModel::Run()) return true;
- if (FDMExec->Holding()) return false;
+ if (FGModel::Run(Holding)) return true;
+ if (Holding) return false;
RunPreFunctions();
if (FDMExec->GetChildFDM(fdm)->mated) ChildFDMWeight += FDMExec->GetChildFDM(fdm)->exec->GetMassBalance()->GetWeight();
}
- Weight = EmptyWeight + Propulsion->GetTanksWeight() + GetTotalPointMassWeight()
- + BuoyantForces->GetGasMass()*slugtolb + ChildFDMWeight;
+ Weight = EmptyWeight + in.TanksWeight + GetTotalPointMassWeight()
+ + in.GasMass*slugtolb + ChildFDMWeight;
Mass = lbtoslug*Weight;
// Calculate new CG
- vXYZcg = (Propulsion->GetTanksMoment() + EmptyWeight*vbaseXYZcg
+ vXYZcg = (EmptyWeight*vbaseXYZcg
+ GetPointMassMoment()
- + BuoyantForces->GetGasMassMoment()) / Weight;
+ + in.TanksMoment
+ + in.GasMoment) / Weight;
// Track frame-by-frame delta CG, and move the EOM-tracked location
// by this amount.
vDeltaXYZcg = vXYZcg - vLastXYZcg;
vDeltaXYZcgBody = StructuralToBody(vLastXYZcg) - StructuralToBody(vXYZcg);
vLastXYZcg = vXYZcg;
- Propagate->NudgeBodyLocation(vDeltaXYZcgBody);
+ FDMExec->GetPropagate()->NudgeBodyLocation(vDeltaXYZcgBody);
// Calculate new total moments of inertia
mJ += GetPointmassInertia( lbtoslug * EmptyWeight, vbaseXYZcg );
// Then add the contributions from the additional pointmasses.
mJ += CalculatePMInertias();
- mJ += Propulsion->CalculateTankInertias();
- mJ += BuoyantForces->GetGasMassInertia();
+ mJ += in.TankInertia;
+ mJ += in.GasInertia;
Ixx = mJ(1,1);
Iyy = mJ(2,2);
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-double FGMassBalance::GetTotalPointMassWeight(void)
+double FGMassBalance::GetTotalPointMassWeight(void) const
{
double PM_total_weight = 0.0;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGColumnVector3& FGMassBalance::GetPointMassMoment(void)
+const FGColumnVector3& FGMassBalance::GetPointMassMoment(void)
{
PointMassCG.InitMatrix();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FGMatrix33& FGMassBalance::CalculatePMInertias(void)
+const FGMatrix33& FGMassBalance::CalculatePMInertias(void)
{
unsigned int size;
<< setw(12) << pm->GetPointMassMoI(3,3) << endl;
}
- for (unsigned int i=0;i<Propulsion->GetNumTanks() ;i++) {
- FGTank* tank = Propulsion->GetTank(i);
- string tankname="";
- if (tank->GetType() == FGTank::ttFUEL && tank->GetGrainType() != FGTank::gtUNKNOWN) {
- tankname = "Solid Fuel";
- } else if (tank->GetType() == FGTank::ttFUEL) {
- tankname = "Fuel";
- } else if (tank->GetType() == FGTank::ttOXIDIZER) {
- tankname = "Oxidizer";
- } else {
- tankname = "(Unknown tank type)";
- }
- cout << highint << left << setw(4) << i << setw(30) << tankname << normint
- << right << setw(10) << tank->GetContents() << setw(8) << tank->GetXYZ(eX)
- << setw(8) << tank->GetXYZ(eY) << setw(8) << tank->GetXYZ(eZ)
- << setw(12) << "*" << setw(12) << "*"
- << setw(12) << "*" << endl;
- }
+ cout << FDMExec->GetPropulsionTankReport();
cout << underon << setw(104) << " " << underoff << endl;
cout << highint << left << setw(30) << " Total: " << right << setw(14) << Weight