Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/GeneralStabilityPointStructuresInput.cs =================================================================== diff -u -r200b418bcf28a2daad8dae6fdf7500bb1ea26627 -ra828baefd6d87005fe1c60fed60979c9b17e45f7 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/GeneralStabilityPointStructuresInput.cs (.../GeneralStabilityPointStructuresInput.cs) (revision 200b418bcf28a2daad8dae6fdf7500bb1ea26627) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/GeneralStabilityPointStructuresInput.cs (.../GeneralStabilityPointStructuresInput.cs) (revision a828baefd6d87005fe1c60fed60979c9b17e45f7) @@ -76,6 +76,7 @@ /// /// Gets the gravitational acceleration. + /// [m/s^2] /// public RoundedDouble GravitationalAcceleration { get; private set; } @@ -107,7 +108,7 @@ #region Model Factors /// - /// Gets the model factor for storage volume. + /// Gets the model factor for the storage volume. /// public LogNormalDistribution ModelFactorStorageVolume { get; private set; } Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/Ringtoets.StabilityPointStructures.Data.csproj =================================================================== diff -u -r341ddc4bed3bbbae529c1c282d15cc9b593d1e6a -ra828baefd6d87005fe1c60fed60979c9b17e45f7 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/Ringtoets.StabilityPointStructures.Data.csproj (.../Ringtoets.StabilityPointStructures.Data.csproj) (revision 341ddc4bed3bbbae529c1c282d15cc9b593d1e6a) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/Ringtoets.StabilityPointStructures.Data.csproj (.../Ringtoets.StabilityPointStructures.Data.csproj) (revision a828baefd6d87005fe1c60fed60979c9b17e45f7) @@ -64,6 +64,11 @@ Core.Common.Base False + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Utils + False + {D4200F43-3F72-4F42-AF0A-8CED416A38EC} Ringtoets.Common.Data Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresInput.cs =================================================================== diff -u -r7a7964c2eb9844cb44c4c02a807bae60e67c4bfe -ra828baefd6d87005fe1c60fed60979c9b17e45f7 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresInput.cs (.../StabilityPointStructuresInput.cs) (revision 7a7964c2eb9844cb44c4c02a807bae60e67c4bfe) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructuresInput.cs (.../StabilityPointStructuresInput.cs) (revision a828baefd6d87005fe1c60fed60979c9b17e45f7) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Linq; using Core.Common.Base; using Core.Common.Base.Data; @@ -27,6 +28,7 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.HydraRing.Data; +using RingtoetsDataCommonProperties = Ringtoets.Common.Data.Properties.Resources; namespace Ringtoets.StabilityPointStructures.Data { @@ -35,12 +37,20 @@ /// public class StabilityPointStructuresInput : Observable, ICalculationInput { - private ForeshoreProfile foreshoreProfile; - private RoundedDouble structureNormalOrientation; - private RoundedDouble volumicWeightWater; private readonly NormalDistribution insideWaterLevelFailureConstruction; private readonly NormalDistribution insideWaterLevel; private readonly LogNormalDistribution stormDuration; + private readonly NormalDistribution modelFactorSuperCriticalFlow; + private readonly NormalDistribution drainCoefficient; + private readonly NormalDistribution levelCrestStructure; + private readonly NormalDistribution thresholdHeightOpenWeir; + private readonly LogNormalDistribution areaFlowApertures; + private readonly LogNormalDistribution constructiveStrengthLinearModel; + private readonly LogNormalDistribution constructiveStrengthQuadraticModel; + private ForeshoreProfile foreshoreProfile; + private RoundedDouble structureNormalOrientation; + private RoundedDouble volumicWeightWater; + private RoundedDouble factorStormDurationOpenStructure; /// /// Creates a new instance of . @@ -49,6 +59,7 @@ { volumicWeightWater = new RoundedDouble(2, 9.81); structureNormalOrientation = new RoundedDouble(2); + factorStormDurationOpenStructure = new RoundedDouble(2, double.NaN); insideWaterLevelFailureConstruction = new NormalDistribution(2) { @@ -68,6 +79,48 @@ }; stormDuration.SetStandardDeviationFromVariationCoefficient(0.25); + modelFactorSuperCriticalFlow = new NormalDistribution(2) + { + Mean = (RoundedDouble) 1.1, + StandardDeviation = (RoundedDouble) 0.03 + }; + + drainCoefficient = new NormalDistribution(2) + { + Mean = (RoundedDouble) 1.0, + StandardDeviation = (RoundedDouble) 0.2 + }; + + levelCrestStructure = new NormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + StandardDeviation = (RoundedDouble) 0.05 + }; + + thresholdHeightOpenWeir = new NormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + StandardDeviation = (RoundedDouble) 0.1 + }; + + areaFlowApertures = new LogNormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN, + StandardDeviation = (RoundedDouble) 0.01 + }; + + constructiveStrengthLinearModel = new LogNormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN + }; + constructiveStrengthLinearModel.SetStandardDeviationFromVariationCoefficient(0.1); + + constructiveStrengthQuadraticModel = new LogNormalDistribution(2) + { + Mean = (RoundedDouble) double.NaN + }; + constructiveStrengthQuadraticModel.SetStandardDeviationFromVariationCoefficient(0.1); + UpdateForeshoreProperties(); } @@ -225,19 +278,62 @@ #region Model Inputs + /// + /// Gets or sets the model factor for super critical flow. + /// + /// Only sets the mean. + public NormalDistribution ModelFactorSuperCriticalFlow + { + get + { + return modelFactorSuperCriticalFlow; + } + set + { + modelFactorSuperCriticalFlow.Mean = value.Mean; + } + } + + /// + /// Gets or sets the factor for the storm duration open structure. + /// + public RoundedDouble FactorStormDurationOpenStructure + { + get + { + return factorStormDurationOpenStructure; + } + set + { + factorStormDurationOpenStructure = value.ToPrecision(factorStormDurationOpenStructure.NumberOfDecimalPlaces); + } + } + + /// + /// Gets or sets the drain coefficient. + /// + /// Only sets the mean. + public NormalDistribution DrainCoefficient + { + get + { + return drainCoefficient; + } + set + { + drainCoefficient.Mean = value.Mean; + } + } + #endregion #region Schematization - #region Orientation - /// /// Gets or sets the orientation of the normal of the structure. + /// [degrees] /// - /// - /// When the value is smaller than 0, it will be set to 0. - /// When the value is larger than 360, it will be set to 360. - /// + /// Thrown when the value of the orientation is not between [0, 360] degrees. public RoundedDouble StructureNormalOrientation { get @@ -246,32 +342,106 @@ } set { - RoundedDouble newOrientationValue = value.ToPrecision(structureNormalOrientation.NumberOfDecimalPlaces); - newOrientationValue = ValidateStructureNormalOrientationInRange(newOrientationValue); + if (double.IsNaN(value)) + { + structureNormalOrientation = new RoundedDouble(2, double.NaN); + return; + } - structureNormalOrientation = newOrientationValue; + RoundedDouble newOrientation = value.ToPrecision(structureNormalOrientation.NumberOfDecimalPlaces); + if (newOrientation < 0 || newOrientation > 360) + { + throw new ArgumentOutOfRangeException("value", RingtoetsDataCommonProperties.Orientation_Value_needs_to_be_between_0_and_360); + } + structureNormalOrientation = newOrientation; } } - private RoundedDouble ValidateStructureNormalOrientationInRange(RoundedDouble newOrientationValue) + /// + /// Gets or sets the level crest of the structure. + /// [m+NAP] + /// + public NormalDistribution LevelCrestStructure { - const double upperBoundaryRange = 360; - const double lowerBoundaryRange = 0.0; + get + { + return levelCrestStructure; + } + set + { + levelCrestStructure.Mean = value.Mean; + levelCrestStructure.StandardDeviation = value.StandardDeviation; + } + } - if (newOrientationValue > upperBoundaryRange) + /// + /// Gets or sets the threshold height of the open weir. + /// [m+MAP] + /// + public NormalDistribution ThresholdHeightOpenWeir + { + get { - newOrientationValue = new RoundedDouble(2, upperBoundaryRange); + return thresholdHeightOpenWeir; } - else if (newOrientationValue < lowerBoundaryRange) + set { - newOrientationValue = new RoundedDouble(2, lowerBoundaryRange); + thresholdHeightOpenWeir.Mean = value.Mean; + thresholdHeightOpenWeir.StandardDeviation = value.StandardDeviation; } + } - return newOrientationValue; + /// + /// Gets or sets the area flow apertures + /// [m^2] + /// + public LogNormalDistribution AreaFlowApertures + { + get + { + return areaFlowApertures; + } + set + { + areaFlowApertures.Mean = value.Mean; + areaFlowApertures.StandardDeviation = value.StandardDeviation; + } } - #endregion + /// + /// Gets or sets the constructive strength of the linear load model. + /// [kN/m^2] + /// + public LogNormalDistribution ConstructiveStrengthLinearLoadModel + { + get + { + return constructiveStrengthLinearModel; + } + set + { + constructiveStrengthLinearModel.Mean = value.Mean; + constructiveStrengthLinearModel.StandardDeviation = value.StandardDeviation; + } + } + /// + /// Gets or sets the constructive strength of the quadratic load model. + /// [kN/m] + /// + public LogNormalDistribution ConstructiveStrengthQuadraticLoadModel + { + get + { + return constructiveStrengthQuadraticModel; + } + set + { + constructiveStrengthQuadraticModel.Mean = value.Mean; + constructiveStrengthQuadraticModel.StandardDeviation = value.StandardDeviation; + } + } + #endregion } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructuresInputTest.cs =================================================================== diff -u -r7a7964c2eb9844cb44c4c02a807bae60e67c4bfe -ra828baefd6d87005fe1c60fed60979c9b17e45f7 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructuresInputTest.cs (.../StabilityPointStructuresInputTest.cs) (revision 7a7964c2eb9844cb44c4c02a807bae60e67c4bfe) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructuresInputTest.cs (.../StabilityPointStructuresInputTest.cs) (revision a828baefd6d87005fe1c60fed60979c9b17e45f7) @@ -24,6 +24,7 @@ using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; @@ -52,22 +53,42 @@ Assert.IsNull(input.ForeshoreProfile); Assert.IsFalse(input.UseBreakWater); Assert.AreEqual(BreakWaterType.Dam, input.BreakWater.Type); - Assert.AreEqual(new RoundedDouble(2), input.BreakWater.Height); + AssertEqualValue(0, input.BreakWater.Height); + Assert.AreEqual(2, input.BreakWater.Height.NumberOfDecimalPlaces); Assert.IsFalse(input.UseForeshore); CollectionAssert.IsEmpty(input.ForeshoreGeometry); Assert.AreEqual(2, input.VolumicWeightWater.NumberOfDecimalPlaces); - AssertEqualValues(9.81, input.VolumicWeightWater); + AssertEqualValue(9.81, input.VolumicWeightWater); + Assert.IsNaN(input.FactorStormDurationOpenStructure); - Assert.IsInstanceOf(input.InsideWaterLevelFailureConstruction); - AssertEqualValues(0.1, input.InsideWaterLevelFailureConstruction.StandardDeviation); + Assert.IsNaN(input.InsideWaterLevelFailureConstruction.Mean); + AssertEqualValue(0.1, input.InsideWaterLevelFailureConstruction.StandardDeviation); - Assert.IsInstanceOf(input.InsideWaterLevel); - AssertEqualValues(0.1, input.InsideWaterLevel.StandardDeviation); + Assert.IsNaN(input.InsideWaterLevel.Mean); + AssertEqualValue(0.1, input.InsideWaterLevel.StandardDeviation); - Assert.IsInstanceOf(input.StormDuration); - AssertEqualValues(6.0, input.StormDuration.Mean); - AssertEqualValues(0.25, input.StormDuration.GetVariationCoefficient()); + AssertEqualValue(6.0, input.StormDuration.Mean); + AssertEqualValue(0.25, input.StormDuration.GetVariationCoefficient()); + + AssertEqualValue(1.1, input.ModelFactorSuperCriticalFlow.Mean); + AssertEqualValue(0.03, input.ModelFactorSuperCriticalFlow.StandardDeviation); + + AssertEqualValue(1, input.DrainCoefficient.Mean); + AssertEqualValue(0.2, input.DrainCoefficient.StandardDeviation); + + Assert.IsNaN(input.LevelCrestStructure.Mean); + AssertEqualValue(0.05, input.LevelCrestStructure.StandardDeviation); + + Assert.IsNaN(input.ThresholdHeightOpenWeir.Mean); + AssertEqualValue(0.1, input.ThresholdHeightOpenWeir.StandardDeviation); + + Assert.IsNaN(input.AreaFlowApertures.Mean); + AssertEqualValue(0.01, input.AreaFlowApertures.StandardDeviation); + + Assert.IsNaN(input.ConstructiveStrengthLinearLoadModel.Mean); + + Assert.IsNaN(input.ConstructiveStrengthQuadraticLoadModel.Mean); } #region Hydraulic loads and data @@ -201,7 +222,7 @@ // Assert Assert.AreEqual(2, input.VolumicWeightWater.NumberOfDecimalPlaces); - AssertEqualValues(volumicWeightWater, input.VolumicWeightWater); + AssertEqualValue(volumicWeightWater, input.VolumicWeightWater); } [Test] @@ -248,18 +269,74 @@ //Assert Assert.AreEqual(stormDuration.Mean, input.StormDuration.Mean); - AssertEqualValues(initialStd, input.StormDuration.StandardDeviation); + AssertEqualValue(initialStd, input.StormDuration.StandardDeviation); } #endregion + #region Model inputs + + [Test] + public void Properties_ModelFactorSuperCriticalFlow_ExpectedValues() + { + // Setup + var input = new StabilityPointStructuresInput(); + NormalDistribution modelFactorSuperCriticalFlow = GenerateNormalDistribution(); + + RoundedDouble initialStd = input.ModelFactorSuperCriticalFlow.StandardDeviation; + + //Call + input.ModelFactorSuperCriticalFlow = modelFactorSuperCriticalFlow; + + //Assert + Assert.AreEqual(modelFactorSuperCriticalFlow.Mean, input.ModelFactorSuperCriticalFlow.Mean); + Assert.AreEqual(initialStd, input.ModelFactorSuperCriticalFlow.StandardDeviation); + } + + [Test] + public void Properties_FactorStormDurationOpenStructure_ExpectedValues() + { + // Setup + var input = new StabilityPointStructuresInput(); + var random = new Random(22); + + var factorStormDuration = new RoundedDouble(5, random.NextDouble()); + + // Call + input.FactorStormDurationOpenStructure = factorStormDuration; + + // Assert + Assert.AreEqual(2, input.FactorStormDurationOpenStructure.NumberOfDecimalPlaces); + AssertEqualValue(factorStormDuration, input.FactorStormDurationOpenStructure); + } + + [Test] + public void Properties_DrainCoefficient_ExpectedValues() + { + // Setup + var input = new StabilityPointStructuresInput(); + NormalDistribution drainCoefficient = GenerateNormalDistribution(); + + RoundedDouble initialStd = input.DrainCoefficient.StandardDeviation; + + //Call + input.DrainCoefficient = drainCoefficient; + + //Assert + Assert.AreEqual(drainCoefficient.Mean, input.DrainCoefficient.Mean); + AssertEqualValue(initialStd, input.DrainCoefficient.StandardDeviation); + } + + #endregion + #region Schematization [Test] [TestCase(360.004)] [TestCase(300)] [TestCase(0)] [TestCase(-0.004)] + [TestCase(double.NaN)] public void Properties_StructureNormalOrientationValidValues_NewValueSet(double orientation) { // Setup @@ -270,32 +347,108 @@ // Assert Assert.AreEqual(2, input.StructureNormalOrientation.NumberOfDecimalPlaces); - AssertEqualValues(orientation, input.StructureNormalOrientation); + AssertEqualValue(orientation, input.StructureNormalOrientation); } [Test] - [TestCase(400, 360)] - [TestCase(360.05, 360)] - [TestCase(-0.005, 0)] - [TestCase(-23, 0)] - public void Properties_StructureNormalOrientationInValidValues_ValueRoundedToValidValue(double invalidValue, double validValue) + [TestCase(400)] + [TestCase(360.05)] + [TestCase(-0.005)] + [TestCase(-23)] + [TestCase(double.NegativeInfinity)] + [TestCase(double.PositiveInfinity)] + public void Properties_StructureNormalOrientationInValidValues_ThrowArgumentOutOfRangeException(double invalidValue) { // Setup var input = new StabilityPointStructuresInput(); // Call - input.StructureNormalOrientation = (RoundedDouble) invalidValue; + TestDelegate call = () => input.StructureNormalOrientation = (RoundedDouble) invalidValue; // Assert - Assert.AreEqual(2, input.StructureNormalOrientation.NumberOfDecimalPlaces); - AssertEqualValues(validValue, input.StructureNormalOrientation); + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "De waarde voor de oriƫntatie moet in het bereik tussen [0, 360] graden liggen."); } + [Test] + public void Properties_LevelCrestStructure_ExpectedValues() + { + // Setup + var input = new StabilityPointStructuresInput(); + NormalDistribution levelCrestStructure = GenerateNormalDistribution(); + + // Call + input.LevelCrestStructure = levelCrestStructure; + + // Assert + AssertEqualValue(levelCrestStructure.Mean, input.LevelCrestStructure.Mean); + AssertEqualValue(levelCrestStructure.StandardDeviation, input.LevelCrestStructure.StandardDeviation); + } + + [Test] + public void Properties_ThresholdHeightOpenWeir_ExpectedValues() + { + // Setup + var input = new StabilityPointStructuresInput(); + NormalDistribution thresholdHeightOpenWeir = GenerateNormalDistribution(); + + // Call + input.ThresholdHeightOpenWeir = thresholdHeightOpenWeir; + + // Assert + AssertEqualValue(thresholdHeightOpenWeir.Mean, input.ThresholdHeightOpenWeir.Mean); + AssertEqualValue(thresholdHeightOpenWeir.StandardDeviation, input.ThresholdHeightOpenWeir.StandardDeviation); + } + + [Test] + public void Properties_AreaFlowApertures_ExpectedValues() + { + // Setup + var input = new StabilityPointStructuresInput(); + LogNormalDistribution areaFlowApertures = GenerateLogNormalDistribution(); + + // Call + input.AreaFlowApertures = areaFlowApertures; + + // Assert + AssertEqualValue(areaFlowApertures.Mean, input.AreaFlowApertures.Mean); + AssertEqualValue(areaFlowApertures.StandardDeviation, input.AreaFlowApertures.StandardDeviation); + } + + [Test] + public void Properties_ConstructiveStrengthLinearLoadModel_ExpectedValues() + { + // Setup + var input = new StabilityPointStructuresInput(); + LogNormalDistribution constructiveStrengthLinearLoadModel = GenerateLogNormalDistribution(); + + // Call + input.ConstructiveStrengthLinearLoadModel = constructiveStrengthLinearLoadModel; + + // Assert + AssertEqualValue(constructiveStrengthLinearLoadModel.Mean, input.ConstructiveStrengthLinearLoadModel.Mean); + AssertEqualValue(constructiveStrengthLinearLoadModel.StandardDeviation, input.ConstructiveStrengthLinearLoadModel.StandardDeviation); + } + + [Test] + public void Properties_ConstructiveStrengthQuadraticLoadModel_ExpectectedValues() + { + // Setup + var input = new StabilityPointStructuresInput(); + LogNormalDistribution constructiveStrengthQuadraticLoadModel = GenerateLogNormalDistribution(); + + // Call + input.ConstructiveStrengthQuadraticLoadModel = constructiveStrengthQuadraticLoadModel; + + // Assert + AssertEqualValue(constructiveStrengthQuadraticLoadModel.Mean, input.ConstructiveStrengthQuadraticLoadModel.Mean); + AssertEqualValue(constructiveStrengthQuadraticLoadModel.StandardDeviation, input.ConstructiveStrengthQuadraticLoadModel.StandardDeviation); + } #endregion #region Helpers - private void AssertEqualValues(double expectedValue, RoundedDouble actualValue) + private void AssertEqualValue(double expectedValue, RoundedDouble actualValue) { Assert.AreEqual(expectedValue, actualValue, actualValue.GetAccuracy()); }