From 86b34010f30814dcc4930028a818074963709b6a Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 16 Apr 2009 06:48:20 +0000 Subject: [PATCH] Sync. w. JSBSim: fix a few unexpected glitches --- src/FDM/JSBSim/models/FGBuoyantForces.cpp | 43 +++++++++++++------ src/FDM/JSBSim/models/FGBuoyantForces.h | 17 +++++--- src/FDM/JSBSim/models/FGGasCell.h | 31 ++++++------- src/FDM/JSBSim/models/propulsion/FGPiston.cpp | 23 ++++------ src/FDM/JSBSim/models/propulsion/FGPiston.h | 3 +- 5 files changed, 69 insertions(+), 48 deletions(-) diff --git a/src/FDM/JSBSim/models/FGBuoyantForces.cpp b/src/FDM/JSBSim/models/FGBuoyantForces.cpp index 2bb3623c7..341f16bd8 100644 --- a/src/FDM/JSBSim/models/FGBuoyantForces.cpp +++ b/src/FDM/JSBSim/models/FGBuoyantForces.cpp @@ -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; iFindElement("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 diff --git a/src/FDM/JSBSim/models/FGBuoyantForces.h b/src/FDM/JSBSim/models/FGBuoyantForces.h index 4cd87259f..b1a7ee291 100644 --- a/src/FDM/JSBSim/models/FGBuoyantForces.h +++ b/src/FDM/JSBSim/models/FGBuoyantForces.h @@ -71,6 +71,10 @@ CLASS DOCUMENTATION @code + + + ballonets/in-flow-ft3ps[0] + 18.8 @@ -84,7 +88,7 @@ CLASS DOCUMENTATION 0.015 - ... {other gass cells} ... + ... {other gas cells} ... @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 interface_properties; + bool NoneDefined; void bind(void); - void unbind(void); void Debug(int from); }; diff --git a/src/FDM/JSBSim/models/FGGasCell.h b/src/FDM/JSBSim/models/FGGasCell.h index 010c6c8eb..fa7021ff4 100644 --- a/src/FDM/JSBSim/models/FGGasCell.h +++ b/src/FDM/JSBSim/models/FGGasCell.h @@ -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 ft2. */ - FGMatrix33& GetInertia(void) {return gasCellJ;} + @return moments of inertia matrix relative the gas cell location + in slug ft2. */ + 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 / ft2. */ - 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 ft2. */ - FGMatrix33& GetInertia(void) {return ballonetJ;} + const FGMatrix33& GetInertia(void) const {return ballonetJ;} /** Get the current volume of the ballonet @return volume in ft3. */ - 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; diff --git a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp index 80ac4dc8b..fbb9f2d02 100644 --- a/src/FDM/JSBSim/models/propulsion/FGPiston.cpp +++ b/src/FDM/JSBSim/models/propulsion/FGPiston.cpp @@ -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 diff --git a/src/FDM/JSBSim/models/propulsion/FGPiston.h b/src/FDM/JSBSim/models/propulsion/FGPiston.h index a71e2933b..56e5e8b5f 100644 --- a/src/FDM/JSBSim/models/propulsion/FGPiston.h +++ b/src/FDM/JSBSim/models/propulsion/FGPiston.h @@ -80,7 +80,7 @@ CLASS DOCUMENTATION {number} {number} {number} - {number} + {number} {number} {number} {0 | 1} @@ -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 //