private static void AssertPopStatePoints(IEnumerable <MacroStabilityInwardsSoilLayer2D> layers, IEnumerable <PersistableStatePoint> popStatePoints) { IEnumerable <MacroStabilityInwardsSoilLayer2D> layersWithPop = layers.Where(l => l.Data.UsePop && l.Data.Pop.Mean != RoundedDouble.NaN && l.Data.Pop.CoefficientOfVariation != RoundedDouble.NaN); Assert.AreEqual(layersWithPop.Count(), popStatePoints.Count()); for (var j = 0; j < layersWithPop.Count(); j++) { MacroStabilityInwardsSoilLayer2D layerWithPop = layersWithPop.ElementAt(j); PersistableStatePoint statePoint = popStatePoints.ElementAt(j); Assert.IsNotNull(statePoint.Id); Assert.AreEqual($"POP - {layerWithPop.Data.MaterialName}", statePoint.Label); Assert.IsNotNull(statePoint.LayerId); Assert.IsTrue(statePoint.IsProbabilistic); Point2D interiorPoint = AdvancedMath2D.GetPolygonInteriorPoint(layerWithPop.OuterRing.Points, layerWithPop.NestedLayers.Select(nl => nl.OuterRing.Points)); Assert.AreEqual(interiorPoint.X, statePoint.Point.X); Assert.AreEqual(interiorPoint.Y, statePoint.Point.Z); Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(layerWithPop.Data).GetDesignValue(), statePoint.Stress.Pop); AssertStochasticParameter(layerWithPop.Data.Pop, statePoint.Stress.PopStochasticParameter); } }
/// <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()); }
/// <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); } }
private static PersistableStress CreatePOPStress(MacroStabilityInwardsSoilLayerData layerData) { return(new PersistableStress { Pop = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(layerData).GetDesignValue(), PopStochasticParameter = PersistableStochasticParameterFactory.Create(layerData.Pop), StateType = PersistableStateType.Pop }); }
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); } } }
/// <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)); }
public void GetPop_ValidSoilLayerData_CreateDesignVariableForPop() { // Setup var data = new MacroStabilityInwardsSoilLayerData { Pop = { Mean = (RoundedDouble)mean, CoefficientOfVariation = (RoundedDouble)coefficientOfVariation } }; // Call VariationCoefficientDesignVariable <VariationCoefficientLogNormalDistribution> pop = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(data); // Assert DistributionAssert.AreEqual(data.Pop, pop.Distribution); AssertPercentile(0.05, pop); }