]> git.mxchange.org Git - flightgear.git/commitdiff
Latest JSBSim changes, including some gear tweaking from Jon and some
authordavid <david>
Sat, 19 Jan 2002 05:32:28 +0000 (05:32 +0000)
committerdavid <david>
Sat, 19 Jan 2002 05:32:28 +0000 (05:32 +0000)
fuel-reporting improvements for piston engines.

src/FDM/JSBSim/FGConfigFile.cpp
src/FDM/JSBSim/FGEngine.cpp
src/FDM/JSBSim/FGEngine.h
src/FDM/JSBSim/FGGroundReactions.cpp
src/FDM/JSBSim/FGLGear.cpp
src/FDM/JSBSim/FGPiston.cpp
src/FDM/JSBSim/FGPiston.h
src/FDM/JSBSim/FGPropulsion.h
src/FDM/JSBSim/FGTank.h

index 488ec0b616f175571e7bc8000c410ff6108c3382..9a03a15176206988dd0d0117a58f7a0a8c9ba959 100644 (file)
@@ -88,6 +88,9 @@ string FGConfigFile::GetNextConfigLine(void)
       comment_length = comment_ends_at + 2 - comment_starts_at + 1;
       LineComment = CurrentLine.substr(comment_starts_at+4, comment_length-4-3);
       CurrentLine.erase(comment_starts_at, comment_length);
+      if (CurrentLine.find_first_not_of(" ") == string::npos) {
+        CurrentLine.erase();
+      }
     } else if ( start_comment && !end_comment) {                       //  <!-- ...
       CommentsOn = true;
       comment_length = line_length - comment_starts_at;
@@ -108,11 +111,12 @@ string FGConfigFile::GetNextConfigLine(void)
       CommentString += CommentStringTemp + "\r\n";
       CurrentLine.erase(0, comment_length);
     }
-    
   } while (CommentsOn);
 
-  if (CurrentLine.length() == 0) GetNextConfigLine();
   CurrentIndex = 0;
+  if (CurrentLine.length() == 0) {
+    GetNextConfigLine();
+  }
   return CurrentLine;
 }
 
index f90587e70d56e7edfc4e434a5761c40d7a18904c..f977a8846bcbf6808ef4ad509cca5a336ef8e572 100644 (file)
@@ -65,28 +65,41 @@ CLASS IMPLEMENTATION
 
 
 FGEngine::FGEngine(FGFDMExec* exec)
