1
0
Fork 0

sync. with JSBSim and expose Oil_Press_Relief_Valve, Oil_Press_RPM_Max, Design_Oil_Temp, Oil_Viscosity_Index

This commit is contained in:
Erik Hofman 2017-04-27 15:41:23 +02:00
parent cbdbe2882b
commit 072bad4f50
10 changed files with 85 additions and 38 deletions

14
src/FDM/JSBSim/math/FGFunction.cpp Normal file → Executable file
View file

@ -43,7 +43,7 @@ using namespace std;
namespace JSBSim {
IDENT(IdSrc,"$Id: FGFunction.cpp,v 1.58 2015/07/12 19:34:08 bcoconni Exp $");
IDENT(IdSrc,"$Id: FGFunction.cpp,v 1.59 2017/03/11 19:31:47 bcoconni Exp $");
IDENT(IdHdr,ID_FUNCTION);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -266,7 +266,7 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, const string& pr
} else if (operation == value_string || operation == v_string) {
Parameters.push_back(new FGRealValue(element->GetDataAsNumber()));
} else if (operation == table_string || operation == t_string) {
Parameters.push_back(new FGTable(PropertyManager, element));
Parameters.push_back(new FGTable(PropertyManager, element, Prefix));
// operations
} else if (operation == product_string ||
operation == difference_string ||
@ -323,7 +323,7 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, const string& pr
element = el->GetNextElement();
}
bind(); // Allow any function to save its value
bind(el); // Allow any function to save its value
Debug(0);
}
@ -784,7 +784,7 @@ string FGFunction::GetValueAsString(void) const
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGFunction::bind(void)
void FGFunction::bind(Element* el)
{
if ( !Name.empty() ) {
string tmp;
@ -796,7 +796,8 @@ void FGFunction::bind(void)
Name = replace(Name,"#",Prefix);
tmp = PropertyManager->mkPropertyName(Name, false);
} else {
cerr << "Malformed function name with number: " << Prefix
cerr << el->ReadFrom()
<< "Malformed function name with number: " << Prefix
<< " and property name: " << Name
<< " but no \"#\" sign for substitution." << endl;
}
@ -808,7 +809,8 @@ void FGFunction::bind(void)
if (PropertyManager->HasNode(tmp)) {
FGPropertyNode* _property = PropertyManager->GetNode(tmp);
if (_property->isTied()) {
cout << "Property " << tmp << " has already been successfully bound (late)." << endl;
cerr << el->ReadFrom()
<< "Property " << tmp << " has already been successfully bound (late)." << endl;
throw("Failed to bind the property to an existing already tied node.");
}
}

4
src/FDM/JSBSim/math/FGFunction.h Normal file → Executable file
View file

@ -43,7 +43,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_FUNCTION "$Id: FGFunction.h,v 1.32 2015/07/12 13:03:23 bcoconni Exp $"
#define ID_FUNCTION "$Id: FGFunction.h,v 1.33 2017/03/11 19:31:47 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -812,7 +812,7 @@ private:
FGPropertyNode_ptr pCopyTo; // Property node for CopyTo property string
unsigned int GetBinary(double) const;
void bind(void);
void bind(Element*);
void Debug(int from);
};

View file

