1
0
Fork 0

Sync. w. JSBSim: fix a few unexpected glitches

This commit is contained in:
ehofman 2009-04-16 06:48:20 +00:00 committed by Tim Moore
parent c74cdade0b
commit 86b34010f3
5 changed files with 69 additions and 48 deletions

View file

@ -5,7 +5,7 @@
Date started: 01/21/08 Date started: 01/21/08
Purpose: Encapsulates the buoyant forces 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) ------------- ------------- Copyright (C) 2008 Jon S. Berndt (jsb@hal-pc.org) -------------
This program is free software; you can redistribute it and/or modify it under 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]; for (unsigned int i=0; i<Cells.size(); i++) delete Cells[i];
Cells.clear(); Cells.clear();
unbind(); for (unsigned int i=0; i<interface_properties.size(); i++)
delete interface_properties[i];
interface_properties.clear();
Debug(1); Debug(1);
} }
@ -125,6 +127,29 @@ bool FGBuoyantForces::Load(Element *element)
document = 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"); gas_cell_element = document->FindElement("gas_cell");
while (gas_cell_element) { while (gas_cell_element) {
NoneDefined = false; NoneDefined = false;
@ -150,7 +175,7 @@ double FGBuoyantForces::GetGasMass(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGColumnVector3& FGBuoyantForces::GetGasMassMoment(void) const FGColumnVector3& FGBuoyantForces::GetGasMassMoment(void)
{ {
vXYZgasCell_arm.InitMatrix(); vXYZgasCell_arm.InitMatrix();
for (unsigned int i = 0; i < Cells.size(); i++) { 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(); const unsigned int size = Cells.size();
@ -190,8 +215,8 @@ FGMatrix33& FGBuoyantForces::GetGasMassInertia(void)
string FGBuoyantForces::GetBuoyancyStrings(string delimeter) string FGBuoyantForces::GetBuoyancyStrings(string delimeter)
{ {
string CoeffStrings = ""; string CoeffStrings = "";
bool firstime = true;
/* /*
bool firstime = true;
for (sd = 0; sd < variables.size(); sd++) { for (sd = 0; sd < variables.size(); sd++) {
if (firstime) { if (firstime) {
firstime = false; firstime = false;
@ -220,8 +245,8 @@ string FGBuoyantForces::GetBuoyancyStrings(string delimeter)
string FGBuoyantForces::GetBuoyancyValues(string delimeter) string FGBuoyantForces::GetBuoyancyValues(string delimeter)
{ {
string SDValues = ""; string SDValues = "";
bool firstime = true;
/* /*
bool firstime = true;
for (sd = 0; sd < variables.size(); sd++) { for (sd = 0; sd < variables.size(); sd++) {
if (firstime) { if (firstime) {
firstime = false; firstime = false;
@ -251,12 +276,6 @@ void FGBuoyantForces::bind(void)
{ {
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGBuoyantForces::unbind(void)
{
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows: // The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print // unset: In this case (the default) JSBSim would only print

View file

@ -71,6 +71,10 @@ CLASS DOCUMENTATION
@code @code
<buoyant_forces> <buoyant_forces>
<!-- Interface properties -->
<property>ballonets/in-flow-ft3ps[0]</property>
<gas_cell type="HYDROGEN"> <gas_cell type="HYDROGEN">
<location unit="M"> <location unit="M">
<x> 18.8 </x> <x> 18.8 </x>
@ -84,7 +88,7 @@ CLASS DOCUMENTATION
<valve_coefficient unit="M4*SEC/KG"> 0.015 </valve_coefficient> <valve_coefficient unit="M4*SEC/KG"> 0.015 </valve_coefficient>
</gas_cell> </gas_cell>
... {other gass cells} ... ... {other gas cells} ...
</buoyant_forces> </buoyant_forces>
@endcode @endcode
@ -124,11 +128,11 @@ public:
/** Gets the total Buoyant force vector. /** Gets the total Buoyant force vector.
@return a force vector. */ @return a force vector. */
FGColumnVector3 GetForces(void) {return vTotalForces;} const FGColumnVector3& GetForces(void) const {return vTotalForces;}
/** Gets the total Buoyancy moment vector. /** Gets the total Buoyancy moment vector.
@return a 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 /** Gets the total gas mass. The gas mass is part of the aircraft's
inertia. inertia.
@ -137,11 +141,11 @@ public:
/** Gets the total moment from the gas mass. /** Gets the total moment from the gas mass.
@return a moment vector. */ @return a moment vector. */
FGColumnVector3& GetGasMassMoment(void); const FGColumnVector3& GetGasMassMoment(void);
/** Gets the total moments of inertia for the gas mass. /** Gets the total moments of inertia for the gas mass.
@return . */ @return . */
FGMatrix33& GetGasMassInertia(void); const FGMatrix33& GetGasMassInertia(void);
/** Gets the strings for the current set of gas cells. /** Gets the strings for the current set of gas cells.
@param delimeter either a tab or comma string depending on output type @param delimeter either a tab or comma string depending on output type
@ -165,10 +169,11 @@ private:
FGColumnVector3 vGasCellXYZ; FGColumnVector3 vGasCellXYZ;
FGColumnVector3 vXYZgasCell_arm; FGColumnVector3 vXYZgasCell_arm;
vector <double*> interface_properties;
bool NoneDefined; bool NoneDefined;
void bind(void); void bind(void);
void unbind(void);
void Debug(int from); void Debug(int from);
}; };

View file

@ -189,40 +189,41 @@ public:
/** Get the index of this gas cell /** Get the index of this gas cell
@return gas cell index. */ @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 /** Get the center of gravity location of the gas cell
(including any ballonets) (including any ballonets)
@return CoG location in the structural frame. */ @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 /** Get the center of gravity location of the gas cell
(including any ballonets) (including any ballonets)
@return CoG location in the structural frame. */ @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) /** Get the current mass of the gas cell (including any ballonets)
@return gas mass in slug. */ @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) /** Get the moments of inertia of the gas cell (including any ballonets)
@return moments of inertia matrix in slug ft<sup>2</sup>. */ @return moments of inertia matrix relative the gas cell location
FGMatrix33& GetInertia(void) {return gasCellJ;} 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) /** 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 Note that the buoyancy of the gas cell is handled separately by the
FGForce part and not included here. FGForce part and not included here.
@return moment vector in lbs ft. */ @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 /** Get the current gas temperature inside the gas cell
@return gas temperature in Rankine. */ @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 /** Get the current gas pressure inside the gas cell
@return gas pressure in lbs / ft<sup>2</sup>. */ @return gas pressure in lbs / ft<sup>2</sup>. */
double GetPressure(void) {return Pressure;} double GetPressure(void) const {return Pressure;}
private: private:
@ -316,25 +317,25 @@ public:
/** Get the center of gravity location of the ballonet /** Get the center of gravity location of the ballonet
@return CoG location in the structural frame. */ @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 /** Get the center of gravity location of the ballonet
@return CoG location in the structural frame. */ @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 /** Get the current mass of the ballonets
@return mass in slug. */ @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 /** Get the moments of inertia of the ballonet
@return moments of inertia matrix in slug ft<sup>2</sup>. */ @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 /** Get the current volume of the ballonet
@return volume in ft<sup>3</sup>. */ @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 /** Get the current heat flow into the ballonet
@return heat flow in lbs ft / sec. */ @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: private:
int CellNum; int CellNum;

View file

@ -322,6 +322,7 @@ void FGPiston::ResetToIC(void)
ManifoldPressure_inHg = Atmosphere->GetPressure() * psftoinhg; // psf to in Hg ManifoldPressure_inHg = Atmosphere->GetPressure() * psftoinhg; // psf to in Hg
MAP = Atmosphere->GetPressure() * psftopa; MAP = Atmosphere->GetPressure() * psftopa;
TMAP = MAP;
double airTemperature_degK = RankineToKelvin(Atmosphere->GetTemperature()); double airTemperature_degK = RankineToKelvin(Atmosphere->GetTemperature());
OilTemp_degK = airTemperature_degK; OilTemp_degK = airTemperature_degK;
CylinderHeadTemp_degK = airTemperature_degK; CylinderHeadTemp_degK = airTemperature_degK;
@ -512,7 +513,7 @@ void FGPiston::doBoostControl(void)
* Inputs: p_amb, Throttle, ThrottleAngle, * Inputs: p_amb, Throttle, ThrottleAngle,
* MeanPistonSpeed_fps, dt * MeanPistonSpeed_fps, dt
* *
* Outputs: MAP, ManifoldPressure_inHg * Outputs: MAP, ManifoldPressure_inHg, TMAP
*/ */
void FGPiston::doMAP(void) void FGPiston::doMAP(void)
@ -524,23 +525,19 @@ void FGPiston::doMAP(void)
if ( map_coefficient < 0.1 ) map_coefficient = 0.1; 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 // Add a one second lag to manifold pressure changes
double dMAP = (MAP - p_amb * map_coefficient) * dt; double dMAP = (TMAP - p_amb * map_coefficient) * dt;
MAP -=dMAP; TMAP -=dMAP;
// Find the mean effective pressure required to achieve this manifold pressure // Find the mean effective pressure required to achieve this manifold pressure
// Doing this before boost so boost doesn't add horsepower to the engine. // Fixme: determine the HP consumed by the supercharger
// A better method would be deterimining 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 (Boosted) {
// If takeoff boost is fitted, we currently assume the following throttle map: // If takeoff boost is fitted, we currently assume the following throttle map:
// (In throttle % - actual input is 0 -> 1) // (In throttle % - actual input is 0 -> 1)
// 99 / 100 - Takeoff boost // 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 // In real life, most planes would be fitted with a mechanical 'gate' between
// the rated boost and takeoff boost positions. // the rated boost and takeoff boost positions.
@ -548,22 +545,20 @@ void FGPiston::doMAP(void)
if (bTakeoffBoost) { if (bTakeoffBoost) {
if (Throttle > 0.98) { if (Throttle > 0.98) {
bTakeoffPos = true; bTakeoffPos = true;
} else if(Throttle <= 0.95) {
bTakeoffPos = false;
} else {
bTakeoffPos = false;
} }
} }
// Boost the manifold pressure. // Boost the manifold pressure.
double boost_factor = BoostMul[BoostSpeed] * map_coefficient * RPM/RatedRPM[BoostSpeed]; 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 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. // Now clip the manifold pressure to BCV or Wastegate setting.
if (bTakeoffPos) { if (bTakeoffPos) {
if (MAP > TakeoffMAP[BoostSpeed]) MAP = TakeoffMAP[BoostSpeed]; if (MAP > TakeoffMAP[BoostSpeed]) MAP = TakeoffMAP[BoostSpeed];
} else { } else {
if (MAP > RatedMAP[BoostSpeed]) MAP = RatedMAP[BoostSpeed]; if (MAP > RatedMAP[BoostSpeed]) MAP = RatedMAP[BoostSpeed];
} }
} else {
MAP = TMAP;
} }
// And set the value in American units as well // And set the value in American units as well

View file

@ -80,7 +80,7 @@ CLASS DOCUMENTATION
<maxrpm> {number} </maxrpm> <maxrpm> {number} </maxrpm>
<maxthrottle> {number} </maxthrottle> <maxthrottle> {number} </maxthrottle>
<minthrottle> {number} </minthrottle> <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> <volumetric_efficiency> {number} </volumetric_efficiency>
<numboostspeeds> {number} </numboostspeeds> <numboostspeeds> {number} </numboostspeeds>
<boostoverride> {0 | 1} </boostoverride> <boostoverride> {0 | 1} </boostoverride>
@ -295,6 +295,7 @@ private:
double minMAP; // Pa double minMAP; // Pa
double maxMAP; // Pa double maxMAP; // Pa
double MAP; // 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 double ISFC; // Indicated specific fuel consumption [lbs/horsepower*hour
// //