]> git.mxchange.org Git - flightgear.git/commitdiff
Sync. w. JSBSim: fix a few unexpected glitches
authorehofman <ehofman>
Thu, 16 Apr 2009 06:48:20 +0000 (06:48 +0000)
committerTim Moore <timoore@redhat.com>
Fri, 1 May 2009 22:44:20 +0000 (00:44 +0200)
src/FDM/JSBSim/models/FGBuoyantForces.cpp
src/FDM/JSBSim/models/FGBuoyantForces.h
src/FDM/JSBSim/models/FGGasCell.h
src/FDM/JSBSim/models/propulsion/FGPiston.cpp
src/FDM/JSBSim/models/propulsion/FGPiston.h

index 2bb3623c75f7a1725ce92a9a2ccbbc5bc0187449..341f16bd8c27e8abc2eebd204af09001de19b174 100644 (file)
@@ -5,7 +5,7 @@
  Date started: 01/21/08
  Purpose:      Encapsulates the buoyant forces
 
- ------------- Copyright (C) 2008  Anders Gidenstam               -------------
+ ------------- Copyright (C) 2008 - 2009  Anders Gidenstam        -------------
  ------------- Copyright (C) 2008  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
@@ -72,7 +72,9 @@ FGBuoyantForces::~FGBuoyantForces()
   for (unsigned int i=0; i<Cells.size(); i++) delete Cells[i];
   Cells.clear();
 
-  unbind();
+  for (unsigned int i=0; i<interface_properties.size(); i++)
+    delete interface_properties[i];
+  interface_properties.clear();
 
   Debug(1);
 }
@@ -125,6 +127,29 @@ bool FGBuoyantForces::Load(Element *element)
     document = element;
   }
 
