Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs =================================================================== diff -u -r0cdb24eee9b746ab5d21381ca51c6836dd460292 -rf5e6d6dbc89bb2059883a47a7be9ab944b4825d6 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs (.../DerivedPipingInput.cs) (revision 0cdb24eee9b746ab5d21381ca51c6836dd460292) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs (.../DerivedPipingInput.cs) (revision f5e6d6dbc89bb2059883a47a7be9ab944b4825d6) @@ -298,11 +298,23 @@ return true; } - var belowPhreaticLevelDeviation = consecutiveAquitardLayers[0].BelowPhreaticLevelDeviation; - var belowPhreaticLevelShift = consecutiveAquitardLayers[0].BelowPhreaticLevelShift; + return consecutiveAquitardLayers.All(currentLayer => AreShiftAndDeviationEqual( + currentLayer, + consecutiveAquitardLayers[0], + deviationNumberOfDecimals, + shiftNumberOfDecimals)); + } - return consecutiveAquitardLayers.All(al => AlmostEquals(belowPhreaticLevelDeviation, al.BelowPhreaticLevelDeviation, deviationNumberOfDecimals) && - AlmostEquals(belowPhreaticLevelShift, al.BelowPhreaticLevelShift, shiftNumberOfDecimals)); + private bool AreShiftAndDeviationEqual(PipingSoilLayer currentLayer, PipingSoilLayer baseLayer, int deviationNumberOfDecimals, int shiftNumberOfDecimals) + { + var belowPhreaticLevelDeviationBase = new RoundedDouble(deviationNumberOfDecimals, baseLayer.BelowPhreaticLevelDeviation); + var belowPhreaticLevelShiftBase = new RoundedDouble(shiftNumberOfDecimals, baseLayer.BelowPhreaticLevelShift); + + var belowPhreaticLevelDeviationCurrent = new RoundedDouble(deviationNumberOfDecimals, currentLayer.BelowPhreaticLevelDeviation); + var belowPhreaticLevelShiftCurrent = new RoundedDouble(shiftNumberOfDecimals, currentLayer.BelowPhreaticLevelShift); + + return belowPhreaticLevelDeviationCurrent == belowPhreaticLevelDeviationBase && + belowPhreaticLevelShiftCurrent == belowPhreaticLevelShiftBase; } private static double GetWeightedMeanForVolumicWeightOfCoverageLayer(PipingSoilLayer[] aquitardLayers, PipingSoilProfile profile, double surfaceLevel) @@ -355,11 +367,6 @@ return new PipingSoilLayer[0]; } - private bool AlmostEquals(double a, double b, int numberOfDecimals) - { - return Math.Abs(a - b) < 0.5 * Math.Pow(10.0, -numberOfDecimals); - } - private static double GetThicknessTopAquiferLayer(PipingSoilProfile soilProfile, RingtoetsPipingSurfaceLine surfaceLine, RoundedDouble exitPointL) { try Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/DerivedPipingInputTest.cs =================================================================== diff -u -r0cdb24eee9b746ab5d21381ca51c6836dd460292 -rf5e6d6dbc89bb2059883a47a7be9ab944b4825d6 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/DerivedPipingInputTest.cs (.../DerivedPipingInputTest.cs) (revision 0cdb24eee9b746ab5d21381ca51c6836dd460292) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/DerivedPipingInputTest.cs (.../DerivedPipingInputTest.cs) (revision f5e6d6dbc89bb2059883a47a7be9ab944b4825d6) @@ -801,6 +801,43 @@ } [Test] + public void SaturatedVolumicWeightOfCoverageLayer_MultipleLayersInequalStandardDeviationOrShiftButEqualWhenRounded_ReturnsWithWeightedMean() + { + // Setup + var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + var derivedInput = new DerivedPipingInput(input); + var belowPhreaticLevelMeanA = 2.5; + var belowPhreaticLevelMeanB = 3.4; + input.StochasticSoilProfile.SoilProfile = new PipingSoilProfile("", -2.0, new[] + { + new PipingSoilLayer(2.5) + { + BelowPhreaticLevelDeviation = 1.014, + BelowPhreaticLevelShift = 1.014, + BelowPhreaticLevelMean = belowPhreaticLevelMeanA + }, + new PipingSoilLayer(-0.5) + { + BelowPhreaticLevelDeviation = 1.006, + BelowPhreaticLevelShift = 1.006, + BelowPhreaticLevelMean = belowPhreaticLevelMeanB + }, + new PipingSoilLayer(-1.5) + { + IsAquifer = true + }, + }, SoilProfileType.SoilProfile1D, 0); + + // Call + var result = derivedInput.SaturatedVolumicWeightOfCoverageLayer; + + // Assert + Assert.AreEqual((belowPhreaticLevelMeanA * 2.5 + belowPhreaticLevelMeanB * 1.0) / 3.5, result.Mean, result.Mean.GetAccuracy()); + Assert.AreEqual((RoundedDouble) 1.01, result.Shift); + Assert.AreEqual((RoundedDouble)1.01, result.StandardDeviation); + } + + [Test] public void DarcyPermeability_NoSoilProfile_ReturnsNaNForParameters() { // Setup