예제 #1
0
            public static void Calculate_WithAirspeedEqualToThresholdAndNoNormalForcePresent_ReturnsExpectedFlightPathAngleRate(AircraftData aircraftData)
            {
                // Setup
                const double heightThreshold = 0.01;

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

                Angle angleOfAttack = aircraftState.PitchAngle - aircraftState.FlightPathAngle;

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

                Assert.IsTrue(lift > takeOffWeightNewton);

                var calculator = new TestTakeOffDynamicsCalculator(aircraftData, airDensity, gravitationalAcceleration);

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

                // Assert
                double expectedRate = (gravitationalAcceleration * (lift - takeOffWeightNewton))
                                      / (takeOffWeightNewton * aircraftState.TrueAirspeed);

                Assert.AreEqual(expectedRate, accelerations.FlightPathRate.Radians, tolerance);
            }
예제 #2
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"));
        }
예제 #3
0
 private double CalculateLiftForce(AircraftState state)
 {
     return(AerodynamicsHelper.CalculateLift(AircraftData.AerodynamicsData,
                                             CalculateAngleOfAttack(state),
                                             Density,
                                             state.TrueAirspeed));
 }
예제 #4
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"));
        }
예제 #5
0
        public static void CalculateLift_WithValidParametersAndWithinLimits_ReturnsExpectedValues(AerodynamicsData aerodynamicsData)
        {
            // Setup
            Angle     angleOfAttack = Angle.FromDegrees(3.0);
            const int velocity      = 10; // m/s

            // Call
            double lift = AerodynamicsHelper.CalculateLift(aerodynamicsData,
                                                           angleOfAttack,
                                                           airDensity,
                                                           velocity);

            // Assert
            Assert.AreEqual(CalculateExpectedLift(aerodynamicsData, angleOfAttack, airDensity, velocity), lift);
        }
예제 #6
0
        public static void CalculateLift_AerodynamicsDataNull_ThrowsArgumentNullException()
        {
            // Setup
            var random = new Random(21);

            // Call
            TestDelegate call = () => AerodynamicsHelper.CalculateLift(null,
                                                                       new Angle(),
                                                                       random.NextDouble(),
                                                                       random.NextDouble());

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

            Assert.AreEqual("aerodynamicsData", exception.ParamName);
        }
예제 #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);
            }
예제 #8
0
            public static void Calculate_WithAircraftStateHeightSmallerThanThresholdAndLiftSmallerThanTakeOffWeight_ReturnsExpectedTrueAirspeedRate(AircraftData aircraftData)
            {
                // Setup
                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);

                double thrust = random.NextDouble() * 1000;
                double drag   = random.NextDouble() * 100;
                double frictionCoefficient = random.NextDouble();
                var    calculator          = new TestTakeOffDynamicsCalculator(aircraftData, airDensity, gravitationalAcceleration)
                {
                    Thrust   = thrust,
                    Drag     = drag,
                    RollDrag = frictionCoefficient
                };

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

                // Assert
                double horizontalWeightComponent = takeOffWeightNewton * Math.Sin(aircraftState.FlightPathAngle.Radians);
                double groundDrag           = frictionCoefficient * (aircraftData.TakeOffWeight * 1000 - lift);
                double expectedAcceleration = (gravitationalAcceleration * (thrust - drag - groundDrag - horizontalWeightComponent))
                                              / takeOffWeightNewton;

                Assert.AreEqual(expectedAcceleration, accelerations.TrueAirSpeedRate, tolerance);
            }
예제 #9
0
        public static void CalculateLift_WithInvalidAngleOfAttack_ThrowsInvalidCalculationException(AerodynamicsData aerodynamicsData,
                                                                                                    Angle invalidAngleOfAttack,
                                                                                                    string expectedExceptionMessage)
        {
            // Setup
            var random = new Random(21);

            // Call
            TestDelegate call = () => AerodynamicsHelper.CalculateLift(aerodynamicsData,
                                                                       invalidAngleOfAttack,
                                                                       airDensity,
                                                                       random.NextDouble());

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

            Assert.AreEqual(expectedExceptionMessage, exception.Message);
        }