X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FIO360.cxx;h=c75b9b3f2fea84f37ca9d4ac62a46a1444b9474d;hb=ee98995d30e75cda88c9866f3cb6a761fda7d078;hp=b66e643862c8493e9d0039209ed3604bbeb50253;hpb=07f5955f8c01327a187eb86de7335b6b147d222a;p=flightgear.git diff --git a/src/FDM/IO360.cxx b/src/FDM/IO360.cxx index b66e64386..c75b9b3f2 100644 --- a/src/FDM/IO360.cxx +++ b/src/FDM/IO360.cxx @@ -82,10 +82,10 @@ void FGNewEngine::init(double dt) { n_R = 2; // Number of crank revolutions per power cycle - 2 for a 4 stroke engine. // Various bits of housekeeping describing the engines initial state. - running = fgGetBool("/engines/engine[0]/running"); + running = false; cranking = false; crank_counter = false; - fgSetBool("/engines/engine[0]/cranking", false); + starter = false; // Initialise Engine Variables used by this instance if(running) @@ -97,7 +97,7 @@ void FGNewEngine::init(double dt) { Fuel_Flow_gals_hr = 0; // Torque = 0; Torque_SI = 0; - CHT_degK = 298.0; //deg Kelvin + CHT = 298.0; //deg Kelvin CHT_degF = (CHT_degF * 1.8) - 459.67; //deg Fahrenheit Mixture = 14; Oil_Pressure = 0; // PSI @@ -133,12 +133,13 @@ void FGNewEngine::update() { // cout << "n = " << RPM << " rpm\n"; // cout << "T_amb = " << T_amb << '\n'; // cout << "running = " << running << '\n'; -// cout << "fuel = " << fgGetFloat("/consumables/fuel/tank[0]/level-gal_us") << '\n'; - cout << "Percentage_Power = " << Percentage_Power << '\n'; - cout << "current_oil_temp = " << current_oil_temp << '\n'; + cout << "fuel = " << fgGetFloat("/consumables/fuel/tank[0]/level-gal_us") << '\n'; +// cout << "Percentage_Power = " << Percentage_Power << '\n'; +// cout << "current_oil_temp = " << current_oil_temp << '\n'; + cout << "EGT = " << EGT << '\n'; } count1++; - if(count1 == 600) + if(count1 == 100) count1 = 0; */ @@ -148,7 +149,6 @@ void FGNewEngine::update() { // Check for spark bool Magneto_Left = false; bool Magneto_Right = false; - int mag_pos = fgGetInt("/engines/engine[0]/magneto"); // Magneto positions: // 0 -> off // 1 -> left only @@ -172,15 +172,10 @@ void FGNewEngine::update() { } // Need to make this better, eg position of fuel selector switch. // Check if we are turning the starter motor - bool temp = fgGetBool("/engines/engine[0]/starter"); - if(cranking != temp) { + if(cranking != starter) { // This check saves .../cranking from getting updated every loop - they only update when changed. - cranking = temp; - if(cranking) - fgSetBool("/engines/engine[0]/cranking", true); - else - fgSetBool("/engines/engine[0]/cranking", false); - crank_counter = 0; + cranking = starter; + crank_counter = 0; } // Note that although /engines/engine[0]/starter and /engines/engine[0]/cranking might appear to be duplication it is // not since the starter may be engaged with the battery voltage too low for cranking to occur (or perhaps the master @@ -206,7 +201,6 @@ void FGNewEngine::update() { if(RPM > 450) { // For now just instantaneously start but later we should maybe crank for a bit running = true; - fgSetBool("/engines/engine[0]/running", true); // RPM = 600; } } @@ -214,7 +208,6 @@ void FGNewEngine::update() { // Cut the engine // note that we only cut the power - the engine may continue to spin if the prop is in a moving airstream running = false; - fgSetBool("/engines/engine[0]/running", false); } // Now we've ascertained whether the engine is running or not we can start to do the engine calculations 'proper' @@ -260,11 +253,13 @@ void FGNewEngine::update() { } //Calculate Exhaust gas temperature - Calc_EGT(); + if(running) + Calc_EGT(); + else + EGT = 298.0; // Calculate Cylinder Head Temperature - CHT_degK = Calc_CHT(CHT_degK); - CHT_degF = (CHT_degK * 1.8) - 459.67; + Calc_CHT(); // Calculate oil temperature current_oil_temp = Calc_Oil_Temp(current_oil_temp); @@ -293,13 +288,16 @@ void FGNewEngine::update() { //Check if we have stalled the engine if (RPM == 0) { running = false; - fgSetBool("/engines/engine[0]/running", false); } else if((RPM <= 480) && (cranking)) { //Make sure the engine noise dosn't play if the engine won't start due to eg mixture lever pulled out. running = false; - fgSetBool("/engines/engine[0]/running", false); + EGT = 298.0; } } + + // And finally, do any unit conversions from internal units to output units + EGT_degF = (EGT * 1.8) - 459.67; + CHT_degF = (CHT * 1.8) - 459.67; } //***************************************************************************************************** @@ -405,7 +403,7 @@ float FGNewEngine::Power_Mixture_Correlation(float thi_actual) // Calculate Cylinder Head Temperature // Crudely models the cylinder head as an arbitary lump of arbitary size and area with one third of combustion energy // as heat input and heat output as a function of airspeed and temperature. Could be improved!!! -float FGNewEngine::Calc_CHT(float CHT) +void FGNewEngine::Calc_CHT() { float h1 = -95.0; //co-efficient for free convection float h2 = -3.95; //co-efficient for forced convection @@ -450,8 +448,6 @@ float FGNewEngine::Calc_CHT(float CHT) dCHTdt = dqdt_cylinder_head / HeatCapacityCylinderHead; CHT += (dCHTdt * time_step); - - return(CHT); } // Calculate exhaust gas temperature @@ -474,8 +470,6 @@ void FGNewEngine::Calc_EGT() //For now we will aim for a peak of around 400 degC (750 degF) EGT *= 0.444 + ((0.544 - 0.444) * Percentage_Power / 100.0); - - EGT_degF = (EGT * 1.8) - 459.67; } // Calculate Manifold Pressure based on Throttle lever Position @@ -643,10 +637,8 @@ float FGNewEngine::Calc_Oil_Press (float Oil_Temp, float Engine_RPM) void FGNewEngine::Do_Prop_Calcs() { float Gear_Ratio = 1.0; - float blade_length; // meters float forward_velocity; // m/s float prop_power_consumed_SI; // Watts - float prop_power_consumed_HP; // HP double J; // advance ratio - dimensionless double Cp_20; // coefficient of power for 20 degree blade angle double Cp_25; // coefficient of power for 25 degree blade angle @@ -678,7 +670,7 @@ void FGNewEngine::Do_Prop_Calcs() //cout << "RPM = " << RPM << '\n'; //cout << "angular_velocity_SI = " << angular_velocity_SI << '\n'; - prop_power_consumed_SI = Cp * rho_air * pow(FGProp1_RPS,3.0) * pow(prop_diameter,5.0); + prop_power_consumed_SI = Cp * rho_air * pow(FGProp1_RPS,3.0f) * pow(float(prop_diameter),5.0f); //cout << "prop HP consumed = " << prop_power_consumed_SI / 745.699 << '\n'; if(angular_velocity_SI == 0) prop_torque = 0;