private IEnumerable <OrderedDictionary> GetNumericsConfiguration() { var orderDictionaries = new List <OrderedDictionary>(); foreach (HydraRingCalculationInput hydraRingCalculationInput in hydraRingInputs) { FailureMechanismDefaults failureMechanismDefaults = failureMechanismDefaultsProvider.GetFailureMechanismDefaults(hydraRingCalculationInput.FailureMechanismType); foreach (int subMechanismId in failureMechanismDefaults.SubMechanismIds) { NumericsSetting numericsSetting = hydraRingCalculationInput.NumericsSettings[subMechanismId]; orderDictionaries.Add(CreateNumericsRecord(hydraRingCalculationInput.Section.SectionId, failureMechanismDefaults.MechanismId, subMechanismId, hydraRingCalculationInput.IterationMethodId, numericsSetting)); } if (hydraRingCalculationInput.PreprocessorSetting.RunPreprocessor) { orderDictionaries.Add(CreateNumericsRecord(hydraRingCalculationInput.Section.SectionId, failureMechanismDefaults.PreprocessorMechanismId, failureMechanismDefaults.PreprocessorSubMechanismId, hydraRingCalculationInput.IterationMethodId, hydraRingCalculationInput.PreprocessorSetting.NumericsSetting)); } } return(orderDictionaries); }
public void GetPreprocessorSetting_UsePreprocessorTrueAndKnownLocationId_ReturnsExpectedPreprocessorSetting() { // Setup using (var provider = new PreprocessorSettingsProvider(completeDatabaseDataPath)) { // Call PreprocessorSetting setting = provider.GetPreprocessorSetting(700131, true); // Assert Assert.IsTrue(setting.RunPreprocessor); Assert.AreEqual(2, setting.ValueMin); Assert.AreEqual(8, setting.ValueMax); NumericsSetting numericsSetting = setting.NumericsSetting; Assert.AreEqual(2, numericsSetting.CalculationTechniqueId); Assert.AreEqual(3, numericsSetting.FormStartMethod); Assert.AreEqual(20, numericsSetting.FormNumberOfIterations); Assert.AreEqual(0.2, numericsSetting.FormRelaxationFactor); Assert.AreEqual(0.1, numericsSetting.FormEpsBeta); Assert.AreEqual(0.1, numericsSetting.FormEpsHoh); Assert.AreEqual(0.1, numericsSetting.FormEpsZFunc); Assert.AreEqual(3, numericsSetting.DsStartMethod); Assert.AreEqual(4, numericsSetting.DsMinNumberOfIterations); Assert.AreEqual(15000, numericsSetting.DsMaxNumberOfIterations); Assert.AreEqual(90000, numericsSetting.DsVarCoefficient); Assert.AreEqual(0.2, numericsSetting.NiUMin); Assert.AreEqual(-4, numericsSetting.NiUMax); Assert.AreEqual(5, numericsSetting.NiNumberSteps); } }
private static Dictionary <int, NumericsSetting> GetOvertoppingDefaults(NumericsSetting numericsSetting) { return(new Dictionary <int, NumericsSetting> { { 102, numericsSetting }, { 103, numericsSetting } }); }
public void ReadNumericsSetting_EmptyTable_ReturnNull() { // Setup using (var reader = new HydraRingSettingsDatabaseReader(emptyDatabasePath)) { // Call NumericsSetting setting = reader.ReadNumericsSetting(700135, 101, 102); // Assert Assert.IsNull(setting); } }
public void GetNumericsSettingForPreprocessor_LocationIdUnknown_ReturnsExpectedDefaultNumericsSetting() { // Setup using (var numericsSettingsProvider = new NumericsSettingsProvider(completeDatabaseDataPath)) { // Call NumericsSetting numericsSetting = numericsSettingsProvider.GetNumericsSettingForPreprocessor(700139); // Assert var expected = new NumericsSetting(11, 4, 150, 0.15, 0.005, 0.005, 0.005, 2, 10000, 40000, 0.1, -6.0, 6.0, 25); AssertNumericsSetting(expected, numericsSetting); } }
public void GetNumericsSettingForPreprocessor_PreprocessorSubMechanismIdUnknownDefaultSubMechanismIdKnown_ReturnExpectedNumericsSetting() { // Setup using (var numericsSettingsProvider = new NumericsSettingsProvider(completeDatabaseDataPath)) { // Call NumericsSetting numericsSetting = numericsSettingsProvider.GetNumericsSettingForPreprocessor(700138); // Assert NumericsSetting expected = GetExpectedNumericsSetting(); AssertNumericsSetting(expected, numericsSetting); } }
public void GetNumericsSettingForPreprocessor_PreprocessorSubMechanismIdKnown_ReturnExpectedNumericsSetting() { // Setup using (var numericsSettingsProvider = new NumericsSettingsProvider(completeDatabaseDataPath)) { // Call NumericsSetting numericsSetting = numericsSettingsProvider.GetNumericsSettingForPreprocessor(700131); // Assert var expected = new NumericsSetting(2, 3, 20, 0.2, 0.1, 0.1, 0.1, 3, 4, 15000, 90000, 0.2, -4, 5); AssertNumericsSetting(expected, numericsSetting); } }
public void ReadNumericsSetting_ValidLocationIdFailureMechanismTypeAndSubMechanismIdNotInDatabase_ReturnNull( long locationId, int mechanismId, int subMechanismId) { // Setup using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath)) { // Call NumericsSetting setting = reader.ReadNumericsSetting(locationId, mechanismId, subMechanismId); // Assert Assert.IsNull(setting); } }
public void GetNumericsSettings_KnownLocationId_ReturnsExpectedNumericsSetting() { // Setup using (var numericsSettingsProvider = new NumericsSettingsProvider(completeDatabaseDataPath)) { // Call Dictionary <int, NumericsSetting> numericsSettings = numericsSettingsProvider.GetNumericsSettings(700132, HydraRingFailureMechanismType.AssessmentLevel); // Assert Assert.IsTrue(numericsSettings.ContainsKey(1)); NumericsSetting expected = GetExpectedNumericsSetting(); AssertNumericsSetting(expected, numericsSettings[1]); } }
private static void AssertNumericsSetting(NumericsSetting expectedNumericsSetting, NumericsSetting actualNumericsSetting) { Assert.AreEqual(expectedNumericsSetting.CalculationTechniqueId, actualNumericsSetting.CalculationTechniqueId); Assert.AreEqual(expectedNumericsSetting.FormStartMethod, actualNumericsSetting.FormStartMethod); Assert.AreEqual(expectedNumericsSetting.FormNumberOfIterations, actualNumericsSetting.FormNumberOfIterations); Assert.AreEqual(expectedNumericsSetting.FormRelaxationFactor, actualNumericsSetting.FormRelaxationFactor); Assert.AreEqual(expectedNumericsSetting.FormEpsBeta, actualNumericsSetting.FormEpsBeta); Assert.AreEqual(expectedNumericsSetting.FormEpsHoh, actualNumericsSetting.FormEpsHoh); Assert.AreEqual(expectedNumericsSetting.FormEpsZFunc, actualNumericsSetting.FormEpsZFunc); Assert.AreEqual(expectedNumericsSetting.DsStartMethod, actualNumericsSetting.DsStartMethod); Assert.AreEqual(expectedNumericsSetting.DsMinNumberOfIterations, actualNumericsSetting.DsMinNumberOfIterations); Assert.AreEqual(expectedNumericsSetting.DsMaxNumberOfIterations, actualNumericsSetting.DsMaxNumberOfIterations); Assert.AreEqual(expectedNumericsSetting.DsVarCoefficient, actualNumericsSetting.DsVarCoefficient); Assert.AreEqual(expectedNumericsSetting.NiNumberSteps, actualNumericsSetting.NiNumberSteps); Assert.AreEqual(expectedNumericsSetting.NiUMin, actualNumericsSetting.NiUMin); Assert.AreEqual(expectedNumericsSetting.NiUMax, actualNumericsSetting.NiUMax); }
public void ParameteredConstructor_ExpectedValues() { // Setup var random = new Random(21); double valueMin = random.NextDouble(); double valueMax = random.NextDouble(); var numericsSetting = new NumericsSetting(1, 4, 50, 0.15, 0.05, 0.01, 0.01, 0, 2, 20000, 100000, 0.1, -6, 6); // Call var preprocessorSetting = new PreprocessorSetting(valueMin, valueMax, numericsSetting); // Assert Assert.IsTrue(preprocessorSetting.RunPreprocessor); Assert.AreEqual(valueMin, preprocessorSetting.ValueMin); Assert.AreEqual(valueMax, preprocessorSetting.ValueMax); Assert.AreSame(numericsSetting, preprocessorSetting.NumericsSetting); }
public void ReadNumericsSetting_ValidLocationIdAndFailureMechanismType_NumericsSettingWithExpectedValues( long locationId, int mechanismId, int subMechanismId, int expectedCalculationTechniqueId, int expectedFormStartMethod, int expectedFormNumberOfIterations, double expectedFormRelaxationFactor, double expectedFormEpsBeta, double expectedFormEpsHoh, double expectedFormEpsZFunc, int expectedDsStartMethod, int expectedDsMinNumberOfIterations, int expectedDsMaxNumberOfIterations, double expectedDsVarCoefficient, double expectedNiUMin, double expectedNiUMax, int expectedNiNumberSteps) { // Setup using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath)) { // Call NumericsSetting setting = reader.ReadNumericsSetting(locationId, mechanismId, subMechanismId); // Assert Assert.AreEqual(expectedCalculationTechniqueId, setting.CalculationTechniqueId); Assert.AreEqual(expectedFormStartMethod, setting.FormStartMethod); Assert.AreEqual(expectedFormNumberOfIterations, setting.FormNumberOfIterations); Assert.AreEqual(expectedFormRelaxationFactor, setting.FormRelaxationFactor); Assert.AreEqual(expectedFormEpsBeta, setting.FormEpsBeta); Assert.AreEqual(expectedFormEpsHoh, setting.FormEpsHoh); Assert.AreEqual(expectedFormEpsZFunc, setting.FormEpsZFunc); Assert.AreEqual(expectedDsStartMethod, setting.DsStartMethod); Assert.AreEqual(expectedDsMinNumberOfIterations, setting.DsMinNumberOfIterations); Assert.AreEqual(expectedDsMaxNumberOfIterations, setting.DsMaxNumberOfIterations); Assert.AreEqual(expectedDsVarCoefficient, setting.DsVarCoefficient); Assert.AreEqual(expectedNiUMin, setting.NiUMin); Assert.AreEqual(expectedNiUMax, setting.NiUMax); Assert.AreEqual(expectedNiNumberSteps, setting.NiNumberSteps); } }
public void Constructor_ExpectedValues() { // Call var numericsSetting = new NumericsSetting(1, 2, 3, 4.4, 5.5, 6.6, 7.7, 8, 9, 10, 11.11, 12.12, 13.13, 14); // Assert Assert.AreEqual(1, numericsSetting.CalculationTechniqueId); Assert.AreEqual(2, numericsSetting.FormStartMethod); Assert.AreEqual(3, numericsSetting.FormNumberOfIterations); Assert.AreEqual(4.4, numericsSetting.FormRelaxationFactor); Assert.AreEqual(5.5, numericsSetting.FormEpsBeta); Assert.AreEqual(6.6, numericsSetting.FormEpsHoh); Assert.AreEqual(7.7, numericsSetting.FormEpsZFunc); Assert.AreEqual(8, numericsSetting.DsStartMethod); Assert.AreEqual(9, numericsSetting.DsMinNumberOfIterations); Assert.AreEqual(10, numericsSetting.DsMaxNumberOfIterations); Assert.AreEqual(11.11, numericsSetting.DsVarCoefficient); Assert.AreEqual(12.12, numericsSetting.NiUMin); Assert.AreEqual(13.13, numericsSetting.NiUMax); Assert.AreEqual(14, numericsSetting.NiNumberSteps); }
public void GetNumericsSettings_UnknownLocationId_ReturnsExpectedDefaultNumericsSetting( HydraRingFailureMechanismType failureMechanismType, int subMechanismId, int expectedCalculationTechniqueId, int expectedFormStartMethod, int expectedDsMinNumberOfIterations, int expectedDsMaxNumberOfIterations) { // Setup using (var numericsSettingsProvider = new NumericsSettingsProvider(completeDatabaseDataPath)) { // Call Dictionary <int, NumericsSetting> numericsSettings = numericsSettingsProvider.GetNumericsSettings(-1, failureMechanismType); // Assert Assert.IsTrue(numericsSettings.ContainsKey(subMechanismId)); var expected = new NumericsSetting(expectedCalculationTechniqueId, expectedFormStartMethod, 150, 0.15, 0.005, 0.005, 0.005, 2, expectedDsMinNumberOfIterations, expectedDsMaxNumberOfIterations, 0.1, -6.0, 6.0, 25); AssertNumericsSetting(expected, numericsSettings[subMechanismId]); } }
private void InitializeDefaultNumericsSettings() { NumericsSetting numericsSettingForm = CreateDefaultNumericsSetting(1, 1); // Settings for a FORM calculation NumericsSetting numericsSettingFDir = CreateDefaultNumericsSetting(11, 4); // Settings for a hybrid calculation; FORM in first instance, DIRS in case of no convergence NumericsSetting numericsSettingDunes = CreateDefaultNumericsSetting(1, 4); var numericsSettingQVariant = new NumericsSetting(4, 4, 150, 0.15, 0.005, 0.005, 0.005, 2, 3000, 10000, 0.1, -6.0, 6.0, 25); defaultNumericsSettings = new Dictionary <HydraRingFailureMechanismType, IDictionary <int, NumericsSetting> > { { HydraRingFailureMechanismType.AssessmentLevel, new Dictionary <int, NumericsSetting> { { 1, numericsSettingFDir } } }, { HydraRingFailureMechanismType.WaveHeight, new Dictionary <int, NumericsSetting> { { 11, numericsSettingFDir } } }, { HydraRingFailureMechanismType.WavePeakPeriod, new Dictionary <int, NumericsSetting> { { 14, numericsSettingFDir } } }, { HydraRingFailureMechanismType.WaveSpectralPeriod, new Dictionary <int, NumericsSetting> { { 16, numericsSettingFDir } } }, { HydraRingFailureMechanismType.QVariant, new Dictionary <int, NumericsSetting> { { 5, numericsSettingQVariant } } }, { HydraRingFailureMechanismType.DikeHeight, GetOvertoppingDefaults(numericsSettingFDir) }, { HydraRingFailureMechanismType.DikesOvertopping, GetOvertoppingDefaults(numericsSettingFDir) }, { HydraRingFailureMechanismType.StructuresOvertopping, new Dictionary <int, NumericsSetting> { { 421, numericsSettingFDir }, { 422, numericsSettingFDir }, { 423, numericsSettingFDir } } }, { HydraRingFailureMechanismType.StructuresClosure, new Dictionary <int, NumericsSetting> { { 422, numericsSettingForm }, { 424, numericsSettingFDir }, { 425, numericsSettingFDir }, { 426, numericsSettingForm }, { 427, numericsSettingForm } } }, { HydraRingFailureMechanismType.StructuresStructuralFailure, new Dictionary <int, NumericsSetting> { { 422, numericsSettingForm }, { 424, numericsSettingFDir }, { 425, numericsSettingFDir }, { 430, numericsSettingFDir }, { 431, numericsSettingForm }, { 432, numericsSettingForm }, { 433, numericsSettingForm }, { 434, numericsSettingFDir }, { 435, numericsSettingFDir } } }, { HydraRingFailureMechanismType.DunesBoundaryConditions, new Dictionary <int, NumericsSetting> { { 6, numericsSettingDunes } } }, { HydraRingFailureMechanismType.OvertoppingRate, GetOvertoppingDefaults(numericsSettingFDir) }, { HydraRingFailureMechanismType.Piping, new Dictionary <int, NumericsSetting> { { 311, numericsSettingFDir }, { 313, numericsSettingFDir }, { 314, numericsSettingFDir } } } }; }
private static OrderedDictionary CreateNumericsRecord(int sectionId, int mechanismId, int subMechanismId, int iterationMethodId, NumericsSetting numericsSetting) { return(new OrderedDictionary { { "SectionId", sectionId }, { "MechanismId", mechanismId }, { "LayerId", defaultLayerId // Fixed: no support for revetments }, { "AlternativeId", defaultAlternativeId // Fixed: no support for piping }, { "SubMechanismId", subMechanismId }, { "Method", numericsSetting.CalculationTechniqueId }, { "FormStartMethod", numericsSetting.FormStartMethod }, { "FormNumberOfIterations", numericsSetting.FormNumberOfIterations }, { "FormRelaxationFactor", GetHydraRingValue(numericsSetting.FormRelaxationFactor) }, { "FormEpsBeta", GetHydraRingValue(numericsSetting.FormEpsBeta) }, { "FormEpsHOH", GetHydraRingValue(numericsSetting.FormEpsHoh) }, { "FormEpsZFunc", GetHydraRingValue(numericsSetting.FormEpsZFunc) }, { "DsStartMethod", numericsSetting.DsStartMethod }, { "DsIterationmethod", iterationMethodId }, { "DsMinNumberOfIterations", numericsSetting.DsMinNumberOfIterations }, { "DsMaxNumberOfIterations", numericsSetting.DsMaxNumberOfIterations }, { "DsVarCoefficient", GetHydraRingValue(numericsSetting.DsVarCoefficient) }, { "NiUMin", GetHydraRingValue(numericsSetting.NiUMin) }, { "NiUMax", GetHydraRingValue(numericsSetting.NiUMax) }, { "NiNumberSteps", numericsSetting.NiNumberSteps } }); }