@ -47,7 +47,7 @@ using namespace std;
namespace JSBSim {
IDENT(IdSrc,"$Id: FGTable.cpp,v 1.32 2016/05/22 09:08:05 bcoconni Exp $");
IDENT(IdSrc,"$Id: FGTable.cpp,v 1.33 2017/03/11 19:31:48 bcoconni Exp $");
IDENT(IdHdr,ID_TABLE);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -112,7 +112,9 @@ FGTable::FGTable(const FGTable& t) : PropertyManager(t.PropertyManager)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(propMan)
FGTable::FGTable(FGPropertyManager* propMan, Element* el,
const std::string& prefix)
: PropertyManager(propMan), Prefix(prefix)
{
unsigned int i;
@ -174,6 +176,11 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop
while (axisElement) {
property_string = axisElement->GetDataLine();
if (property_string.find("#") != string::npos) {
if (is_number(Prefix)) {
property_string = replace(property_string,"#",Prefix);
}
}
// The property string passed into GetNode() must have no spaces or tabs.
node = PropertyManager->GetNode(property_string);
@ -347,7 +354,7 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop
}
}
bind();
bind(el);
if (debug_lvl & 1) Print();
}
@ -632,11 +639,37 @@ void FGTable::Print(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGTable::bind(void)
void FGTable::bind(Element* el)
{
typedef double (FGTable::*PMF)(void) const;
if ( !Name.empty() && !internal) {
string tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper
string tmp;
if (Prefix.empty())
tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper
else {
if (is_number(Prefix)) {
if (Name.find("#") != string::npos) { // if "#" is found
Name = replace(Name,"#",Prefix);
tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper
} else {
cerr << el->ReadFrom()
<< "Malformed table name with number: " << Prefix
<< " and property name: " << Name
<< " but no \"#\" sign for substitution." << endl;
}
} else {
tmp = PropertyManager->mkPropertyName(Prefix + "/" + Name, false);
}
}
if (PropertyManager->HasNode(tmp)) {
FGPropertyNode* _property = PropertyManager->GetNode(tmp);
if (_property->isTied()) {
cerr << el->ReadFrom()
<< "Property " << tmp << " has already been successfully bound (late)." << endl;
throw("Failed to bind the property to an existing already tied node.");
}
}
PropertyManager->Tie( tmp, this, (PMF)&FGTable::GetValue);
}
}

View file

@ -48,7 +48,7 @@ INCLUDES
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#define ID_TABLE "$Id: FGTable.h,v 1.15 2013/01/26 17:06:49 bcoconni Exp $"
#define ID_TABLE "$Id: FGTable.h,v 1.16 2017/03/11 19:31:48 bcoconni Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@ -233,7 +233,7 @@ combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio
@endcode
@author Jon S. Berndt
@version $Id: FGTable.h,v 1.15 2013/01/26 17:06:49 bcoconni Exp $
@version $Id: FGTable.h,v 1.16 2017/03/11 19:31:48 bcoconni Exp $
*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -251,7 +251,7 @@ public:
FGTable(const FGTable& table);
/// The constructor for a table
FGTable (FGPropertyManager* propMan, Element* el);
FGTable (FGPropertyManager* propMan, Element* el, const std::string& prefix="");
FGTable (int );
FGTable (int, int);
double GetValue(void) const;
@ -311,8 +311,9 @@ private:
mutable int lastRowIndex, lastColumnIndex, lastTableIndex;
double** Allocate(void);
FGPropertyManager* const PropertyManager;
std::string Prefix;
std::string Name;
void bind(void);
void bind(Element*);
unsigned int FindNumColumns(const std::string&);
void Debug(int from);

View file

@ -104,8 +104,6 @@ bool FGAccelerations::InitModel(void)
vGravAccel.InitMatrix();
vBodyAccel.InitMatrix();
maxiter = 50;
matrixSize = iter = 0;
return true;
}
@ -257,7 +255,6 @@ void FGAccelerations::ResolveFrictionForces(double dt)
FGColumnVector3 vdot, wdot;
vector<LagrangeMultiplier*>& multipliers = *in.MultipliersList;
size_t n = multipliers.size();
matrixSize = n;
vFrictionForces.InitMatrix();
vFrictionMoments.InitMatrix();
@ -306,7 +303,7 @@ void FGAccelerations::ResolveFrictionForces(double dt)
}
// Resolve the Lagrange multipliers with the projected Gauss-Seidel method
for (iter=0; iter < maxiter; iter = iter+1) {
for (int iter=0; iter < 50; iter++) {
double norm = 0.;
for (unsigned int i=0; i < n; i++) {
@ -387,10 +384,6 @@ void FGAccelerations::bind(void)
PropertyManager->Tie("forces/fbx-gear-lbs", this, eX, (PMF)&FGAccelerations::GetGroundForces);
PropertyManager->Tie("forces/fby-gear-lbs", this, eY, (PMF)&FGAccelerations::GetGroundForces);
PropertyManager->Tie("forces/fbz-gear-lbs", this, eZ, (PMF)&FGAccelerations::GetGroundForces);
iter = PropertyManager->CreatePropertyObject<int>("numerical/friction-resolver/iterations");
maxiter = PropertyManager->CreatePropertyObject<int>("numerical/friction-resolver/max-iterations");
matrixSize = PropertyManager->CreatePropertyObject<int>("numerical/friction-resolver/matrix-size");
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -40,7 +40,6 @@ INCLUDES
#include <vector>
#include "simgear/props/propertyObject.hxx"
#include "models/FGModel.h"
#include "math/FGColumnVector3.h"
#include "math/LagrangeMultiplier.h"
@ -392,7 +391,6 @@ private:
FGColumnVector3 vGravAccel;
FGColumnVector3 vFrictionForces;
FGColumnVector3 vFrictionMoments;
simgear::PropertyObject<int> iter, maxiter, matrixSize;
int gravType;
bool gravTorque;

View file

@ -234,6 +234,19 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number, struct Input
RatedAltitude[2] = el->FindElementValueAsNumberConvertTo("ratedaltitude3", "FT");
}
Design_Oil_Temp = 358; // degK;
Oil_Viscosity_Index = 0.25;
Oil_Press_Relief_Valve = 60; // psi
Oil_Press_RPM_Max = MaxRPM*0.75;
if (el->FindElement("oil-pressure-relief-valve-psi"))
Oil_Press_Relief_Valve = el->FindElementValueAsNumberConvertTo("oil-pressure-relief-valve-psi", "PSI");
if (el->FindElement("design-oil-temp-degK"))
Design_Oil_Temp = el->FindElementValueAsNumberConvertTo("design-oil-temp-degK", "DEGK");
if (el->FindElement("oil-pressure-rpm-max"))
Oil_Press_RPM_Max = el->FindElementValueAsNumber("oil-pressure-rpm-max");
if (el->FindElement("oil-viscosity-index"))
Oil_Viscosity_Index = el->FindElementValueAsNumber("oil-viscosity-index");
while((table_element = el->FindNextElement("table")) != 0) {
string name = table_element->GetAttributeValue("name");
try {
@ -920,11 +933,6 @@ void FGPiston::doOilTemperature(void)
void FGPiston::doOilPressure(void)
{
double Oil_Press_Relief_Valve = 60; // FIXME: may vary by engine
double Oil_Press_RPM_Max = MaxRPM * 0.75; // 75% of max rpm FIXME: may vary by engine
double Design_Oil_Temp = 358; // degK; FIXME: may vary by engine
double Oil_Viscosity_Index = 0.25;
OilPressure_psi = (Oil_Press_Relief_Valve / Oil_Press_RPM_Max) * RPM;
if (OilPressure_psi >= Oil_Press_Relief_Valve) {

View file

@ -361,6 +361,11 @@ private:
bool Magneto_Right;
int Magnetos;
double Oil_Press_Relief_Valve;
double Oil_Press_RPM_Max;
double Design_Oil_Temp; // degK
double Oil_Viscosity_Index;
//
// Outputs (in addition to those in FGEngine).
//

View file

@ -45,7 +45,7 @@ using namespace std;
namespace JSBSim {
IDENT(IdSrc,"$Id: FGPropeller.cpp,v 1.60 2017/03/03 23:00:39 bcoconni Exp $");
IDENT(IdSrc,"$Id: FGPropeller.cpp,v 1.61 2017/03/22 21:27:47 bcoconni Exp $");
IDENT(IdHdr,ID_PROPELLER);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -211,7 +211,7 @@ double FGPropeller::Calculate(double EnginePower)
FGColumnVector3 localAeroVel = Transform().Transposed() * in.AeroUVW;
double omega, PowerAvailable;
double Vel = localAeroVel(eU) + Vinduced;
double Vel = localAeroVel(eU);
double rho = in.Density;
double RPS = RPM/60.0;

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

@ -55,7 +55,7 @@ using namespace std;
namespace JSBSim {
IDENT(IdSrc,"$Id: FGTurboProp.cpp,v 1.36 2017/02/26 11:41:28 bcoconni Exp $");
IDENT(IdSrc,"$Id: FGTurboProp.cpp,v 1.37 2017/03/11 19:50:03 bcoconni Exp $");
IDENT(IdHdr,ID_TURBOPROP);
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@ -146,7 +146,14 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
while (table_element) {
string name = table_element->GetAttributeValue("name");
if (!EnginePowerVC && name == "EnginePowerVC") {
EnginePowerVC = new FGTable(PropertyManager, table_element);
// Get a different name for each engines otherwise FGTable::bind() will
// complain that the property 'EnginePowerVC' is already bound. This is a
// ugly hack but the functionality is obsolete and will be removed some
// time in the future.
table_element->SetAttributeValue("name", string("propulsion/engine[#]/") + name);
EnginePowerVC = new FGTable(PropertyManager, table_element,
to_string((int)EngineNumber));
table_element->SetAttributeValue("name", name);
cerr << table_element->ReadFrom()
<<"Note: Using the EnginePowerVC without enclosed <function> tag is deprecated"
<< endl;