Beispiel #1
0
        private void SetStaticSimulation()
        {
            ambientTherm = EngineThermodynamics.StandardConditions(true);

            inletTherm    = ambientTherm;
            inletTherm.P *= AJEInlet.OverallStaticTPR(defaultTPR);

            areaRatio = 1d;
            lastPropellantFraction = 1d;
        }
Beispiel #2
0
 protected void PushAreaToInlet()
 {
     if (intakeMatchArea)
     {
         AJEInlet intake = part.FindModuleImplementing <AJEInlet>();
         if (intake != null)
         {
             intake.Area = RequiredIntakeArea();
         }
     }
 }
Beispiel #3
0
        public void FitEngine(double dryThrust, double drySFC, double wetThrust, double idleNozzlePressureRatio, double defaultTPR = 1d)
        {
            float TPR = AJEInlet.OverallStaticTPR((float)defaultTPR);

            SetEngineState(true, 1d);
            SetStaticConditions(usePlanetarium: false, overallTPR: TPR);

            double dryThrottle = Afterburning ? 2d / 3d : 1d;

            this.drySFC = drySFC;
            if (drySFC > 0d)
            {
                CalculatePerformance(1d, dryThrottle, 1d, 1d);
                if (Math.Abs(SFC / drySFC - 1d) > 0.0001d)
                {
                    h_f = SolverMathUtil.BrentsMethod(DrySFCFittingFunction, 10e6, 200e6, maxIter: 1000);
                    CalculateTTR();
                }
            }

            // Min throttle
            // Set to make sure tailpipe pressure is greater than ambient

            minThrottle = 0.01f;
            CalculatePerformance(1d, 0f, 1d, 1d);

            idleNPR = idleNozzlePressureRatio;
            if (th7.P > 1.25 * th0.P)
            {
                minThrottle = 0.01f;
            }
            else
            {
                CalculatePerformance(1d, dryThrottle, 1d, 1d);
                if (th7.P < idleNPR * th0.P)
                {
                    Debug.Log("Cannot fit min throttle because jet pipe pressure is too low.  Perhaps TIT is too low or CPR is too high.");
                    minThrottle = 0.01f;
                }
                else
                {
                    minThrottle = SolverMathUtil.BrentsMethod(MinThrottleFittingFunction, 0.01f, 1f, maxIter: 1000);
                }
            }

            CalculatePerformance(1d, dryThrottle, 1d, 1d);
            double aTurbine = th4.CalculateFlowArea(coreAirflow * th4.MassRatio, 1d);
            double fakeAref = th1.CalculateFlowArea(coreAirflow, 0.5d);

            turbineAreaRatio = aTurbine / fakeAref;

            this.dryThrust = dryThrust;
            if (dryThrust > 0d)
            {
                CalculatePerformance(1d, dryThrottle, 1d, 1d);

                Aref *= dryThrust / thrust;
            }
            this.wetThrust = wetThrust;
            if (wetThrust > 0d)
            {
                bool   doFit  = true;
                double oldTt7 = Tt7;

                if (Tt7 <= 0d)
                {
                    Tt7 = 2500d;
                }
                else
                {
                    CalculatePerformance(1d, 1d, 1d, 1d);
                    if (Math.Abs(thrust / wetThrust - 1d) <= 0.0001d)
                    {
                        // TAB already correct, no need to fit
                        doFit = false;
                    }
                }

                // Check bounds
                if (doFit)
                {
                    CalculatePerformance(1d, 2d / 3d, 1d, 1d);

                    if (thrust >= wetThrust)
                    {
                        Debug.LogWarning("Cannot fit wet thrust on engine because dry thrust is already greater than specified value.");
                        doFit = false;
                    }

                    Tt7 = 4000d;
                    CalculatePerformance(1d, 1d, 1d, 1d);
                    if (thrust <= wetThrust)
                    {
                        Debug.LogWarning("Cannot fit wet thrust on engine solver because it would require an afterburner temperature of more than 4000 K.");
                        doFit = false;
                    }
                }

                if (doFit)
                {
                    Tt7 = SolverMathUtil.BrentsMethod(WetThrustFittingFunction, th5.T, 4000d, maxIter: 1000);
                }
                else
                {
                    Tt7 = oldTt7;
                }
            }
        }