Exemplo n.º 1
0
        public void FixedUpdate()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                return;
            }
            if (engine.type == EngineWrapper.EngineType.NONE || !engine.EngineIgnited)
            {
                return;
            }
            if ((!vessel.mainBody.atmosphereContainsOxygen && useOxygen) || part.vessel.altitude > vessel.mainBody.maxAtmosphereAltitude)
            {
                engine.SetThrust(0);
                return;
            }


            Vector3d V = vessel.srf_velocity;
            Vector3d t = part.FindModelTransform(engine.thrustVectorTransformName).forward.normalized;

            vx = (float)Vector3d.Cross(V, t).magnitude;
            vz = -(float)Vector3d.Dot(V, t);



            float density = (float)ferram4.FARAeroUtil.GetCurrentDensity(part.vessel.mainBody, (float)part.vessel.altitude);

            aje.calc(density, vx, vz, weight * 9.801f);


            engine.SetThrust(aje.lift / 1000f);
            float isp = aje.lift / 9.801f / BSFC / aje.power;

            engine.SetIsp(isp);

            ShaftPower = ((int)(aje.power / 745.7f)).ToString() + "HP";

            if (sas != null)
            {
                float sasMultiplier = aje.lift / weight / 9.801f;
                if (sasMultiplier < 0)
                {
                    sasMultiplier = 0;
                }
                sas.PitchTorque = sasP * sasMultiplier;
                sas.YawTorque   = sasY * sasMultiplier;
                sas.RollTorque  = sasR * sasMultiplier;
            }
        }
Exemplo n.º 2
0
        public void FixedUpdate()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                return;
            }
            if (engine.type == EngineWrapper.EngineType.NONE || !engine.EngineIgnited)
            {
                return;
            }
            if (vessel.mainBody.atmosphereContainsOxygen == false || part.vessel.altitude > vessel.mainBody.maxAtmosphereAltitude)
            {
                engine.SetThrust(0);
                return;
            }

            #region Inlet

            float     Arearatio, OverallTPR = 0, EngineArea = 0, InletArea = 0;
            AJEModule e;
            AJEInlet  i;
            foreach (Part p in vessel.parts)
            {
                if (p.Modules.Contains("AJEModule"))
                {
                    e           = (AJEModule)p.Modules["AJEModule"];
                    EngineArea += (float)(e.aje.areaCore * (1 + e.aje.byprat));
                }
                if (p.Modules.Contains("AJEInlet"))
                {
                    i = (AJEInlet)p.Modules["AJEInlet"];
                    if (true)
                    {
                        InletArea  += i.Area;
                        OverallTPR += i.Area * i.cosine * i.cosine * i.GetTPR((float)aje.fsmach);
                    }
                }
            }
            if (InletArea > 0)
            {
                OverallTPR /= InletArea;
            }
            Arearatio  = Mathf.Min(InletArea / EngineArea, 1f);
            aje.eta[2] = Mathf.Clamp(Mathf.Sqrt(Arearatio) * OverallTPR, 0.001f, 1f);

            Inlet = "Area:" + ((int)(Arearatio * 100f)).ToString() + "%  TPR:" + ((int)(OverallTPR * 100f)).ToString() + "%";

            #endregion

            aje.FARps0 = FlightGlobals.getStaticPressure(vessel.altitude, vessel.mainBody);
            aje.FARts0 = FlightGlobals.getExternalTemperature((float)vessel.altitude, vessel.mainBody) + 273.15f;

            Environment = (((int)(aje.FARps0 * 100f)) / 100f).ToString() + "atm;" + (((int)(aje.FARts0 * 100f)) / 100f) + "K";

            if (usePrat3Curve)
            {
                aje.prat[3] = aje.p3p2d = (double)(prat3Curve.Evaluate((float)aje.fsmach));
            }
            aje.u0d         = part.vessel.srfSpeed * 3.6d;
            OverallThrottle = vessel.ctrlState.mainThrottle * engine.thrustPercentage / 100f;
            if (!useAB)
            {
                aje.comPute();
                engine.SetThrust(((float)aje.forceNetlb) * 0.004448f);
                engine.SetIsp((float)aje.isp);
                Mode = "Cruise " + System.Convert.ToString((int)(OverallThrottle * 100f)) + "%";
            }
            else
            {
                if (OverallThrottle <= ABthreshold)
                {
                    engine.useEngineResponseTime = true;
                    aje.abflag = 0;
                    aje.comPute();
                    engine.SetThrust(((float)aje.forceNetlb) * 0.004448f / ABthreshold);
                    engine.SetIsp((float)aje.isp);
                    Mode = "Cruise " + System.Convert.ToString((int)(OverallThrottle / ABthreshold * 100f)) + "%";
                }
                else
                {
                    // only allow instance response when already at max RPM; if the compressor is still spooling up, it's still spooling up.
                    if (engine.currentThrottle > ABthreshold)
                    {
                        engine.useEngineResponseTime = false;
                    }
                    else
                    {
                        engine.useEngineResponseTime = true;
                    }

                    aje.abflag = 1;
                    aje.tt7    = (OverallThrottle - ABthreshold) * (ABmax - ABmin) / (1 - ABthreshold) + ABmin;

                    aje.comPute();
                    engine.SetThrust(((float)aje.forceNetlb) * 0.004448f / OverallThrottle);
                    engine.SetIsp((float)aje.isp * ABIspMult);
                    Mode = "Afterburner " + System.Convert.ToString((int)((OverallThrottle - ABthreshold) / (1 - ABthreshold) * 100f)) + "%";
                }
            }
            Mode += " (" + (aje.forceGrosslb * 0.004448f).ToString("N2") + "kN gr)";



            if (aje.fireflag > 0.9f && useOverheat)
            {
                part.temperature = (aje.fireflag * 2f - 1.2f) * part.maxTemp;
            }

            fireflag = aje.fireflag;
            parttemp = part.temperature;
            maxtemp  = part.maxTemp;


            //           mach = (float)aje.fsmach;
        }