Пример #1
0
        private void AnalyzeRCS()
        {
            torqueRcs.Reset();

            EachKey(rcs, p => {
                List <ModuleRCS> mlist = p.Modules.GetModules <ModuleRCS>();

                for (int m = 0; m < mlist.Count; m++)
                {
                    Vector3 pos;
                    Vector3 neg;
                    ModuleRCS rw = mlist[m];
                    rw.GetPotentialTorque(out pos, out neg);
                    torqueRcs.Add(pos);
                    torqueRcs.Add(-neg);
                }
            });
        }
Пример #2
0
        private void AnalyzeControlSurfaces()
        {
            torqueControlSurface.Reset();

            foreach (var pair in controlSurfaces)
            {
                Part p = pair.Key;

                List <ModuleControlSurface> mlist = p.Modules.GetModules <ModuleControlSurface>();

                for (int m = 0; m < mlist.Count; m++)
                {
                    Vector3 pos;
                    Vector3 neg;
                    ModuleControlSurface cs = mlist[m];
                    cs.GetPotentialTorque(out pos, out neg);
                    torqueReactionWheel.Add(pos);
                    torqueReactionWheel.Add(-neg);
                }
            }
        }
Пример #3
0
        private void AnalyzeReactionWheels()
        {
            torqueReactionWheel.Reset();

            foreach (var pair in reactionWheels)
            {
                Part p = pair.Key;

                List <ModuleReactionWheel> mlist = p.Modules.GetModules <ModuleReactionWheel>();

                for (int m = 0; m < mlist.Count; m++)
                {
                    Vector3             pos;
                    Vector3             neg;
                    ModuleReactionWheel rw = mlist[m];
                    rw.GetPotentialTorque(out pos, out neg);
                    torqueReactionWheel.Add(pos);
                    torqueReactionWheel.Add(-neg);
                }
            }
        }
Пример #4
0
        private void AnalyzeOtherTorque()
        {
            torqueOthers.Reset();

            /* this is a special list of ITorqueProvider-containing Parts that are *NOT* Engines, RW, RCS, Control Surfaces */
            foreach (var pair in otherTorque)
            {
                Part p = pair.Key;

                List <ITorqueProvider> mlist = p.Modules.GetModules <ITorqueProvider>();

                for (int m = 0; m < mlist.Count; m++)
                {
                    Vector3         pos;
                    Vector3         neg;
                    ITorqueProvider it = mlist[m];
                    it.GetPotentialTorque(out pos, out neg);
                    torqueOthers.Add(pos);
                    torqueOthers.Add(-neg);
                }
            }
        }
Пример #5
0
        private void AnalyzeEngines()
        {
            torqueGimbal.Reset();

            double thrustOverVe = 0.0;

            foreach (var pair in engines)
            {
                Part p = pair.Key;

                List <ModuleGimbal> glist = p.Modules.GetModules <ModuleGimbal>();
                for (int m = 0; m < glist.Count; m++)
                {
                    Vector3      pos;
                    Vector3      neg;
                    ModuleGimbal g = glist[m];
                    g.GetPotentialTorque(out pos, out neg);
                    torqueRcs.Add(pos);
                    torqueRcs.Add(-neg);
                }

                List <ModuleEngines> elist = p.Modules.GetModules <ModuleEngines>();

                for (int m = 0; m < elist.Count; m++)
                {
                    ModuleEngines e = elist[m];
                    if ((!e.EngineIgnited) || (!e.isEnabled) || (!e.isOperational))
                    {
                        continue;
                    }
                    float thrustLimiter = e.thrustPercentage / 100f;

                    double Isp0 = e.atmosphereCurve.Evaluate((float)atmPressure);
                    double Isp1 = e.atmosphereCurve.Evaluate((float)atmPressure1);
                    double Isp  = Math.Min(Isp0, Isp1);
                    double Ve   = Isp * e.g;

                    double maxThrust = e.maxFuelFlow * e.flowMultiplier * Ve;
                    double minThrust = e.minFuelFlow * e.flowMultiplier * Ve;

                    /* handle RealFuels engines */
                    if (e.finalThrust == 0.0f && minThrust > 0.0f)
                    {
                        minThrust = maxThrust = 0.0;
                    }

                    double eMaxThrust     = minThrust + (maxThrust - minThrust) * thrustLimiter;
                    double eMinThrust     = e.throttleLocked ? eMaxThrust : minThrust;
                    double eCurrentThrust = e.finalThrust;

                    thrustMaximum += eMaxThrust;
                    thrustMinimum += eMinThrust;
                    thrustCurrent += eCurrentThrust;

                    thrustOverVe += eMaxThrust / Ve;

                    /* FIXME: Cosine losses */
                }
            }

            totalVe = thrustMaximum / thrustOverVe;
        }