Exemplo n.º 1
0
        public override void OnStart(StartState state)
        {
            if (state == StartState.Editor)
                return;
            if (vessel == null)
                return;
            engine = new EngineWrapper(part);
            engine.IspMultiplier = IspMultiplier;
            engine.idle = idle;
            engine.useVelocityCurve = false;
            engine.ThrustUpperLimit = maxThrust;
            engine.useEngineResponseTime = false;

            part.maxTemp = 200f;
            engine.heatProduction = 10f;
            //v0 *= 0.5144f;
            //omega0 *= 0.1047f;
            //power0 *= 745.7f;
            //omega *= 0.1047f;
            //power *= 745.7f;

            //propeller = new AJEPropellerSolver(r0, v0 * 0.5144f, omega0 * PistonEngine.RPM2RADPS, rho0, power0 * PistonEngine.HP2W);
            pistonengine = new PistonEngine(power * PistonEngine.HP2W, maxRPM * PistonEngine.RPM2RADPS, BSFC);
            pistonengine._hasSuper = boost0 > 0;
            pistonengine.setBoostParams(wastegateMP * INHG2PA, boost0 * INHG2PA, boost1 * INHG2PA, rated0, rated1, cost1 * PistonEngine.HP2W, switchAlt, turbo);
            if (displacement > 0)
                pistonengine._displacement = displacement * PistonEngine.CIN2CM;
            pistonengine._compression = compression;
            pistonengine._coolerEffic = coolerEffic;
            pistonengine._coolerMin = coolerMin + CTOK;
            pistonengine._ramAir = ramAir;

            propJSB = new AJEPropJSB(propName, minRPM * gearratio, maxRPM * gearratio, propDiam, propIxx);

            if(propJSB.GetConstantSpeed() == 0)
                Fields["propPitch"].guiActive = false;
            if (exhaustThrust <= 0f)
                Fields["netExhaustThrust"].guiActive = false;
            if (meredithEffect <= 0f)
                Fields["netMeredithEffect"].guiActive = false;

            pistonengine.ComputeVEMultiplier(); // given newly-set stats

            omega = 30; // start slow
        }
Exemplo n.º 2
0
        public override void CreateEngine()
        {
            SetUnits();

            pistonEngine = null;

            if (maxEngineTemp == 0d)
            {
                maxEngineTemp = 3600d;
            }
            heatProduction = 10f; // HACK fixme. But we don't want to create much heat in the part.

            double powW = power * powerMultiplier;

            if (useOxygen)
            {
                pistonEngine = new PistonEngine(
                    powW,
                    maxRPM,
                    BSFC,
                    ramAir,
                    displacement * displMultiplier,
                    compression,
                    coolerEffic,
                    coolerMin + CTOK,
                    exhaustThrust,
                    meredithEffect,
                    // Super/turbo params:
                    wastegateMP * boostMultiplier, boost0 * boostMultiplier, boost1 * boostMultiplier, rated0, rated1, cost1 * powerMultiplier, switchAlt, turbo
                    );

                if (autoignitionTemp < 0f || float.IsInfinity(autoignitionTemp))
                {
                    autoignitionTemp = 560f; // Approximate for gasoline
                }
            }
            else
            {
                if (autoignitionTemp < 0f || float.IsInfinity(autoignitionTemp))
                {
                    autoignitionTemp = 0f;
                }
            }
            engineSolver = solverProp = new SolverPropeller(pistonEngine, powW, BSFC, gearratio, propName, minRPM * gearratio, maxRPM * gearratio, propDiam, propIxx);

            if (solverProp.GetConstantSpeed() == 0)
            {
                Fields["propPitch"].guiActive = false;
            }
            if (exhaustThrust <= 0f)
            {
                Fields["netExhaustThrust"].guiActive = false;
            }
            if (meredithEffect <= 0f)
            {
                Fields["netMeredithEffect"].guiActive = false;
            }

            Fields["statusL2"].guiActive = true; // always show

            useAtmCurve = atmChangeFlow = useVelCurve = useAtmCurveIsp = useVelCurveIsp = false;
        }