/// <summary>
        /// Create the output of the calculation.
        /// </summary>
        /// <param name="duneLocationName">The name of the location.</param>
        /// <param name="targetReliability">The target reliability for the calculation.</param>
        /// <param name="targetProbability">The target probability for the calculation.</param>
        /// <param name="messageProvider">The object which is used to build log messages.</param>
        /// <returns>A <see cref="DuneLocationCalculationOutput"/>.</returns>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="targetProbability"/>
        /// or the calculated probability falls outside the [0.0, 1.0] range and is not <see cref="double.NaN"/>.</exception>
        private DuneLocationCalculationOutput CreateDuneLocationCalculationOutput(string duneLocationName,
                                                                                  double targetReliability,
                                                                                  double targetProbability,
                                                                                  ICalculationMessageProvider messageProvider)
        {
            double reliability = calculator.ReliabilityIndex;
            double probability = StatisticsConverter.ReliabilityToProbability(reliability);

            CalculationConvergence converged = RiskeerCommonDataCalculationService.GetCalculationConvergence(calculator.Converged);

            if (converged != CalculationConvergence.CalculatedConverged)
            {
                log.WarnFormat(messageProvider.GetCalculatedNotConvergedMessage(duneLocationName));
            }

            return(new DuneLocationCalculationOutput(converged,
                                                     new DuneLocationCalculationOutput.ConstructionProperties
            {
                WaterLevel = calculator.WaterLevel,
                WaveHeight = calculator.WaveHeight,
                WavePeriod = calculator.WavePeriod,
                TargetProbability = targetProbability,
                TargetReliability = targetReliability,
                CalculatedProbability = probability,
                CalculatedReliability = reliability
            }));
        }
Example #2
0
        public void GetCalculationConvergence_WithDifferentValues_ReturnsExpectedConvergence(bool?value, CalculationConvergence expectedConvergence)
        {
            // Call
            CalculationConvergence calculationConverged = RiskeerCommonDataCalculationService.GetCalculationConvergence(value);

            // Assert
            Assert.AreEqual(expectedConvergence, calculationConverged);
        }
        /// <summary>
        /// Creates the <see cref="WaveConditionsOutput"/> based on the provided parameters.
        /// </summary>
        /// <param name="waterLevel">The water level that was calculated for.</param>
        /// <param name="waveHeight">The calculated wave height.</param>
        /// <param name="wavePeakPeriod">The calculated wave peak period.</param>
        /// <param name="waveAngle">The calculated wave angle with respect to the dike normal.</param>
        /// <param name="waveDirection">The calculated wave direction with respect to the North.</param>
        /// <param name="targetProbability">The target probability that was calculated for.</param>
        /// <param name="calculatedReliability">The calculated reliability.</param>
        /// <param name="calculatedConvergence">The calculated convergence value.</param>
        /// <returns>The created <see cref="WaveConditionsOutput"/>.</returns>
        public static WaveConditionsOutput CreateOutput(double waterLevel, double waveHeight,
                                                        double wavePeakPeriod, double waveAngle,
                                                        double waveDirection, double targetProbability,
                                                        double calculatedReliability, bool?calculatedConvergence)
        {
            double targetReliability           = StatisticsConverter.ProbabilityToReliability(targetProbability);
            double calculatedProbability       = StatisticsConverter.ReliabilityToProbability(calculatedReliability);
            CalculationConvergence convergence = RiskeerCommonDataCalculationService.GetCalculationConvergence(calculatedConvergence);

            return(new WaveConditionsOutput(waterLevel, waveHeight, wavePeakPeriod, waveAngle, waveDirection, targetProbability,
                                            targetReliability, calculatedProbability, calculatedReliability, convergence));
        }
        /// <summary>
        /// Creates the output of an overtopping rate calculation.
        /// </summary>
        /// <param name="calculator">The calculator used for performing the calculation.</param>
        /// <param name="calculationName">The name of the calculation.</param>
        /// <param name="targetReliability">The target reliability for the calculation.</param>
        /// <param name="targetProbability">The target probability for the calculation.</param>
        /// <param name="shouldIllustrationPointsBeCalculated">Indicates whether the illustration points
        /// should be calculated for the calculation.</param>
        /// <returns>A <see cref="OvertoppingRateOutput"/>.</returns>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="targetProbability"/>
        /// or the calculated probability falls outside the [0.0, 1.0] range and is not <see cref="double.NaN"/>.</exception>
        private static OvertoppingRateOutput CreateOvertoppingRateOutput(IHydraulicLoadsCalculator calculator,
                                                                         string calculationName,
                                                                         double targetReliability,
                                                                         double targetProbability,
                                                                         bool shouldIllustrationPointsBeCalculated)
        {
            double overtoppingRate = calculator.Value;
            double reliability     = calculator.ReliabilityIndex;
            double probability     = StatisticsConverter.ReliabilityToProbability(reliability);

            CalculationConvergence converged = RiskeerCommonDataCalculationService.GetCalculationConvergence(calculator.Converged);

            if (converged != CalculationConvergence.CalculatedConverged)
            {
                log.Warn(
                    string.Format(Resources.GrassCoverErosionInwardsCalculationService_Calculation_of_type_0_for_calculation_with_name_1_not_converged,
                                  Resources.GrassCoverErosionInwardsCalculationService_OvertoppingRate,
                                  calculationName));
            }

            GeneralResult <TopLevelFaultTreeIllustrationPoint> generalResult = null;

            try
            {
                generalResult = shouldIllustrationPointsBeCalculated
                                    ? ConvertIllustrationPointsResult(calculator.IllustrationPointsResult,
                                                                      calculator.IllustrationPointsParserErrorMessage)
                                    : null;
            }
            catch (ArgumentException e)
            {
                log.Warn(string.Format(Resources.GrassCoverErosionInwardsCalculationService_CalculateOvertopping_Error_in_reading_illustrationPoints_for_CalculationName_0_overtopping_rate_with_ErrorMessage_1,
                                       calculationName,
                                       e.Message));
            }

            return(new OvertoppingRateOutput(overtoppingRate, targetProbability,
                                             targetReliability, probability, reliability,
                                             converged, generalResult));
        }