// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI 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 Deltares.Dam.Tests { using System; using System.Collections.Generic; using System.Linq; using System.Text; using Deltares.Dam.Data; using NUnit.Framework; [TestFixture] public class OvertoppingErosionCalculatorTest { private EntityFactory entityFactory; [TestFixtureSetUp] public void FixtureSetup() { entityFactory = new EntityFactory(); } [Test] public void CheckIfDecayIsCalculatedCorrectlyWithParameters() { const double cTolerance = 0.000001; double remainingStrength; var overtoppingErosionCalculator = new OvertoppingErosionCalculator(); remainingStrength = overtoppingErosionCalculator.CalculateRemainingStrength(20, Deg2Rad(22.5), 0.7, 9.0); Assert.AreEqual(1.0 - 0.0, remainingStrength, cTolerance); remainingStrength = overtoppingErosionCalculator.CalculateRemainingStrength(20, Deg2Rad(22.5), 0.7, 12.0); Assert.AreEqual(1.0 - 0.000138, remainingStrength, cTolerance); remainingStrength = overtoppingErosionCalculator.CalculateRemainingStrength(20, Deg2Rad(22.5), 0.7, 22.0); Assert.AreEqual(0.0, remainingStrength, cTolerance); // decay = 1.053672948 remainingStrength = overtoppingErosionCalculator.CalculateRemainingStrength(20, Deg2Rad(22.5), 0.7, 45.0); Assert.AreEqual(0.0, remainingStrength, cTolerance); // decay = 3503.01008749 remainingStrength = overtoppingErosionCalculator.CalculateRemainingStrength(20, Deg2Rad(22.5), 0.7, 50.0); Assert.AreEqual(0.0, remainingStrength, cTolerance); // decay = 9615.35064791 } private static double Deg2Rad(double deg) { return (Math.PI * deg) / 180.0; } [Test] public void CheckIfDecayIsCalculatedCorrectly() { const double cTolerance = 0.000001; double remainingStrength; double decayWithParameters; var overtoppingErosionCalculator = new OvertoppingErosionCalculator(); using (var dummyDike = entityFactory.CreateDummyDike("Test")) { overtoppingErosionCalculator.Location = dummyDike.Locations.First(); overtoppingErosionCalculator.TimeStepInHours = 0.15; overtoppingErosionCalculator.GrassQualityFactor = 0.7; remainingStrength = overtoppingErosionCalculator.Calculate(50.0); // Location 1: Top dike polder = (35.2, 8.62) // InsteekShoulderInside or (if not exists) Toe dike polder = (41.5, -3.76); // dx = 41.5 - 35.2 = 6.3 // dy = 8.62 - (-3.76) = 12.38 // DikeSlope = ATan(12.38 / 6.3) = 1.100 decayWithParameters = overtoppingErosionCalculator.CalculateRemainingStrength(0.15, 1.1000657712071196, 0.7, 50.0); Assert.AreEqual(decayWithParameters, remainingStrength, cTolerance); } } [TestFixtureTearDown] public void FixtureTearDown() { } } }