Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationImporter.cs =================================================================== diff -u -rb09f4737de300a8cdedc66f9d6ade8bffbd4f619 -r28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationImporter.cs (.../StabilityPointStructuresCalculationConfigurationImporter.cs) (revision b09f4737de300a8cdedc66f9d6ade8bffbd4f619) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationImporter.cs (.../StabilityPointStructuresCalculationConfigurationImporter.cs) (revision 28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1) @@ -116,7 +116,8 @@ return null; } - private bool TryReadStochasts(StabilityPointStructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) + private bool TryReadStochasts(StabilityPointStructuresCalculationConfiguration readCalculation, + StructuresCalculation calculation) { if (!readCalculation.ValidateStructureBaseStochasts(Log)) { @@ -134,29 +135,48 @@ readCalculation.AllowedLevelIncreaseStorage, i => i.AllowedLevelIncreaseStorage, (i, d) => i.AllowedLevelIncreaseStorage = d) && TryReadStandardDeviationStochast( + StabilityPointStructuresConfigurationSchemaIdentifiers.AreaFlowAperturesStochastName, + calculation.Name, + calculation.InputParameters, + readCalculation.AreaFlowApertures, + i => i.AreaFlowApertures, (i, d) => i.AreaFlowApertures = d) + && TryReadStandardDeviationStochast( + StabilityPointStructuresConfigurationSchemaIdentifiers.BankWidthStochastName, + calculation.Name, + calculation.InputParameters, + readCalculation.BankWidth, + i => i.BankWidth, (i, d) => i.BankWidth = d) + && TryReadVariationCoefficientStochast( + ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName, + calculation.Name, + calculation.InputParameters, + readCalculation.CriticalOvertoppingDischarge, + i => i.CriticalOvertoppingDischarge, (i, d) => i.CriticalOvertoppingDischarge = d) + && TryReadStandardDeviationStochast( + StabilityPointStructuresConfigurationSchemaIdentifiers.DrainCoefficientStochastName, + calculation.Name, + calculation.InputParameters, + readCalculation.DrainCoefficient, + i => i.DrainCoefficient, (i, d) => i.DrainCoefficient = d) + && TryReadStandardDeviationStochast( ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName, calculation.Name, calculation.InputParameters, readCalculation.FlowWidthAtBottomProtection, i => i.FlowWidthAtBottomProtection, (i, d) => i.FlowWidthAtBottomProtection = d) && TryReadStandardDeviationStochast( - ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName, + StabilityPointStructuresConfigurationSchemaIdentifiers.InsideWaterLevelStochastName, calculation.Name, calculation.InputParameters, - readCalculation.ModelFactorSuperCriticalFlow, - i => i.ModelFactorSuperCriticalFlow, (i, d) => i.ModelFactorSuperCriticalFlow = d) + readCalculation.InsideWaterLevel, + i => i.InsideWaterLevel, (i, d) => i.InsideWaterLevel = d) && TryReadStandardDeviationStochast( - ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName, + ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName, calculation.Name, calculation.InputParameters, - readCalculation.WidthFlowApertures, i => i.WidthFlowApertures, (i, d) => i.WidthFlowApertures = d) + readCalculation.ModelFactorSuperCriticalFlow, + i => i.ModelFactorSuperCriticalFlow, (i, d) => i.ModelFactorSuperCriticalFlow = d) && TryReadVariationCoefficientStochast( - ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName, - calculation.Name, - calculation.InputParameters, - readCalculation.CriticalOvertoppingDischarge, - i => i.CriticalOvertoppingDischarge, (i, d) => i.CriticalOvertoppingDischarge = d) - && TryReadVariationCoefficientStochast( ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName, calculation.Name, calculation.InputParameters, @@ -167,7 +187,18 @@ calculation.Name, calculation.InputParameters, readCalculation.StormDuration, - i => i.StormDuration, (i, d) => i.StormDuration = d); + i => i.StormDuration, (i, d) => i.StormDuration = d) + && TryReadStandardDeviationStochast( + ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName, + calculation.Name, + calculation.InputParameters, + readCalculation.WidthFlowApertures, i => i.WidthFlowApertures, (i, d) => i.WidthFlowApertures = d) + && TryReadStandardDeviationStochast( + StabilityPointStructuresConfigurationSchemaIdentifiers.ThresholdHeightOpenWeirStochastName, + calculation.Name, + calculation.InputParameters, + readCalculation.ThresholdHeightOpenWeir, + i => i.ThresholdHeightOpenWeir, (i, d) => i.ThresholdHeightOpenWeir = d); } private bool ValidateStochasts(StabilityPointStructuresCalculationConfiguration configuration) Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/Configurations/StabilityPointStructuresCalculationConfigurationImporterTest.cs =================================================================== diff -u -rb09f4737de300a8cdedc66f9d6ade8bffbd4f619 -r28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/Configurations/StabilityPointStructuresCalculationConfigurationImporterTest.cs (.../StabilityPointStructuresCalculationConfigurationImporterTest.cs) (revision b09f4737de300a8cdedc66f9d6ade8bffbd4f619) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/Configurations/StabilityPointStructuresCalculationConfigurationImporterTest.cs (.../StabilityPointStructuresCalculationConfigurationImporterTest.cs) (revision 28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1) @@ -23,6 +23,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; @@ -48,6 +50,10 @@ get { yield return new TestCaseData( + "validConfigurationAreaFlowAperturesVariationCoefficient.xml", + "Indien voor parameter 'doorstroomoppervlak' de spreiding wordt opgegeven, moet dit door middel van een standaardafwijking. Voor berekening 'Berekening 1' is een variatiecoëfficiënt gevonden."); + + yield return new TestCaseData( "validConfigurationDrainCoefficientStandardDeviation.xml", "Er kan geen spreiding voor stochast 'afvoercoefficient' opgegeven worden."); yield return new TestCaseData( @@ -239,6 +245,154 @@ CollectionAssert.IsEmpty(calculationGroup.Children); } + [Test] + public void Import_FullCalculationConfiguration_DataAddedToModel() + { + // Setup + string filePath = Path.Combine(importerPath, "validFullConfiguration.xml"); + + var calculationGroup = new CalculationGroup(); + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("Locatie1"); + var foreshoreProfile = new TestForeshoreProfile("profiel1", new List + { + new Point2D(0, 3) + }); + var structure = new TestStabilityPointStructure("kunstwerk1"); + var importer = new StabilityPointStructuresCalculationConfigurationImporter( + filePath, + calculationGroup, + new[] + { + hydraulicBoundaryLocation + }, + new[] + { + foreshoreProfile + }, + new[] + { + structure + }); + + // Call + bool successful = importer.Import(); + + // Assert + Assert.IsTrue(successful); + var expectedCalculation = new StructuresCalculation + { + Name = "Berekening 1", + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation, + Structure = structure, + ForeshoreProfile = foreshoreProfile, + + BankWidth = + { + Mean = (RoundedDouble) 1.2, + StandardDeviation = (RoundedDouble) 0.1 + }, + BreakWater = + { + Height = (RoundedDouble) 1.23, + Type = BreakWaterType.Dam + }, + + FactorStormDurationOpenStructure = (RoundedDouble) 0.002, + FailureProbabilityRepairClosure = 0.001, + FailureProbabilityStructureWithErosion = 0.0001, + + + + + InflowModelType = StabilityPointStructureInflowModelType.FloodedCulvert, + + + + + + + + + + + + + StructureNormalOrientation = (RoundedDouble) 7, + + + + UseBreakWater = true, + UseForeshore = false, + + + + + + + + + StormDuration = + { + Mean = (RoundedDouble) 6.0 + }, + ModelFactorSuperCriticalFlow = + { + Mean = (RoundedDouble) 1.10 + }, + FlowWidthAtBottomProtection = + { + Mean = (RoundedDouble) 15.2, + StandardDeviation = (RoundedDouble) 0.1 + }, + WidthFlowApertures = + { + Mean = (RoundedDouble) 15.2, + StandardDeviation = (RoundedDouble) 0.1 + }, + StorageStructureArea = + { + Mean = (RoundedDouble) 15000, + CoefficientOfVariation = (RoundedDouble) 0.01 + }, + AllowedLevelIncreaseStorage = + { + Mean = (RoundedDouble) 0.2, + StandardDeviation = (RoundedDouble) 0.01 + }, + CriticalOvertoppingDischarge = + { + Mean = (RoundedDouble) 2, + CoefficientOfVariation = (RoundedDouble) 0.1 + }, + + AreaFlowApertures = + { + Mean = (RoundedDouble) 80.5, + StandardDeviation = (RoundedDouble) 1 + }, + DrainCoefficient = + { + Mean = (RoundedDouble) 0.1 + }, + InsideWaterLevel = + { + Mean = (RoundedDouble) 0.5, + StandardDeviation = (RoundedDouble) 0.1 + }, + ThresholdHeightOpenWeir = + { + Mean = (RoundedDouble) 1.2, + StandardDeviation = (RoundedDouble) 0.1 + } + } + }; + + Assert.AreEqual(1, calculationGroup.Children.Count); + AssertCalculation(expectedCalculation, (StructuresCalculation)calculationGroup.Children[0]); + } + private static void AssertCalculation(StructuresCalculation expectedCalculation, StructuresCalculation actualCalculation) { Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validConfigurationAreaFlowAperturesVariationCoefficient.xml =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validConfigurationAreaFlowAperturesVariationCoefficient.xml (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validConfigurationAreaFlowAperturesVariationCoefficient.xml (revision 28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1) @@ -0,0 +1,11 @@ + + + + kunstwerk1 + + + 0.21 + + + + Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validFullConfiguration.xml =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validFullConfiguration.xml (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validFullConfiguration.xml (revision 28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1) @@ -0,0 +1,112 @@ + + + + Locatie1 + 9.81 + 0.002 + kunstwerk1 + 7 + verdronkenkoker + lineair + 0.1 + 2 + 0.001 + 1 + 1E-05 + 0.0001 + profiel1 + + true + havendam + 1.23 + false + + + + 6 + + + 0.5 + 0.1 + + + 0.7 + 0.1 + + + 1.1 + + + 0.1 + + + 15.2 + 0.1 + + + 80.5 + 1 + + + 15.2 + 0.1 + + + 15000 + 0.01 + + + 0.2 + 0.01 + + + 4.3 + 0.1 + + + 1.2 + 0.1 + + + 2 + 0.1 + + + 1.1 + 0.12 + + + 2 + 0.1 + + + 2 + 0.1 + + + 1.2 + 0.1 + + + 1.2 + 0.1 + + + 16000 + 0.1 + + + 1.2 + 0.1 + + + 1.2 + 0.1 + + + 1.2 + 0.1 + + + + \ No newline at end of file