+  : Name(""),
+    Type(etUnknown),
+    X(0), Y(0), Z(0),
+    EnginePitch(0), EngineYaw(0),
+    SLFuelFlowMax(0), SLOxiFlowMax(0),
+    MaxThrottle(1.0), MinThrottle(0.0),
+    Thrust(0.0),
+    Throttle(0.0),
+    Mixture(1.0),
+    Magnetos(0),
+    Starter(false),
+    FuelNeed(0.0), OxidizerNeed(0.0),
+    Starved(false), Flameout(false), Running(false), Cranking(false),
+    PctPower(0.0),
+    EngineNumber(-1),
+    TrimMode(false),
+    FuelFlow_gph(0.0),
+    ManifoldPressure_inHg(0.0),
+    ExhaustGasTemp_degK(0.0),
+    CylinderHeadTemp_degK(0.0),
+    OilPressure_psi(0.0),
+    OilTemp_degK(0.0),
+    FDMExec(exec),
+    State(FDMExec->GetState()),
+    Atmosphere(FDMExec->GetAtmosphere()),
+    FCS(FDMExec->GetFCS()),
+    Propulsion(FDMExec->GetPropulsion()),
+    Aircraft(FDMExec->GetAircraft()),
+    Translation(FDMExec->GetTranslation()),
+    Rotation(FDMExec->GetRotation()),
+    Position(FDMExec->GetPosition()),
+    Auxiliary(FDMExec->GetAuxiliary()),
+    Output(FDMExec->GetOutput())
 {
-  FDMExec     = exec;
-  State       = FDMExec->GetState();
-  Atmosphere  = FDMExec->GetAtmosphere();
-  FCS         = FDMExec->GetFCS();
-  Propulsion  = FDMExec->GetPropulsion();
-  Aircraft    = FDMExec->GetAircraft();
-  Translation = FDMExec->GetTranslation();
-  Rotation    = FDMExec->GetRotation();
-  Position    = FDMExec->GetPosition();
-  Auxiliary   = FDMExec->GetAuxiliary();
-  Output      = FDMExec->GetOutput();
-
-  Mixture = 1.0;               // FIXME: get actual value
-
-  Thrust = PctPower = 0.0;
-  Starved = Flameout = false;
-  Running = false;
-  Cranking = Starter = false;
-
   Debug(0);
-  TrimMode = false;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 8e2f92471d9ce6714ebc0836c9b7bae1708f5a9e..ac5ea64208461a8339c719240bdfa75214a4a82b 100644 (file)
@@ -115,17 +115,21 @@ public:
 
   virtual double  GetThrottleMin(void) { return MinThrottle; }
   virtual double  GetThrottleMax(void) { return MaxThrottle; }
-  double  GetThrottle(void) { return Throttle; }
-  double  GetMixture(void) { return Mixture; }
-  int     GetMagnetos(void) { return Magnetos; }
-  bool    GetStarter(void) { return Starter; }
-  double  GetThrust(void) { return Thrust; }
-  bool    GetStarved(void) { return Starved; }
-  bool    GetFlameout(void) { return Flameout; }
-  bool    GetRunning(void) { return Running; }
-  bool    GetCranking(void) { return Cranking; }
-  int     GetType(void) { return Type; }
-  string  GetName(void) { return Name; }
+  virtual double  GetThrottle(void) { return Throttle; }
+  virtual double  GetMixture(void) { return Mixture; }
+  virtual int     GetMagnetos(void) { return Magnetos; }
+  virtual bool    GetStarter(void) { return Starter; }
+  virtual double  GetThrust(void) { return Thrust; }
+  virtual bool    GetStarved(void) { return Starved; }
+  virtual bool    GetFlameout(void) { return Flameout; }
+  virtual bool    GetRunning(void) { return Running; }
+  virtual bool    GetCranking(void) { return Cranking; }
+  virtual int     GetType(void) { return Type; }
+  virtual string  GetName(void) { return Name; }
+
+  virtual double getFuelFlow_gph () const {
+    return FuelFlow_gph;
+  }
 
   virtual double getManifoldPressure_inHg () const {
     return ManifoldPressure_inHg;
@@ -143,15 +147,15 @@ public:
     return (OilTemp_degK - 273.0) * (9.0 / 5.0) + 32.0;
   }
 
-  void SetStarved(bool tt) {Starved = tt;}
-  void SetStarved(void)    {Starved = true;}
+  virtual void SetStarved(bool tt) {Starved = tt;}
+  virtual void SetStarved(void)    {Starved = true;}
 
-  void SetRunning(bool bb) { Running=bb; }
-  void SetName(string name) {Name = name;}
-  void AddFeedTank(int tkID);
+  virtual void SetRunning(bool bb) { Running=bb; }
+  virtual void SetName(string name) {Name = name;}
+  virtual void AddFeedTank(int tkID);
 
-  void SetMagnetos(int m) { Magnetos = m; }
-  void SetStarter(bool s) { Starter = s;}
+  virtual void SetMagnetos(int m) { Magnetos = m; }
+  virtual void SetStarter(bool s) { Starter = s;}
 
   /** Calculates the thrust of the engine, and other engine functions.
       @param PowerRequired this is the power required to run the thrusting device
@@ -165,30 +169,30 @@ public:
       derived class' Calculate() function before any other calculations are
       done. This base class method removes fuel from the fuel tanks as
       appropriate, and sets the starved flag if necessary. */
-  void ConsumeFuel(void);
+  virtual void ConsumeFuel(void);
 
   /** The fuel need is calculated based on power levels and flow rate for that
       power level. It is also turned from a rate into an actual amount (pounds)
       by multiplying it by the delta T and the rate.
       @return Total fuel requirement for this engine in pounds. */
-  double CalcFuelNeed(void);
+  virtual double CalcFuelNeed(void);
 
   /** The oxidizer need is calculated based on power levels and flow rate for that
       power level. It is also turned from a rate into an actual amount (pounds)
       by multiplying it by the delta T and the rate.
       @return Total oxidizer requirement for this engine in pounds. */
-  double CalcOxidizerNeed(void);
+  virtual double CalcOxidizerNeed(void);
 
   /// Sets engine placement information
-  void SetPlacement(double x, double y, double z, double pitch, double yaw);
+  virtual void SetPlacement(double x, double y, double z, double pitch, double yaw);
 
   /// Sets the engine number
-  void SetEngineNumber(int nn) {EngineNumber = nn;}
+  virtual void SetEngineNumber(int nn) {EngineNumber = nn;}
 
   virtual double GetPowerAvailable(void) {return 0.0;};
 
-  bool GetTrimMode(void) {return TrimMode;}
-  void SetTrimMode(bool state) {TrimMode = state;}
+  virtual bool GetTrimMode(void) {return TrimMode;}
+  virtual void SetTrimMode(bool state) {TrimMode = state;}
 
 protected:
   string Name;
@@ -215,6 +219,7 @@ protected:
   int   EngineNumber;
   bool  TrimMode;
 
+  double FuelFlow_gph;
   double ManifoldPressure_inHg;
   double ExhaustGasTemp_degK;
   double CylinderHeadTemp_degK;
index 30f61113aaf4d614ca89c407ea8ccdb827a22d8b..3f133eeace2253605406d1a1418314abf350b4de 100644 (file)
@@ -60,11 +60,9 @@ FGGroundReactions::~FGGroundReactions(void)
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 bool FGGroundReactions::Run(void)
 {
-//  double steerAngle = 0.0;
-//  double xForces = 0.0, yForces = 0.0;
-
   if (!FGModel::Run()) {
     vForces.InitMatrix();
     vMoments.InitMatrix();
@@ -83,55 +81,6 @@ bool FGGroundReactions::Run(void)
         iGear++;
       }
 
-      // Only execute this code when the aircraft ground speed is very, very small.
-      /*
-      if (fabs(Translation->GetUVW(eX)) < 0.1 &&
-          fabs(Translation->GetUVW(eZ)) < 0.1)
-      {
-        // Initialize the comparison matrices.
-        vMaxStaticGrip.InitMatrix();
-        vMaxMomentResist.InitMatrix();
-        iGear = lGear.begin();
-        // For each gear that is touching the ground (which had better be all of them!)
-        // calculate the X and Y direction maximum "gripping" power. Also, keep track
-        // of the number of gear that have weight on wheels. This is probably unnecessary.
-        while (iGear != lGear.end()) {
-          // calculate maximum gripping power for each gear here based on brake
-          // and steering settings
-          // also calculate total number of wheels with WOW set true?
-          if (iGear->GetWOW()) {
-            steerAngle = iGear->GetSteerAngle();
-            vMaxStaticGrip(eX) += (iGear->GetBrakeFCoeff()*cos(steerAngle) - 
-                 iGear->GetstaticFCoeff()*sin(steerAngle))*iGear->GetCompForce();
-            vMaxStaticGrip(eY) += iGear->GetBrakeFCoeff()*sin(steerAngle) + 
-                  iGear->GetstaticFCoeff()*cos(steerAngle)*iGear->GetCompForce();
-            vMaxStaticGrip(eZ)  = 0.0;
-//            vMaxMomentResist += 1;
-          }
-          iGear++;
-        }
-
-        // Calculate the X and Y direction non-gear forces to counteract if needed.
-        xForces =  -1.0 * ( Aerodynamics->GetForces(eX)
-                          + Propulsion->GetForces(eX)
-                          + Inertial->GetForces(eX));
-
-        yForces =  -1.0 * ( Aerodynamics->GetForces(eY)
-                          + Propulsion->GetForces(eY)
-                          + Inertial->GetForces(eY));
-
-        // These if statement comparisons probably need some validation and work
-        if (fabs(xForces) < fabs(vMaxStaticGrip(eX))) { // forces exceed gear power
-          vForces(eX) = xForces;
-        }
-
-        if (fabs(yForces) < fabs(vMaxStaticGrip(eY))) { // forces exceed gear power
-          vForces(eY) = yForces;
-        }
-
-        vMoments(eZ) = -(Aerodynamics->GetMoments(eZ) + Propulsion->GetMoments(eZ));
-      }
-      */
     } else {
       // Crash Routine
     }
index d899dbecba1dc5fe599b4362d3ef2ae9ba0dc86e..1ddc4a9a35654617f8a19498358f35b1094caa89 100644 (file)
@@ -326,16 +326,6 @@ FGColumnVector3& FGLGear::Force(void)
         WheelSlip = radtodeg*atan2(SideWhlVel, RollingWhlVel);
       }
 