+  Element *property_element = document->FindElement("property");
+  if (property_element)
+    cout << endl << "    Declared properties" << endl << endl;
+  while (property_element) {
+    string interface_property_string = property_element->GetDataLine();
+
+    if (PropertyManager->HasNode(interface_property_string)) {
+      cout << "      Property " << interface_property_string <<
+        " is already defined." << endl;
+    } else {
+      double value=0.0;
+      if ( ! property_element->GetAttributeValue("value").empty())
+        value = property_element->GetAttributeValueAsNumber("value");
+      interface_properties.push_back(new double(value));
+      interface_property_string = property_element->GetDataLine();
+      PropertyManager->Tie(interface_property_string,
+                           interface_properties.back());
+      cout << "      " << interface_property_string <<
+        " (initial value: " << value << ")" << endl;
+    }
+    property_element = document->FindNextElement("property");
+  }
+
   gas_cell_element = document->FindElement("gas_cell");
   while (gas_cell_element) {
     NoneDefined = false;
@@ -150,7 +175,7 @@ double FGBuoyantForces::GetGasMass(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-FGColumnVector3& FGBuoyantForces::GetGasMassMoment(void)
+const FGColumnVector3& FGBuoyantForces::GetGasMassMoment(void)
 {
   vXYZgasCell_arm.InitMatrix();
   for (unsigned int i = 0; i < Cells.size(); i++) {
@@ -161,7 +186,7 @@ FGColumnVector3& FGBuoyantForces::GetGasMassMoment(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-FGMatrix33& FGBuoyantForces::GetGasMassInertia(void)
+const FGMatrix33& FGBuoyantForces::GetGasMassInertia(void)
 {
   const unsigned int size = Cells.size();
   
@@ -190,8 +215,8 @@ FGMatrix33& FGBuoyantForces::GetGasMassInertia(void)
 string FGBuoyantForces::GetBuoyancyStrings(string delimeter)
 {
   string CoeffStrings = "";
-  bool firstime = true;
 /*
+  bool firstime = true;
   for (sd = 0; sd < variables.size(); sd++) {
     if (firstime) {
       firstime = false;
@@ -220,8 +245,8 @@ string FGBuoyantForces::GetBuoyancyStrings(string delimeter)
 string FGBuoyantForces::GetBuoyancyValues(string delimeter)
 {
   string SDValues = "";
-  bool firstime = true;
 /*
+  bool firstime = true;
   for (sd = 0; sd < variables.size(); sd++) {
     if (firstime) {
       firstime = false;
@@ -251,12 +276,6 @@ void FGBuoyantForces::bind(void)
 {
 }
 
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGBuoyantForces::unbind(void)
-{
-}
-
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 //    The bitmasked value choices are as follows:
 //    unset: In this case (the default) JSBSim would only print
index 4cd87259fab0b72e27d701378a540e4eaed3c848..b1a7ee2917b07297665cb9cf557e871415a60a6d 100644 (file)
@@ -71,6 +71,10 @@ CLASS DOCUMENTATION
 
     @code
     <buoyant_forces>
+
+      <!-- Interface properties -->
+      <property>ballonets/in-flow-ft3ps[0]</property>
+
       <gas_cell type="HYDROGEN">
         <location unit="M">
           <x> 18.8 </x>
@@ -84,7 +88,7 @@ CLASS DOCUMENTATION
         <valve_coefficient unit="M4*SEC/KG"> 0.015 </valve_coefficient>
       </gas_cell>
       
-      ... {other gass cells} ...
+      ... {other gas cells} ...
       
     </buoyant_forces>
     @endcode
@@ -124,11 +128,11 @@ public:
 
   /** Gets the total Buoyant force vector.
       @return a force vector. */
-  FGColumnVector3 GetForces(void) {return vTotalForces;}
+  const FGColumnVector3& GetForces(void) const {return vTotalForces;}
 
   /** Gets the total Buoyancy moment vector.
       @return a moment vector. */
-  FGColumnVector3 GetMoments(void) {return vTotalMoments;}
+  const FGColumnVector3& GetMoments(void) const {return vTotalMoments;}
 
   /** Gets the total gas mass. The gas mass is part of the aircraft's
       inertia.
@@ -137,11 +141,11 @@ public:
 
   /** Gets the total moment from the gas mass.
       @return a moment vector. */
-  FGColumnVector3& GetGasMassMoment(void);
+  const FGColumnVector3& GetGasMassMoment(void);
 
   /** Gets the total moments of inertia for the gas mass.
       @return . */
-  FGMatrix33& GetGasMassInertia(void);
+  const FGMatrix33& GetGasMassInertia(void);
 
   /** Gets the strings for the current set of gas cells.
       @param delimeter either a tab or comma string depending on output type
@@ -165,10 +169,11 @@ private:
   FGColumnVector3 vGasCellXYZ;
   FGColumnVector3 vXYZgasCell_arm;
 
+  vector <double*> interface_properties;
+
   bool NoneDefined;
 
   void bind(void);
-  void unbind(void);
 
   void Debug(int from);
 };
index 010c6c8eb4095cc394e272eadbc5f7f7bde7a2ff..fa7021ff474bd8a54f9691077164847f9c292b7b 100644 (file)
@@ -189,40 +189,41 @@ public:
 
   /** Get the index of this gas cell
       @return gas cell index. */
-  int GetIndex(void) {return CellNum;}
+  int GetIndex(void) const {return CellNum;}
 
   /** Get the center of gravity location of the gas cell
       (including any ballonets)
       @return CoG location in the structural frame. */
-  const FGColumnVector3& GetXYZ(void) {return vXYZ;}
+  const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
 
   /** Get the center of gravity location of the gas cell
       (including any ballonets)
       @return CoG location in the structural frame. */
-  double GetXYZ(int idx) {return vXYZ(idx);}
+  double GetXYZ(int idx) const {return vXYZ(idx);}
 
   /** Get the current mass of the gas cell (including any ballonets)
       @return gas mass in slug. */
-  double GetMass(void) {return Mass;}
+  double GetMass(void) const {return Mass;}
 
   /** Get the moments of inertia of the gas cell (including any ballonets)
-      @return moments of inertia matrix in slug ft<sup>2</sup>. */
-  FGMatrix33& GetInertia(void) {return gasCellJ;}
+      @return moments of inertia matrix relative the gas cell location
+      in slug ft<sup>2</sup>. */
+  const FGMatrix33& GetInertia(void) const {return gasCellJ;}
 
   /** Get the moment due to mass of the gas cell (including any ballonets)
 
       Note that the buoyancy of the gas cell is handled separately by the
       FGForce part and not included here.
       @return moment vector in lbs ft. */
-  FGColumnVector3& GetMassMoment(void) {return gasCellM;}
+  const FGColumnVector3& GetMassMoment(void) const {return gasCellM;}
 
   /** Get the current gas temperature inside the gas cell
       @return gas temperature in Rankine. */
-  double GetTemperature(void) {return Temperature;}
+  double GetTemperature(void) const {return Temperature;}
 
   /** Get the current gas pressure inside the gas cell
       @return gas pressure in lbs / ft<sup>2</sup>. */
-  double GetPressure(void) {return Pressure;}
+  double GetPressure(void) const {return Pressure;}
 
 private:
 
@@ -316,25 +317,25 @@ public:
 
   /** Get the center of gravity location of the ballonet
       @return CoG location in the structural frame. */
-  const FGColumnVector3& GetXYZ(void) {return vXYZ;}
+  const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
   /** Get the center of gravity location of the ballonet
       @return CoG location in the structural frame. */
-  double GetXYZ(int idx) {return vXYZ(idx);}
+  double GetXYZ(int idx) const {return vXYZ(idx);}
 
   /** Get the current mass of the ballonets
       @return mass in slug. */
-  double GetMass(void) {return Contents * M_air;}
+  double GetMass(void) const {return Contents * M_air;}
 
   /** Get the moments of inertia of the ballonet
       @return moments of inertia matrix in slug ft<sup>2</sup>. */
-  FGMatrix33& GetInertia(void) {return ballonetJ;}
+  const FGMatrix33& GetInertia(void) const {return ballonetJ;}
 
   /** Get the current volume of the ballonet
       @return volume in ft<sup>3</sup>. */
-  double GetVolume(void) {return Volume;}
+  double GetVolume(void) const {return Volume;}
   /** Get the current heat flow into the ballonet
       @return heat flow in lbs ft / sec. */
-  double GetHeatFlow(void) {return dU;}             // [lbs ft / sec]
+  double GetHeatFlow(void) const {return dU;}       // [lbs ft / sec]
 
 private:
   int CellNum;
index 80ac4dc8bf5b6420758fa7641557e424bab64e4e..fbb9f2d02425caf6a02e77c0bfdcd5baf2a59314 100644 (file)
@@ -322,6 +322,7 @@ void FGPiston::ResetToIC(void)
 
   ManifoldPressure_inHg = Atmosphere->GetPressure() * psftoinhg; // psf to in Hg
   MAP = Atmosphere->GetPressure() * psftopa;
+  TMAP = MAP;
   double airTemperature_degK = RankineToKelvin(Atmosphere->GetTemperature());
   OilTemp_degK = airTemperature_degK;
   CylinderHeadTemp_degK = airTemperature_degK;
@@ -512,7 +513,7 @@ void FGPiston::doBoostControl(void)
  * Inputs: p_amb, Throttle, ThrottleAngle,
  *         MeanPistonSpeed_fps, dt
  *
- * Outputs: MAP, ManifoldPressure_inHg
+ * Outputs: MAP, ManifoldPressure_inHg, TMAP
  */
 
 void FGPiston::doMAP(void)
@@ -524,23 +525,19 @@ void FGPiston::doMAP(void)
 
   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;
+  double dMAP = (TMAP - p_amb * map_coefficient) * dt;
+  TMAP -=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
+  // Fixme: determine the HP consumed by the supercharger
 
-  PMEP = MAP - p_amb; // Fixme: p_amb should be exhaust manifold pressure
+  PMEP = TMAP - p_amb; // Fixme: p_amb should be exhaust manifold pressure
 
   if (Boosted) {
     // If takeoff boost is fitted, we currently assume the following throttle map:
     // (In throttle % - actual input is 0 -> 1)
     // 99 / 100 - Takeoff boost
-    // 96 / 97 / 98 - Rated boost
-    // 0 - 95 - Idle to Rated boost (MinManifoldPressure to MaxManifoldPressure)
     // In real life, most planes would be fitted with a mechanical 'gate' between
     // the rated boost and takeoff boost positions.
 
@@ -548,22 +545,20 @@ void FGPiston::doMAP(void)
     if (bTakeoffBoost) {
       if (Throttle > 0.98) {
         bTakeoffPos = true;
-      } else if(Throttle <= 0.95) {
-        bTakeoffPos = false;
-      } else {
-        bTakeoffPos = false;
       }
     }
     // Boost the manifold pressure.
     double boost_factor = BoostMul[BoostSpeed] * map_coefficient * RPM/RatedRPM[BoostSpeed];
     if (boost_factor < 1.0) boost_factor = 1.0;  // boost will never reduce the MAP
-    MAP *= boost_factor;
+    MAP = TMAP * boost_factor;
     // Now clip the manifold pressure to BCV or Wastegate setting.
     if (bTakeoffPos) {
       if (MAP > TakeoffMAP[BoostSpeed]) MAP = TakeoffMAP[BoostSpeed];
     } else {
       if (MAP > RatedMAP[BoostSpeed]) MAP = RatedMAP[BoostSpeed];
     }
+  } else {
+      MAP = TMAP;
   }
 
   // And set the value in American units as well
index a71e2933b5431e1578f7377646c731b501fdabaa..56e5e8b5f27939375e8061058bd2d40f6a7bd510 100644 (file)
@@ -80,7 +80,7 @@ CLASS DOCUMENTATION
   <maxrpm> {number} </maxrpm>
   <maxthrottle> {number} </maxthrottle>
   <minthrottle> {number} </minthrottle>
-  <bsfc unit="{LBS/HP*HR | "KG/KW*HR"}"> {number} </bsft>
+  <bsfc unit="{LBS/HP*HR | "KG/KW*HR"}"> {number} </bsfc>
   <volumetric_efficiency> {number} </volumetric_efficiency>
   <numboostspeeds> {number} </numboostspeeds>
   <boostoverride> {0 | 1} </boostoverride>
@@ -295,6 +295,7 @@ private:
   double minMAP;  // Pa
   double maxMAP;  // Pa
   double MAP;     // Pa
+  double TMAP;    // Pa - throttle manifold pressure e.g. before the supercharger boost
   double ISFC;    // Indicated specific fuel consumption [lbs/horsepower*hour
 
   //