1
0
Fork 0

JSBSim syncing. The changelog is:

* The Pitot angle can now be tweaked with the <pitot_angle> tag in the <metrics> block.
* The refuel rate is now configurable with the <refuel-rate> tag in the <propulsion> block.
* Fixed C++11 compliance. JSBSim can now be compiled with a C++11 compiler.
* Avoid a spurious mass report to be issued when resetting.
* Fixed the moments computation. Previously they were computed with the previous time step CG position.
* Fixed a bug where the CG update was delayed to the next time step when point masses location were modified via the FCS.
This commit is contained in:
bcoconni 2015-02-15 11:37:13 +01:00
parent 6e3486349b
commit 5349d3367f
16 changed files with 194 additions and 135 deletions

View file

@ -76,7 +76,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.164 2014/11/30 12:35:32 bcoconni Exp $"); IDENT(IdSrc,"$Id: FGFDMExec.cpp,v 1.170 2015/02/07 17:52:36 bcoconni Exp $");
IDENT(IdHdr,ID_FDMEXEC); IDENT(IdHdr,ID_FDMEXEC);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -267,25 +267,28 @@ bool FGFDMExec::Allocate(void)
Models.resize(eNumStandardModels); Models.resize(eNumStandardModels);
// First build the inertial model since some other models are relying on
// the inertial model and the ground callback to build themselves.
// Note that this does not affect the order in which the models will be
// executed later.
Models[eInertial] = new FGInertial(this);
SetGroundCallback(new FGDefaultGroundCallback(static_cast<FGInertial*>(Models[eInertial])->GetRefRadius()));
// See the eModels enum specification in the header file. The order of the // See the eModels enum specification in the header file. The order of the
// enums specifies the order of execution. The Models[] vector is the primary // enums specifies the order of execution. The Models[] vector is the primary
// storage array for the list of models. // storage array for the list of models.
// The model FGInertial is constructed first because some other models are
// using its input during their construction
Models[eInertial] = new FGInertial(this);
SetGroundCallback(new FGDefaultGroundCallback(static_cast<FGInertial*>(Models[eInertial])->GetRefRadius()));
Models[ePropagate] = new FGPropagate(this); Models[ePropagate] = new FGPropagate(this);
Models[eInput] = new FGInput(this); Models[eInput] = new FGInput(this);
Models[eAtmosphere] = new FGStandardAtmosphere(this); Models[eAtmosphere] = new FGStandardAtmosphere(this);
Models[eWinds] = new FGWinds(this); Models[eWinds] = new FGWinds(this);
Models[eAuxiliary] = new FGAuxiliary(this);
Models[eSystems] = new FGFCS(this); Models[eSystems] = new FGFCS(this);
Models[eMassBalance] = new FGMassBalance(this);
Models[eAuxiliary] = new FGAuxiliary(this);
Models[ePropulsion] = new FGPropulsion(this); Models[ePropulsion] = new FGPropulsion(this);
Models[eAerodynamics] = new FGAerodynamics (this); Models[eAerodynamics] = new FGAerodynamics (this);
Models[eGroundReactions] = new FGGroundReactions(this); Models[eGroundReactions] = new FGGroundReactions(this);
Models[eExternalReactions] = new FGExternalReactions(this); Models[eExternalReactions] = new FGExternalReactions(this);
Models[eBuoyantForces] = new FGBuoyantForces(this); Models[eBuoyantForces] = new FGBuoyantForces(this);
Models[eMassBalance] = new FGMassBalance(this);
Models[eAircraft] = new FGAircraft(this); Models[eAircraft] = new FGAircraft(this);
Models[eAccelerations] = new FGAccelerations(this); Models[eAccelerations] = new FGAccelerations(this);
Models[eOutput] = new FGOutput(this); Models[eOutput] = new FGOutput(this);
@ -295,14 +298,14 @@ bool FGFDMExec::Allocate(void)
Inertial = (FGInertial*)Models[eInertial]; Inertial = (FGInertial*)Models[eInertial];
Atmosphere = (FGAtmosphere*)Models[eAtmosphere]; Atmosphere = (FGAtmosphere*)Models[eAtmosphere];
Winds = (FGWinds*)Models[eWinds]; Winds = (FGWinds*)Models[eWinds];
Auxiliary = (FGAuxiliary*)Models[eAuxiliary];
FCS = (FGFCS*)Models[eSystems]; FCS = (FGFCS*)Models[eSystems];
MassBalance = (FGMassBalance*)Models[eMassBalance];
Auxiliary = (FGAuxiliary*)Models[eAuxiliary];
Propulsion = (FGPropulsion*)Models[ePropulsion]; Propulsion = (FGPropulsion*)Models[ePropulsion];
Aerodynamics = (FGAerodynamics*)Models[eAerodynamics]; Aerodynamics = (FGAerodynamics*)Models[eAerodynamics];
GroundReactions = (FGGroundReactions*)Models[eGroundReactions]; GroundReactions = (FGGroundReactions*)Models[eGroundReactions];
ExternalReactions = (FGExternalReactions*)Models[eExternalReactions]; ExternalReactions = (FGExternalReactions*)Models[eExternalReactions];
BuoyantForces = (FGBuoyantForces*)Models[eBuoyantForces]; BuoyantForces = (FGBuoyantForces*)Models[eBuoyantForces];
MassBalance = (FGMassBalance*)Models[eMassBalance];
Aircraft = (FGAircraft*)Models[eAircraft]; Aircraft = (FGAircraft*)Models[eAircraft];
Accelerations = (FGAccelerations*)Models[eAccelerations]; Accelerations = (FGAccelerations*)Models[eAccelerations];
Output = (FGOutput*)Models[eOutput]; Output = (FGOutput*)Models[eOutput];
@ -347,14 +350,6 @@ bool FGFDMExec::DeAllocate(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFDMExec::Schedule(FGModel* model, int rate)
{
model->SetRate(rate);
Models.push_back(model);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGFDMExec::Run(void) bool FGFDMExec::Run(void)
{ {
bool success=true; bool success=true;
@ -448,6 +443,7 @@ void FGFDMExec::LoadInputs(unsigned int idx)
Auxiliary->in.TurbPQR = Winds->GetTurbPQR(); Auxiliary->in.TurbPQR = Winds->GetTurbPQR();
Auxiliary->in.WindPsi = Winds->GetWindPsi(); Auxiliary->in.WindPsi = Winds->GetWindPsi();
Auxiliary->in.Vwind = Winds->GetTotalWindNED().Magnitude(); Auxiliary->in.Vwind = Winds->GetTotalWindNED().Magnitude();
Auxiliary->in.PitotAngle = Aircraft->GetPitotAngle();
break; break;
case eSystems: case eSystems:
// Dynamic inputs come into the components that FCS manages through properties // Dynamic inputs come into the components that FCS manages through properties

View file

@ -54,7 +54,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.93 2014/11/30 13:06:05 bcoconni Exp $" #define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.95 2015/02/07 17:52:36 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -178,7 +178,7 @@ CLASS DOCUMENTATION
property actually maps toa function call of DoTrim(). property actually maps toa function call of DoTrim().
@author Jon S. Berndt @author Jon S. Berndt
@version $Revision: 1.93 $ @version $Revision: 1.95 $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -221,21 +221,28 @@ public:
/// Default destructor /// Default destructor
~FGFDMExec(); ~FGFDMExec();
// This list of enums is very important! The order in which models are listed here // This list of enums is very important! The order in which models are listed
// determines the order of execution of the models. // here determines the order of execution of the models.
//
// There are some conditions that need to be met :
// 1. FCS can request mass geometry changes via the inertia/pointmass-*
// properties so it must be executed before MassBalance
// 2. MassBalance must be executed before Propulsion, Aerodynamics,
// GroundReactions, ExternalReactions and BuoyantForces to ensure that
// their moments are computed with the updated CG position.
enum eModels { ePropagate=0, enum eModels { ePropagate=0,
eInput, eInput,
eInertial, eInertial,
eAtmosphere, eAtmosphere,
eWinds, eWinds,
eAuxiliary,
eSystems, eSystems,
eMassBalance,
eAuxiliary,
ePropulsion, ePropulsion,
eAerodynamics, eAerodynamics,
eGroundReactions, eGroundReactions,
eExternalReactions, eExternalReactions,
eBuoyantForces, eBuoyantForces,
eMassBalance,
eAircraft, eAircraft,
eAccelerations, eAccelerations,
eOutput, eOutput,
@ -244,19 +251,6 @@ public:
/** Unbind all tied JSBSim properties. */ /** Unbind all tied JSBSim properties. */
void Unbind(void) {instance->Unbind();} void Unbind(void) {instance->Unbind();}
/** This routine places a model into the runlist at the specified rate. The
"rate" is not really a clock rate. It represents how many calls to the
FGFDMExec::Run() method must be made before the model is executed. A
value of 1 means that the model will be executed for each call to the
exec's Run() method. A value of 5 means that the model will only be
executed every 5th call to the exec's Run() method. Use of a rate other than
one is at this time not recommended.
@param model A pointer to the model being scheduled.
@param rate The rate at which to execute the model as described above.
Default is every frame (rate=1).
@return Currently returns 0 always. */
void Schedule(FGModel* model, int rate=1);
/** This function executes each scheduled model in succession. /** This function executes each scheduled model in succession.
@return true if successful, false if sim should be ended */ @return true if successful, false if sim should be ended */
bool Run(void); bool Run(void);

View file

@ -49,7 +49,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_STRINGUTILS "$Id: string_utilities.h,v 1.20 2014/06/13 22:10:33 bcoconni Exp $" #define ID_STRINGUTILS "$Id: string_utilities.h,v 1.21 2015/02/14 14:03:00 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -74,10 +74,11 @@ CLASS DECLARATION
extern bool is_number(const std::string& str); extern bool is_number(const std::string& str);
std::vector <std::string> split(std::string str, char d); std::vector <std::string> split(std::string str, char d);
// libc++ has these as built-ins for all C++ language versions // These functions are built-ins for:
// as well as Visual Studio for versions greater than 2010 // * C++11
// (1700 -> MSVC++ 11.0 and VS 2012) // * libc++ for all C++ language versions
#if !defined(_LIBCPP_VERSION) && _MSC_VER < 1700 // * Visual Studio for versions greater than 2010 (1700 -> MSVC++ 11.0 and VS 2012)
#if !defined(_LIBCPP_VERSION) && _MSC_VER < 1700 && __cplusplus < 201103L
extern std::string to_string(int); extern std::string to_string(int);
extern std::string to_string(double); extern std::string to_string(double);
extern std::string to_string(float); extern std::string to_string(float);
@ -165,7 +166,12 @@ CLASS DECLARATION
return str_array; return str_array;
} }
/* Comment out to_string functions when they are defined already - C++ 11 defines these */
// These functions are built-ins for:
// * C++11
// * libc++ for all C++ language versions
// * Visual Studio for versions greater than 2010 (1700 -> MSVC++ 11.0 and VS 2012)
#if !defined(_LIBCPP_VERSION) && _MSC_VER < 1700 && __cplusplus < 201103L
string to_string(int i) string to_string(int i)
{ {
char buffer[32]; char buffer[32];
@ -186,6 +192,7 @@ CLASS DECLARATION
if (!(o << x)) cerr << "Bad double to string conversion" << endl; if (!(o << x)) cerr << "Bad double to string conversion" << endl;
return o.str(); return o.str();
} }
#endif
string replace(string str, const string& oldstr, const string& newstr) string replace(string str, const string& oldstr, const string& newstr)
{ {

View file

@ -60,7 +60,7 @@ DEFINITIONS
GLOBAL DATA GLOBAL DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
IDENT(IdSrc,"$Id: FGAircraft.cpp,v 1.40 2014/05/17 15:29:30 jberndt Exp $"); IDENT(IdSrc,"$Id: FGAircraft.cpp,v 1.43 2015/01/31 14:56:21 bcoconni Exp $");
IDENT(IdHdr,ID_AIRCRAFT); IDENT(IdHdr,ID_AIRCRAFT);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -78,6 +78,7 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
lbarh = lbarv = 0.0; lbarh = lbarv = 0.0;
vbarh = vbarv = 0.0; vbarh = vbarv = 0.0;
WingIncidence = 0.0; WingIncidence = 0.0;
PitotAngle = 0.0;
bind(); bind();
@ -154,6 +155,8 @@ bool FGAircraft::Load(Element* el)
VTailArea = el->FindElementValueAsNumberConvertTo("vtailarea", "FT2"); VTailArea = el->FindElementValueAsNumberConvertTo("vtailarea", "FT2");
if (el->FindElement("vtailarm")) if (el->FindElement("vtailarm"))
VTailArm = el->FindElementValueAsNumberConvertTo("vtailarm", "FT"); VTailArm = el->FindElementValueAsNumberConvertTo("vtailarm", "FT");
if (el->FindElement("pitot_angle"))
PitotAngle = el->FindElementValueAsNumberConvertTo("pitot_angle", "RAD");
// Find all LOCATION elements that descend from this METRICS branch of the // Find all LOCATION elements that descend from this METRICS branch of the
// config file. This would be CG location, eyepoint, etc. // config file. This would be CG location, eyepoint, etc.

View file

@ -49,7 +49,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.21 2013/11/24 11:40:55 bcoconni Exp $" #define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.24 2015/01/31 14:56:21 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -80,6 +80,7 @@ CLASS DOCUMENTATION
<vtailarea unit="{FT2 | M}"> {number} </vtailarea> <vtailarea unit="{FT2 | M}"> {number} </vtailarea>
<vtailarm unit="{FT | M}"> {number} </vtailarm> <vtailarm unit="{FT | M}"> {number} </vtailarm>
<wing_incidence unit="{RAD | DEG}"> {number} </wing_incidence> <wing_incidence unit="{RAD | DEG}"> {number} </wing_incidence>
<pitot_angle unit="{RAD | DEG}"> {number} </pitot_angle>
<location name="{AERORP | EYEPOINT | VRP}" unit="{IN | M}"> <location name="{AERORP | EYEPOINT | VRP}" unit="{IN | M}">
<x> {number} </x> <x> {number} </x>
<y> {number} </y> <y> {number} </y>
@ -90,7 +91,7 @@ CLASS DOCUMENTATION
@endcode @endcode
@author Jon S. Berndt @author Jon S. Berndt
@version $Id: FGAircraft.h,v 1.21 2013/11/24 11:40:55 bcoconni Exp $ @version $Id: FGAircraft.h,v 1.24 2015/01/31 14:56:21 bcoconni Exp $
@see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
School, January 1994 School, January 1994
@ -145,6 +146,7 @@ public:
double GetWingSpan(void) const { return WingSpan; } double GetWingSpan(void) const { return WingSpan; }
/// Gets the average wing chord /// Gets the average wing chord
double Getcbar(void) const { return cbar; } double Getcbar(void) const { return cbar; }
double GetPitotAngle(void) const { return PitotAngle; }
double GetWingIncidence(void) const { return WingIncidence; } double GetWingIncidence(void) const { return WingIncidence; }
double GetWingIncidenceDeg(void) const { return WingIncidence*radtodeg; } double GetWingIncidenceDeg(void) const { return WingIncidence*radtodeg; }
double GetHTailArea(void) const { return HTailArea; } double GetHTailArea(void) const { return HTailArea; }
@ -197,7 +199,7 @@ private:
double WingArea, WingSpan, cbar, WingIncidence; double WingArea, WingSpan, cbar, WingIncidence;
double HTailArea, VTailArea, HTailArm, VTailArm; double HTailArea, VTailArea, HTailArm, VTailArm;
double lbarh,lbarv,vbarh,vbarv; double lbarh,lbarv,vbarh,vbarv,PitotAngle;
std::string AircraftName; std::string AircraftName;
void Debug(int from); void Debug(int from);

49
src/FDM/JSBSim/models/FGAuxiliary.cpp Normal file → Executable file
View file

@ -51,7 +51,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
IDENT(IdSrc,"$Id: FGAuxiliary.cpp,v 1.67 2014/05/17 15:28:51 jberndt Exp $"); IDENT(IdSrc,"$Id: FGAuxiliary.cpp,v 1.68 2014/12/27 05:41:11 dpculp Exp $");
IDENT(IdHdr,ID_AUXILIARY); IDENT(IdHdr,ID_AUXILIARY);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -68,10 +68,10 @@ FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
vcas = veas = 0.0; vcas = veas = 0.0;
qbar = qbarUW = qbarUV = 0.0; qbar = qbarUW = qbarUV = 0.0;
Mach = MachU = 0.0; Mach = MachU = MachPitot = 0.0;
alpha = beta = 0.0; alpha = beta = 0.0;
adot = bdot = 0.0; adot = bdot = 0.0;
gamma = Vt = Vground = 0.0; gamma = Vt = Vground = Vpitot = 0.0;
psigt = 0.0; psigt = 0.0;
day_of_year = 1; day_of_year = 1;
seconds_in_day = 0.0; seconds_in_day = 0.0;
@ -85,6 +85,8 @@ FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
vAeroUVW.InitMatrix(); vAeroUVW.InitMatrix();
vAeroPQR.InitMatrix(); vAeroPQR.InitMatrix();
vMachUVW.InitMatrix(); vMachUVW.InitMatrix();
vWindUVW.InitMatrix();
vPitotUVW.InitMatrix();
vEuler.InitMatrix(); vEuler.InitMatrix();
vEulerRates.InitMatrix(); vEulerRates.InitMatrix();
@ -105,10 +107,10 @@ bool FGAuxiliary::InitModel(void)
vcas = veas = 0.0; vcas = veas = 0.0;
qbar = qbarUW = qbarUV = 0.0; qbar = qbarUW = qbarUV = 0.0;
Mach = MachU = 0.0; Mach = MachU = MachPitot = 0.0;
alpha = beta = 0.0; alpha = beta = 0.0;
adot = bdot = 0.0; adot = bdot = 0.0;
gamma = Vt = Vground = 0.0; gamma = Vt = Vground = Vpitot = 0.0;
psigt = 0.0; psigt = 0.0;
day_of_year = 1; day_of_year = 1;
seconds_in_day = 0.0; seconds_in_day = 0.0;
@ -196,7 +198,6 @@ bool FGAuxiliary::Run(bool Holding)
MachU = vMachUVW(eU) = vAeroUVW(eU) / in.SoundSpeed; MachU = vMachUVW(eU) = vAeroUVW(eU) / in.SoundSpeed;
vMachUVW(eV) = vAeroUVW(eV) / in.SoundSpeed; vMachUVW(eV) = vAeroUVW(eV) / in.SoundSpeed;
vMachUVW(eW) = vAeroUVW(eW) / in.SoundSpeed; vMachUVW(eW) = vAeroUVW(eW) / in.SoundSpeed;
double MachU2 = MachU * MachU;
// Position // Position
@ -209,17 +210,26 @@ bool FGAuxiliary::Run(bool Holding)
tat = in.Temperature*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow tat = in.Temperature*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow
tatc = RankineToCelsius(tat); tatc = RankineToCelsius(tat);
if (MachU < 1) { // Calculate total pressure assuming isentropic flow // Pitot
pt = in.Pressure*pow((1 + 0.2*MachU2),3.5);
vWindUVW(eU) = Vt;
vPitotUVW = mTw2p * vWindUVW;
Vpitot = vPitotUVW(eU);
if (Vpitot < 0.0) Vpitot = 0.0;
MachPitot = Vpitot / in.SoundSpeed;
double MachP2 = MachPitot * MachPitot;
if (MachPitot < 1) { // Calculate total pressure assuming isentropic flow
pt = in.Pressure*pow((1 + 0.2*MachP2),3.5);
} else { } else {
// Use Rayleigh pitot tube formula for normal shock in front of pitot tube // Use Rayleigh pitot tube formula for normal shock in front of pitot tube
B = 5.76 * MachU2 / (5.6*MachU2 - 0.8); B = 5.76 * MachP2 / (5.6*MachP2 - 0.8);
D = (2.8 * MachU2 - 0.4) * 0.4167; D = (2.8 * MachP2 - 0.4) * 0.4167;
pt = in.Pressure*pow(B,3.5)*D; pt = in.Pressure*pow(B,3.5)*D;
} }
A = pow(((pt-in.Pressure)/in.PressureSL + 1),0.28571); A = pow(((pt-in.Pressure)/in.PressureSL + 1),0.28571);
if (abs(MachU) > 0.0) { if (abs(MachPitot) > 0.0) {
vcas = sqrt(7 * in.PressureSL / in.DensitySL * (A-1)); vcas = sqrt(7 * in.PressureSL / in.DensitySL * (A-1));
veas = sqrt(2 * qbar / in.DensitySL); veas = sqrt(2 * qbar / in.DensitySL);
vtrue = 1116.43559 * Mach * sqrt(in.Temperature / 518.67); vtrue = 1116.43559 * Mach * sqrt(in.Temperature / 518.67);
@ -291,6 +301,23 @@ void FGAuxiliary::UpdateWindMatrices(void)
mTw2b(3,3) = ca; mTw2b(3,3) = ca;
mTb2w = mTw2b.Transposed(); mTb2w = mTw2b.Transposed();
// The pitot frame is the same as the body frame except rotated about the
// Y axis by the pitot attachment angle.
ca = cos(alpha + in.PitotAngle);
sa = sin(alpha + in.PitotAngle);
mTw2p(1,1) = ca*cb;
mTw2p(1,2) = -ca*sb;
mTw2p(1,3) = -sa;
mTw2p(2,1) = sb;
mTw2p(2,2) = cb;
mTw2p(2,3) = 0.0;
mTw2p(3,1) = sa*cb;
mTw2p(3,2) = -sa*sb;
mTw2p(3,3) = ca;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -48,7 +48,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.28 2013/06/10 01:56:27 jberndt Exp $" #define ID_AUXILIARY "$Id: FGAuxiliary.h,v 1.29 2014/12/27 05:41:11 dpculp Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -99,7 +99,7 @@ CLASS DOCUMENTATION
to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR. to the JSBSim vPQRdot vector, and the w parameter is equivalent to vPQR.
@author Tony Peden, Jon Berndt @author Tony Peden, Jon Berndt
@version $Id: FGAuxiliary.h,v 1.28 2013/06/10 01:56:27 jberndt Exp $ @version $Id: FGAuxiliary.h,v 1.29 2014/12/27 05:41:11 dpculp Exp $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -289,6 +289,7 @@ public:
FGColumnVector3 TurbPQR; FGColumnVector3 TurbPQR;
double WindPsi; double WindPsi;
double Vwind; double Vwind;
double PitotAngle;
} in; } in;
private: private:
@ -297,6 +298,7 @@ private:
FGMatrix33 mTw2b; FGMatrix33 mTw2b;
FGMatrix33 mTb2w; FGMatrix33 mTb2w;
FGMatrix33 mTw2p;
FGColumnVector3 vPilotAccel; FGColumnVector3 vPilotAccel;
FGColumnVector3 vPilotAccelN; FGColumnVector3 vPilotAccelN;
@ -307,9 +309,12 @@ private:
FGColumnVector3 vEuler; FGColumnVector3 vEuler;
FGColumnVector3 vEulerRates; FGColumnVector3 vEulerRates;
FGColumnVector3 vMachUVW; FGColumnVector3 vMachUVW;
FGColumnVector3 vWindUVW;
FGColumnVector3 vPitotUVW;
FGLocation vLocationVRP; FGLocation vLocationVRP;
double Vt, Vground, Mach, MachU; double Vt, Vground, Vpitot;
double Mach, MachU, MachPitot;
double qbar, qbarUW, qbarUV; double qbar, qbarUW, qbarUV;
double Re; // Reynolds Number = V*c/mu double Re; // Reynolds Number = V*c/mu
double alpha, beta; double alpha, beta;

View file

@ -51,7 +51,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
IDENT(IdSrc,"$Id: FGMassBalance.cpp,v 1.51 2014/11/29 13:47:19 bcoconni Exp $"); IDENT(IdSrc,"$Id: FGMassBalance.cpp,v 1.52 2015/02/15 10:14:46 bcoconni Exp $");
IDENT(IdHdr,ID_MASSBALANCE); IDENT(IdHdr,ID_MASSBALANCE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -403,7 +403,8 @@ void FGMassBalance::bind(void)
PropertyManager->Tie("inertia/cg-z-in", this,3, PropertyManager->Tie("inertia/cg-z-in", this,3,
(PMF)&FGMassBalance::GetXYZcg); (PMF)&FGMassBalance::GetXYZcg);
typedef int (FGMassBalance::*iOPV)() const; typedef int (FGMassBalance::*iOPV)() const;
PropertyManager->Tie("inertia/print-mass-properties", this, (iOPV)0, &FGMassBalance::GetMassPropertiesReport); PropertyManager->Tie("inertia/print-mass-properties", this, (iOPV)0,
&FGMassBalance::GetMassPropertiesReport, false);
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -65,7 +65,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
IDENT(IdSrc,"$Id: FGPropulsion.cpp,v 1.80 2014/06/29 10:18:16 bcoconni Exp $"); IDENT(IdSrc,"$Id: FGPropulsion.cpp,v 1.83 2015/01/31 14:56:21 bcoconni Exp $");
IDENT(IdHdr,ID_PROPULSION); IDENT(IdHdr,ID_PROPULSION);
extern short debug_lvl; extern short debug_lvl;
@ -86,6 +86,7 @@ FGPropulsion::FGPropulsion(FGFDMExec* exec) : FGModel(exec)
tankJ.InitMatrix(); tankJ.InitMatrix();
refuel = dump = false; refuel = dump = false;
DumpRate = 0.0; DumpRate = 0.0;
RefuelRate = 6000.0;
FuelFreeze = false; FuelFreeze = false;
TotalFuelQuantity = 0.0; TotalFuelQuantity = 0.0;
IsBound = IsBound =
@ -353,6 +354,7 @@ bool FGPropulsion::Load(Element* el)
Debug(2); Debug(2);
ReadingEngine = false; ReadingEngine = false;
double FuelDensity = 6.0;
Name = "Propulsion Model: " + el->GetAttributeValue("name"); Name = "Propulsion Model: " + el->GetAttributeValue("name");
@ -365,7 +367,10 @@ bool FGPropulsion::Load(Element* el)
Element* tank_element = el->FindElement("tank"); Element* tank_element = el->FindElement("tank");
while (tank_element) { while (tank_element) {
Tanks.push_back(new FGTank(FDMExec, tank_element, numTanks)); Tanks.push_back(new FGTank(FDMExec, tank_element, numTanks));
if (Tanks.back()->GetType() == FGTank::ttFUEL) numFuelTanks++; if (Tanks.back()->GetType() == FGTank::ttFUEL) {
FuelDensity = Tanks[numFuelTanks]->GetDensity();
numFuelTanks++;
}
else if (Tanks.back()->GetType() == FGTank::ttOXIDIZER) numOxiTanks++; else if (Tanks.back()->GetType() == FGTank::ttOXIDIZER) numOxiTanks++;
else {cerr << "Unknown tank type specified." << endl; return false;} else {cerr << "Unknown tank type specified." << endl; return false;}
numTanks++; numTanks++;
@ -426,9 +431,16 @@ bool FGPropulsion::Load(Element* el)
CalculateTankInertias(); CalculateTankInertias();
// Process fuel dump rate
if (el->FindElement("dump-rate")) if (el->FindElement("dump-rate"))
DumpRate = el->FindElementValueAsNumberConvertTo("dump-rate", "LBS/MIN"); DumpRate = el->FindElementValueAsNumberConvertTo("dump-rate", "LBS/MIN");
if (el->FindElement("refuel-rate"))
RefuelRate = el->FindElementValueAsNumberConvertTo("refuel-rate", "LBS/MIN");
unsigned int i;
for (i=0; i<Engines.size(); i++) {
Engines[i]->SetFuelDensity(FuelDensity);
}
PostLoad(el, PropertyManager); PostLoad(el, PropertyManager);
@ -585,6 +597,7 @@ void FGPropulsion::SetMagnetos(int setting)
// ToDo: first need to make sure the engine Type is really appropriate: // ToDo: first need to make sure the engine Type is really appropriate:
// do a check to see if it is of type Piston. This should be done for // do a check to see if it is of type Piston. This should be done for
// all of this kind of possibly across-the-board settings. // all of this kind of possibly across-the-board settings.
if (Engines[i]->GetType() == FGEngine::etPiston)
((FGPiston*)Engines[i])->SetMagnetos(setting); ((FGPiston*)Engines[i])->SetMagnetos(setting);
} }
} else { } else {
@ -679,13 +692,14 @@ void FGPropulsion::DoRefuel(double time_slice)
{ {
unsigned int i; unsigned int i;
double fillrate = 100 * time_slice; // 100 lbs/sec = 6000 lbs/min double fillrate = RefuelRate / 60.0 * time_slice;
int TanksNotFull = 0; int TanksNotFull = 0;
for (i=0; i<numTanks; i++) { for (i=0; i<numTanks; i++) {
if (Tanks[i]->GetPctFull() < 99.99) ++TanksNotFull; if (Tanks[i]->GetPctFull() < 99.99) ++TanksNotFull;
} }
// adds fuel equally to all tanks that are not full
if (TanksNotFull) { if (TanksNotFull) {
for (i=0; i<numTanks; i++) { for (i=0; i<numTanks; i++) {
if (Tanks[i]->GetPctFull() < 99.99) if (Tanks[i]->GetPctFull() < 99.99)

View file

@ -49,7 +49,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.34 2014/06/09 11:52:07 bcoconni Exp $" #define ID_PROPULSION "$Id: FGPropulsion.h,v 1.35 2015/01/07 23:22:59 dpculp Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -87,11 +87,12 @@ CLASS DOCUMENTATION
</tank> </tank>
... more tanks ... ... more tanks ...
<dump-rate unit="{LBS/MIN | KG/MIN}"> {number} </dump-rate> <dump-rate unit="{LBS/MIN | KG/MIN}"> {number} </dump-rate>
<refuel-rate unit="{LBS/MIN | KG/MIN}"> {number} </refuel-rate>
</propulsion> </propulsion>
@endcode @endcode
@author Jon S. Berndt @author Jon S. Berndt
@version $Id: FGPropulsion.h,v 1.34 2014/06/09 11:52:07 bcoconni Exp $ @version $Id: FGPropulsion.h,v 1.35 2015/01/07 23:22:59 dpculp Exp $
@see @see
FGEngine FGEngine
FGTank FGTank
@ -216,6 +217,7 @@ private:
bool FuelFreeze; bool FuelFreeze;
double TotalFuelQuantity; double TotalFuelQuantity;
double DumpRate; double DumpRate;
double RefuelRate;
bool IsBound; bool IsBound;
bool HavePistonEngine; bool HavePistonEngine;
bool HaveTurbineEngine; bool HaveTurbineEngine;

View file

@ -53,7 +53,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
IDENT(IdSrc,"$Id: FGEngine.cpp,v 1.60 2014/06/09 11:52:07 bcoconni Exp $"); IDENT(IdSrc,"$Id: FGEngine.cpp,v 1.61 2015/01/07 23:22:59 dpculp Exp $");
IDENT(IdHdr,ID_ENGINE); IDENT(IdHdr,ID_ENGINE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -71,7 +71,7 @@ FGEngine::FGEngine(FGFDMExec* exec, int engine_number, struct Inputs& input)
FuelExpended = 0.0; FuelExpended = 0.0;
MaxThrottle = 1.0; MaxThrottle = 1.0;
MinThrottle = 0.0; MinThrottle = 0.0;
FuelDensity = 6.02;
Debug(0); Debug(0);
} }

View file

@ -53,7 +53,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_ENGINE "$Id: FGEngine.h,v 1.42 2014/06/09 11:52:07 bcoconni Exp $" #define ID_ENGINE "$Id: FGEngine.h,v 1.43 2015/01/07 23:22:59 dpculp Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -111,7 +111,7 @@ CLASS DOCUMENTATION
documentation for engine and thruster classes. documentation for engine and thruster classes.
</pre> </pre>
@author Jon S. Berndt @author Jon S. Berndt
@version $Id: FGEngine.h,v 1.42 2014/06/09 11:52:07 bcoconni Exp $ @version $Id: FGEngine.h,v 1.43 2015/01/07 23:22:59 dpculp Exp $
*/ */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -166,7 +166,7 @@ public:
virtual double getFuelFlow_gph () const {return FuelFlow_gph;} virtual double getFuelFlow_gph () const {return FuelFlow_gph;}
virtual double getFuelFlow_pph () const {return FuelFlow_pph;} virtual double getFuelFlow_pph () const {return FuelFlow_pph;}
virtual double GetFuelFlowRate(void) const {return FuelFlowRate;} virtual double GetFuelFlowRate(void) const {return FuelFlowRate;}
virtual double GetFuelFlowRateGPH(void) const {return FuelFlowRate*3600/6.02;} virtual double GetFuelFlowRateGPH(void) const {return FuelFlowRate*3600/FuelDensity;}
virtual double GetFuelUsedLbs(void) const {return FuelUsedLbs;} virtual double GetFuelUsedLbs(void) const {return FuelUsedLbs;}
virtual bool GetStarved(void) const { return Starved; } virtual bool GetStarved(void) const { return Starved; }
virtual bool GetRunning(void) const { return Running; } virtual bool GetRunning(void) const { return Running; }
@ -178,6 +178,7 @@ public:
virtual void SetRunning(bool bb) { Running=bb; } virtual void SetRunning(bool bb) { Running=bb; }
virtual void SetName(const std::string& name) { Name = name; } virtual void SetName(const std::string& name) { Name = name; }
virtual void SetFuelFreeze(bool f) { FuelFreeze = f; } virtual void SetFuelFreeze(bool f) { FuelFreeze = f; }
virtual void SetFuelDensity(double d) { FuelDensity = d; }
virtual void SetStarter(bool s) { Starter = s; } virtual void SetStarter(bool s) { Starter = s; }
@ -250,6 +251,7 @@ protected:
double FuelFlow_gph; double FuelFlow_gph;
double FuelFlow_pph; double FuelFlow_pph;
double FuelUsedLbs; double FuelUsedLbs;
double FuelDensity;
FGFDMExec* FDMExec; FGFDMExec* FDMExec;
FGThruster* Thruster; FGThruster* Thruster;

View file

@ -51,7 +51,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
IDENT(IdSrc,"$Id: FGPiston.cpp,v 1.77 2014/06/08 12:00:35 bcoconni Exp $"); IDENT(IdSrc,"$Id: FGPiston.cpp,v 1.78 2015/01/07 23:22:59 dpculp Exp $");
IDENT(IdHdr,ID_PISTON); IDENT(IdHdr,ID_PISTON);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -752,8 +752,8 @@ void FGPiston::doFuelFlow(void)
FuelFlowRate = 0.0; FuelFlowRate = 0.0;
m_dot_fuel = 0.0; m_dot_fuel = 0.0;
} }
FuelFlow_pph = FuelFlowRate * 3600; // seconds to hours FuelFlow_pph = FuelFlowRate * 3600;
FuelFlow_gph = FuelFlow_pph / 6.0; // Assumes 6 lbs / gallon FuelFlow_gph = FuelFlow_pph / FuelDensity;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -45,7 +45,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
IDENT(IdSrc,"$Id: FGPropeller.cpp,v 1.48 2014/01/13 10:46:10 ehofman Exp $"); IDENT(IdSrc,"$Id: FGPropeller.cpp,v 1.49 2014/12/27 14:37:37 dpculp Exp $");
IDENT(IdHdr,ID_PROPELLER); IDENT(IdHdr,ID_PROPELLER);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -360,7 +360,7 @@ double FGPropeller::GetPowerRequired(void)
double local_RPS = RPS < 0.01 ? 0.01 : RPS; double local_RPS = RPS < 0.01 ? 0.01 : RPS;
PowerRequired = cPReq*local_RPS*RPS*local_RPS*D5*rho; PowerRequired = cPReq*local_RPS*local_RPS*local_RPS*D5*rho;
vTorque(eX) = -Sense*PowerRequired / (local_RPS*2.0*M_PI); vTorque(eX) = -Sense*PowerRequired / (local_RPS*2.0*M_PI);
return PowerRequired; return PowerRequired;

View file

@ -48,7 +48,7 @@ using namespace std;
namespace JSBSim { namespace JSBSim {
IDENT(IdSrc,"$Id: FGTank.cpp,v 1.40 2014/05/17 15:09:42 jberndt Exp $"); IDENT(IdSrc,"$Id: FGTank.cpp,v 1.43 2015/02/02 20:49:11 bcoconni Exp $");
IDENT(IdHdr,ID_TANK); IDENT(IdHdr,ID_TANK);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -56,26 +56,26 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number) FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number)
: TankNumber(tank_number), Exec(exec) : TankNumber(tank_number)
{ {
string token, strFuelName; string token, strFuelName;
Element* element; Element* element;
Element* element_Grain; Element* element_Grain;
FGPropertyManager *PropertyManager = exec->GetPropertyManager();
Area = 1.0; Area = 1.0;
Density = 6.6; Density = 6.6;
InitialTemperature = Temperature = -9999.0; InitialTemperature = Temperature = -9999.0;
Ixx = Iyy = Izz = 0.0; Ixx = Iyy = Izz = 0.0;
InertiaFactor = 1.0; InertiaFactor = 1.0;
Radius = Contents = Standpipe = Length = InnerRadius = 0.0; Radius = Contents = Standpipe = Length = InnerRadius = 0.0;
PreviousUsed = 0.0;
ExternalFlow = 0.0; ExternalFlow = 0.0;
InitialStandpipe = 0.0; InitialStandpipe = 0.0;
Capacity = 0.00001; Capacity = 0.00001;
Priority = InitialPriority = 1; Priority = InitialPriority = 1;
PropertyManager = Exec->GetPropertyManager();
vXYZ.InitMatrix(); vXYZ.InitMatrix();
vXYZ_drain.InitMatrix(); vXYZ_drain.InitMatrix();
ixx_unit = iyy_unit = izz_unit = 1.0; ixx_unit = iyy_unit = izz_unit = 1.0;
grainType = gtUNKNOWN; // This is the default
type = el->GetAttributeValue("type"); type = el->GetAttributeValue("type");
if (type == "FUEL") Type = ttFUEL; if (type == "FUEL") Type = ttFUEL;
@ -129,31 +129,8 @@ FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number)
PctFull = 100.0*Contents/Capacity; // percent full; 0 to 100.0 PctFull = 100.0*Contents/Capacity; // percent full; 0 to 100.0
string property_name, base_property_name;
base_property_name = CreateIndexedPropertyName("propulsion/tank", TankNumber);
property_name = base_property_name + "/contents-lbs";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetContents,
&FGTank::SetContents );
property_name = base_property_name + "/pct-full";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetPctFull);
property_name = base_property_name + "/priority";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetPriority,
&FGTank::SetPriority );
property_name = base_property_name + "/external-flow-rate-pps";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetExternalFlow,
&FGTank::SetExternalFlow );
property_name = base_property_name + "/local-ixx-slug_ft2";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetIxx);
property_name = base_property_name + "/local-iyy-slug_ft2";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetIyy);
property_name = base_property_name + "/local-izz-slug_ft2";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetIzz);
// Check whether this is a solid propellant "tank". Initialize it if true. // Check whether this is a solid propellant "tank". Initialize it if true.
grainType = gtUNKNOWN; // This is the default
element_Grain = el->FindElement("grain_config"); element_Grain = el->FindElement("grain_config");
if (element_Grain) { if (element_Grain) {
@ -230,6 +207,8 @@ FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number)
// A named fuel type will override a previous density value // A named fuel type will override a previous density value
if (!strFuelName.empty()) Density = ProcessFuelName(strFuelName); if (!strFuelName.empty()) Density = ProcessFuelName(strFuelName);
bind(PropertyManager);
Debug(0); Debug(0);
} }
@ -249,7 +228,7 @@ void FGTank::ResetToIC(void)
SetContents ( InitialContents ); SetContents ( InitialContents );
PctFull = 100.0*Contents/Capacity; PctFull = 100.0*Contents/Capacity;
SetPriority( InitialPriority ); SetPriority( InitialPriority );
PreviousUsed = 0.0; CalculateInertias();
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -270,7 +249,6 @@ double FGTank::GetXYZ(int idx) const
double FGTank::Drain(double used) double FGTank::Drain(double used)
{ {
// double AmountToDrain = 2.0*used - PreviousUsed;
double remaining = Contents - used; double remaining = Contents - used;
if (remaining >= 0) { // Reduce contents by amount used. if (remaining >= 0) { // Reduce contents by amount used.
@ -283,8 +261,8 @@ double FGTank::Drain(double used)
Contents = 0.0; Contents = 0.0;
PctFull = 0.0; PctFull = 0.0;
} }
// PreviousUsed = AmountToDrain;
if (grainType != gtUNKNOWN) CalculateInertias(); CalculateInertias();
return remaining; return remaining;
} }
@ -304,6 +282,9 @@ double FGTank::Fill(double amount)
} else { } else {
PctFull = Contents/Capacity*100.0; PctFull = Contents/Capacity*100.0;
} }
CalculateInertias();
return overage; return overage;
} }
@ -318,6 +299,8 @@ void FGTank::SetContents(double amount)
} else { } else {
PctFull = Contents/Capacity*100.0; PctFull = Contents/Capacity*100.0;
} }
CalculateInertias();
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -400,7 +383,7 @@ void FGTank::CalculateInertias(void)
Iyy = function_iyy->GetValue()*iyy_unit; Iyy = function_iyy->GetValue()*iyy_unit;
Izz = function_izz->GetValue()*izz_unit; Izz = function_izz->GetValue()*izz_unit;
break; break;
case gtUNKNOWN: default:
cerr << "Unknown grain type found." << endl; cerr << "Unknown grain type found." << endl;
exit(-1); exit(-1);
break; break;
@ -449,6 +432,31 @@ double FGTank::ProcessFuelName(const std::string& name)
return 6.6; return 6.6;
} }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGTank::bind(FGPropertyManager* PropertyManager)
{
string property_name, base_property_name;
base_property_name = CreateIndexedPropertyName("propulsion/tank", TankNumber);
property_name = base_property_name + "/contents-lbs";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetContents,
&FGTank::SetContents );
property_name = base_property_name + "/pct-full";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetPctFull);
property_name = base_property_name + "/priority";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetPriority,
&FGTank::SetPriority );
property_name = base_property_name + "/external-flow-rate-pps";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetExternalFlow,
&FGTank::SetExternalFlow );
property_name = base_property_name + "/local-ixx-slug_ft2";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetIxx);
property_name = base_property_name + "/local-iyy-slug_ft2";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetIyy);
property_name = base_property_name + "/local-izz-slug_ft2";
PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetIzz);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows: // The bitmasked value choices are as follows:

View file

@ -53,7 +53,7 @@ INCLUDES
DEFINITIONS DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_TANK "$Id: FGTank.h,v 1.28 2014/05/17 15:09:42 jberndt Exp $" #define ID_TANK "$Id: FGTank.h,v 1.30 2015/02/02 20:49:11 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS FORWARD DECLARATIONS
@ -331,17 +331,15 @@ private:
double InertiaFactor; double InertiaFactor;
double PctFull; double PctFull;
double Contents, InitialContents; double Contents, InitialContents;
double PreviousUsed;
double Area; double Area;
double Temperature, InitialTemperature; double Temperature, InitialTemperature;
double Standpipe, InitialStandpipe; double Standpipe, InitialStandpipe;
double ExternalFlow; double ExternalFlow;
bool Selected; bool Selected;
int Priority, InitialPriority; int Priority, InitialPriority;
FGFDMExec* Exec;
FGPropertyManager* PropertyManager;
void CalculateInertias(void); void CalculateInertias(void);
void bind(FGPropertyManager* PropertyManager);
void Debug(int from); void Debug(int from);
}; };
} }