-// The following code normalizes the wheel velocity vector, reverses it, and zeroes out
-// the z component of the velocity. The question is, should the Z axis velocity be zeroed
-// out first before the normalization takes place or not? Subsequent to that, the Wheel
-// Velocity vector now points as a unit vector backwards and parallel to the wheel
-// velocity vector. It acts AT the wheel.
-
-// Note to Jon: I commented out this line because I wasn't sure we want to do this.
-//    vWhlVelVec      = -1.0 * vWhlVelVec.Normalize();
-//    vWhlVelVec(eZ)  =  0.00;
-
 // Compute the sideforce coefficients using similar assumptions to LaRCSim for now.
 // Allow a maximum of 10 degrees tire slip angle before wheel slides.  At that point,
 // transition from static to dynamic friction.  There are more complicated formulations
@@ -351,7 +341,7 @@ FGColumnVector3& FGLGear::Force(void)
 // in paper AIAA-2000-4303 - see header prologue comments). We might consider
 // allowing for both square and linear damping force calculation. Also need to
 // possibly give a "rebound damping factor" that differs from the compression
-// case. NOTE: SQUARE LAW DAMPING NO GOOD!
+// case.
 
       vLocalForce(eZ) =  min(-compressLength * kSpring
                              - compressSpeed * bDamp, (double)0.0);
index 4cc055bf602eed77425910a4a239bec767cad7e1..56f511a479e11b2e9785dbbfc1c504b276a3772a 100644 (file)
@@ -78,7 +78,6 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec),
     else if (token == "IDLERPM") *Eng_cfg >> IdleRPM;
     else if (token == "MAXTHROTTLE") *Eng_cfg >> MaxThrottle;
     else if (token == "MINTHROTTLE") *Eng_cfg >> MinThrottle;
-    else if (token == "SLFUELFLOWMAX") *Eng_cfg >> SLFuelFlowMax;
     else cerr << "Unhandled token in Engine config file: " << token << endl;
   }
 
@@ -332,6 +331,10 @@ void FGPiston::doFuelFlow(void)
   double thi_sea_level = 1.3 * Mixture;
   equivalence_ratio = thi_sea_level * p_amb_sea_level / p_amb;
   m_dot_fuel = m_dot_air / 14.7 * equivalence_ratio;
+  FuelFlow_gph = m_dot_fuel
+    * 3600                     // seconds to hours
+    * 2.2046                   // kg to lb
+    / 6.6;                     // lb to gal_us of kerosene
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -549,7 +552,6 @@ void FGPiston::Debug(int from)
       cout << "      IdleRPM: "             << IdleRPM                  << endl;
       cout << "      MaxThrottle: "         << MaxThrottle              << endl;
       cout << "      MinThrottle: "         << MinThrottle              << endl;
-      cout << "      SLFuelFlowMax: "       << SLFuelFlowMax            << endl;
 
       cout << endl;
       cout << "      Combustion Efficiency table:" << endl;
@@ -581,3 +583,9 @@ void FGPiston::Debug(int from)
   }
 }
 
+double
+FGPiston::CalcFuelNeed(void)
+{
+                               // FIXME: is this right?
+  return FuelFlow_gph * State->Getdt() * Propulsion->GetRate();
+}
index 7d9eb19163bfd7802fdff42ea2c72c026f6f3666..02fa16892930f13e701880835ef5ddb45e0ef6e3 100644 (file)
@@ -86,6 +86,7 @@ public:
 
   double Calculate(double PowerRequired);
   double GetPowerAvailable(void) {return PowerAvailable;}
+  double CalcFuelNeed(void);
 
 private:
   int crank_counter;
index 6072da1b1f19b79061fda1df8094eb299cc558be..ba1747a1cb5c1f979bd4e65d199d5284444273a2 100644 (file)
@@ -136,6 +136,9 @@ public:
                       if (index <= Engines.size()-1) return Engines[index];
                       else                           return 0L;      }
 
+  // Retrieves the number of tanks defined for the aircraft.
+  inline unsigned int GetNumTanks(void) {return Tanks.size();}
+
   /** Retrieves a tank object pointer from the list of tanks.
       @param index the tank index within the vector container
       @return the address of the specific tank, or zero if no such tank is
index 2408ed9dd77070f7f787dedb7c3c4c200333ea32..895308d9fe466dc92cac42d0a360745bdb08d8b0 100644 (file)
@@ -91,6 +91,8 @@ public:
   double inline GetY(void) {return Y;}
   double inline GetZ(void) {return Z;}
 
+  void SetContents(double contents) { Contents = contents; }
+
   enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
 
 private: