1
0
Fork 0

JSBSim fixes.

This commit is contained in:
Erik Hofman 2011-09-26 09:07:59 +02:00
parent 3bf8b9d91f
commit 1df7b9cdc2
16 changed files with 66 additions and 36 deletions

View file

@ -70,7 +70,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.114 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.115 2011/09/25 11:56:00 bcoconni Exp $";
static const char *IdHdr = ID_FDMEXEC;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -564,8 +564,8 @@ void FGFDMExec::Initialize(FGInitialCondition *FGIC)
LoadInputs(eAtmosphere);
Atmosphere->Run(false);
Winds->SetWindNED( FGIC->GetWindNFpsIC(),
FGIC->GetWindEFpsIC(),
FGIC->GetWindDFpsIC() );
FGIC->GetWindEFpsIC(),
FGIC->GetWindDFpsIC() );
Auxiliary->Run(false);
}
@ -1152,11 +1152,14 @@ bool FGFDMExec::SetOutputDirectives(const string& fname)
result = Output->Load(0);
if (result) {
Output->Run(holding);
Outputs.push_back(Output);
typedef double (FGOutput::*iOPMF)(void) const;
string outputProp = CreateIndexedPropertyName("simulation/output",Outputs.size()-1);
instance->Tie(outputProp+"/log_rate_hz", Output, (iOPMF)0, &FGOutput::SetRate, false);
}
else
delete Output;
return result;
}

View file

@ -64,7 +64,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGFCS.cpp,v 1.76 2011/08/14 20:15:56 jberndt Exp $";
static const char *IdSrc = "$Id: FGFCS.cpp,v 1.77 2011/09/25 14:05:40 bcoconni Exp $";
static const char *IdHdr = ID_FCS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -665,6 +665,8 @@ bool FGFCS::Load(Element* el, SystemType systype)
channel_element = document->FindNextElement("channel");
}
PostLoad(document, PropertyManager);
ResetParser();
return true;

View file

@ -77,7 +77,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGOutput.cpp,v 1.60 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdSrc = "$Id: FGOutput.cpp,v 1.62 2011/09/25 15:38:30 bcoconni Exp $";
static const char *IdHdr = ID_OUTPUT;
// (stolen from FGFS native_fdm.cxx)
@ -1003,8 +1003,12 @@ bool FGOutput::Load(Element* element)
if (!document) return false;
name = FDMExec->GetRootDir() + document->GetAttributeValue("name");
SetType(document->GetAttributeValue("type"));
name = document->GetAttributeValue("name");
if (((Type == otCSV) || (Type == otTab)) && (name != "cout") && (name !="COUT"))
name = FDMExec->GetRootDir() + name;
Port = document->GetAttributeValue("port");
if (!Port.empty() && (Type == otSocket || Type == otFlightGear)) {
port = atoi(Port.c_str());

View file

@ -50,7 +50,7 @@ INCLUDES
namespace JSBSim {
static const char *IdSrc = "$Id: FGStandardAtmosphere.cpp,v 1.19 2011/09/11 11:36:04 bcoconni Exp $";
static const char *IdSrc = "$Id: FGStandardAtmosphere.cpp,v 1.20 2011/09/18 12:06:21 bcoconni Exp $";
static const char *IdHdr = ID_STANDARDATMOSPHERE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -420,7 +420,7 @@ void FGStandardAtmosphere::bind(void)
(PMF)&FGStandardAtmosphere::SetTemperatureBias);
PropertyManager->Tie("atmosphere/SL-graded-delta-T", this, eRankine,
(PMFi)&FGStandardAtmosphere::GetTemperatureDeltaGradient,
(PMF)&FGStandardAtmosphere::SetSLTemperatureGradedDelta);
(PMF)&FGStandardAtmosphere::SetSLTemperatureGradedDelta);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_STANDARDATMOSPHERE "$Id: FGStandardAtmosphere.h,v 1.15 2011/08/17 23:56:01 jberndt Exp $"
#define ID_STANDARDATMOSPHERE "$Id: FGStandardAtmosphere.h,v 1.16 2011/09/18 12:06:21 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -93,7 +93,7 @@ consistently and accurately calculated.
@author Jon Berndt
@see "U.S. Standard Atmosphere, 1976", NASA TM-X-74335
@version $Id: FGStandardAtmosphere.h,v 1.15 2011/08/17 23:56:01 jberndt Exp $
@version $Id: FGStandardAtmosphere.h,v 1.16 2011/09/18 12:06:21 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -139,11 +139,13 @@ public:
virtual double GetStdTemperatureRatio(double h) const { return GetStdTemperature(h)*rSLtemperature; }
/// Returns the temperature bias over the sea level value in degrees Rankine.
virtual double GetTemperatureBias(eTemperature to) const {return TemperatureBias;}
virtual double GetTemperatureBias(eTemperature to) const
{ if (to == eCelsius || to == eKelvin) return TemperatureBias/1.80; else return TemperatureBias; }
/// Returns the temperature gradient to be applied on top of the standard
/// temperature gradient.
virtual double GetTemperatureDeltaGradient() { return TemperatureDeltaGradient;}
virtual double GetTemperatureDeltaGradient(eTemperature to)
{ if (to == eCelsius || to == eKelvin) return TemperatureDeltaGradient/1.80; else return TemperatureDeltaGradient; }
/// Sets the Sea Level temperature, if it is to be different than the standard.
/// This function will calculate a bias - a difference - from the standard

View file

@ -284,8 +284,13 @@ void FGWinds::Turbulence(double h)
double
T_V = in.totalDeltaT, // for compatibility of nomenclature
sig_p = 1.9/sqrt(L_w*b_w)*sig_w, // Yeager1998, eq. (8)
<<<<<<< FGWinds.cpp
// sig_q = sqrt(M_PI/2/L_w/b_w), // eq. (14)
/// sig_r = sqrt(2*M_PI/3/L_w/b_w), // eq. (17)
=======
//sig_q = sqrt(M_PI/2/L_w/b_w), // eq. (14)
//sig_r = sqrt(2*M_PI/3/L_w/b_w), // eq. (17)
>>>>>>> 1.5
L_p = sqrt(L_w*b_w)/2.6, // eq. (10)
tau_u = L_u/in.V, // eq. (6)
tau_w = L_w/in.V, // eq. (3)

View file

@ -50,7 +50,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGPiston.cpp,v 1.65 2011/09/11 12:06:54 bcoconni Exp $";
static const char *IdSrc = "$Id: FGPiston.cpp,v 1.67 2011/09/25 23:56:11 jentron Exp $";
static const char *IdHdr = ID_PISTON;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -336,8 +336,6 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number, struct Input
PropertyManager->Tie(property_name, &BoostSpeed);
property_name = base_property_name + "/cht-degF";
PropertyManager->Tie(property_name, this, &FGPiston::getCylinderHeadTemp_degF);
property_name = base_property_name + "/engine-rpm";
PropertyManager->Tie(property_name, this, &FGPiston::getRPM);
property_name = base_property_name + "/oil-temperature-degF";
PropertyManager->Tie(property_name, this, &FGPiston::getOilTemp_degF);
property_name = base_property_name + "/oil-pressure-psi";
@ -436,7 +434,9 @@ void FGPiston::Calculate(void)
RunPreFunctions();
RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
/* The thruster controls the engine RPM because it encapsulates the gear ratio and other transmission variables */
RPM = Thruster->GetEngineRPM();
MeanPistonSpeed_fps = ( RPM * Stroke) / (360); // AKA 2 * (RPM/60) * ( Stroke / 12) or 2NS
IAS = in.Vc;
@ -479,6 +479,7 @@ void FGPiston::Calculate(void)
double FGPiston::CalcFuelNeed(void)
{
FuelExpended = FuelFlowRate * in.TotalDeltaT;
if (!Starved) FuelUsedLbs += FuelExpended;
return FuelExpended;
}

View file

@ -45,7 +45,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.37 2011/09/11 12:06:54 bcoconni Exp $";
static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.38 2011/09/24 14:26:46 jentron Exp $";
static const char *IdHdr = ID_PROPELLER;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -147,6 +147,8 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
string property_name, base_property_name;
base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNum);
property_name = base_property_name + "/engine-rpm";
PropertyManager->Tie( property_name.c_str(), this, &FGPropeller::GetEngineRPM );
property_name = base_property_name + "/advance-ratio";
PropertyManager->Tie( property_name.c_str(), &J );
property_name = base_property_name + "/blade-angle";

View file

@ -45,7 +45,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_PROPELLER "$Id: FGPropeller.h,v 1.18 2011/06/06 22:39:52 jentron Exp $"
#define ID_PROPELLER "$Id: FGPropeller.h,v 1.19 2011/09/24 14:26:46 jentron Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -142,7 +142,7 @@ CLASS DOCUMENTATION
<li>Various NACA Technical Notes and Reports</li>
</ul>
@author Jon S. Berndt
@version $Id: FGPropeller.h,v 1.18 2011/06/06 22:39:52 jentron Exp $
@version $Id: FGPropeller.h,v 1.19 2011/09/24 14:26:46 jentron Exp $
@see FGEngine
@see FGThruster
*/
@ -171,6 +171,9 @@ public:
@param rpm the rotational velocity of the propeller */
void SetRPM(double rpm) {RPM = rpm;}
/** Sets the Revolutions Per Minute for the propeller using the engine gear ratio **/
void SetEngineRPM(double rpm) {RPM = rpm/GearRatio;}
/// Returns true of this propeller is variable pitch
bool IsVPitch(void) {return MaxPitch != MinPitch;}
@ -209,6 +212,9 @@ public:
/// Retrieves the RPMs of the propeller
double GetRPM(void) const { return RPM; }
/// Calculates the RPMs of the engine based on gear ratio
double GetEngineRPM(void) const { return RPM * GearRatio; }
/// Retrieves the propeller moment of inertia
double GetIxx(void) { return Ixx; }

View file

