X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGMassBalance.cpp;h=dbd8ab3a64565c40fa7b0ac28d4bab5bcd69a30c;hb=1575fad886a0b18825363d41d53a287e8d36b9c8;hp=9e485c1a6a6a9bae82a82aaec92038288413bb3e;hpb=63b3f802ec9412b47c089d7c82f740a6c41f3e3e;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGMassBalance.cpp b/src/FDM/JSBSim/models/FGMassBalance.cpp index 9e485c1a6..dbd8ab3a6 100644 --- a/src/FDM/JSBSim/models/FGMassBalance.cpp +++ b/src/FDM/JSBSim/models/FGMassBalance.cpp @@ -38,20 +38,18 @@ HISTORY INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#include "FGMassBalance.h" -#include "FGPropulsion.h" -#include "propulsion/FGTank.h" -#include "FGBuoyantForces.h" -#include "input_output/FGPropertyManager.h" #include #include #include +#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.32 2010/08/12 04:07:11 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; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -92,8 +90,6 @@ FGMassBalance::~FGMassBalance() bool FGMassBalance::InitModel(void) { - if (!FGModel::InitModel()) return false; - vLastXYZcg.InitMatrix(0.0); vDeltaXYZcg.InitMatrix(0.0); @@ -151,12 +147,12 @@ bool FGMassBalance::Load(Element* el) 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; - FGModel::PostLoad(el); + PostLoad(el, PropertyManager); Debug(2); return true; @@ -164,13 +160,13 @@ bool FGMassBalance::Load(Element* el) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -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(); @@ -179,16 +175,17 @@ bool FGMassBalance::Run(void) 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. @@ -196,7 +193,7 @@ bool FGMassBalance::Run(void) vDeltaXYZcg = vXYZcg - vLastXYZcg; vDeltaXYZcgBody = StructuralToBody(vLastXYZcg) - StructuralToBody(vXYZcg); vLastXYZcg = vXYZcg; - Propagate->NudgeBodyLocation(vDeltaXYZcgBody); + FDMExec->GetPropagate()->NudgeBodyLocation(vDeltaXYZcgBody); // Calculate new total moments of inertia @@ -206,8 +203,8 @@ bool FGMassBalance::Run(void) 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); @@ -294,7 +291,7 @@ void FGMassBalance::AddPointMass(Element* el) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -double FGMassBalance::GetTotalPointMassWeight(void) +double FGMassBalance::GetTotalPointMassWeight(void) const { double PM_total_weight = 0.0; @@ -306,7 +303,7 @@ double FGMassBalance::GetTotalPointMassWeight(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGColumnVector3& FGMassBalance::GetPointMassMoment(void) +const FGColumnVector3& FGMassBalance::GetPointMassMoment(void) { PointMassCG.InitMatrix(); @@ -318,7 +315,7 @@ FGColumnVector3& FGMassBalance::GetPointMassMoment(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGMatrix33& FGMassBalance::CalculatePMInertias(void) +const FGMatrix33& FGMassBalance::CalculatePMInertias(void) { unsigned int size; @@ -432,24 +429,7 @@ void FGMassBalance::GetMassPropertiesReport(void) const << setw(12) << pm->GetPointMassMoI(3,3) << endl; } - for (unsigned int i=0;iGetNumTanks() ;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