/// <summary> /// Sets the <see cref="WaveConditionsInputWaterLevelType"/> of the <paramref name="waveConditionsInput"/> /// based on the <see cref="NormativeProbabilityType"/>. /// </summary> /// <param name="waveConditionsInput">The <see cref="WaveConditionsInput"/> to set the water level type for.</param> /// <param name="normativeProbabilityType">The <see cref="NormativeProbabilityType"/> to set the <paramref name="waveConditionsInput"/> for.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="waveConditionsInput"/> is <c>null</c>.</exception> /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="normativeProbabilityType"/> is an invalid value.</exception> /// <exception cref="NotSupportedException">Thrown when <paramref name="normativeProbabilityType"/> is a valid value, /// but unsupported.</exception> public static void SetWaterLevelType(WaveConditionsInput waveConditionsInput, NormativeProbabilityType normativeProbabilityType) { if (waveConditionsInput == null) { throw new ArgumentNullException(nameof(waveConditionsInput)); } if (!Enum.IsDefined(typeof(NormativeProbabilityType), normativeProbabilityType)) { throw new InvalidEnumArgumentException(nameof(normativeProbabilityType), (int)normativeProbabilityType, typeof(NormativeProbabilityType)); } switch (normativeProbabilityType) { case NormativeProbabilityType.MaximumAllowableFloodingProbability: waveConditionsInput.WaterLevelType = WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability; break; case NormativeProbabilityType.SignalFloodingProbability: waveConditionsInput.WaterLevelType = WaveConditionsInputWaterLevelType.SignalFloodingProbability; break; default: throw new NotSupportedException(); } }
/// <summary> /// Gets the assessment level to use during wave conditions calculations based on the provided <paramref name="input"/>. /// </summary> /// <param name="input">The wave conditions input to get the assessment level for.</param> /// <param name="assessmentSection">The assessment section the wave conditions input belongs to.</param> /// <returns>An assessment level, or <see cref="RoundedDouble.NaN"/> when: /// <list type="bullet"> /// <item><see cref="WaveConditionsInput.WaterLevelType"/> equals <see cref="WaveConditionsInputWaterLevelType.None"/>;</item> /// <item><see cref="WaveConditionsInput.HydraulicBoundaryLocation"/> equals <c>null</c>;</item> /// <item>no assessment level is calculated door the selected <see cref="WaveConditionsInput.HydraulicBoundaryLocation"/>.</item> /// </list> /// </returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> /// <exception cref="InvalidEnumArgumentException">Thrown when <see cref="WaveConditionsInput.WaterLevelType"/> /// is an invalid value.</exception> /// <exception cref="NotSupportedException">Thrown when <see cref="WaveConditionsInput.WaterLevelType"/> /// is a valid value, but unsupported.</exception> public static RoundedDouble GetAssessmentLevel(WaveConditionsInput input, IAssessmentSection assessmentSection) { if (input == null) { throw new ArgumentNullException(nameof(input)); } if (assessmentSection == null) { throw new ArgumentNullException(nameof(assessmentSection)); } if (!Enum.IsDefined(typeof(WaveConditionsInputWaterLevelType), input.WaterLevelType)) { throw new InvalidEnumArgumentException(nameof(input.WaterLevelType), (int)input.WaterLevelType, typeof(WaveConditionsInputWaterLevelType)); } if (input.HydraulicBoundaryLocation == null) { return(RoundedDouble.NaN); } switch (input.WaterLevelType) { case WaveConditionsInputWaterLevelType.None: return(RoundedDouble.NaN); case WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability: return(GetAssessmentLevelFromHydraulicBoundaryLocationCalculations(assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability, input)); case WaveConditionsInputWaterLevelType.SignalFloodingProbability: return(GetAssessmentLevelFromHydraulicBoundaryLocationCalculations(assessmentSection.WaterLevelCalculationsForSignalFloodingProbability, input)); case WaveConditionsInputWaterLevelType.UserDefinedTargetProbability: return(GetAssessmentLevelFromHydraulicBoundaryLocationCalculations(input.CalculationsTargetProbability.HydraulicBoundaryLocationCalculations, input)); default: throw new NotSupportedException(); } }
/// <summary> /// Gets the water levels to perform a wave conditions calculation for. /// </summary> /// <param name="waveConditionsInput">The wave conditions input.</param> /// <param name="assessmentLevel">The assessment level to use.</param> /// <returns>An <see cref="IEnumerable{T}"/> containing water levels.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="waveConditionsInput"/> is <c>null</c>.</exception> public static IEnumerable <RoundedDouble> GetWaterLevels(this WaveConditionsInput waveConditionsInput, RoundedDouble assessmentLevel) { if (waveConditionsInput == null) { throw new ArgumentNullException(nameof(waveConditionsInput)); } var waterLevels = new List <RoundedDouble>(); var upperBoundary = new RoundedDouble(2, Math.Min(WaveConditionsInputHelper.GetUpperBoundaryAssessmentLevel(assessmentLevel), Math.Min(waveConditionsInput.UpperBoundaryRevetment, !double.IsNaN(waveConditionsInput.UpperBoundaryWaterLevels) ? waveConditionsInput.UpperBoundaryWaterLevels : double.MaxValue))); var lowerBoundary = new RoundedDouble(2, Math.Max(waveConditionsInput.LowerBoundaryRevetment, !double.IsNaN(waveConditionsInput.LowerBoundaryWaterLevels) ? waveConditionsInput.LowerBoundaryWaterLevels : double.MinValue)); if (double.IsNaN(upperBoundary) || double.IsNaN(lowerBoundary) || lowerBoundary >= upperBoundary) { return(waterLevels); } waterLevels.Add(upperBoundary); double stepSizeValue = waveConditionsInput.StepSize.AsValue(); var currentWaterLevel = new RoundedDouble(2, Math.Ceiling(upperBoundary / stepSizeValue) * stepSizeValue - stepSizeValue); while (currentWaterLevel > lowerBoundary) { waterLevels.Add(currentWaterLevel); currentWaterLevel = new RoundedDouble(currentWaterLevel.NumberOfDecimalPlaces, currentWaterLevel - stepSizeValue); } waterLevels.Add(lowerBoundary); return(waterLevels); }
/// <summary> /// Gets the target probability to use during wave conditions calculations based on the provided <paramref name="input"/>. /// </summary> /// <param name="input">The wave conditions input to get the target probability for.</param> /// <param name="assessmentSection">The assessment section the wave conditions input belongs to.</param> /// <returns>A target probability, or <see cref="double.NaN"/> when <see cref="WaveConditionsInput.WaterLevelType"/> /// equals <see cref="WaveConditionsInputWaterLevelType.None"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> /// <exception cref="InvalidEnumArgumentException">Thrown when <see cref="WaveConditionsInput.WaterLevelType"/> /// is an invalid value.</exception> /// <exception cref="NotSupportedException">Thrown when <see cref="WaveConditionsInput.WaterLevelType"/> /// is a valid value, but unsupported.</exception> public static double GetTargetProbability(WaveConditionsInput input, IAssessmentSection assessmentSection) { if (input == null) { throw new ArgumentNullException(nameof(input)); } if (assessmentSection == null) { throw new ArgumentNullException(nameof(assessmentSection)); } if (!Enum.IsDefined(typeof(WaveConditionsInputWaterLevelType), input.WaterLevelType)) { throw new InvalidEnumArgumentException(nameof(input.WaterLevelType), (int)input.WaterLevelType, typeof(WaveConditionsInputWaterLevelType)); } switch (input.WaterLevelType) { case WaveConditionsInputWaterLevelType.None: return(double.NaN); case WaveConditionsInputWaterLevelType.MaximumAllowableFloodingProbability: return(assessmentSection.FailureMechanismContribution.MaximumAllowableFloodingProbability); case WaveConditionsInputWaterLevelType.SignalFloodingProbability: return(assessmentSection.FailureMechanismContribution.SignalFloodingProbability); case WaveConditionsInputWaterLevelType.UserDefinedTargetProbability: return(input.CalculationsTargetProbability.TargetProbability); default: throw new NotSupportedException(); } }
private static RoundedDouble GetAssessmentLevelFromHydraulicBoundaryLocationCalculations(IEnumerable <HydraulicBoundaryLocationCalculation> calculations, WaveConditionsInput input) { return(GetRelatedHydraulicBoundaryLocationCalculation(calculations, input).Output?.Result ?? RoundedDouble.NaN); }
private static HydraulicBoundaryLocationCalculation GetRelatedHydraulicBoundaryLocationCalculation(IEnumerable <HydraulicBoundaryLocationCalculation> calculations, WaveConditionsInput input) { return(calculations.First(c => ReferenceEquals(c.HydraulicBoundaryLocation, input.HydraulicBoundaryLocation))); }