//----------------------------------------------------------------------- // // Copyright (c) 2009 Deltares. All rights reserved. // // B.S.T.I.M. The // tom.the@deltares.nl // 07-07-2009 // Test for OvertoppingErosionCalculator //----------------------------------------------------------------------- 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() { } } }