コード例 #1
0
        public override void CalculatePerformance(double airRatio, double commandedThrottle, double flowMult, double ispMult)
        {
            base.CalculatePerformance(airRatio, commandedThrottle, flowMult, ispMult);

            combusting   = running;
            statusString = "Nominal";
            if (ffFraction <= 0d)
            {
                combusting   = false;
                statusString = "No fuel";
            }
            else if (underwater)
            {
                combusting   = false;
                statusString = "Underwater";
            }

            shaftPower   = 0d;
            engineThrust = 0d;
            double deltaTime = TimeWarp.fixedDeltaTime;

            if (engine == null)
            {
                if (combusting)
                {
                    fxPower    = (float)throttle;
                    shaftPower = maxPower * throttle * ispMult * flowMult;
                    fuelFlow   = shaftPower * BSFC * flowMult;
                }
                else
                {
                    fxPower = 0f;
                }
                if (shaftPower > 0d)
                {
                    double desiredTemp = t0 + 20d + throttle * 100d; // total hack
                    if (temperature > desiredTemp - 1d)
                    {
                        temperature = desiredTemp;
                    }
                    else
                    {
                        temperature += 20d * deltaTime;
                    }
                }
                else
                {
                    if (temperature < t0 + 1d)
                    {
                        temperature = t0;
                    }
                    else
                    {
                        temperature += (t0 - temperature) * 0.05d * deltaTime;
                    }
                }
            }
            else
            {
                engine.Update(this, propRPM * gearRatioRecip, deltaTime);
                shaftPower   = engine.GetShaftPower() * ispMult * flowMult;
                fuelFlow     = engine.GetFuelFlow() * flowMult;
                temperature  = engine.GetTemp();
                fxPower      = engine.GetFXPower();
                engineThrust = engine.GetEngineThrust();
                statusString = engine.GetStatus();
            }
            thrust += engineThrust;

            // now handle propeller
            if (rho > 0d)
            {
                propJSB.SetAdvance(rpmLever);
                propThrust = propJSB.Calculate(shaftPower, rho, vel, eair0, TimeWarp.fixedDeltaTime);
                propRPM    = propJSB.GetRPM();
                propPitch  = (float)propJSB.GetPitch();

                // TODO: Assign thrustRot and thrustOffset based on PFactor calcs

                double tmpRatio = propRPM * maxRPMRecip;
                if (tmpRatio > 1d)
                {
                    tmpRatio *= tmpRatio;
                }
                // engine overspeed correction (internal friction at high RPM)
                if (tmpRatio > 1.1)
                {
                    propRPM -= (tmpRatio * tmpRatio * tmpRatio) * maxRPM * deltaTime;
                }

                thrust += propThrust;
            }
            if (fuelFlow > 0d)
            {
                Isp = thrust / (fuelFlow * 9.80665d);
                SFC = 3600d / Isp;
            }
        }