@ -55,7 +55,7 @@ using std::cout;
namespace JSBSim {
static const char *IdSrc = "$Id: FGRotor.cpp,v 1.16 2011/09/17 16:39:19 bcoconni Exp $";
static const char *IdSrc = "$Id: FGRotor.cpp,v 1.17 2011/09/24 14:26:46 jentron Exp $";
static const char *IdHdr = ID_ROTOR;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -706,7 +706,7 @@ bool FGRotor::BindModel(void)
property_name = base_property_name + "/rotor-rpm";
PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetRPM );
property_name = base_property_name + "/x-engine-rpm"; // used for RPM eXchange
property_name = base_property_name + "/engine-rpm";
PropertyManager->Tie( property_name.c_str(), this, &FGRotor::GetEngineRPM );
property_name = base_property_name + "/rotor-thrust-lbs"; // might be redundant - check!
@ -778,11 +778,11 @@ bool FGRotor::BindModel(void)
ExtRPMsource = PropertyManager->GetNode(property_name, true);
} else if (RPMdefinition >= 0 && RPMdefinition != EngineNum) {
string ipn = CreateIndexedPropertyName("propulsion/engine", RPMdefinition);
property_name = ipn + "/x-engine-rpm";
property_name = ipn + "/engine-rpm";
ExtRPMsource = PropertyManager->GetNode(property_name, false);
if (! ExtRPMsource) {
cerr << "# Warning: Engine number " << EngineNum << "." << endl;
cerr << "# No 'x-engine-rpm' property found for engine " << RPMdefinition << "." << endl;
cerr << "# No 'engine-rpm' property found for engine " << RPMdefinition << "." << endl;
cerr << "# Please check order of engine definitons." << endl;
}
} else {

View file

@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_ROTOR "$Id: FGRotor.h,v 1.10 2011/09/17 16:39:19 bcoconni Exp $"
#define ID_ROTOR "$Id: FGRotor.h,v 1.11 2011/09/24 14:26:46 jentron Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -205,7 +205,7 @@ CLASS DOCUMENTATION
</dl>
@author Thomas Kreitler
@version $Id: FGRotor.h,v 1.10 2011/09/17 16:39:19 bcoconni Exp $
@version $Id: FGRotor.h,v 1.11 2011/09/24 14:26:46 jentron Exp $
*/
@ -238,11 +238,11 @@ public:
/// Retrieves the RPMs of the rotor.
double GetRPM(void) const { return RPM; }
// void SetRPM(double rpm) { RPM = rpm; }
void SetRPM(double rpm) { RPM = rpm; }
/// Retrieves the RPMs of the Engine, as seen from this rotor.
double GetEngineRPM(void) const { return GearRatio*RPM; } // bit of a hack.
void SetEngineRPM(double rpm) { RPM = rpm/GearRatio; } // bit of a hack.
/// Tells the rotor's gear ratio, usually the engine asks for this.
double GetGearRatio(void) { return GearRatio; }
/// Retrieves the thrust of the rotor.

View file

@ -47,7 +47,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGTank.cpp,v 1.31 2011/08/03 03:21:06 jberndt Exp $";
static const char *IdSrc = "$Id: FGTank.cpp,v 1.32 2011/09/18 13:04:34 bcoconni Exp $";
static const char *IdHdr = ID_TANK;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -204,7 +204,7 @@ const FGColumnVector3 FGTank::GetXYZ(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const double FGTank::GetXYZ(int idx)
double FGTank::GetXYZ(int idx)
{
return vXYZ_drain(idx) + (Contents/Capacity)*(vXYZ(idx)-vXYZ_drain(idx));
}

View file

@ -52,7 +52,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_TANK "$Id: FGTank.h,v 1.24 2011/08/03 03:21:06 jberndt Exp $"
#define ID_TANK "$Id: FGTank.h,v 1.25 2011/09/18 13:04:34 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -289,7 +289,7 @@ public:
void SetExternalFlow(double f) { ExternalFlow = f; }
const FGColumnVector3 GetXYZ(void);
const double GetXYZ(int idx);
double GetXYZ(int idx);
const GrainType GetGrainType(void) {return grainType;}

View file

@ -46,7 +46,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_THRUSTER "$Id: FGThruster.h,v 1.17 2011/08/03 03:21:06 jberndt Exp $"
#define ID_THRUSTER "$Id: FGThruster.h,v 1.18 2011/09/24 14:26:46 jentron Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -74,7 +74,7 @@ CLASS DOCUMENTATION
1.57 (pi/2) results in no thrust at all.
@author Jon Berndt
@version $Id: FGThruster.h,v 1.17 2011/08/03 03:21:06 jberndt Exp $
@version $Id: FGThruster.h,v 1.18 2011/09/24 14:26:46 jentron Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -98,6 +98,7 @@ public:
}
void SetName(string name) {Name = name;}
virtual void SetRPM(double rpm) {};
virtual void SetEngineRPM(double rpm) {};
virtual double GetPowerRequired(void) {return 0.0;}
virtual void SetdeltaT(double dt) {deltaT = dt;}
double GetThrust(void) const {return Thrust;}
@ -108,6 +109,7 @@ public:
double GetClutchCtrl(void) const { return ClutchCtrlNorm; }
void SetClutchCtrl(double c) { ClutchCtrlNorm = c; }
virtual double GetRPM(void) const { return 0.0; };
virtual double GetEngineRPM(void) const { return 0.0; };
double GetGearRatio(void) {return GearRatio; }
virtual string GetThrusterLabels(int id, string delimeter);
virtual string GetThrusterValues(int id, string delimeter);

View file

@ -49,7 +49,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGTurbine.cpp,v 1.35 2011/08/04 13:45:42 jberndt Exp $";
static const char *IdSrc = "$Id: FGTurbine.cpp,v 1.36 2011/09/25 23:56:11 jentron Exp $";
static const char *IdHdr = ID_TURBINE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -385,6 +385,7 @@ double FGTurbine::CalcFuelNeed(void)
{
FuelFlowRate = FuelFlow_pph / 3600.0; // Calculates flow in lbs/sec from lbs/hr
FuelExpended = FuelFlowRate * in.TotalDeltaT; // Calculates fuel expended in this time step
if (!Starved) FuelUsedLbs += FuelExpended;
return FuelExpended;
}

6
src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp Normal file → Executable file
View file

@ -53,7 +53,7 @@ using namespace std;
namespace JSBSim {
static const char *IdSrc = "$Id: FGTurboProp.cpp,v 1.22 2011/08/04 13:45:42 jberndt Exp $";
static const char *IdSrc = "$Id: FGTurboProp.cpp,v 1.24 2011/09/25 23:56:11 jentron Exp $";
static const char *IdHdr = ID_TURBOPROP;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -170,7 +170,8 @@ void FGTurboProp::Calculate(void)
ThrottlePos = in.ThrottlePos[EngineNumber];
RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
/* The thruster controls the engine RPM because it encapsulates the gear ratio and other transmission variables */
RPM = Thruster->GetEngineRPM();
if (thrusterType == FGThruster::ttPropeller) {
((FGPropeller*)Thruster)->SetAdvance(in.PropAdvance[EngineNumber]);
((FGPropeller*)Thruster)->SetFeather(in.PropFeather[EngineNumber]);
@ -409,6 +410,7 @@ double FGTurboProp::CalcFuelNeed(void)
{
FuelFlowRate = FuelFlow_pph / 3600.0;
FuelExpended = FuelFlowRate * in.TotalDeltaT;
if (!Starved) FuelUsedLbs += FuelExpended;
return FuelExpended;
}