Exemple #1
0
        public override void PreUpdate(double dt)
        {
            // Update sub-model atmospheric properties
            mainRotor.Density = Atmosphere.Density;
            tailRotor.Density = Atmosphere.Density;
            if (Fuselage != null)
            {
                Fuselage.mrdistance = MainRotor.Translation - Fuselage.Translation;
            }
            if (horizontalStabilizer != null)
            {
                horizontalStabilizer.Density = Atmosphere.Density;
            }
            if (verticalStabilizer != null)
            {
                verticalStabilizer.Density = Atmosphere.Density;
            }
            mainRotor.HeightAboveGround = Height - mainRotor.Translation[2];

            // Update sub-model controls
            mainRotor.Collective = FCS.Collective;
            mainRotor.LongCyclic = FCS.LongCyclic;
            mainRotor.LatCyclic  = FCS.LatCyclic;
            tailRotor.Collective = -FCS.Pedal;     // TODO make pedal-collective inversion a parameter, or figure it out

            // Update engine and drivetrain
            if (UseEngineModel)
            {
                if (Engine.phase == Engine.Phase.START && GearBox.autoBrakeRPM > 1e-5)
                {
                    GearBox.BrakeEnabled = false;
                }
                GearBox.MainRotorLoad    = MainRotor.Enabled ? MainRotor.ShaftTorque : 0;
                GearBox.TailRotorLoad    = TailRotor.Enabled ? TailRotor.ShaftTorque : 0;
                GearBox.MainRotorInertia = MainRotor.Enabled ? MainRotor.Inertia : 0;
                GearBox.TailRotorInertia = TailRotor.Enabled ? TailRotor.Inertia : 0;
                GearBox.Update(dt);
                Engine.load    = GearBox.Load;
                Engine.inertia = GearBox.Inertia;
                Engine.Update(dt);
                GearBox.RotspeedDrive = Engine.RotSpeed;
                MainRotor.RotSpeed    = MainRotor.Enabled ? GearBox.MainRotorSpeed : 0;
                TailRotor.RotSpeed    = TailRotor.Enabled ? GearBox.TailRotorSpeed : 0;
            }
        }
Exemple #2
0
        public void ModerateLoad_MaintainsRPM()
        {
            model.Init(100);
            model.load     = 800;
            model.throttle = 1.0;

            for (double t = 0.0; t < 10.0; t += 0.1)
            {
                model.Update(0.1);
            }
            Console.WriteLine("RPM " + model.RPM.ToStr() + " designRPM " + model.designRPM.ToStr());
            Assert.IsTrue(model.RPM > 0.99 * model.designRPM);
            Console.WriteLine("P " + (model.Qeng * model.Omega).ToStr() + " max " + model.maxPower);
            Assert.IsTrue(model.Qeng * model.Omega < 0.99 * model.maxPower);
        }
Exemple #3
0
        public override void PreUpdate(double dt)
        {
            // Update sub-model atmospheric properties
            foreach (var rotor in Rotors)
            {
                rotor.Density           = Atmosphere.Density;
                rotor.HeightAboveGround = Height - rotor.Translation[2];
            }

            // Update sub-model controls
            foreach (var rotor in Rotors)
            {
                rotor.Collective = FCS.Collective;
                if (rotor.Translation.x() > 0)
                {
                    rotor.Collective -= FCS.LongCyclic;
                }
                if (rotor.Translation.x() < 0)
                {
                    rotor.Collective += FCS.LongCyclic;
                }
                if (rotor.Translation.y() > 0)
                {
                    rotor.Collective -= FCS.LatCyclic;
                }
                if (rotor.Translation.y() < 0)
                {
                    rotor.Collective += FCS.LatCyclic;
                }
                if (rotor.direction == Rotor.Direction.CounterClockwise)
                {
                    rotor.Collective += FCS.Pedal;
                }
                if (rotor.direction == Rotor.Direction.Clockwise)
                {
                    rotor.Collective -= FCS.Pedal;
                }

                if (rotor.Collective > 1.0)
                {
                    rotor.Collective = 1.0;
                }
                if (rotor.Collective < -1.0)
                {
                    rotor.Collective = -1.0;
                }
            }

            // Update engine and drivetrain
            if (UseEngineModel)
            {
                if (Engine.phase == Engine.Phase.START && GearBox.autoBrakeRPM > 1e-5)
                {
                    GearBox.BrakeEnabled = false;
                }
                GearBox.MainRotorLoad    = 0;
                GearBox.MainRotorInertia = 0;
                foreach (var rotor in Rotors)
                {
                    if (!rotor.Enabled)
                    {
                        continue;
                    }
                    GearBox.MainRotorLoad    += Math.Abs(rotor.ShaftTorque);
                    GearBox.MainRotorInertia += rotor.Inertia;
                }
                GearBox.TailRotorLoad    = 0;
                GearBox.TailRotorInertia = 0;
                GearBox.Update(dt);
                Engine.load    = GearBox.Load;
                Engine.inertia = GearBox.Inertia;
                Engine.Update(dt);
                GearBox.RotspeedDrive = Engine.RotSpeed;
                foreach (var rotor in Rotors)
                {
                    rotor.RotSpeed = rotor.Enabled ? GearBox.MainRotorSpeed : 0;
                }
            }
        }