Exemplo n.º 1
0
        private static IEnumerable <TestCaseData> GetNegativeVelocityTestCases()
        {
            var random = new Random(21);
            AerodynamicsData aerodynamicsData = AerodynamicsDataTestFactory.CreateAerodynamicsData();
            Angle            angleOfAttack    = random.NextAngle();
            double           liftCoefficient  = random.NextDouble();
            double           density          = random.NextDouble();
            double           invalidVelocity  = -random.NextDouble();

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateLift(aerodynamicsData,
                                                                                            angleOfAttack,
                                                                                            density,
                                                                                            invalidVelocity)))
                         .SetName("CalculateLift"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithEngineFailure(aerodynamicsData,
                                                                                                             liftCoefficient,
                                                                                                             density,
                                                                                                             invalidVelocity)))
                         .SetName("CalculateDragWithEngineFailure"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithoutEngineFailure(aerodynamicsData,
                                                                                                                liftCoefficient,
                                                                                                                density,
                                                                                                                invalidVelocity)))
                         .SetName("CalculateDragWithoutEngineFailure"));
        }
Exemplo n.º 2
0
        private static IEnumerable <TestCaseData> GetInvalidDensityTestCases()
        {
            var random = new Random(21);
            AerodynamicsData aerodynamicsData = AerodynamicsDataTestFactory.CreateAerodynamicsData();
            Angle            angleOfAttack    = random.NextAngle();
            double           liftCoefficient  = random.NextDouble();
            double           invalidDensity   = -random.NextDouble();
            double           velocity         = random.NextDouble();
            double           takeOffWeight    = random.NextDouble();

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateLift(aerodynamicsData,
                                                                                            angleOfAttack,
                                                                                            invalidDensity,
                                                                                            velocity)))
                         .SetName("CalculateLift - Negative"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateLift(aerodynamicsData,
                                                                                            angleOfAttack,
                                                                                            0,
                                                                                            velocity)))
                         .SetName("CalculateLift - Zero"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithEngineFailure(aerodynamicsData,
                                                                                                             liftCoefficient,
                                                                                                             invalidDensity,
                                                                                                             velocity)))
                         .SetName("CalculateDragWithEngineFailure - Negative"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithEngineFailure(aerodynamicsData,
                                                                                                             liftCoefficient,
                                                                                                             0,
                                                                                                             velocity)))
                         .SetName("CalculateDragWithEngineFailure - Zero"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithoutEngineFailure(aerodynamicsData,
                                                                                                                liftCoefficient,
                                                                                                                invalidDensity,
                                                                                                                velocity)))
                         .SetName("CalculateDragWithoutEngineFailure - Negative"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateDragWithoutEngineFailure(aerodynamicsData,
                                                                                                                liftCoefficient,
                                                                                                                0,
                                                                                                                velocity)))
                         .SetName("CalculateDragWithoutEngineFailure - Zero"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateStallSpeed(aerodynamicsData,
                                                                                                  takeOffWeight,
                                                                                                  invalidDensity)))
                         .SetName("CalculateStallSpeed - Negative"));

            yield return(new TestCaseData(new Action(() => AerodynamicsHelper.CalculateStallSpeed(aerodynamicsData,
                                                                                                  takeOffWeight,
                                                                                                  0)))
                         .SetName("CalculateStallSpeed - Zero"));
        }
Exemplo n.º 3
0
        protected override double CalculateAerodynamicDragForce(AircraftState state)
        {
            double liftCoefficient = AerodynamicsHelper.CalculateLiftCoefficient(AerodynamicsData,
                                                                                 CalculateAngleOfAttack(state));

            return(AerodynamicsHelper.CalculateDragWithEngineFailure(AerodynamicsData,
                                                                     liftCoefficient,
                                                                     Density,
                                                                     state.TrueAirspeed));
        }
