Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Base/HydraRingCalculation.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Base/HydraRingCalculation.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Base/HydraRingCalculation.cs (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -0,0 +1,113 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; +using Ringtoets.HydraRing.Calculation.Data; + +namespace Ringtoets.HydraRing.Calculation.Base +{ + /// + /// Container of all data necessary for performing a Hydra-Ring calculation. + /// + public abstract class HydraRingCalculation + { + private readonly int hydraulicBoundaryLocationId; + + /// + /// Creates a new instance of the class. + /// + /// The id of the hydraulic station to use during the calculation. + protected HydraRingCalculation(int hydraulicBoundaryLocationId) + { + this.hydraulicBoundaryLocationId = hydraulicBoundaryLocationId; + } + + /// + /// Gets the . + /// + public abstract HydraRingFailureMechanismType FailureMechanismType { get; } + + /// + /// Gets the id corresponding to the type of calculation that should be performed. + /// + public abstract int CalculationTypeId { get; } + + /// + /// Gets the id of the hydraulic station to use during the calculation. + /// + public int HydraulicBoundaryLocationId + { + get + { + return hydraulicBoundaryLocationId; + } + } + + /// + /// Gets the dike section to perform the calculation for. + /// + public abstract HydraRingDikeSection DikeSection { get; } + + /// + /// Gets the variables to use during the calculation. + /// + public virtual IEnumerable Variables + { + get + { + yield break; + } + } + + /// + /// Gets the profile points to use during the calculation. + /// + public virtual IEnumerable ProfilePoints + { + get + { + yield break; + } + } + + /// + /// Gets the target reliability index to use during the calculation. + /// + /// Only relevant for type 2 computations. + public virtual double Beta + { + get + { + return double.NaN; + } + } + + /// + /// Gets the sub mechanism model id corresponding to the provided sub mechanism id. + /// + /// The sub mechanim id to get the sub mechanism model id for. + /// The corresponding sub mechanism model id or null otherwise. + public virtual int? GetSubMechanismModelId(int subMechanismId) + { + return null; + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Base/HydraRingConfiguration.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Base/HydraRingConfiguration.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Base/HydraRingConfiguration.cs (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -0,0 +1,708 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Globalization; +using System.Linq; +using Ringtoets.HydraRing.Calculation.Data; +using Ringtoets.HydraRing.Calculation.Settings; + +namespace Ringtoets.HydraRing.Calculation.Base +{ + /// + /// Container for all configurations that are necessary for performing a Hydra-Ring calculation. + /// The following Hydra-Ring features are not exposed (yet): + /// + /// + /// Combination of multiple dike sections + /// + /// + /// Coupling two hydraulic boundary stations + /// + /// + /// Performing revetment calculations (DesignTables > LayerId) + /// + /// + /// Performing piping calculations (DesignTables > AlternativeId) + /// + /// + /// Type 3 computations (DesignTables > Method) + /// + /// + /// In the end, the configuration can be used to generate a Hydra-Ring database creation script. + /// + public class HydraRingConfiguration + { + private const double defaultLayerId = 1; + private const double defaultAlternativeId = 1; + private const double defaultHydraRingValue = 0.0; + + private readonly string ringId; + private readonly IList hydraRingCalculations; + private readonly SubMechanismSettingsProvider subMechanismSettingsProvider = new SubMechanismSettingsProvider(); + private readonly FailureMechanismSettingsProvider failureMechanismSettingsProvider = new FailureMechanismSettingsProvider(); + private readonly FailureMechanismDefaultsProvider failureMechanismDefaultsProvider = new FailureMechanismDefaultsProvider(); + private readonly VariableDefaultsProvider variableDefaultsProvider = new VariableDefaultsProvider(); + private readonly HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType; + private readonly HydraRingUncertaintiesType uncertaintiesType; + + /// + /// Creates a new instance of the class. + /// + /// The id of the ring to perform the configured Hydra-Ring calculations for. + /// The to use while executing the configured Hydra-Ring calculations. + /// The to use while executing the configured Hydra-Ring calculations. + public HydraRingConfiguration(string ringId, HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType, HydraRingUncertaintiesType uncertaintiesType) + { + hydraRingCalculations = new List(); + + this.ringId = ringId; + this.timeIntegrationSchemeType = timeIntegrationSchemeType; + this.uncertaintiesType = uncertaintiesType; + } + + /// + /// Gets the id of the ring to perform the configured Hydra-Ring calculations for. + /// + public string RingId + { + get + { + return ringId; + } + } + + /// + /// Gets the to use while executing the configured Hydra-Ring calculations. + /// + public HydraRingTimeIntegrationSchemeType? TimeIntegrationSchemeType + { + get + { + return timeIntegrationSchemeType; + } + } + + /// + /// Gets the to use while executing the configured Hydra-Ring calculations. + /// + public HydraRingUncertaintiesType? UncertaintiesType + { + get + { + return uncertaintiesType; + } + } + + /// + /// Adds a Hydra-Ring calculation to the . + /// + /// The container that holds all data for configuring the calculation. + public void AddHydraRingCalculation(HydraRingCalculation hydraRingCalculation) + { + hydraRingCalculations.Add(hydraRingCalculation); + } + + /// + /// Generates a database creation script that can be used to perform a Hydra-Ring calculation. + /// + /// The database creation script. + /// Thrown when one of the relevant input properties is not set. + public string GenerateDataBaseCreationScript() + { + var configurationDictionary = new Dictionary>(); + + InitializeHydraulicModelsConfiguration(configurationDictionary); + InitializeSectionsConfiguration(configurationDictionary); + InitializeDesignTablesConfiguration(configurationDictionary); + InitializeNumericsConfiguration(configurationDictionary); + InitializeVariableDatasConfiguration(configurationDictionary); + InitializeCalculationProfilesConfiguration(configurationDictionary); + InitializeSectionFaultTreeModelsConfiguration(configurationDictionary); + InitializeSectionSubMechanismModelsConfiguration(configurationDictionary); + InitializeFetchesConfiguration(configurationDictionary); + InitializeAreaPointsConfiguration(configurationDictionary); + InitializePresentationSectionsConfiguration(configurationDictionary); + InitializeProfilesConfiguration(configurationDictionary); + InitializeForelandModelsConfiguration(configurationDictionary); + InitializeForelandsConfiguration(configurationDictionary); + InitializeProbabilityAlternativesConfiguration(configurationDictionary); + InitializeSetUpHeightsConfiguration(configurationDictionary); + InitializeCalcWindDirectionsConfiguration(configurationDictionary); + InitializeSwellsConfiguration(configurationDictionary); + InitializeWaveReductionsConfiguration(configurationDictionary); + InitializeAreasConfiguration(configurationDictionary); + InitializeProjectsConfiguration(configurationDictionary); + + return GenerateDataBaseCreationScript(configurationDictionary); + } + + private void InitializeHydraulicModelsConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["HydraulicModels"] = new List + { + new OrderedDictionary + { + { + "TimeIntegrationSchemeID", (int?) TimeIntegrationSchemeType + }, + { + "UncertaintiesID", (int?) UncertaintiesType + }, + { + "DataSetName", "WTI 2017" // Fixed: use the WTI 2017 set of station locations + } + } + }; + } + + private void InitializeSectionsConfiguration(Dictionary> configurationDictionary) + { + var orderedDictionaries = new List(); + + foreach (var hydraRingCalculation in hydraRingCalculations) + { + var hydraRingDikeSection = hydraRingCalculation.DikeSection; + + orderedDictionaries.Add(new OrderedDictionary + { + { + "SectionId", hydraRingDikeSection.SectionId + }, + { + "PresentationId", 1 // Fixed: no support for combination of multiple dike sections + }, + { + "MainMechanismId", 1 // Fixed: no support for combination of multiple dike sections + }, + { + "Name", hydraRingDikeSection.SectionName + }, + { + "Description", hydraRingDikeSection.SectionName // Just use the section name + }, + { + "RingCoordinateBegin", GetHydraRingValue(hydraRingDikeSection.SectionBeginCoordinate) + }, + { + "RingCoordinateEnd", GetHydraRingValue(hydraRingDikeSection.SectionEndCoordinate) + }, + { + "XCoordinate", GetHydraRingValue(hydraRingDikeSection.CrossSectionXCoordinate) + }, + { + "YCoordinate", GetHydraRingValue(hydraRingDikeSection.CrossSectionYCoordinate) + }, + { + "StationId1", hydraRingCalculation.HydraulicBoundaryLocationId + }, + { + "StationId2", hydraRingCalculation.HydraulicBoundaryLocationId // Same as "StationId1": no support for coupling two stations + }, + { + "Relative", 100.0 // Fixed: no support for coupling two stations + }, + { + "Normal", GetHydraRingValue(hydraRingDikeSection.CrossSectionNormal) + }, + { + "Length", GetHydraRingValue(hydraRingDikeSection.SectionLength) + } + }); + } + + configurationDictionary["Sections"] = orderedDictionaries; + } + + private void InitializeDesignTablesConfiguration(Dictionary> configurationDictionary) + { + var orderedDictionaries = new List(); + + foreach (var hydraRingCalculation in hydraRingCalculations) + { + var failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculation.FailureMechanismType); + var failureMechanismSettings = failureMechanismSettingsProvider.GetFailureMechanismSettings(hydraRingCalculation.FailureMechanismType); + + orderedDictionaries.Add(new OrderedDictionary + { + { + "SectionId", hydraRingCalculation.DikeSection.SectionId + }, + { + "MechanismId", failureMechanismDefaults.MechanismId + }, + { + "LayerId", defaultLayerId // Fixed: no support for revetments + }, + { + "AlternativeId", defaultAlternativeId // Fixed: no support for piping + }, + { + "Method", hydraRingCalculation.CalculationTypeId + }, + { + "VariableId", failureMechanismDefaults.VariableId + }, + { + "LoadVariableId", defaultHydraRingValue // Fixed: not relevant + }, + { + "TableMin", defaultHydraRingValue // Fixed: no support for type 3 computations (see "Method") + }, + { + "TableMax", defaultHydraRingValue // Fixed: no support for type 3 computations (see "Method") + }, + { + "TableStepSize", defaultHydraRingValue // Fixed: no support for type 3 computations (see "Method") + }, + { + "ValueMin", GetHydraRingValue(failureMechanismSettings.ValueMin) + }, + { + "ValueMax", GetHydraRingValue(failureMechanismSettings.ValueMax) + }, + { + "Beta", GetHydraRingValue(hydraRingCalculation.Beta) + } + }); + } + + configurationDictionary["DesignTables"] = orderedDictionaries; + } + + private void InitializeNumericsConfiguration(Dictionary> configurationDictionary) + { + var orderDictionaries = new List(); + + foreach (var hydraRingCalculation in hydraRingCalculations) + { + var failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculation.FailureMechanismType); + + foreach (var subMechanimsId in failureMechanismDefaults.SubMechanismIds) + { + var subMechanismSettings = subMechanismSettingsProvider.GetSubMechanismSettings(hydraRingCalculation.FailureMechanismType, subMechanimsId, ringId); + + orderDictionaries.Add(new OrderedDictionary + { + { + "SectionId", hydraRingCalculation.DikeSection.SectionId + }, + { + "MechanismId", failureMechanismDefaults.MechanismId + }, + { + "LayerId", defaultLayerId // Fixed: no support for revetments + }, + { + "AlternativeId", defaultAlternativeId // Fixed: no support for piping + }, + { + "SubMechanismId", subMechanimsId + }, + { + "Method", subMechanismSettings.CalculationTechniqueId + }, + { + "FormStartMethod", subMechanismSettings.FormStartMethod + }, + { + "FormNumberOfIterations", subMechanismSettings.FormNumberOfIterations + }, + { + "FormRelaxationFactor", GetHydraRingValue(subMechanismSettings.FormRelaxationFactor) + }, + { + "FormEpsBeta", GetHydraRingValue(subMechanismSettings.FormEpsBeta) + }, + { + "FormEpsHOH", GetHydraRingValue(subMechanismSettings.FormEpsHoh) + }, + { + "FormEpsZFunc", GetHydraRingValue(subMechanismSettings.FormEpsZFunc) + }, + { + "DsStartMethod", subMechanismSettings.DsStartMethod + }, + { + "DsIterationmethod", 1 // Fixed: not relevant + }, + { + "DsMinNumberOfIterations", subMechanismSettings.DsMinNumberOfIterations + }, + { + "DsMaxNumberOfIterations", subMechanismSettings.DsMaxNumberOfIterations + }, + { + "DsVarCoefficient", GetHydraRingValue(subMechanismSettings.DsVarCoefficient) + }, + { + "NiUMin", GetHydraRingValue(subMechanismSettings.NiUMin) + }, + { + "NiUMax", GetHydraRingValue(subMechanismSettings.NiUMax) + }, + { + "NiNumberSteps", subMechanismSettings.NiNumberSteps + } + }); + } + } + + configurationDictionary["Numerics"] = orderDictionaries; + } + + private void InitializeVariableDatasConfiguration(Dictionary> configurationDictionary) + { + var orderDictionaries = new List(); + + foreach (var hydraRingCalculation in hydraRingCalculations) + { + var failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculation.FailureMechanismType); + + foreach (var hydraRingVariable in hydraRingCalculation.Variables) + { + var variableDefaults = variableDefaultsProvider.GetVariableDefaults(hydraRingCalculation.FailureMechanismType, hydraRingVariable.VariableId); + + orderDictionaries.Add(new OrderedDictionary + { + { + "SectionId", hydraRingCalculation.DikeSection.SectionId + }, + { + "MechanismId", failureMechanismDefaults.MechanismId + }, + { + "LayerId", defaultLayerId // Fixed: no support for revetments + }, + { + "AlternativeId", defaultAlternativeId // Fixed: no support for piping + }, + { + "VariableId", hydraRingVariable.VariableId + }, + { + "Value", hydraRingVariable.DistributionType == HydraRingDistributionType.Deterministic + ? GetHydraRingValue(hydraRingVariable.Value) + : defaultHydraRingValue + }, + { + "DistributionType", (int?) hydraRingVariable.DistributionType + }, + { + "Parameter1", hydraRingVariable.DistributionType != HydraRingDistributionType.Deterministic + ? GetHydraRingValue(hydraRingVariable.Mean) + : defaultHydraRingValue + }, + { + "Parameter2", hydraRingVariable.DistributionType != HydraRingDistributionType.Deterministic + && hydraRingVariable.DeviationType == HydraRingDeviationType.Standard + ? GetHydraRingValue(hydraRingVariable.Variability) + : defaultHydraRingValue + }, + { + "Parameter3", hydraRingVariable.DistributionType == HydraRingDistributionType.LogNormal + ? GetHydraRingValue(hydraRingVariable.Shift) + : defaultHydraRingValue + }, + { + "Parameter4", defaultHydraRingValue // Fixed: Not relevant + }, + { + "DeviationType", (int?) hydraRingVariable.DeviationType + }, + { + "CoefficientOfVariation", hydraRingVariable.DistributionType != HydraRingDistributionType.Deterministic + && hydraRingVariable.DeviationType == HydraRingDeviationType.Variation + ? GetHydraRingValue(hydraRingVariable.Variability) + : defaultHydraRingValue + }, + { + "CorrelationLength", GetHydraRingValue(variableDefaults.CorrelationLength) + } + }); + } + } + + configurationDictionary["VariableDatas"] = orderDictionaries; + } + + private void InitializeCalculationProfilesConfiguration(Dictionary> configurationDictionary) + { + var orderDictionaries = new List(); + + foreach (var hydraRingCalculation in hydraRingCalculations) + { + for (var i = 0; i < hydraRingCalculation.ProfilePoints.Count(); i++) + { + var hydraRingProfilePoint = hydraRingCalculation.ProfilePoints.ElementAt(i); + + orderDictionaries.Add(new OrderedDictionary + { + { + "SectionId", hydraRingCalculation.DikeSection.SectionId + }, + { + "SequenceNumber", i + 1 + }, + { + "XCoordinate", GetHydraRingValue(hydraRingProfilePoint.X) + }, + { + "ZCoordinate", GetHydraRingValue(hydraRingProfilePoint.Z) + }, + { + "Roughness", GetHydraRingValue(hydraRingProfilePoint.Roughness) + } + }); + } + } + + configurationDictionary["CalculationProfiles"] = orderDictionaries; + } + + private void InitializeSectionFaultTreeModelsConfiguration(Dictionary> configurationDictionary) + { + var orderedDictionaries = new List(); + + foreach (var hydraRingCalculation in hydraRingCalculations) + { + var failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculation.FailureMechanismType); + var failureMechanismSettings = failureMechanismSettingsProvider.GetFailureMechanismSettings(hydraRingCalculation.FailureMechanismType); + + orderedDictionaries.Add(new OrderedDictionary + { + { + "SectionId", hydraRingCalculation.DikeSection.SectionId + }, + { + "MechanismId", failureMechanismDefaults.MechanismId + }, + { + "LayerId", defaultLayerId // Fixed: no support for revetments + }, + { + "AlternativeId", defaultAlternativeId // Fixed: no support for piping + }, + { + "FaultTreeModelId", failureMechanismSettings.FaultTreeModelId + } + }); + } + + configurationDictionary["SectionFaultTreeModels"] = orderedDictionaries; + } + + private void InitializeSectionSubMechanismModelsConfiguration(Dictionary> configurationDictionary) + { + var orderedDictionaries = new List(); + + foreach (var hydraRingCalculation in hydraRingCalculations) + { + var failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculation.FailureMechanismType); + + foreach (var subMechanismId in failureMechanismDefaults.SubMechanismIds) + { + var subMechanismModelId = hydraRingCalculation.GetSubMechanismModelId(subMechanismId); + + if (subMechanismModelId != null) + { + orderedDictionaries.Add(new OrderedDictionary + { + { + "SectionId", hydraRingCalculation.DikeSection.SectionId + }, + { + "MechanismId", failureMechanismDefaults.MechanismId + }, + { + "LayerId", defaultLayerId // Fixed: no support for revetments + }, + { + "AlternativeId", defaultAlternativeId // Fixed: no support for piping + }, + { + "SubMechanismId", subMechanismId + }, + { + "SubMechanismModelId", subMechanismModelId + } + }); + } + } + } + + configurationDictionary["SectionSubMechanismModels"] = orderedDictionaries; + } + + private void InitializeFetchesConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["Fetches"] = new List(); + } + + private void InitializeAreaPointsConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["AreaPoints"] = new List(); + } + + private void InitializePresentationSectionsConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["PresentationSections"] = new List(); + } + + private void InitializeProfilesConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["Profiles"] = new List(); + } + + private void InitializeForelandModelsConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["ForelandModels"] = new List(); + } + + private void InitializeForelandsConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["Forelands"] = new List(); + } + + private void InitializeProbabilityAlternativesConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["ProbabilityAlternatives"] = new List(); + } + + private void InitializeSetUpHeightsConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["SetUpHeights"] = new List(); + } + + private void InitializeCalcWindDirectionsConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["CalcWindDirections"] = new List(); + } + + private void InitializeSwellsConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["Swells"] = new List(); + } + + private void InitializeWaveReductionsConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["WaveReductions"] = new List(); + } + + private void InitializeAreasConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["Areas"] = new List + { + new OrderedDictionary + { + { + "aDefault", 1 // Fixed: not relevant + }, + { + "bDefault", "1" // Fixed: not relevant + }, + { + "cDefault", "Nederland" // Fixed: not relevant + } + } + }; + } + + private void InitializeProjectsConfiguration(Dictionary> configurationDictionary) + { + configurationDictionary["Projects"] = new List + { + new OrderedDictionary + { + { + "aDefault", 1 // Fixed: not relevant + }, + { + "bDefault", "WTI 2017" // Fixed: not relevant + }, + { + "cDefault", "Ringtoets calculation" // Fixed: not relevant + } + } + }; + } + + private static string GenerateDataBaseCreationScript(Dictionary> configurationDictionary) + { + var lines = new List(); + + foreach (var tableName in configurationDictionary.Keys) + { + lines.Add("DELETE FROM [" + tableName + "];"); + + if (configurationDictionary[tableName].Count <= 0) + { + lines.Add(""); + + continue; + } + + foreach (var orderedDictionary in configurationDictionary[tableName]) + { + var valueStrings = new List(); + + foreach (var val in orderedDictionary.Values) + { + if (val == null) + { + valueStrings.Add("NULL"); + continue; + } + + if (val is string) + { + valueStrings.Add("'" + val + "'"); + continue; + } + + if (val is double) + { + valueStrings.Add(((double) val).ToString(CultureInfo.InvariantCulture)); + continue; + } + + valueStrings.Add(val.ToString()); + } + + var valuesString = string.Join(", ", valueStrings); + + lines.Add("INSERT INTO [" + tableName + "] VALUES (" + valuesString + ");"); + } + + lines.Add(""); + } + + return string.Join(Environment.NewLine, lines); + } + + private double? GetHydraRingValue(double value) + { + return !double.IsNaN(value) ? value : defaultHydraRingValue; + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Base/IterateTowardsTargetProbabilityCalculation.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Base/IterateTowardsTargetProbabilityCalculation.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Base/IterateTowardsTargetProbabilityCalculation.cs (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -0,0 +1,57 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.HydraRing.Calculation.Base +{ + /// + /// Container of all data necessary for performing a type-2 calculation via Hydra-Ring ("iterate towards a target probability, provided as reliability index"). + /// + public abstract class IterateTowardsTargetProbabilityCalculation : HydraRingCalculation + { + private readonly double beta; + + /// + /// Creates a new instance of the class. + /// + /// The id of the hydraulic station to use during the calculation. + /// The reliability index to use during the calculation. + protected IterateTowardsTargetProbabilityCalculation(int hydraulicBoundaryLocationId, double beta) : base(hydraulicBoundaryLocationId) + { + this.beta = beta; + } + + public override int CalculationTypeId + { + get + { + return 2; + } + } + + public override double Beta + { + get + { + return beta; + } + } + } +} \ No newline at end of file Fisheye: Tag ace9ccbb49504742caff42a44fdd4c79d5217424 refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingCalculation.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ace9ccbb49504742caff42a44fdd4c79d5217424 refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingCalculator.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ace9ccbb49504742caff42a44fdd4c79d5217424 refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingConfiguration.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ace9ccbb49504742caff42a44fdd4c79d5217424 refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Hydraulics/AssessmentLevelCalculation.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ace9ccbb49504742caff42a44fdd4c79d5217424 refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Hydraulics/IterateTowardsTargetProbabilityCalculation.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj =================================================================== diff -u -re58872a87106093853d59f6cae8f57e63b623202 -race9ccbb49504742caff42a44fdd4c79d5217424 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision e58872a87106093853d59f6cae8f57e63b623202) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -41,9 +41,9 @@ - - - + + + True @@ -61,9 +61,9 @@ - + - + Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingCalculationService.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingCalculationService.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/HydraRingCalculationService.cs (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -0,0 +1,121 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using Ringtoets.HydraRing.Calculation.Base; +using Ringtoets.HydraRing.Calculation.Data; +using Ringtoets.HydraRing.Calculation.Settings; + +namespace Ringtoets.HydraRing.Calculation.Service +{ + /// + /// Static class that provides methods for performing Hydra-Ring calculations. + /// + public static class HydraRingCalculationService + { + /// + /// This method performs a single failure mechanism calculation via Hydra-Ring. + /// + /// The directory of the HLCD file that should be used for performing the failure mechanism calculation. + /// The id of the ring to perform the failure mechanism calculation for. + /// The to use while executing the failure mechanism calculation. + /// The to use while executing the failure mechanism calculation. + /// The failure mechanism calculation to perform. + public static void PerformFailureMechanismCalculation(string hlcdDirectory, string ringId, HydraRingTimeIntegrationSchemeType timeIntegrationSchemeType, HydraRingUncertaintiesType uncertaintiesType, HydraRingCalculation hydraRingCalculation) + { + var hydraulicBoundaryLocationId = hydraRingCalculation.HydraulicBoundaryLocationId; + var mechanismId = new FailureMechanismDefaultsProvider().GetFailureMechanismDefaults(hydraRingCalculation.FailureMechanismType).MechanismId; + + // Create a Hydra-Ring configuration + var hydraRingConfiguration = new HydraRingConfiguration(ringId, timeIntegrationSchemeType, uncertaintiesType); + hydraRingConfiguration.AddHydraRingCalculation(hydraRingCalculation); + + // Calculation file names + var outputFileName = "designTable.txt"; + var logFileName = hydraulicBoundaryLocationId + ".log"; + var iniFileName = hydraulicBoundaryLocationId + ".ini"; + var dataBaseCreationScriptFileName = hydraulicBoundaryLocationId + ".sql"; + + // Obtain some calculation file paths + var workingDirectory = CreateWorkingDirectory(hydraulicBoundaryLocationId.ToString()); + var iniFilePath = Path.Combine(workingDirectory, iniFileName); + var dataBaseCreationScriptFilePath = Path.Combine(workingDirectory, dataBaseCreationScriptFileName); + var hlcdFilePath = Path.Combine(hlcdDirectory, "HLCD.sqlite"); + + // Obtain some Hydra-Ring related paths + var hydraRingDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"HydraRing"); + var mechanismComputationExeFilePath = Path.Combine(hydraRingDirectory, "MechanismComputation.exe"); + var configurationDatabaseFilePath = Path.Combine(hydraRingDirectory, "config.sqlite"); + + // Write the ini file + File.WriteAllLines(Path.Combine(workingDirectory, iniFilePath), new List + { + "section = " + hydraulicBoundaryLocationId, + "mechanism = " + mechanismId, + "alternative = 1", // Fixed: no support for piping + "layer = 1", // Fixed: no support for revetments + "logfile = " + logFileName, + "outputverbosity = basic", + "outputtofile = file", + "projectdbfilename = " + dataBaseCreationScriptFileName, + "outputfilename = " + outputFileName, + "configdbfilename = " + configurationDatabaseFilePath, + "hydraulicdbfilename = " + hlcdFilePath + }); + + // Write the database creation script + File.WriteAllText(dataBaseCreationScriptFilePath, hydraRingConfiguration.GenerateDataBaseCreationScript()); + + // Perform the calculation + var hydraRingProcess = new Process + { + StartInfo = new ProcessStartInfo(mechanismComputationExeFilePath, iniFilePath) + { + WorkingDirectory = workingDirectory, + UseShellExecute = false, + CreateNoWindow = true + } + }; + + hydraRingProcess.Start(); + hydraRingProcess.WaitForExit(); + + // TODO: Parse output + } + + private static string CreateWorkingDirectory(string folderName) + { + var workingDirectory = Path.Combine(Path.GetTempPath(), folderName); + + if (Directory.Exists(workingDirectory)) + { + Directory.Delete(workingDirectory, true); + } + + Directory.CreateDirectory(workingDirectory); + + return workingDirectory; + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/Hydraulics/AssessmentLevelCalculation.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/Hydraulics/AssessmentLevelCalculation.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Service/Hydraulics/AssessmentLevelCalculation.cs (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -0,0 +1,74 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; +using Ringtoets.HydraRing.Calculation.Base; +using Ringtoets.HydraRing.Calculation.Data; + +namespace Ringtoets.HydraRing.Calculation.Service.Hydraulics +{ + /// + /// Container of all data necessary for performing an assessment level calculation via Hydra-Ring. + /// + public class AssessmentLevelCalculation : IterateTowardsTargetProbabilityCalculation + { + private readonly HydraRingDikeSection dikeSection; + + /// + /// Creates a new instance of the class. + /// + /// The id of the hydraulic station to use during the calculation. + /// The reliability index to use during the calculation. + public AssessmentLevelCalculation(int hydraulicBoundaryLocationId, double beta) : base(hydraulicBoundaryLocationId, beta) + { + dikeSection = new HydraRingDikeSection(HydraulicBoundaryLocationId, HydraulicBoundaryLocationId.ToString(), double.NaN, double.NaN, double.NaN, double.NaN, double.NaN, double.NaN); + } + + public override HydraRingFailureMechanismType FailureMechanismType + { + get + { + return HydraRingFailureMechanismType.AssessmentLevel; + } + } + + public override HydraRingDikeSection DikeSection + { + get + { + return dikeSection; + } + } + + public override IEnumerable Variables + { + get + { + yield return new AssessmentLevelVariable(); + } + } + + private class AssessmentLevelVariable : HydraRingVariable + { + public AssessmentLevelVariable() : base(26, HydraRingDistributionType.Deterministic, 0, HydraRingDeviationType.Standard, double.NaN, double.NaN, double.NaN) {} + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Base/HydraRingCalculationTest.cs =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Base/HydraRingCalculationTest.cs (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Base/HydraRingCalculationTest.cs (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -0,0 +1,100 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using NUnit.Framework; +using Ringtoets.HydraRing.Calculation.Base; +using Ringtoets.HydraRing.Calculation.Data; + +namespace Ringtoets.HydraRing.Calculation.Test.Base +{ + [TestFixture] + public class HydraRingCalculationTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var hydraRingCalculation = new HydraRingCalculationImplementation(1); + + // Assert + Assert.AreEqual(1, hydraRingCalculation.HydraulicBoundaryLocationId); + Assert.AreEqual(HydraRingFailureMechanismType.QVariant, hydraRingCalculation.FailureMechanismType); + Assert.AreEqual(4, hydraRingCalculation.CalculationTypeId); + CollectionAssert.IsEmpty(hydraRingCalculation.Variables); + CollectionAssert.IsEmpty(hydraRingCalculation.ProfilePoints); + Assert.IsNaN(hydraRingCalculation.Beta); + } + + [Test] + public void GetSubMechanismModelId_ReturnsExpectedValues() + { + // Call + var hydraRingCalculation = new HydraRingCalculationImplementation(1); + + // Assert + Assert.AreEqual(10, hydraRingCalculation.GetSubMechanismModelId(1)); + Assert.AreEqual(20, hydraRingCalculation.GetSubMechanismModelId(2)); + Assert.IsNull(hydraRingCalculation.GetSubMechanismModelId(3)); + } + + private class HydraRingCalculationImplementation : HydraRingCalculation + { + public HydraRingCalculationImplementation(int hydraulicBoundaryLocationId) : base(hydraulicBoundaryLocationId) {} + + public override HydraRingFailureMechanismType FailureMechanismType + { + get + { + return HydraRingFailureMechanismType.QVariant; + } + } + + public override int CalculationTypeId + { + get + { + return 4; + } + } + + public override HydraRingDikeSection DikeSection + { + get + { + return new HydraRingDikeSection(1, "Name", 2.2, 3.3, 4.4, 5.5, 6.6, 7.7); + } + } + + public override int? GetSubMechanismModelId(int subMechanismId) + { + switch (subMechanismId) + { + case 1: + return 10; + case 2: + return 20; + default: + return null; + } + } + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Base/HydraRingConfigurationTest.cs =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Base/HydraRingConfigurationTest.cs (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Base/HydraRingConfigurationTest.cs (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -0,0 +1,203 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using NUnit.Framework; +using Ringtoets.HydraRing.Calculation.Base; +using Ringtoets.HydraRing.Calculation.Data; + +namespace Ringtoets.HydraRing.Calculation.Test.Base +{ + [TestFixture] + public class HydraRingConfigurationTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var hydraRingConfiguration = new HydraRingConfiguration("34-1", HydraRingTimeIntegrationSchemeType.NTI, HydraRingUncertaintiesType.Model); + + // Assert + Assert.AreEqual("34-1", hydraRingConfiguration.RingId); + Assert.AreEqual(HydraRingTimeIntegrationSchemeType.NTI, hydraRingConfiguration.TimeIntegrationSchemeType); + Assert.AreEqual(HydraRingUncertaintiesType.Model, hydraRingConfiguration.UncertaintiesType); + } + + [Test] + public void GenerateDataBaseCreationScript_NonDefaultHydraRingConfiguration_ReturnsExpectedCreationScript() + { + var hydraRingConfiguration = new HydraRingConfiguration("34-1", HydraRingTimeIntegrationSchemeType.NTI, HydraRingUncertaintiesType.Model); + + hydraRingConfiguration.AddHydraRingCalculation(new HydraRingCalculationImplementation(700004)); + + var expectedCreationScript = "DELETE FROM [HydraulicModels];" + Environment.NewLine + + "INSERT INTO [HydraulicModels] VALUES (3, 2, 'WTI 2017');" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Sections];" + Environment.NewLine + + "INSERT INTO [Sections] VALUES (9999, 1, 1, 'LocationName', 'LocationName', 2.2, 3.3, 5.5, 6.6, 700004, 700004, 100, 7.7, 4.4);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [DesignTables];" + Environment.NewLine + + "INSERT INTO [DesignTables] VALUES (9999, 1, 1, 1, 4, 26, 0, 0, 0, 0, 0, 50, 1.1);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Numerics];" + Environment.NewLine + + "INSERT INTO [Numerics] VALUES (9999, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [VariableDatas];" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 2.2, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 22.2, 0, 0, 0, 0, 0, 1, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 0, 2, 333.3, 444.4, 0, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 0, 2, 3333.3, 0, 0, 0, 1, 4444.4, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 0, 4, 33333.3, 44444.4, 55555.5, 0, 0, 0, 300);" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (9999, 1, 1, 1, 26, 0, 4, 333333.3, 0, 555555.5, 0, 1, 444444.4, 300);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [CalculationProfiles];" + Environment.NewLine + + "INSERT INTO [CalculationProfiles] VALUES (9999, 1, 1.1, 2.2, 3.3);" + Environment.NewLine + + "INSERT INTO [CalculationProfiles] VALUES (9999, 2, 11.1, 22.2, 33.3);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [SectionFaultTreeModels];" + Environment.NewLine + + "INSERT INTO [SectionFaultTreeModels] VALUES (9999, 1, 1, 1, 1);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [SectionSubMechanismModels];" + Environment.NewLine + + "INSERT INTO [SectionSubMechanismModels] VALUES (9999, 1, 1, 1, 1, 1234);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Fetches];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [AreaPoints];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [PresentationSections];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Profiles];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [ForelandModels];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Forelands];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [ProbabilityAlternatives];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [SetUpHeights];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [CalcWindDirections];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Swells];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [WaveReductions];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Areas];" + Environment.NewLine + + "INSERT INTO [Areas] VALUES (1, '1', 'Nederland');" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Projects];" + Environment.NewLine + + "INSERT INTO [Projects] VALUES (1, 'WTI 2017', 'Ringtoets calculation');" + Environment.NewLine; + + var creationScript = hydraRingConfiguration.GenerateDataBaseCreationScript(); + + Assert.AreEqual(expectedCreationScript, creationScript); + } + + private class HydraRingCalculationImplementation : HydraRingCalculation + { + public HydraRingCalculationImplementation(int hydraulicBoundaryLocationId) : base(hydraulicBoundaryLocationId) {} + + public override HydraRingFailureMechanismType FailureMechanismType + { + get + { + return HydraRingFailureMechanismType.AssessmentLevel; + } + } + + public override int CalculationTypeId + { + get + { + return 4; + } + } + + public override HydraRingDikeSection DikeSection + { + get + { + return new HydraRingDikeSection(9999, "LocationName", 2.2, 3.3, 4.4, 5.5, 6.6, 7.7); + } + } + + public override IEnumerable Variables + { + get + { + yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.Deterministic, 2.2, HydraRingDeviationType.Standard, 3.3, 4.4, 5.5); + yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.Deterministic, 22.2, HydraRingDeviationType.Variation, 33.3, 44.4, 55.5); + yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.Normal, 222.2, HydraRingDeviationType.Standard, 333.3, 444.4, 555.5); + yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.Normal, 2222.2, HydraRingDeviationType.Variation, 3333.3, 4444.4, 5555.5); + yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.LogNormal, 22222.2, HydraRingDeviationType.Standard, 33333.3, 44444.4, 55555.5); + yield return new HydraRingVariableImplementation(26, HydraRingDistributionType.LogNormal, 222222.2, HydraRingDeviationType.Variation, 333333.3, 444444.4, 555555.5); + } + } + + public override IEnumerable ProfilePoints + { + get + { + yield return new HydraRingProfilePointDerivative(1.1, 2.2, 3.3); + yield return new HydraRingProfilePointDerivative(11.1, 22.2, 33.3); + } + } + + public override double Beta + { + get + { + return 1.1; + } + } + + public override int? GetSubMechanismModelId(int subMechanismId) + { + return 1234; + } + } + + private class HydraRingVariableImplementation : HydraRingVariable + { + public HydraRingVariableImplementation(int variableId, HydraRingDistributionType distributionType, double value, HydraRingDeviationType deviationType, double mean, double variability, double shift) + : base(variableId, distributionType, value, deviationType, mean, variability, shift) {} + } + + private class HydraRingProfilePointDerivative : HydraRingProfilePoint + { + private readonly double roughness; + + public HydraRingProfilePointDerivative(double x, double z, double roughness) : base(x, z) + { + this.roughness = roughness; + } + + public override double Roughness + { + get + { + return roughness; + } + } + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Base/IterateTowardsTargetProbabilityCalculationTest.cs =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Base/IterateTowardsTargetProbabilityCalculationTest.cs (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Base/IterateTowardsTargetProbabilityCalculationTest.cs (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -0,0 +1,67 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using NUnit.Framework; +using Ringtoets.HydraRing.Calculation.Base; +using Ringtoets.HydraRing.Calculation.Data; + +namespace Ringtoets.HydraRing.Calculation.Test.Base +{ + [TestFixture] + public class IterateTowardsTargetProbabilityCalculationTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var iterateTowardsTargetProbabilityCalculationImplementation = new IterateTowardsTargetProbabilityCalculationImplementation(1, 2.2); + + // Assert + Assert.AreEqual(1, iterateTowardsTargetProbabilityCalculationImplementation.HydraulicBoundaryLocationId); + Assert.AreEqual(HydraRingFailureMechanismType.DikesPiping, iterateTowardsTargetProbabilityCalculationImplementation.FailureMechanismType); + Assert.AreEqual(2, iterateTowardsTargetProbabilityCalculationImplementation.CalculationTypeId); + CollectionAssert.IsEmpty(iterateTowardsTargetProbabilityCalculationImplementation.Variables); + CollectionAssert.IsEmpty(iterateTowardsTargetProbabilityCalculationImplementation.ProfilePoints); + Assert.AreEqual(2.2, iterateTowardsTargetProbabilityCalculationImplementation.Beta); + } + + private class IterateTowardsTargetProbabilityCalculationImplementation : IterateTowardsTargetProbabilityCalculation + { + public IterateTowardsTargetProbabilityCalculationImplementation(int hydraulicBoundaryLocationId, double beta) : base(hydraulicBoundaryLocationId, beta) {} + + public override HydraRingFailureMechanismType FailureMechanismType + { + get + { + return HydraRingFailureMechanismType.DikesPiping; + } + } + + public override HydraRingDikeSection DikeSection + { + get + { + return new HydraRingDikeSection(1, "Name", 2.2, 3.3, 4.4, 5.5, 6.6, 7.7); + } + } + } + } +} \ No newline at end of file Fisheye: Tag ace9ccbb49504742caff42a44fdd4c79d5217424 refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/HydraRingCalculationTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ace9ccbb49504742caff42a44fdd4c79d5217424 refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/HydraRingConfigurationIntegrationTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ace9ccbb49504742caff42a44fdd4c79d5217424 refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/HydraRingConfigurationTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ace9ccbb49504742caff42a44fdd4c79d5217424 refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Hydraulics/AssessmentLevelCalculationTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ace9ccbb49504742caff42a44fdd4c79d5217424 refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Hydraulics/IterateTowardsTargetProbabilityCalculationTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj =================================================================== diff -u -re58872a87106093853d59f6cae8f57e63b623202 -race9ccbb49504742caff42a44fdd4c79d5217424 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj (.../Ringtoets.HydraRing.Calculation.Test.csproj) (revision e58872a87106093853d59f6cae8f57e63b623202) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Ringtoets.HydraRing.Calculation.Test.csproj (.../Ringtoets.HydraRing.Calculation.Test.csproj) (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -48,14 +48,14 @@ - - + + - - - + + + Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingConfigurationIntegrationTest.cs =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingConfigurationIntegrationTest.cs (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/HydraRingConfigurationIntegrationTest.cs (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -0,0 +1,95 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using NUnit.Framework; +using Ringtoets.HydraRing.Calculation.Base; +using Ringtoets.HydraRing.Calculation.Data; +using Ringtoets.HydraRing.Calculation.Service.Hydraulics; + +namespace Ringtoets.HydraRing.Calculation.Test.Service +{ + [TestFixture] + public class HydraRingConfigurationIntegrationTest + { + [Test] + public void GenerateDataBaseCreationScript_HydraRingConfigurationWithAssessmentLevelCalculation_ReturnsExpectedCreationScript() + { + var hydraRingConfiguration = new HydraRingConfiguration("34-1", HydraRingTimeIntegrationSchemeType.FBC, HydraRingUncertaintiesType.All); + + hydraRingConfiguration.AddHydraRingCalculation(new AssessmentLevelCalculation(700004, 3.29053)); + + var expectedCreationScript = "DELETE FROM [HydraulicModels];" + Environment.NewLine + + "INSERT INTO [HydraulicModels] VALUES (1, 1, 'WTI 2017');" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Sections];" + Environment.NewLine + + "INSERT INTO [Sections] VALUES (700004, 1, 1, '700004', '700004', 0, 0, 0, 0, 700004, 700004, 100, 0, 0);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [DesignTables];" + Environment.NewLine + + "INSERT INTO [DesignTables] VALUES (700004, 1, 1, 1, 2, 26, 0, 0, 0, 0, 0, 50, 3.29053);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Numerics];" + Environment.NewLine + + "INSERT INTO [Numerics] VALUES (700004, 1, 1, 1, 1, 1, 4, 50, 0.15, 0.01, 0.01, 0.01, 2, 1, 20000, 100000, 0.1, -6, 6, 25);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [VariableDatas];" + Environment.NewLine + + "INSERT INTO [VariableDatas] VALUES (700004, 1, 1, 1, 26, 0, 0, 0, 0, 0, 0, 0, 0, 300);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [CalculationProfiles];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [SectionFaultTreeModels];" + Environment.NewLine + + "INSERT INTO [SectionFaultTreeModels] VALUES (700004, 1, 1, 1, 1);" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [SectionSubMechanismModels];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Fetches];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [AreaPoints];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [PresentationSections];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Profiles];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [ForelandModels];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Forelands];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [ProbabilityAlternatives];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [SetUpHeights];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [CalcWindDirections];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Swells];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [WaveReductions];" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Areas];" + Environment.NewLine + + "INSERT INTO [Areas] VALUES (1, '1', 'Nederland');" + Environment.NewLine + + Environment.NewLine + + "DELETE FROM [Projects];" + Environment.NewLine + + "INSERT INTO [Projects] VALUES (1, 'WTI 2017', 'Ringtoets calculation');" + Environment.NewLine; + + var creationScript = hydraRingConfiguration.GenerateDataBaseCreationScript(); + + Assert.AreEqual(expectedCreationScript, creationScript); + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/Hydraulics/AssessmentLevelCalculationTest.cs =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/Hydraulics/AssessmentLevelCalculationTest.cs (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Service/Hydraulics/AssessmentLevelCalculationTest.cs (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -0,0 +1,56 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using NUnit.Framework; +using Ringtoets.HydraRing.Calculation.Data; +using Ringtoets.HydraRing.Calculation.Service.Hydraulics; + +namespace Ringtoets.HydraRing.Calculation.Test.Service.Hydraulics +{ + [TestFixture] + public class AssessmentLevelCalculationTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var assessmentLevelCalculation = new AssessmentLevelCalculation(1, 2.2); + + // Assert + Assert.AreEqual(1, assessmentLevelCalculation.HydraulicBoundaryLocationId); + Assert.AreEqual(HydraRingFailureMechanismType.AssessmentLevel, assessmentLevelCalculation.FailureMechanismType); + Assert.AreEqual(2, assessmentLevelCalculation.CalculationTypeId); + CollectionAssert.IsEmpty(assessmentLevelCalculation.ProfilePoints); + Assert.AreEqual(2.2, assessmentLevelCalculation.Beta); + Assert.AreEqual(1, assessmentLevelCalculation.Variables.Count()); + + var assessmentLevelVariable = assessmentLevelCalculation.Variables.First(); + Assert.AreEqual(26, assessmentLevelVariable.VariableId); + Assert.AreEqual(HydraRingDistributionType.Deterministic, assessmentLevelVariable.DistributionType); + Assert.AreEqual(0.0, assessmentLevelVariable.Value); + Assert.AreEqual(HydraRingDeviationType.Standard, assessmentLevelVariable.DeviationType); + Assert.IsNaN(assessmentLevelVariable.Mean); + Assert.IsNaN(assessmentLevelVariable.Variability); + Assert.IsNaN(assessmentLevelVariable.Shift); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs =================================================================== diff -u -r80aeb6fb275f0d7ea3f470bb8ba0ef0fc5caa113 -race9ccbb49504742caff42a44fdd4c79d5217424 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 80aeb6fb275f0d7ea3f470bb8ba0ef0fc5caa113) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision ace9ccbb49504742caff42a44fdd4c79d5217424) @@ -40,10 +40,9 @@ using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Placeholder; -using Ringtoets.HydraRing.Calculation; using Ringtoets.HydraRing.Calculation.Data; -using Ringtoets.HydraRing.Calculation.Hydraulics; -using Ringtoets.HydraRing.Data; +using Ringtoets.HydraRing.Calculation.Service; +using Ringtoets.HydraRing.Calculation.Service.Hydraulics; using Ringtoets.Integration.Data.Placeholders; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.PropertyClasses; @@ -611,7 +610,7 @@ protected override void OnRun() { - HydraRingCalculator.PerformFailureMechanismCalculation(hlcdDirectory, ringId, timeIntegrationSchemeType, uncertaintiesType, new AssessmentLevelCalculation(hydraulicBoundaryLocationId, beta)); + HydraRingCalculationService.PerformFailureMechanismCalculation(hlcdDirectory, ringId, timeIntegrationSchemeType, uncertaintiesType, new AssessmentLevelCalculation(hydraulicBoundaryLocationId, beta)); } protected override void OnCancel()