public void Pop_Always_ExpectedValues()
        {
            // Setup
            var random = new Random(21);
            var data   = new MacroStabilityInwardsSoilLayerData();

            var distributionToSet = new VariationCoefficientLogNormalDistribution
            {
                Mean = random.NextRoundedDouble(),
                CoefficientOfVariation = random.NextRoundedDouble(),
                Shift = random.NextRoundedDouble()
            };

            // Call
            data.Pop = distributionToSet;

            // Assert
            var expectedDistribution = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = distributionToSet.Mean,
                CoefficientOfVariation = distributionToSet.CoefficientOfVariation,
                Shift = data.Pop.Shift
            };

            DistributionTestHelper.AssertDistributionCorrectlySet(data.Pop, distributionToSet, expectedDistribution);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Asserts whether <paramref name="actual"/> corresponds to <paramref name="original"/>.
        /// </summary>
        /// <param name="original">The original <see cref="MacroStabilityInwardsSoilLayer2D"/> array.</param>
        /// <param name="actual">The actual <see cref="SoilLayer"/> array.</param>
        /// <exception cref="AssertionException">Thrown when <paramref name="original"/>
        /// does not correspond to <paramref name="original"/>.</exception>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="original"/>
        /// contains an item with an invalid value of the enum <see cref="MacroStabilityInwardsShearStrengthModel"/>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="original"/>
        /// contains an item with an unsupported value of <see cref="MacroStabilityInwardsShearStrengthModel"/>.</exception>
        private static void AssertLayers(MacroStabilityInwardsSoilLayer2D[] original, SoilLayer[] actual)
        {
            Assert.AreEqual(original.Length, actual.Length);

            for (var i = 0; i < original.Length; i++)
            {
                CollectionAssert.AreEqual(original[i].OuterRing.Points, actual[i].OuterRing);

                AssertLayers(original[i].NestedLayers.ToArray(), actual[i].NestedLayers.ToArray());

                MacroStabilityInwardsSoilLayerData expectedData = original[i].Data;
                Assert.AreEqual(expectedData.MaterialName, actual[i].MaterialName);
                Assert.AreEqual(expectedData.UsePop, actual[i].UsePop);
                Assert.AreEqual(expectedData.IsAquifer, actual[i].IsAquifer);
                Assert.AreEqual(0.0, actual[i].Dilatancy);
                Assert.AreEqual(WaterPressureInterpolationModel.Automatic, actual[i].WaterPressureInterpolationModel);
                Assert.AreEqual(ConvertShearStrengthModel(expectedData.ShearStrengthModel), actual[i].ShearStrengthModel);

                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(expectedData).GetDesignValue(), actual[i].AbovePhreaticLevel);
                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(expectedData).GetDesignValue(), actual[i].BelowPhreaticLevel);
                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(expectedData).GetDesignValue(), actual[i].Cohesion);
                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(expectedData).GetDesignValue(), actual[i].FrictionAngle);
                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(expectedData).GetDesignValue(), actual[i].StrengthIncreaseExponent);
                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(expectedData).GetDesignValue(), actual[i].ShearStrengthRatio);
                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(expectedData).GetDesignValue(), actual[i].Pop);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts <see cref="MacroStabilityInwardsSoilLayer2D"/> objects into <see cref="SoilLayer"/> objects.
        /// </summary>
        /// <param name="layers">The layers to convert.</param>
        /// <returns>The converted <see cref="SoilLayer"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when
        /// <see cref="MacroStabilityInwardsSoilLayerData.ShearStrengthModel"/>
        /// is an invalid value.</exception>
        /// <exception cref="NotSupportedException">Thrown when
        /// <see cref="MacroStabilityInwardsSoilLayerData.ShearStrengthModel"/>
        /// is a valid value, but unsupported.</exception>
        private static IEnumerable <SoilLayer> ConvertLayers(IEnumerable <MacroStabilityInwardsSoilLayer2D> layers)
        {
            return(layers.Select(l =>
            {
                MacroStabilityInwardsSoilLayerData data = l.Data;

                return new SoilLayer(RingToPoints(l.OuterRing),
                                     new SoilLayer.ConstructionProperties
                {
                    MaterialName = SoilLayerDataHelper.GetValidName(data.MaterialName),
                    UsePop = data.UsePop,
                    IsAquifer = data.IsAquifer,
                    ShearStrengthModel = ConvertShearStrengthModel(data.ShearStrengthModel),
                    AbovePhreaticLevel = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(data).GetDesignValue(),
                    BelowPhreaticLevel = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(data).GetDesignValue(),
                    Cohesion = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(data).GetDesignValue(),
                    FrictionAngle = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(data).GetDesignValue(),
                    ShearStrengthRatio = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(data).GetDesignValue(),
                    StrengthIncreaseExponent = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(data).GetDesignValue(),
                    Pop = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(data).GetDesignValue(),
                    Dilatancy = 0.0,
                    WaterPressureInterpolationModel = WaterPressureInterpolationModel.Automatic
                },
                                     ConvertLayers(l.NestedLayers));
            }).ToArray());
        }
        public void DefaultConstructor_DefaultValuesSet()
        {
            // Call
            var data = new MacroStabilityInwardsSoilLayerData();

            // Assert
            Assert.IsFalse(data.IsAquifer);
            Assert.IsEmpty(data.MaterialName);
            Assert.AreEqual(Color.Empty, data.Color);

            Assert.IsFalse(data.UsePop);
            Assert.AreEqual(MacroStabilityInwardsShearStrengthModel.CPhi, data.ShearStrengthModel);

            DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN,
                Shift = RoundedDouble.NaN
            }, data.AbovePhreaticLevel);

            DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN,
                Shift = RoundedDouble.NaN
            }, data.BelowPhreaticLevel);

            DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            }, data.Cohesion);

            DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            }, data.FrictionAngle);

            DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            }, data.ShearStrengthRatio);

            DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            }, data.StrengthIncreaseExponent);

            DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            }, data.Pop);
        }
Ejemplo n.º 5
0
 private static PersistableStress CreatePOPStress(MacroStabilityInwardsSoilLayerData layerData)
 {
     return(new PersistableStress
     {
         Pop = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(layerData).GetDesignValue(),
         PopStochasticParameter = PersistableStochasticParameterFactory.Create(layerData.Pop),
         StateType = PersistableStateType.Pop
     });
 }
        /// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsSoilLayer1D"/>.
        /// </summary>
        /// <param name="top">The top level of the soil layer.</param>
        /// <param name="data">The data of the soil layer.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="data"/> is <c>null</c>.</exception>
        public MacroStabilityInwardsSoilLayer1D(double top, MacroStabilityInwardsSoilLayerData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            Top  = top;
            Data = data;
        }
        public void MaterialName_NotNullValue_ValueSet(string materialName)
        {
            // Setup
            var data = new MacroStabilityInwardsSoilLayerData();

            // Call
            data.MaterialName = materialName;

            // Assert
            Assert.AreEqual(materialName, data.MaterialName);
        }
