1
0
Fork 0

Updates to trial engine model.

This commit is contained in:
curt 2000-08-29 03:15:51 +00:00
parent 306f01c41a
commit ed9fcb74b7
5 changed files with 54 additions and 56 deletions

View file

@ -64,9 +64,7 @@ float FGEngine::Calc_Engine_RPM (float LeverPosition)
// Calculate RPM as set by Prop Lever Position. Assumes engine // Calculate RPM as set by Prop Lever Position. Assumes engine
// will run at 1000 RPM at full course // will run at 1000 RPM at full course
float RPM; float RPM = LeverPosition * (Max_RPM - Min_RPM) /100 + Min_RPM ;
RPM = LeverPosition * Max_RPM / 100.0;
// * ((FGEng_Max_RPM + FGEng_Min_RPM) / 100);
if ( RPM >= Max_RPM ) { if ( RPM >= Max_RPM ) {
RPM = Max_RPM; RPM = Max_RPM;
@ -110,7 +108,7 @@ void FGEngine::init() {
// Initialise Engine Variables used by this instance // Initialise Engine Variables used by this instance
Percentage_Power = 0; Percentage_Power = 0;
Manifold_Pressure = 29.00; // Inches Manifold_Pressure = 29.00; // Inches
RPM = 2700; RPM = 500;
Fuel_Flow = 0; // lbs/hour Fuel_Flow = 0; // lbs/hour
Torque = 0; Torque = 0;
CHT = 370; CHT = 370;
@ -132,6 +130,7 @@ void FGEngine::init() {
Alpha1 = 13.5; Alpha1 = 13.5;
FGProp1_Blade_Angle = 13.5; FGProp1_Blade_Angle = 13.5;
FGProp_Fine_Pitch_Stop = 13.5; FGProp_Fine_Pitch_Stop = 13.5;
FGProp_Course_Pitch_Stop = 55;
// Other internal values // Other internal values
Rho = 0.002378; Rho = 0.002378;
@ -176,46 +175,43 @@ static float Calc_CHT (float Fuel_Flow, float Mixture, float IAS)
// Calculate Density Ratio // Calculate Density Ratio
static float Density_Ratio ( float x ) static float Density_Ratio ( float x )
{ {
float y ; float y = ((3E-10 * x * x) - (3E-05 * x) + 0.9998);
y = ((3E-10 * x * x) - (3E-05 * x) + 0.9998); return y;
return(y);
} }
// Calculate Air Density - Rho // Calculate Air Density - Rho
static float Density ( float x ) static float Density ( float x )
{ {
float y ; float y = ((9E-08 * x * x) - (7E-08 * x) + 0.0024);
y = ((9E-08 * x * x) - (7E-08 * x) + 0.0024); return y;
return(y);
} }
// Calculate Speed in FPS given Knots CAS // Calculate Speed in FPS given Knots CAS
static float IAS_to_FPS (float x) static float IAS_to_FPS (float ias)
{ {
float y; return ias * 1.68888888;
y = x * 1.68888888;
return y;
} }
// update the engine model based on current control positions // update the engine model based on current control positions
void FGEngine::update() { void FGEngine::update() {
// Declare local variables // Declare local variables
int num = 0; int num = 0; // Not used. Counting variables
const int num2 = 1; // default is 100, number if iterations to run int num2 = 100; // Not used.
float ManXRPM = 0; float ManXRPM = 0;
float Vo = 0; float Vo = 0;
float V1 = 0; float V1 = 0;
// Set up the new variables // Set up the new variables
float Blade_Station = 30; float Blade_Station = 30;
float Rho = 0.002378;
float FGProp_Area = 1.405/3; float FGProp_Area = 1.405/3;
float PI = 3.1428571; float PI = 3.1428571;
// Input Variables // Input Variables
// float IAS = 0;
// 0 = Closed, 100 = Fully Open // 0 = Closed, 100 = Fully Open
// float Throttle_Lever_Pos = 75; // float Throttle_Lever_Pos = 75;
@ -269,48 +265,44 @@ void FGEngine::update() {
Manifold_Pressure = Manifold_Pressure =
Calc_Manifold_Pressure( Throttle_Lever_Pos, Max_Manifold_Pressure ); Calc_Manifold_Pressure( Throttle_Lever_Pos, Max_Manifold_Pressure );
// cout << "manifold pressure = " << Manifold_Pressure << endl; cout << "manifold pressure = " << Manifold_Pressure << endl;
// Calculate Manifold Pressure (Engine 2) as set by throttle opening
// FGEng2_Manifold_Pressure = Manifold_Pressure(FGEng2_Throttle_Lever_Pos, FGEng2_Manifold_Pressure);
// Show_Manifold_Pressure(FGEng2_Manifold_Pressure);
RPM = Calc_Engine_RPM(Propeller_Lever_Pos); RPM = Calc_Engine_RPM(Propeller_Lever_Pos);
// cout << "Engine RPM = " << RPM << endl; // cout << "Engine RPM = " << RPM << endl;
Desired_RPM = RPM; Desired_RPM = RPM;
cout << "Desired RPM = " << Desired_RPM << endl;
//================================================================== //==================================================================
// Engine Power & Torque Calculations // Engine Power & Torque Calculations
// Loop until stable - required for testing only // Loop until stable - required for testing only
for (num = 0; num < num2; num++) { for (num = 0; num < num2; num++) {
// cout << Manifold_Pressure << " Inches" << "\t"; // cout << endl << "====================" << endl;
// cout << RPM << " RPM" << "\t"; // cout << "MP Inches = " << Manifold_Pressure << "\t";
// cout << " RPM = " << RPM << "\t";
// For a given Manifold Pressure and RPM calculate the % Power // For a given Manifold Pressure and RPM calculate the % Power
// Multiply Manifold Pressure by RPM // Multiply Manifold Pressure by RPM
ManXRPM = Manifold_Pressure * RPM; ManXRPM = Manifold_Pressure * RPM;
// cout << ManXRPM; // cout << ManXRPM << endl;
// cout << endl;
// Calculate % Power // Calculate % Power
Percentage_Power = (+ 7E-09 * ManXRPM * ManXRPM) Percentage_Power = (+ 7E-09 * ManXRPM * ManXRPM)
+ ( + 7E-04 * ManXRPM) - 0.1218; + ( + 7E-04 * ManXRPM) - 0.1218;
// cout << Percentage_Power << "%" << "\t"; // cout << "percent power = " << Percentage_Power << "%" << "\t";
// Adjust for Temperature - Temperature above Standard decrease // Adjust for Temperature - Temperature above Standard decrease
// power % by 7/120 per degree F increase, and incease power for // power % by 7/120 per degree F increase, and incease power for
// temps below at the same ratio // temps below at the same ratio
Percentage_Power = Percentage_Power - (FG_ISA_VAR * 7 /120); Percentage_Power = Percentage_Power - (FG_ISA_VAR * 7 /120);
// cout << Percentage_Power << "%" << "\t"; // cout << " adjusted T = " << Percentage_Power << "%" << "\t";
// Adjust for Altitude. In this version a linear variation is // Adjust for Altitude. In this version a linear variation is
// used. Decrease 1% for each 1000' increase in Altitde // used. Decrease 1% for each 1000' increase in Altitde
Percentage_Power = Percentage_Power + (FG_Pressure_Ht * 12/10000); Percentage_Power = Percentage_Power + (FG_Pressure_Ht * 12/10000);
// cout << Percentage_Power << "%" << "\t"; // cout << " adjusted A = " << Percentage_Power << "%" << "\t";
// Now Calculate Fuel Flow based on % Power Best Power Mixture // Now Calculate Fuel Flow based on % Power Best Power Mixture
Fuel_Flow = Percentage_Power * Max_Fuel_Flow / 100.0; Fuel_Flow = Percentage_Power * Max_Fuel_Flow / 100.0;
@ -327,8 +319,8 @@ void FGEngine::update() {
Percentage_Power = Percentage_Power * Percentage_Power = Percentage_Power *
((100.0 - Mag_Derate_Percent)/100.0); ((100.0 - Mag_Derate_Percent)/100.0);
// cout << FGEng1_Percentage_Power << "%" << "\t";
} }
// cout << "Final engine % power = " << Percentage_Power << "%" << endl;
// Calculate Engine Horsepower // Calculate Engine Horsepower
@ -357,7 +349,7 @@ void FGEngine::update() {
//Radial Flow Vector (V2) Ft/sec at Ref Blade Station (usually 30") //Radial Flow Vector (V2) Ft/sec at Ref Blade Station (usually 30")
FGProp1_Angular_V = FGProp1_RPS * 2 * PI * (Blade_Station / 12); FGProp1_Angular_V = FGProp1_RPS * 2 * PI * (Blade_Station / 12);
// cout << FGProp1_Angular_V << "Angular Velocity " << endl; // cout << "Angular Velocity " << FGProp1_Angular_V << endl;
// Axial Flow Vector (Vo) Ft/sec // Axial Flow Vector (Vo) Ft/sec
// Some further work required here to allow for inflow at low speeds // Some further work required here to allow for inflow at low speeds
@ -370,19 +362,24 @@ void FGEngine::update() {
// Relative Velocity (V1) // Relative Velocity (V1)
V1 = sqrt((FGProp1_Angular_V * FGProp1_Angular_V) + V1 = sqrt((FGProp1_Angular_V * FGProp1_Angular_V) +
(Vo * Vo)); (Vo * Vo));
// cout << V1 << "Relative Velocity " << endl; // cout << "Relative Velocity " << V1 << endl;
if ( FGProp1_Blade_Angle >= FGProp_Course_Pitch_Stop ) {
FGProp1_Blade_Angle = FGProp_Course_Pitch_Stop;
}
// cout << FGProp1_Blade_Angle << " Prop Blade Angle" << endl; // cout << FGProp1_Blade_Angle << " Prop Blade Angle" << endl;
// Blade Angle of Attack (Alpha1) // Blade Angle of Attack (Alpha1)
cout << " Alpha1 = " << Alpha1
<< " Blade angle = " << FGProp1_Blade_Angle
<< " Vo = " << Vo
<< " FGProp1_Angular_V = " << FGProp1_Angular_V << endl;
Alpha1 = FGProp1_Blade_Angle -(atan(Vo / FGProp1_Angular_V) * (180/PI)); Alpha1 = FGProp1_Blade_Angle -(atan(Vo / FGProp1_Angular_V) * (180/PI));
// cout << Alpha1 << " Alpha1" << endl; // cout << Alpha1 << " Alpha1" << endl;
// cout << " Alpha1 = " << Alpha1
// << " Blade angle = " << FGProp1_Blade_Angle
// << " Vo = " << Vo
// << " FGProp1_Angular_V = " << FGProp1_Angular_V << endl;
// Calculate Coefficient of Drag at Alpha1 // Calculate Coefficient of Drag at Alpha1
FGProp1_Coef_Drag = (0.0005 * (Alpha1 * Alpha1)) + (0.0003 * Alpha1) FGProp1_Coef_Drag = (0.0005 * (Alpha1 * Alpha1)) + (0.0003 * Alpha1)
+ 0.0094; + 0.0094;
@ -401,21 +398,20 @@ void FGEngine::update() {
* ((FGProp1_Coef_Lift * sin(Alpha1 * PI / 180)) * ((FGProp1_Coef_Lift * sin(Alpha1 * PI / 180))
+ (FGProp1_Coef_Drag * cos(Alpha1 * PI / 180)))) + (FGProp1_Coef_Drag * cos(Alpha1 * PI / 180))))
* (Blade_Station/12); * (Blade_Station/12);
// cout << FGProp1_Torque << " Prop Torque" << endl; // cout << "Prop Torque = " << FGProp1_Torque << endl;
// Calculate Prop Thrust // Calculate Prop Thrust
// cout << " V1 = " << V1 << " Alpha1 = " << Alpha1 << endl; // cout << " V1 = " << V1 << " Alpha1 = " << Alpha1 << endl;
FGProp1_Thrust = 0.5 * Rho * (V1 * V1) * FGProp_Area FGProp1_Thrust = 0.5 * Rho * (V1 * V1) * FGProp_Area
* ((FGProp1_Coef_Lift * cos(Alpha1 * PI / 180)) * ((FGProp1_Coef_Lift * cos(Alpha1 * PI / 180))
- (FGProp1_Coef_Drag * sin(Alpha1 * PI / 180))); - (FGProp1_Coef_Drag * sin(Alpha1 * PI / 180)));
// cout << FGProp1_Thrust << " Prop Thrust " << endl; // cout << " Prop Thrust = " << FGProp1_Thrust << endl;
// End of Propeller Calculations // End of Propeller Calculations
//============================================================== //==============================================================
#if 0
Torque_Imbalance = FGProp1_Torque - Torque; Torque_Imbalance = FGProp1_Torque - Torque;
// cout << Torque_Imbalance << endl; // cout << Torque_Imbalance << endl;
@ -437,7 +433,6 @@ void FGEngine::update() {
if (RPM >= 2700) { if (RPM >= 2700) {
RPM = 2700; RPM = 2700;
} }
#endif
// cout << FGEng1_RPM << " Blade_Angle " << FGProp1_Blade_Angle << endl << endl; // cout << FGEng1_RPM << " Blade_Angle " << FGProp1_Blade_Angle << endl << endl;

View file

@ -104,6 +104,7 @@ private:
float Alpha1; float Alpha1;
float FGProp1_Blade_Angle; float FGProp1_Blade_Angle;
float FGProp_Fine_Pitch_Stop; float FGProp_Fine_Pitch_Stop;
float FGProp_Course_Pitch_Stop;
// Other internal values // Other internal values
float Rho; float Rho;

View file

@ -35,6 +35,7 @@
#include "LaRCsim.hxx" #include "LaRCsim.hxx"
#define USE_NEW_ENGINE_CODE 1
FGEngine eng; FGEngine eng;
@ -87,12 +88,12 @@ int FGLaRCsim::update( int multiloop ) {
#ifdef USE_NEW_ENGINE_CODE #ifdef USE_NEW_ENGINE_CODE
// update simple engine model // update simple engine model
eng.set_IAS( V_calibrated_kts ); eng.set_IAS( V_calibrated_kts );
eng.set_Throttle_Lever_Pos( Throttle_pct * 100.0 ); eng.set_Throttle_Lever_Pos( controls.get_throttle( 0 ) * 100.0 );
eng.set_Propeller_Lever_Pos( 95 ); eng.set_Propeller_Lever_Pos( 95 );
eng.set_Mixture_Lever_Pos( 100 ); eng.set_Mixture_Lever_Pos( 100 );
eng.update(); eng.update();
cout << " Thrust = " << eng.get_FGProp1_Thrust() << endl; cout << " Thrust = " << eng.get_FGProp1_Thrust() << endl;
F_X_engine = eng.get_FGProp1_Thrust() * 7; F_X_engine = eng.get_FGProp1_Thrust() * 1.5;
#endif #endif
double save_alt = 0.0; double save_alt = 0.0;

View file

@ -11,10 +11,12 @@ libFlight_a_SOURCES = \
LaRCsim.cxx LaRCsim.hxx \ LaRCsim.cxx LaRCsim.hxx \
MagicCarpet.cxx MagicCarpet.hxx MagicCarpet.cxx MagicCarpet.hxx
bin_PROGRAMS = engine bin_PROGRAMS = engine ps
engine_SOURCES = engine.cxx engine_SOURCES = engine.cxx
engine_LDADD = libFlight.a engine_LDADD = libFlight.a
ps_SOURCES = ps-10520c.cxx
INCLUDES += -I$(top_builddir) -I$(top_builddir)/src INCLUDES += -I$(top_builddir) -I$(top_builddir)/src

View file

@ -7,18 +7,17 @@ int main() {
e.init(); e.init();
for ( int i = 0; i < 10000; ++i ) { e.set_IAS( 80 );
e.set_IAS( 45 ); e.set_Throttle_Lever_Pos( 50.0 );
e.set_Throttle_Lever_Pos( (double)i / 100.0 ); e.set_Propeller_Lever_Pos( 100.0 );
e.set_Propeller_Lever_Pos( 100 );
e.set_Mixture_Lever_Pos( 75 ); e.set_Mixture_Lever_Pos( 75 );
e.update(); e.update();
// cout << "Rho = " << e.get_Rho(); // cout << "Rho = " << e.get_Rho();
cout << "Throttle = " << i / 100.0; cout << "Throttle = " << 100.0;
cout << " RPM = " << e.get_RPM(); cout << " RPM = " << e.get_RPM();
cout << " Thrust = " << e.get_FGProp1_Thrust() << endl; cout << " Thrust = " << e.get_FGProp1_Thrust() << endl;
}
return 0; return 0;
} }