Exemplo n.º 4
0
        public static void CalculateDragWithEngineFailure_WithValidParameters_ReturnsExpectedValues(AerodynamicsData aerodynamicsData)
        {
            // Setup
            var    random          = new Random(21);
            double liftCoefficient = random.NextDouble();
            double velocity        = random.NextDouble();

            // Call
            double drag = AerodynamicsHelper.CalculateDragWithEngineFailure(aerodynamicsData, liftCoefficient, airDensity, velocity);

            // Assert
            double expectedDrag = CalculateExpectedDrag(aerodynamicsData, liftCoefficient, airDensity, velocity, true);

            Assert.AreEqual(expectedDrag, drag, tolerance);
        }
Exemplo n.º 5
0
        public static void CalculateDragWithEngineFailure_AerodynamicsDataNull_ThrowsArgumentNullException()
        {
            // Setup
            var random = new Random(21);

            // Call
            TestDelegate call = () => AerodynamicsHelper.CalculateDragWithEngineFailure(null,
                                                                                        random.NextDouble(),
                                                                                        random.NextDouble(),
                                                                                        random.NextDouble());

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(call);

            Assert.AreEqual("aerodynamicsData", exception.ParamName);
        }
Exemplo n.º 6
0
        public static void CalculateDragWithEngineFailure_InvalidLiftCoefficient_ThrowsInvalidCalculationException(AerodynamicsData aerodynamicsData,
                                                                                                                   double invalidLiftCoefficient)
        {
            // Setup
            var random = new Random(21);

            // Call
            TestDelegate call = () => AerodynamicsHelper.CalculateDragWithEngineFailure(aerodynamicsData,
                                                                                        invalidLiftCoefficient,
                                                                                        random.NextDouble(),
                                                                                        random.NextDouble());

            // Assert
            var exception = Assert.Throws <InvalidCalculationException>(call);

            Assert.AreEqual("Lift coefficient must be in the range of [0, CLMax].", exception.Message);
        }
Exemplo n.º 7
0
            public static void Calculate_WithAircraftStateHeightSmallerThanThresholdAndLiftSmallerThanTakeOffWeight_ReturnsExpectedTrueAirspeedRate(AircraftData aircraftData)
            {
                // Setup
                const int    nrOfFailedEngines = 1;
                const double airspeed          = 10.0;
                const double threshold         = 0.01;

                var random        = new Random(21);
                var aircraftState = new AircraftState(aircraftData.MaximumPitchAngle,
                                                      random.NextAngle(),
                                                      airspeed,
                                                      threshold - random.NextDouble(),
                                                      random.NextDouble());

                Angle angleOfAttack = aircraftState.PitchAngle - aircraftState.FlightPathAngle;

                // Precondition
                double lift = AerodynamicsHelper.CalculateLift(aircraftData.AerodynamicsData,
                                                               angleOfAttack,
                                                               airDensity,
                                                               airspeed);
                double takeOffWeightNewton = aircraftData.TakeOffWeight * 1000; // N

                Assert.IsTrue(lift < takeOffWeightNewton);

                var calculator = new ContinuedTakeOffDynamicsCalculator(aircraftData, nrOfFailedEngines, airDensity, gravitationalAcceleration);

                // Call
                AircraftAccelerations accelerations = calculator.Calculate(aircraftState);

                // Assert
                double liftCoefficient = AerodynamicsHelper.CalculateLiftCoefficient(aircraftData.AerodynamicsData, angleOfAttack);
                double normalForce     = takeOffWeightNewton - lift;
                double dragForce       = AerodynamicsHelper.CalculateDragWithEngineFailure(aircraftData.AerodynamicsData,
                                                                                           liftCoefficient,
                                                                                           airDensity,
                                                                                           airspeed) + normalForce * aircraftData.RollingResistanceCoefficient;

                double thrustForce = (aircraftData.NrOfEngines - nrOfFailedEngines) * aircraftData.MaximumThrustPerEngine * 1000;
                double horizontalWeightComponent = takeOffWeightNewton * Math.Sin(aircraftState.FlightPathAngle.Radians);
                double expectedAcceleration      = (gravitationalAcceleration * (thrustForce - dragForce - horizontalWeightComponent))
                                                   / takeOffWeightNewton;

                Assert.AreEqual(expectedAcceleration, accelerations.TrueAirSpeedRate, tolerance);
            }