1
0
Fork 0

Latest JSBSim changes, including some gear tweaking from Jon and some

fuel-reporting improvements for piston engines.
This commit is contained in:
david 2002-01-19 05:32:28 +00:00
parent 4be27ce2bf
commit eedf9f9671
9 changed files with 87 additions and 112 deletions

View 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;
}

View 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;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View 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;

View 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
}

View 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);

View 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();
}

View file

@ -86,6 +86,7 @@ public:
double Calculate(double PowerRequired);
double GetPowerAvailable(void) {return PowerAvailable;}
double CalcFuelNeed(void);
private:
int crank_counter;

View 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

View 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: