/// <summary>
        /// Creates a <see cref="BalancedFieldLengthOutput"/> based on <see cref="AggregatedDistanceOutput"/>.
        /// </summary>
        /// <param name="outputs">The collection of <see cref="AggregatedDistanceOutput"/>
        /// to create the output for.</param>
        /// <returns>A <see cref="BalancedFieldLengthOutput"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="outputs"/> is <c>null</c>.</exception>
        /// <exception cref="KernelCalculationException">Thrown when <see cref="BalancedFieldLengthOutput"/>
        /// could not be calculated.</exception>
        public static BalancedFieldLengthOutput Create(IEnumerable <AggregatedDistanceOutput> outputs)
        {
            if (outputs == null)
            {
                throw new ArgumentNullException(nameof(outputs));
            }

            try
            {
                KernelBalancedFieldLengthOutput output = BalancedFieldLengthCalculator.CalculateBalancedFieldLength(outputs);
                return(new BalancedFieldLengthOutput(output.Velocity, output.Distance));
            }
            catch (ArgumentException e)
            {
                throw new KernelCalculationException(e.Message, e);
            }
        }
Beispiel #2
0
        public void GivenKernel_WhenCalculationsAreMadeForVelocityRange_ThenReturnsExpectedOutputsAndBalancedFieldLength(AircraftData aircraftData,
                                                                                                                         IntegrationReferenceData integrationReferenceData)
        {
            // Given
            var integrator        = new EulerIntegrator();
            var calculationKernel = new AggregatedDistanceCalculatorKernel();

            // When
            var outputs = new List <AggregatedDistanceOutput>();

            for (int i = 0; i < 90; i++)
            {
                var calculationSettings         = new CalculationSettings(i, maximumTimeSteps, timeStep);
                AggregatedDistanceOutput result = calculationKernel.Calculate(aircraftData,
                                                                              integrator,
                                                                              1,
                                                                              density,
                                                                              gravitationalAcceleration,
                                                                              calculationSettings);
                outputs.Add(result);
            }

            BalancedFieldLength balancedFieldLength = BalancedFieldLengthCalculator.CalculateBalancedFieldLength(outputs);

            // Then
            IEnumerable <ReferenceOutput> referenceOutputs = GetReferenceOutputs(integrationReferenceData.FileName);
            int expectedLength = referenceOutputs.Count();

            Assert.AreEqual(expectedLength, outputs.Count, "Number of reference data entries do not match with actual number of entries");

            int velocity = 0;

            foreach (ReferenceOutput referenceOutput in referenceOutputs)
            {
                Assert.AreEqual(referenceOutput.Velocity, outputs[velocity].FailureSpeed);
                Assert.AreEqual(referenceOutput.ContinuedTakeOffDistance, outputs[velocity].ContinuedTakeOffDistance, tolerance);
                Assert.AreEqual(referenceOutput.AbortedTakeOffDistance, outputs[velocity].AbortedTakeOffDistance, tolerance);

                velocity++;
            }

            Assert.AreEqual(integrationReferenceData.Velocity, balancedFieldLength.Velocity, tolerance);
            Assert.AreEqual(integrationReferenceData.Distance, balancedFieldLength.Distance, tolerance);
        }