Ejemplo n.º 8
0
        public void SetData_WithData_ExpectedValuesInTable()
        {
            // Setup
            using (var table = new MacroStabilityInwardsSoilLayerDataTable())
            {
                MacroStabilityInwardsSoilLayerData[] layers =
                {
                    CreateMacroStabilityInwardsSoilLayerData(),
                    CreateMacroStabilityInwardsSoilLayerData(),
                    CreateMacroStabilityInwardsSoilLayerData()
                };
                table.SetData(new[]
                {
                    new MacroStabilityInwardsSoilLayerData()
                });

                // Call
                table.SetData(layers);

                // Assert
                Assert.AreEqual(layers.Length, table.Rows.Count);
                for (var i = 0; i < table.Rows.Count; i++)
                {
                    MacroStabilityInwardsSoilLayerData soilLayerData = layers[i];
                    DataGridViewCellCollection         rowCells      = table.Rows[i].Cells;
                    Assert.AreEqual(soilLayerData.MaterialName,
                                    rowCells[nameColumnIndex].Value);
                    Assert.AreEqual(soilLayerData.Color,
                                    rowCells[colorColumnIndex].Value);
                    Assert.AreEqual(soilLayerData.IsAquifer,
                                    rowCells[isAquiferColumnIndex].Value);
                    AssertShiftedDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(soilLayerData),
                                                                rowCells[abovePhreaticLevelColumnIndex].Value);
                    AssertShiftedDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(soilLayerData),
                                                                rowCells[belowPhreaticLevelColumnIndex].Value);
                    Assert.AreEqual(soilLayerData.ShearStrengthModel,
                                    rowCells[shearStrengthModelColumnIndex].Value);
                    AssertDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(soilLayerData),
                                                         rowCells[cohesionColumnIndex].Value);
                    AssertDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(soilLayerData),
                                                         rowCells[frictionAngleColumnIndex].Value);
                    AssertDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(soilLayerData),
                                                         rowCells[shrearStrengthRatioColumnIndex].Value);
                    AssertDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(soilLayerData),
                                                         rowCells[strengthIncreaseExponentColumnIndex].Value);
                    Assert.AreEqual(soilLayerData.UsePop,
                                    rowCells[usePopColumnIndex].Value);
                    AssertDesignVariableColumnValueEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(soilLayerData),
                                                         rowCells[popColumnIndex].Value);
                }
            }
        }
Ejemplo n.º 9
0
        private static void AssertMacroStabilityInwardsSoilLayer2D(MacroStabilityInwardsSoilLayerTwoDEntity entity,
                                                                   MacroStabilityInwardsSoilLayer2D layer)
        {
            Assert.IsNotNull(layer);
            MacroStabilityInwardsSoilLayerData data = layer.Data;

            Assert.AreEqual(Convert.ToBoolean(entity.IsAquifer), data.IsAquifer);
            Assert.AreEqual(entity.Color, data.Color.ToInt64());
            Assert.AreEqual(entity.MaterialName, data.MaterialName);

            Assert.AreEqual(entity.AbovePhreaticLevelMean ?? double.NaN, data.AbovePhreaticLevel.Mean,
                            data.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(entity.AbovePhreaticLevelCoefficientOfVariation ?? double.NaN, data.AbovePhreaticLevel.CoefficientOfVariation,
                            data.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(entity.AbovePhreaticLevelShift ?? double.NaN, data.AbovePhreaticLevel.Shift,
                            data.AbovePhreaticLevel.GetAccuracy());

            Assert.AreEqual(entity.BelowPhreaticLevelMean ?? double.NaN, data.BelowPhreaticLevel.Mean,
                            data.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(entity.BelowPhreaticLevelCoefficientOfVariation ?? double.NaN, data.BelowPhreaticLevel.CoefficientOfVariation,
                            data.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(entity.BelowPhreaticLevelShift ?? double.NaN, data.BelowPhreaticLevel.Shift,
                            data.BelowPhreaticLevel.GetAccuracy());

            Assert.AreEqual(entity.CohesionMean ?? double.NaN, data.Cohesion.Mean,
                            data.Cohesion.GetAccuracy());
            Assert.AreEqual(entity.CohesionCoefficientOfVariation ?? double.NaN, data.Cohesion.CoefficientOfVariation,
                            data.Cohesion.GetAccuracy());

            Assert.AreEqual(entity.FrictionAngleMean ?? double.NaN, data.FrictionAngle.Mean,
                            data.FrictionAngle.GetAccuracy());
            Assert.AreEqual(entity.FrictionAngleCoefficientOfVariation ?? double.NaN, data.FrictionAngle.CoefficientOfVariation,
                            data.FrictionAngle.GetAccuracy());

            Assert.AreEqual(entity.ShearStrengthRatioMean ?? double.NaN, data.ShearStrengthRatio.Mean,
                            data.ShearStrengthRatio.GetAccuracy());
            Assert.AreEqual(entity.ShearStrengthRatioCoefficientOfVariation ?? double.NaN, data.ShearStrengthRatio.CoefficientOfVariation,
                            data.ShearStrengthRatio.GetAccuracy());

            Assert.AreEqual(entity.StrengthIncreaseExponentMean ?? double.NaN, data.StrengthIncreaseExponent.Mean,
                            data.StrengthIncreaseExponent.GetAccuracy());
            Assert.AreEqual(entity.StrengthIncreaseExponentCoefficientOfVariation ?? double.NaN, data.StrengthIncreaseExponent.CoefficientOfVariation,
                            data.StrengthIncreaseExponent.GetAccuracy());

            Assert.AreEqual(entity.PopMean ?? double.NaN, data.Pop.Mean, data.Pop.GetAccuracy());
            Assert.AreEqual(entity.PopCoefficientOfVariation ?? double.NaN, data.Pop.CoefficientOfVariation,
                            data.Pop.GetAccuracy());

            CollectionAssert.AreEqual(new Point2DCollectionXmlSerializer().FromXml(entity.OuterRingXml),
                                      layer.OuterRing.Points);
            CollectionAssert.IsEmpty(layer.NestedLayers);
        }
        public void MaterialName_Null_ThrowsArgumentNullException()
        {
            // Setup
            var data = new MacroStabilityInwardsSoilLayerData();

            // Call
            void Call() => data.MaterialName = null;

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(Call).ParamName;

            Assert.AreEqual("value", paramName);
        }
        public void Constructor_WithTopAndData_ReturnsNewInstance()
        {
            // Setup
            double top  = new Random(22).NextDouble();
            var    data = new MacroStabilityInwardsSoilLayerData();

            // Call
            var layer = new MacroStabilityInwardsSoilLayer1D(top, data);

            // Assert
            Assert.IsInstanceOf <IMacroStabilityInwardsSoilLayer>(layer);
            Assert.AreEqual(top, layer.Top);
            Assert.AreSame(data, layer.Data);
        }
Ejemplo n.º 12
0
        public void Constructor_WithOuterRingDataAndNestedLayers_ReturnsNewInstance()
        {
            // Setup
            Ring outerRing = RingTestFactory.CreateRandomRing();
            var  data      = new MacroStabilityInwardsSoilLayerData();
            IEnumerable <MacroStabilityInwardsSoilLayer2D> nestedLayers = Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>();

            // Call
            var layer = new MacroStabilityInwardsSoilLayer2D(outerRing, data, nestedLayers);

            // Assert
            Assert.IsInstanceOf <IMacroStabilityInwardsSoilLayer>(layer);
            Assert.AreSame(outerRing, layer.OuterRing);
            Assert.AreSame(data, layer.Data);
            Assert.AreSame(nestedLayers, layer.NestedLayers);
        }
Ejemplo n.º 13
0
        private static void AssertSoilData(SoilLayer2D original, MacroStabilityInwardsSoilLayer2D actual)
        {
            Assert.AreEqual(original.MaterialName, actual.Data.MaterialName);
            Assert.AreEqual(original.IsAquifer.Equals(1.0), actual.Data.IsAquifer);
            Assert.AreEqual(Color.FromArgb(Convert.ToInt32(original.Color)), actual.Data.Color);

            MacroStabilityInwardsSoilLayerData soilLayerData = actual.Data;

            Assert.AreEqual(original.AbovePhreaticLevelMean, soilLayerData.AbovePhreaticLevel.Mean,
                            soilLayerData.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(original.AbovePhreaticLevelCoefficientOfVariation, soilLayerData.AbovePhreaticLevel.CoefficientOfVariation,
                            soilLayerData.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(original.AbovePhreaticLevelShift, soilLayerData.AbovePhreaticLevel.Shift,
                            soilLayerData.AbovePhreaticLevel.GetAccuracy());

            Assert.AreEqual(original.BelowPhreaticLevelMean, soilLayerData.BelowPhreaticLevel.Mean,
                            soilLayerData.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(original.BelowPhreaticLevelCoefficientOfVariation, soilLayerData.BelowPhreaticLevel.CoefficientOfVariation,
                            soilLayerData.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(original.BelowPhreaticLevelShift, soilLayerData.BelowPhreaticLevel.Shift,
                            soilLayerData.BelowPhreaticLevel.GetAccuracy());

            Assert.AreEqual(original.CohesionMean, soilLayerData.Cohesion.Mean,
                            soilLayerData.Cohesion.GetAccuracy());
            Assert.AreEqual(original.CohesionCoefficientOfVariation, soilLayerData.Cohesion.CoefficientOfVariation,
                            soilLayerData.Cohesion.GetAccuracy());

            Assert.AreEqual(original.FrictionAngleMean, soilLayerData.FrictionAngle.Mean,
                            soilLayerData.FrictionAngle.GetAccuracy());
            Assert.AreEqual(original.FrictionAngleCoefficientOfVariation, soilLayerData.FrictionAngle.CoefficientOfVariation,
                            soilLayerData.FrictionAngle.GetAccuracy());

            Assert.AreEqual(original.ShearStrengthRatioMean, soilLayerData.ShearStrengthRatio.Mean,
                            soilLayerData.ShearStrengthRatio.GetAccuracy());
            Assert.AreEqual(original.ShearStrengthRatioCoefficientOfVariation, soilLayerData.ShearStrengthRatio.CoefficientOfVariation,
                            soilLayerData.ShearStrengthRatio.GetAccuracy());

            Assert.AreEqual(original.StrengthIncreaseExponentMean, soilLayerData.StrengthIncreaseExponent.Mean,
                            soilLayerData.StrengthIncreaseExponent.GetAccuracy());
            Assert.AreEqual(original.StrengthIncreaseExponentCoefficientOfVariation, soilLayerData.StrengthIncreaseExponent.CoefficientOfVariation,
                            soilLayerData.StrengthIncreaseExponent.GetAccuracy());

            Assert.AreEqual(original.PopMean, soilLayerData.Pop.Mean, soilLayerData.Pop.GetAccuracy());
            Assert.AreEqual(original.PopCoefficientOfVariation, soilLayerData.Pop.CoefficientOfVariation,
                            soilLayerData.Pop.GetAccuracy());
        }
        /// <summary>
        /// Create <see cref="ChartMultipleAreaData"/> for a <see cref="MacroStabilityInwardsSoilLayer2D"/>.
        /// </summary>
        /// <param name="layer">The layer to create the <see cref="ChartMultipleAreaData"/> for.</param>
        /// <returns>The created <see cref="ChartMultipleAreaData"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="layer"/> is <c>null</c>.</exception>
        public static ChartMultipleAreaData CreateSoilLayerChartData(MacroStabilityInwardsSoilLayer2D layer)
        {
            if (layer == null)
            {
                throw new ArgumentNullException(nameof(layer));
            }

            MacroStabilityInwardsSoilLayerData data = layer.Data;

            return(new ChartMultipleAreaData(SoilLayerDataHelper.GetValidName(data.MaterialName),
                                             new ChartAreaStyle
            {
                FillColor = SoilLayerDataHelper.GetValidColor(data.Color),
                StrokeColor = Color.Black,
                StrokeThickness = 1
            }));
        }
        /// <summary>
        /// Asserts whether the <see cref="PersistableSoil"/> contains the data
        /// that is representative for the <paramref name="originalLayers"/>.
        /// </summary>
        /// <param name="originalLayers">The layers that contain the original data.</param>
        /// <param name="actualSoils">The collection of <see cref="PersistableSoil"/>
        /// that needs to be asserted.</param>
        /// <exception cref="AssertionException">Thrown when the data in <paramref name="actualSoils"/>
        /// is not correct.</exception>
        public static void AssertPersistableSoils(IEnumerable <IMacroStabilityInwardsSoilLayer> originalLayers, IEnumerable <PersistableSoil> actualSoils)
        {
            Assert.AreEqual(originalLayers.Count(), actualSoils.Count());

            for (var i = 0; i < originalLayers.Count(); i++)
            {
                PersistableSoil soil = actualSoils.ElementAt(i);
                MacroStabilityInwardsSoilLayerData layerData = originalLayers.ElementAt(i).Data;

                Assert.IsNotNull(soil.Id);
                Assert.AreEqual(layerData.MaterialName, soil.Name);
                Assert.AreEqual($"{layerData.MaterialName}-{soil.Id}", soil.Code);
                Assert.IsTrue(soil.IsProbabilistic);

                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(layerData).GetDesignValue(), soil.Cohesion);
                AssertStochasticParameter(layerData.Cohesion, soil.CohesionStochasticParameter);

                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(layerData).GetDesignValue(), soil.FrictionAngle);
                AssertStochasticParameter(layerData.FrictionAngle, soil.FrictionAngleStochasticParameter);

                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(layerData).GetDesignValue(), soil.ShearStrengthRatio);
                AssertStochasticParameter(layerData.ShearStrengthRatio, soil.ShearStrengthRatioStochasticParameter);

                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(layerData).GetDesignValue(), soil.StrengthIncreaseExponent);
                AssertStochasticParameter(layerData.StrengthIncreaseExponent, soil.StrengthIncreaseExponentStochasticParameter);

                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(layerData).GetDesignValue(), soil.VolumetricWeightAbovePhreaticLevel);
                Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(layerData).GetDesignValue(), soil.VolumetricWeightBelowPhreaticLevel);

                Assert.IsFalse(soil.CohesionAndFrictionAngleCorrelated);
                Assert.IsFalse(soil.ShearStrengthRatioAndShearStrengthExponentCorrelated);

                Assert.AreEqual(GetExpectedShearStrengthModelTypeForAbovePhreaticLevel(layerData.ShearStrengthModel), soil.ShearStrengthModelTypeAbovePhreaticLevel);
                Assert.AreEqual(GetExpectedShearStrengthModelTypeForBelowPhreaticLevel(layerData.ShearStrengthModel), soil.ShearStrengthModelTypeBelowPhreaticLevel);

                var dilatancyDistribution = new VariationCoefficientNormalDistribution(2)
                {
                    Mean = (RoundedDouble)1,
                    CoefficientOfVariation = (RoundedDouble)0
                };

                Assert.AreEqual(0, soil.Dilatancy);
                AssertStochasticParameter(dilatancyDistribution, soil.DilatancyStochasticParameter, false);
            }
        }
        public void GetStrengthIncreaseExponent_ValidSoilLayerData_CreateDesignVariableForStrengthIncreaseExponent()
        {
            // Setup
            var data = new MacroStabilityInwardsSoilLayerData
            {
                StrengthIncreaseExponent =
                {
                    Mean                   = (RoundedDouble)mean,
                    CoefficientOfVariation = (RoundedDouble)coefficientOfVariation
                }
            };

            // Call
            VariationCoefficientDesignVariable <VariationCoefficientLogNormalDistribution> strengthIncreaseExponent = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(data);

            // Assert
            DistributionAssert.AreEqual(data.StrengthIncreaseExponent, strengthIncreaseExponent.Distribution);
            AssertPercentile(0.05, strengthIncreaseExponent);
        }
        public void GetCohesion_ValidSoilLayerData_CreateDesignVariableForCohesion()
        {
            // Setup
            var data = new MacroStabilityInwardsSoilLayerData
            {
                Cohesion =
                {
                    Mean                   = (RoundedDouble)mean,
                    CoefficientOfVariation = (RoundedDouble)coefficientOfVariation
                }
            };

            // Call
            VariationCoefficientDesignVariable <VariationCoefficientLogNormalDistribution> cohesion = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(data);

            // Assert
            DistributionAssert.AreEqual(data.Cohesion, cohesion.Distribution);
            AssertPercentile(0.05, cohesion);
        }
Ejemplo n.º 18
0
        public void Read_WithNullValues_ReturnsMacroStabilityInwardsSoilLayer1DWithNaNValues()
        {
            // Setup
            var entity = new MacroStabilityInwardsSoilLayerOneDEntity
            {
                MaterialName = nameof(MacroStabilityInwardsSoilLayerOneDEntity)
            };

            // Call
            MacroStabilityInwardsSoilLayer1D layer = entity.Read();

            // Assert
            Assert.IsNotNull(layer);
            MacroStabilityInwardsSoilLayerData data = layer.Data;

            Assert.AreEqual(entity.MaterialName, data.MaterialName);

            Assert.IsNaN(layer.Top);

            Assert.IsNaN(data.AbovePhreaticLevel.Mean);
            Assert.IsNaN(data.AbovePhreaticLevel.CoefficientOfVariation);
            Assert.IsNaN(data.AbovePhreaticLevel.Shift);

            Assert.IsNaN(data.BelowPhreaticLevel.Mean);
            Assert.IsNaN(data.BelowPhreaticLevel.CoefficientOfVariation);
            Assert.IsNaN(data.BelowPhreaticLevel.Shift);

            Assert.IsNaN(data.Cohesion.Mean);
            Assert.IsNaN(data.Cohesion.CoefficientOfVariation);

            Assert.IsNaN(data.FrictionAngle.Mean);
            Assert.IsNaN(data.FrictionAngle.CoefficientOfVariation);

            Assert.IsNaN(data.ShearStrengthRatio.Mean);
            Assert.IsNaN(data.ShearStrengthRatio.CoefficientOfVariation);

            Assert.IsNaN(data.StrengthIncreaseExponent.Mean);
            Assert.IsNaN(data.StrengthIncreaseExponent.CoefficientOfVariation);

            Assert.IsNaN(data.Pop.Mean);
            Assert.IsNaN(data.Pop.CoefficientOfVariation);
        }
        public void GetBelowPhreaticLevel_ValidSoilLayerData_CreateDesignVariableForBelowPhreaticLevel()
        {
            // Setup
            var data = new MacroStabilityInwardsSoilLayerData
            {
                BelowPhreaticLevel =
                {
                    Mean                   = (RoundedDouble)mean,
                    CoefficientOfVariation = (RoundedDouble)coefficientOfVariation,
                    Shift                  = (RoundedDouble)(mean - 0.1)
                }
            };

            // Call
            VariationCoefficientDeterministicDesignVariable <VariationCoefficientLogNormalDistribution> belowPhreaticLevel = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(data);

            // Assert
            DistributionAssert.AreEqual(data.BelowPhreaticLevel, belowPhreaticLevel.Distribution);
            Assert.AreEqual(data.BelowPhreaticLevel.Mean, belowPhreaticLevel.GetDesignValue());
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsFormattedSoilLayerDataRow"/>.
        /// </summary>
        /// <param name="layerData">The <see cref="MacroStabilityInwardsSoilLayerData"/> to format.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="layerData"/>
        /// is <c>null</c>.</exception>
        public MacroStabilityInwardsFormattedSoilLayerDataRow(MacroStabilityInwardsSoilLayerData layerData)
        {
            if (layerData == null)
            {
                throw new ArgumentNullException(nameof(layerData));
            }

            MaterialName             = SoilLayerDataHelper.GetValidName(layerData.MaterialName);
            Color                    = SoilLayerDataHelper.GetValidColor(layerData.Color);
            IsAquifer                = layerData.IsAquifer;
            AbovePhreaticLevel       = FormatVariationCoefficientDesignVariableWithShift(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(layerData));
            BelowPhreaticLevel       = FormatVariationCoefficientDesignVariableWithShift(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(layerData));
            ShearStrengthModel       = layerData.ShearStrengthModel;
            Cohesion                 = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(layerData));
            FrictionAngle            = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(layerData));
            ShearStrengthRatio       = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(layerData));
            StrengthIncreaseExponent = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(layerData));
            UsePop                   = layerData.UsePop;
            Pop = FormatVariationCoefficientDesignVariable(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(layerData));
        }
Ejemplo n.º 21
0
        public void Read_WithNullValues_ReturnsMacroStabilityInwardsSoilLayer2DWithNaNValues()
        {
            // Setup
            var entity = new MacroStabilityInwardsSoilLayerTwoDEntity
            {
                MaterialName = nameof(MacroStabilityInwardsSoilLayerTwoDEntity),
                OuterRingXml = new Point2DCollectionXmlSerializer().ToXml(RingTestFactory.CreateRandomRing().Points)
            };

            // Call
            MacroStabilityInwardsSoilLayer2D layer = entity.Read();

            // Assert
            Assert.IsNotNull(layer);
            MacroStabilityInwardsSoilLayerData data = layer.Data;

            Assert.AreEqual(entity.MaterialName, data.MaterialName);

            Assert.IsNaN(data.AbovePhreaticLevel.Mean);
            Assert.IsNaN(data.AbovePhreaticLevel.CoefficientOfVariation);
            Assert.IsNaN(data.AbovePhreaticLevel.Shift);

            Assert.IsNaN(data.BelowPhreaticLevel.Mean);
            Assert.IsNaN(data.BelowPhreaticLevel.CoefficientOfVariation);
            Assert.IsNaN(data.BelowPhreaticLevel.Shift);

            Assert.IsNaN(data.Cohesion.Mean);
            Assert.IsNaN(data.Cohesion.CoefficientOfVariation);

            Assert.IsNaN(data.FrictionAngle.Mean);
            Assert.IsNaN(data.FrictionAngle.CoefficientOfVariation);

            Assert.IsNaN(data.ShearStrengthRatio.Mean);
            Assert.IsNaN(data.ShearStrengthRatio.CoefficientOfVariation);

            Assert.IsNaN(data.StrengthIncreaseExponent.Mean);
            Assert.IsNaN(data.StrengthIncreaseExponent.CoefficientOfVariation);

            Assert.IsNaN(data.Pop.Mean);
            Assert.IsNaN(data.Pop.CoefficientOfVariation);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Creates a <see cref="MacroStabilityInwardsSoilLayerTwoDEntity"/> based on the information
        /// of the <see cref="MacroStabilityInwardsSoilLayer2D"/>.
        /// </summary>
        /// <param name="soilLayer">The soil layer to create a database entity for.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsSoilLayerOneDEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="soilLayer"/> is <c>null</c>.</exception>
        public static MacroStabilityInwardsSoilLayerTwoDEntity Create(this MacroStabilityInwardsSoilLayer2D soilLayer,
                                                                      int order)
        {
            if (soilLayer == null)
            {
                throw new ArgumentNullException(nameof(soilLayer));
            }

            MacroStabilityInwardsSoilLayerData data = soilLayer.Data;
            var entity = new MacroStabilityInwardsSoilLayerTwoDEntity
            {
                OuterRingXml           = new Point2DCollectionXmlSerializer().ToXml(soilLayer.OuterRing.Points),
                IsAquifer              = Convert.ToByte(data.IsAquifer),
                MaterialName           = data.MaterialName.DeepClone(),
                Color                  = data.Color.ToInt64(),
                UsePop                 = Convert.ToByte(data.UsePop),
                ShearStrengthModel     = Convert.ToByte(data.ShearStrengthModel),
                AbovePhreaticLevelMean = data.AbovePhreaticLevel.Mean.ToNaNAsNull(),
                AbovePhreaticLevelCoefficientOfVariation = data.AbovePhreaticLevel.CoefficientOfVariation.ToNaNAsNull(),
                AbovePhreaticLevelShift = data.AbovePhreaticLevel.Shift.ToNaNAsNull(),
                BelowPhreaticLevelMean  = data.BelowPhreaticLevel.Mean.ToNaNAsNull(),
                BelowPhreaticLevelCoefficientOfVariation = data.BelowPhreaticLevel.CoefficientOfVariation.ToNaNAsNull(),
                BelowPhreaticLevelShift                        = data.BelowPhreaticLevel.Shift.ToNaNAsNull(),
                CohesionMean                                   = data.Cohesion.Mean.ToNaNAsNull(),
                CohesionCoefficientOfVariation                 = data.Cohesion.CoefficientOfVariation.ToNaNAsNull(),
                FrictionAngleMean                              = data.FrictionAngle.Mean.ToNaNAsNull(),
                FrictionAngleCoefficientOfVariation            = data.FrictionAngle.CoefficientOfVariation.ToNaNAsNull(),
                ShearStrengthRatioMean                         = data.ShearStrengthRatio.Mean.ToNaNAsNull(),
                ShearStrengthRatioCoefficientOfVariation       = data.ShearStrengthRatio.CoefficientOfVariation.ToNaNAsNull(),
                StrengthIncreaseExponentMean                   = data.StrengthIncreaseExponent.Mean.ToNaNAsNull(),
                StrengthIncreaseExponentCoefficientOfVariation = data.StrengthIncreaseExponent.CoefficientOfVariation.ToNaNAsNull(),
                PopMean = data.Pop.Mean.ToNaNAsNull(),
                PopCoefficientOfVariation = data.Pop.CoefficientOfVariation.ToNaNAsNull(),
                Order = order
            };

            AddNestedLayers(entity, soilLayer);

            return(entity);
        }
        /// <summary>
        /// Creates a new instance of <see cref="PersistableSoil"/>.
        /// </summary>
        /// <param name="layer">The layer to use.</param>
        /// <param name="idFactory">The factory for creating IDs.</param>
        /// <param name="registry">The persistence registry.</param>
        /// <returns>The created <see cref="PersistableSoil"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when
        /// <see cref="MacroStabilityInwardsShearStrengthModel"/> has an invalid value.</exception>
        /// <exception cref="NotSupportedException">Thrown when <see cref="MacroStabilityInwardsShearStrengthModel"/>
        /// has a valid value but is not supported.</exception>
        private static PersistableSoil Create(MacroStabilityInwardsSoilLayer2D layer, IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            MacroStabilityInwardsSoilLayerData layerData = layer.Data;

            var soil = new PersistableSoil
            {
                Id                                                   = idFactory.Create(),
                Name                                                 = layerData.MaterialName,
                IsProbabilistic                                      = true,
                Cohesion                                             = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(layerData).GetDesignValue(),
                CohesionStochasticParameter                          = PersistableStochasticParameterFactory.Create(layerData.Cohesion),
                FrictionAngle                                        = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(layerData).GetDesignValue(),
                FrictionAngleStochasticParameter                     = PersistableStochasticParameterFactory.Create(layerData.FrictionAngle),
                ShearStrengthRatio                                   = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(layerData).GetDesignValue(),
                ShearStrengthRatioStochasticParameter                = PersistableStochasticParameterFactory.Create(layerData.ShearStrengthRatio),
                StrengthIncreaseExponent                             = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(layerData).GetDesignValue(),
                StrengthIncreaseExponentStochasticParameter          = PersistableStochasticParameterFactory.Create(layerData.StrengthIncreaseExponent),
                CohesionAndFrictionAngleCorrelated                   = false,
                ShearStrengthRatioAndShearStrengthExponentCorrelated = false,
                ShearStrengthModelTypeAbovePhreaticLevel             = GetShearStrengthModelTypeForAbovePhreaticLevel(layerData.ShearStrengthModel),
                ShearStrengthModelTypeBelowPhreaticLevel             = GetShearStrengthModelTypeForBelowPhreaticLevel(layerData.ShearStrengthModel),
                VolumetricWeightAbovePhreaticLevel                   = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(layerData).GetDesignValue(),
                VolumetricWeightBelowPhreaticLevel                   = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(layerData).GetDesignValue(),
                Dilatancy                                            = 0,
                DilatancyStochasticParameter                         = PersistableStochasticParameterFactory.Create(new VariationCoefficientNormalDistribution(2)
                {
                    Mean = (RoundedDouble)1,
                    CoefficientOfVariation = (RoundedDouble)0
                }, false)
            };

            soil.Code = $"{soil.Name}-{soil.Id}";

            registry.AddSoil(layer, soil.Id);

            return(soil);
        }
        /// <summary>
        /// Creates a <see cref="MacroStabilityInwardsSoilLayerOneDEntity"/> based on the information
        /// of the <see cref="MacroStabilityInwardsSoilLayer1D"/>.
        /// </summary>
        /// <param name="soilLayer">The soil layer to create a database entity for.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsSoilLayerOneDEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="soilLayer"/> is <c>null</c>.</exception>
        public static MacroStabilityInwardsSoilLayerOneDEntity Create(this MacroStabilityInwardsSoilLayer1D soilLayer,
                                                                      int order)
        {
            if (soilLayer == null)
            {
                throw new ArgumentNullException(nameof(soilLayer));
            }

            MacroStabilityInwardsSoilLayerData data = soilLayer.Data;

            return(new MacroStabilityInwardsSoilLayerOneDEntity
            {
                Top = soilLayer.Top.ToNaNAsNull(),
                IsAquifer = Convert.ToByte(data.IsAquifer),
                MaterialName = data.MaterialName.DeepClone(),
                Color = data.Color.ToInt64(),
                UsePop = Convert.ToByte(data.UsePop),
                ShearStrengthModel = Convert.ToByte(data.ShearStrengthModel),
                AbovePhreaticLevelMean = data.AbovePhreaticLevel.Mean.ToNaNAsNull(),
                AbovePhreaticLevelCoefficientOfVariation = data.AbovePhreaticLevel.CoefficientOfVariation.ToNaNAsNull(),
                AbovePhreaticLevelShift = data.AbovePhreaticLevel.Shift.ToNaNAsNull(),
                BelowPhreaticLevelMean = data.BelowPhreaticLevel.Mean.ToNaNAsNull(),
                BelowPhreaticLevelCoefficientOfVariation = data.BelowPhreaticLevel.CoefficientOfVariation.ToNaNAsNull(),
                BelowPhreaticLevelShift = data.BelowPhreaticLevel.Shift.ToNaNAsNull(),
                CohesionMean = data.Cohesion.Mean.ToNaNAsNull(),
                CohesionCoefficientOfVariation = data.Cohesion.CoefficientOfVariation.ToNaNAsNull(),
                FrictionAngleMean = data.FrictionAngle.Mean.ToNaNAsNull(),
                FrictionAngleCoefficientOfVariation = data.FrictionAngle.CoefficientOfVariation.ToNaNAsNull(),
                ShearStrengthRatioMean = data.ShearStrengthRatio.Mean.ToNaNAsNull(),
                ShearStrengthRatioCoefficientOfVariation = data.ShearStrengthRatio.CoefficientOfVariation.ToNaNAsNull(),
                StrengthIncreaseExponentMean = data.StrengthIncreaseExponent.Mean.ToNaNAsNull(),
                StrengthIncreaseExponentCoefficientOfVariation = data.StrengthIncreaseExponent.CoefficientOfVariation.ToNaNAsNull(),
                PopMean = data.Pop.Mean.ToNaNAsNull(),
                PopCoefficientOfVariation = data.Pop.CoefficientOfVariation.ToNaNAsNull(),
                Order = order
            });
        }
Ejemplo n.º 25
0
        public void SoilLayer1DTransform_PropertiesSetAndValid_ReturnMacroStabilityInwardSoilLayer1D()
        {
            // Setup
            var random = new Random(22);

            double       isAquifer    = random.Next(0, 2);
            double       top          = random.NextDouble();
            const string materialName = "materialX";
            double       color        = random.NextDouble();

            const double abovePhreaticLevelMean = 0.3;
            const double abovePhreaticLevelCoefficientOfVariation = 0.2;
            const double abovePhreaticLevelShift = 0.1;
            const double belowPhreaticLevelMean  = 0.4;
            const double belowPhreaticLevelCoefficientOfVariation = 0.3;
            const double belowPhreaticLevelShift                        = 0.2;
            double       cohesionMean                                   = random.NextDouble();
            double       cohesionCoefficientOfVariation                 = random.NextDouble();
            double       frictionAngleMean                              = random.NextDouble();
            double       frictionAngleCoefficientOfVariation            = random.NextDouble();
            double       shearStrengthRatioMean                         = random.NextDouble();
            double       shearStrengthRatioCoefficientOfVariation       = random.NextDouble();
            double       strengthIncreaseExponentMean                   = random.NextDouble();
            double       strengthIncreaseExponentCoefficientOfVariation = random.NextDouble();
            double       popMean = random.NextDouble();
            double       popCoefficientOfVariation = random.NextDouble();

            var layer = new SoilLayer1D(top)
            {
                IsAquifer              = isAquifer,
                MaterialName           = materialName,
                Color                  = color,
                AbovePhreaticLevelMean = abovePhreaticLevelMean,
                AbovePhreaticLevelCoefficientOfVariation = abovePhreaticLevelCoefficientOfVariation,
                AbovePhreaticLevelShift = abovePhreaticLevelShift,
                BelowPhreaticLevelMean  = belowPhreaticLevelMean,
                BelowPhreaticLevelCoefficientOfVariation = belowPhreaticLevelCoefficientOfVariation,
                BelowPhreaticLevelShift                        = belowPhreaticLevelShift,
                CohesionMean                                   = cohesionMean,
                CohesionCoefficientOfVariation                 = cohesionCoefficientOfVariation,
                FrictionAngleMean                              = frictionAngleMean,
                FrictionAngleCoefficientOfVariation            = frictionAngleCoefficientOfVariation,
                ShearStrengthRatioMean                         = shearStrengthRatioMean,
                ShearStrengthRatioCoefficientOfVariation       = shearStrengthRatioCoefficientOfVariation,
                StrengthIncreaseExponentMean                   = strengthIncreaseExponentMean,
                StrengthIncreaseExponentCoefficientOfVariation = strengthIncreaseExponentCoefficientOfVariation,
                PopMean = popMean,
                PopCoefficientOfVariation = popCoefficientOfVariation
            };

            // Call
            MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Assert.AreEqual(top, soilLayer1D.Top);

            MacroStabilityInwardsSoilLayerData data = soilLayer1D.Data;

            Assert.AreEqual(materialName, data.MaterialName);
            bool expectedIsAquifer = isAquifer.Equals(1.0);

            Assert.AreEqual(expectedIsAquifer, data.IsAquifer);
            Color expectedColor = Color.FromArgb(Convert.ToInt32(color));

            Assert.AreEqual(expectedColor, data.Color);

            Assert.AreEqual(abovePhreaticLevelMean, data.AbovePhreaticLevel.Mean,
                            data.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(abovePhreaticLevelCoefficientOfVariation, data.AbovePhreaticLevel.CoefficientOfVariation,
                            data.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(abovePhreaticLevelShift, data.AbovePhreaticLevel.Shift,
                            data.AbovePhreaticLevel.GetAccuracy());

            Assert.AreEqual(belowPhreaticLevelMean, data.BelowPhreaticLevel.Mean,
                            data.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(belowPhreaticLevelCoefficientOfVariation, data.BelowPhreaticLevel.CoefficientOfVariation,
                            data.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(belowPhreaticLevelShift, data.BelowPhreaticLevel.Shift,
                            data.BelowPhreaticLevel.GetAccuracy());

            Assert.AreEqual(cohesionMean, data.Cohesion.Mean,
                            data.Cohesion.GetAccuracy());
            Assert.AreEqual(cohesionCoefficientOfVariation, data.Cohesion.CoefficientOfVariation,
                            data.Cohesion.GetAccuracy());

            Assert.AreEqual(frictionAngleMean, data.FrictionAngle.Mean,
                            data.FrictionAngle.GetAccuracy());
            Assert.AreEqual(frictionAngleCoefficientOfVariation, data.FrictionAngle.CoefficientOfVariation,
                            data.FrictionAngle.GetAccuracy());

            Assert.AreEqual(shearStrengthRatioMean, data.ShearStrengthRatio.Mean,
                            data.ShearStrengthRatio.GetAccuracy());
            Assert.AreEqual(shearStrengthRatioCoefficientOfVariation, data.ShearStrengthRatio.CoefficientOfVariation,
                            data.ShearStrengthRatio.GetAccuracy());

            Assert.AreEqual(strengthIncreaseExponentMean, data.StrengthIncreaseExponent.Mean,
                            data.StrengthIncreaseExponent.GetAccuracy());
            Assert.AreEqual(strengthIncreaseExponentCoefficientOfVariation, data.StrengthIncreaseExponent.CoefficientOfVariation,
                            data.StrengthIncreaseExponent.GetAccuracy());

            Assert.AreEqual(popMean, data.Pop.Mean, data.Pop.GetAccuracy());
            Assert.AreEqual(popCoefficientOfVariation, data.Pop.CoefficientOfVariation,
                            data.Pop.GetAccuracy());
        }
        public void Constructor_WithSoilLayerDataEmptyAndNaN_ExpectedValues()
        {
            // Setup
            var soilLayerData = new MacroStabilityInwardsSoilLayerData
            {
                MaterialName       = string.Empty,
                Color              = Color.Empty,
                IsAquifer          = true,
                AbovePhreaticLevel = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)double.NaN,
                    Mean = (RoundedDouble)double.NaN
                },
                BelowPhreaticLevel = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)double.NaN,
                    Mean = (RoundedDouble)double.NaN
                },
                ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.CPhi,
                ShearStrengthRatio = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)double.NaN,
                    Mean = (RoundedDouble)double.NaN
                },
                Cohesion = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)double.NaN,
                    Mean = (RoundedDouble)double.NaN
                },
                FrictionAngle = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)double.NaN,
                    Mean = (RoundedDouble)double.NaN
                },
                StrengthIncreaseExponent = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)double.NaN,
                    Mean = (RoundedDouble)double.NaN
                },
                UsePop = true,
                Pop    = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)double.NaN,
                    Mean = (RoundedDouble)double.NaN
                }
            };

            // Call
            var formattedSoilLayerDataRow = new MacroStabilityInwardsFormattedSoilLayerDataRow(soilLayerData);

            // Assert
            TestHelper.AssertTypeConverter <MacroStabilityInwardsFormattedSoilLayerDataRow, EnumTypeConverter>(
                nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.ShearStrengthModel));

            Assert.AreEqual("Onbekend", formattedSoilLayerDataRow.MaterialName);
            Assert.AreEqual(Color.White, formattedSoilLayerDataRow.Color);
            Assert.AreEqual(soilLayerData.IsAquifer, formattedSoilLayerDataRow.IsAquifer);
            Assert.AreEqual("NaN", formattedSoilLayerDataRow.AbovePhreaticLevel);
            Assert.AreEqual("NaN", formattedSoilLayerDataRow.BelowPhreaticLevel);
            Assert.AreEqual(soilLayerData.ShearStrengthModel, formattedSoilLayerDataRow.ShearStrengthModel);
            Assert.AreEqual("NaN", formattedSoilLayerDataRow.ShearStrengthRatio);
            Assert.AreEqual("NaN", formattedSoilLayerDataRow.Cohesion);
            Assert.AreEqual("NaN", formattedSoilLayerDataRow.FrictionAngle);
            Assert.AreEqual("NaN", formattedSoilLayerDataRow.StrengthIncreaseExponent);
            Assert.AreEqual(soilLayerData.UsePop, formattedSoilLayerDataRow.UsePop);
            Assert.AreEqual("NaN", formattedSoilLayerDataRow.Pop);
        }
        public void Constructor_WithSoilLayerData_ExpectedValues()
        {
            // Setup
            var soilLayerData = new MacroStabilityInwardsSoilLayerData
            {
                MaterialName       = "Sand",
                Color              = Color.Black,
                IsAquifer          = true,
                AbovePhreaticLevel = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)1.0,
                    Mean  = (RoundedDouble)1.0,
                    Shift = (RoundedDouble)0.5
                },
                BelowPhreaticLevel = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)2.0,
                    Mean  = (RoundedDouble)2.0,
                    Shift = (RoundedDouble)1.0
                },
                ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.CPhi,
                ShearStrengthRatio = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)3.0,
                    Mean = (RoundedDouble)3.0
                },
                Cohesion = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)4.0,
                    Mean = (RoundedDouble)4.0
                },
                FrictionAngle = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)5.0,
                    Mean = (RoundedDouble)5.0
                },
                StrengthIncreaseExponent = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)6.0,
                    Mean = (RoundedDouble)6.0
                },
                UsePop = true,
                Pop    = new VariationCoefficientLogNormalDistribution
                {
                    CoefficientOfVariation = (RoundedDouble)7.0,
                    Mean = (RoundedDouble)7.0
                }
            };

            // Call
            var formattedSoilLayerDataRow = new MacroStabilityInwardsFormattedSoilLayerDataRow(soilLayerData);

            // Assert
            TestHelper.AssertTypeConverter <MacroStabilityInwardsFormattedSoilLayerDataRow, EnumTypeConverter>(
                nameof(MacroStabilityInwardsFormattedSoilLayerDataRow.ShearStrengthModel));

            Assert.AreEqual(soilLayerData.MaterialName, formattedSoilLayerDataRow.MaterialName);
            Assert.AreEqual(soilLayerData.Color, formattedSoilLayerDataRow.Color);
            Assert.AreEqual(soilLayerData.IsAquifer, formattedSoilLayerDataRow.IsAquifer);
            Assert.AreEqual("1,00 (Verwachtingswaarde = 1,00, Variatiecoëfficiënt = 1,00, Verschuiving = 0,50)", formattedSoilLayerDataRow.AbovePhreaticLevel);
            Assert.AreEqual("2,00 (Verwachtingswaarde = 2,00, Variatiecoëfficiënt = 2,00, Verschuiving = 1,00)", formattedSoilLayerDataRow.BelowPhreaticLevel);
            Assert.AreEqual(soilLayerData.ShearStrengthModel, formattedSoilLayerDataRow.ShearStrengthModel);
            Assert.AreEqual("0,08 (Verwachtingswaarde = 3,00, Variatiecoëfficiënt = 3,00)", formattedSoilLayerDataRow.ShearStrengthRatio);
            Assert.AreEqual("0,06 (Verwachtingswaarde = 4,00, Variatiecoëfficiënt = 4,00)", formattedSoilLayerDataRow.Cohesion);
            Assert.AreEqual("0,05 (Verwachtingswaarde = 5,00, Variatiecoëfficiënt = 5,00)", formattedSoilLayerDataRow.FrictionAngle);
            Assert.AreEqual("0,04 (Verwachtingswaarde = 6,00, Variatiecoëfficiënt = 6,00)", formattedSoilLayerDataRow.StrengthIncreaseExponent);
            Assert.AreEqual(soilLayerData.UsePop, formattedSoilLayerDataRow.UsePop);
            Assert.AreEqual("0,04 (Verwachtingswaarde = 7,00, Variatiecoëfficiënt = 7,00)", formattedSoilLayerDataRow.Pop);
        }
Ejemplo n.º 28
0
 public TempSoilLayerGeometry(IEnumerable <Point2D> outerLoop, MacroStabilityInwardsSoilLayerData data)
 {
     OuterLoop = outerLoop;
     Data      = data;
 }
        public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet()
        {
            // Setup
            var random    = new Random(31);
            var soilLayer = new MacroStabilityInwardsSoilLayer1D(random.NextDouble())
            {
                Data =
                {
                    IsAquifer          = random.NextBoolean(),
                    MaterialName       = "MaterialName",
                    Color              = Color.FromKnownColor(random.NextEnumValue <KnownColor>()),
                    UsePop             = random.NextBoolean(),
                    ShearStrengthModel = random.NextEnumValue <MacroStabilityInwardsShearStrengthModel>(),
                    AbovePhreaticLevel =
                    {
                        Mean                   = (RoundedDouble)0.3,
                        CoefficientOfVariation = (RoundedDouble)0.2,
                        Shift                  = (RoundedDouble)0.1
                    },
                    BelowPhreaticLevel         =
                    {
                        Mean                   = (RoundedDouble)10,
                        CoefficientOfVariation = (RoundedDouble)0.5,
                        Shift                  = (RoundedDouble)2
                    },
                    Cohesion                   =
                    {
                        Mean                   = (RoundedDouble)10,
                        CoefficientOfVariation = (RoundedDouble)1
                    },
                    FrictionAngle              =
                    {
                        Mean                   = (RoundedDouble)12,
                        CoefficientOfVariation = (RoundedDouble)0.8
                    },
                    ShearStrengthRatio         =
                    {
                        Mean                   = (RoundedDouble)10,
                        CoefficientOfVariation = (RoundedDouble)0.6
                    },
                    StrengthIncreaseExponent   =
                    {
                        Mean                   = (RoundedDouble)11,
                        CoefficientOfVariation = (RoundedDouble)0.7
                    },
                    Pop                        =
                    {
                        Mean                   = (RoundedDouble)14,
                        CoefficientOfVariation = (RoundedDouble)0.9
                    }
                }
            };
            int order = random.Next();

            // Call
            MacroStabilityInwardsSoilLayerOneDEntity entity = soilLayer.Create(order);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(soilLayer.Top, entity.Top);

            MacroStabilityInwardsSoilLayerData data = soilLayer.Data;

            Assert.AreEqual(Convert.ToByte(data.IsAquifer), entity.IsAquifer);
            Assert.AreEqual(data.MaterialName, entity.MaterialName);
            Assert.AreEqual(data.Color.ToInt64(), Convert.ToInt64(entity.Color));
            Assert.AreEqual(Convert.ToByte(data.UsePop), entity.UsePop);
            Assert.AreEqual(Convert.ToByte(data.ShearStrengthModel), entity.ShearStrengthModel);

            VariationCoefficientLogNormalDistribution abovePhreaticLevelDistribution = data.AbovePhreaticLevel;

            Assert.AreEqual(abovePhreaticLevelDistribution.Mean, entity.AbovePhreaticLevelMean,
                            abovePhreaticLevelDistribution.GetAccuracy());
            Assert.AreEqual(abovePhreaticLevelDistribution.CoefficientOfVariation, entity.AbovePhreaticLevelCoefficientOfVariation,
                            abovePhreaticLevelDistribution.GetAccuracy());
            Assert.AreEqual(abovePhreaticLevelDistribution.Shift, entity.AbovePhreaticLevelShift,
                            abovePhreaticLevelDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution belowPhreaticLevelDistribution = data.BelowPhreaticLevel;

            Assert.AreEqual(belowPhreaticLevelDistribution.Mean, entity.BelowPhreaticLevelMean,
                            belowPhreaticLevelDistribution.GetAccuracy());
            Assert.AreEqual(belowPhreaticLevelDistribution.CoefficientOfVariation, entity.BelowPhreaticLevelCoefficientOfVariation,
                            belowPhreaticLevelDistribution.GetAccuracy());
            Assert.AreEqual(belowPhreaticLevelDistribution.Shift, entity.BelowPhreaticLevelShift,
                            belowPhreaticLevelDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution cohesionDistribution = data.Cohesion;

            Assert.AreEqual(cohesionDistribution.Mean, entity.CohesionMean,
                            cohesionDistribution.GetAccuracy());
            Assert.AreEqual(cohesionDistribution.CoefficientOfVariation, entity.CohesionCoefficientOfVariation,
                            cohesionDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution frictionAngleDistribution = data.FrictionAngle;

            Assert.AreEqual(frictionAngleDistribution.Mean, entity.FrictionAngleMean,
                            frictionAngleDistribution.GetAccuracy());
            Assert.AreEqual(frictionAngleDistribution.CoefficientOfVariation, entity.FrictionAngleCoefficientOfVariation,
                            frictionAngleDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution shearStrengthRatioDistribution = data.ShearStrengthRatio;

            Assert.AreEqual(shearStrengthRatioDistribution.Mean, entity.ShearStrengthRatioMean,
                            shearStrengthRatioDistribution.GetAccuracy());
            Assert.AreEqual(shearStrengthRatioDistribution.CoefficientOfVariation, entity.ShearStrengthRatioCoefficientOfVariation,
                            shearStrengthRatioDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution strengthIncreaseExponentDistribution = data.StrengthIncreaseExponent;

            Assert.AreEqual(strengthIncreaseExponentDistribution.Mean, entity.StrengthIncreaseExponentMean,
                            strengthIncreaseExponentDistribution.GetAccuracy());
            Assert.AreEqual(strengthIncreaseExponentDistribution.CoefficientOfVariation, entity.StrengthIncreaseExponentCoefficientOfVariation,
                            strengthIncreaseExponentDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution popDistribution = data.Pop;

            Assert.AreEqual(popDistribution.Mean, entity.PopMean, popDistribution.GetAccuracy());
            Assert.AreEqual(popDistribution.CoefficientOfVariation, entity.PopCoefficientOfVariation, popDistribution.GetAccuracy());
            Assert.AreEqual(order, entity.Order);
        }
Ejemplo n.º 30
0
        private static void AssertMacroStabilityInwardsSoilLayerTwoDEntity(MacroStabilityInwardsSoilLayer2D soilLayer,
                                                                           MacroStabilityInwardsSoilLayerTwoDEntity entity, int order)
        {
            Assert.IsNotNull(entity);

            MacroStabilityInwardsSoilLayerData data = soilLayer.Data;

            Assert.AreEqual(Convert.ToByte(data.IsAquifer), entity.IsAquifer);
            Assert.AreEqual(data.MaterialName, entity.MaterialName);
            Assert.AreEqual(data.Color.ToInt64(), Convert.ToInt64(entity.Color));
            Assert.AreEqual(Convert.ToByte(data.UsePop), entity.UsePop);
            Assert.AreEqual(Convert.ToByte(data.ShearStrengthModel), entity.ShearStrengthModel);

            VariationCoefficientLogNormalDistribution abovePhreaticLevelDistribution = data.AbovePhreaticLevel;

            Assert.AreEqual(abovePhreaticLevelDistribution.Mean, entity.AbovePhreaticLevelMean,
                            abovePhreaticLevelDistribution.GetAccuracy());
            Assert.AreEqual(abovePhreaticLevelDistribution.CoefficientOfVariation, entity.AbovePhreaticLevelCoefficientOfVariation,
                            abovePhreaticLevelDistribution.GetAccuracy());
            Assert.AreEqual(abovePhreaticLevelDistribution.Shift, entity.AbovePhreaticLevelShift,
                            abovePhreaticLevelDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution belowPhreaticLevelDistribution = data.BelowPhreaticLevel;

            Assert.AreEqual(belowPhreaticLevelDistribution.Mean, entity.BelowPhreaticLevelMean,
                            belowPhreaticLevelDistribution.GetAccuracy());
            Assert.AreEqual(belowPhreaticLevelDistribution.CoefficientOfVariation, entity.BelowPhreaticLevelCoefficientOfVariation,
                            belowPhreaticLevelDistribution.GetAccuracy());
            Assert.AreEqual(belowPhreaticLevelDistribution.Shift, entity.BelowPhreaticLevelShift,
                            belowPhreaticLevelDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution cohesionDistribution = data.Cohesion;

            Assert.AreEqual(cohesionDistribution.Mean, entity.CohesionMean,
                            cohesionDistribution.GetAccuracy());
            Assert.AreEqual(cohesionDistribution.CoefficientOfVariation, entity.CohesionCoefficientOfVariation,
                            cohesionDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution frictionAngleDistribution = data.FrictionAngle;

            Assert.AreEqual(frictionAngleDistribution.Mean, entity.FrictionAngleMean,
                            frictionAngleDistribution.GetAccuracy());
            Assert.AreEqual(frictionAngleDistribution.CoefficientOfVariation, entity.FrictionAngleCoefficientOfVariation,
                            frictionAngleDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution shearStrengthRatioDistribution = data.ShearStrengthRatio;

            Assert.AreEqual(shearStrengthRatioDistribution.Mean, entity.ShearStrengthRatioMean,
                            shearStrengthRatioDistribution.GetAccuracy());
            Assert.AreEqual(shearStrengthRatioDistribution.CoefficientOfVariation, entity.ShearStrengthRatioCoefficientOfVariation,
                            shearStrengthRatioDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution strengthIncreaseExponentDistribution = data.StrengthIncreaseExponent;

            Assert.AreEqual(strengthIncreaseExponentDistribution.Mean, entity.StrengthIncreaseExponentMean,
                            strengthIncreaseExponentDistribution.GetAccuracy());
            Assert.AreEqual(strengthIncreaseExponentDistribution.CoefficientOfVariation, entity.StrengthIncreaseExponentCoefficientOfVariation,
                            strengthIncreaseExponentDistribution.GetAccuracy());

            VariationCoefficientLogNormalDistribution popDistribution = data.Pop;

            Assert.AreEqual(popDistribution.Mean, entity.PopMean, popDistribution.GetAccuracy());
            Assert.AreEqual(popDistribution.CoefficientOfVariation, entity.PopCoefficientOfVariation, popDistribution.GetAccuracy());

            Assert.AreEqual(order, entity.Order);

            AssertOuterRing(soilLayer.OuterRing, entity);
            CollectionAssert.IsEmpty(entity.MacroStabilityInwardsSoilLayerTwoDEntity1);
        }