// Copyright (C) Stichting Deltares 2025. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero 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 Deltares.DamEngine.Data.Geotechnics; using NUnit.Framework; namespace Deltares.DamEngine.Data.Tests.Geotechnics; [TestFixture] public class SoilProfile1DAquiferLayerCombinerTests { [Test] public void TestResultsOfCombinedLayers() { const double diff = 0.0001; SoilProfile1D soilProfile1D = CreateProfile(); var topLayerName = "L2"; SoilProfile1DAquiferLayerCombiner.AquiferLayerProperties aquiferLayer = SoilProfile1DAquiferLayerCombiner.CombineLayers(soilProfile1D, topLayerName); // D70 from layer L2 Assert.That(aquiferLayer.D70, Is.EqualTo(0.0002).Within(diff)); // Height from L2 + all layers below it that are aquifer unless an aquitard is in between // so sum of L2 and L3: 3 + 2 = 5 Assert.That(aquiferLayer.Height, Is.EqualTo(5.0).Within(diff)); // PermeabilityKx is average of L2 and L3 based on height // (0.0001 * 3 + 0.0006 * 2) / (3 + 2) = 0.0003 Assert.That(aquiferLayer.PermeabilityKx, Is.EqualTo(0.0003).Within(diff)); } [Test] [SetUICulture("nl-NL")] public void TestThrowsExceptionWhenInterpolationModelIsNotTheSameForAllCombinedLayers() { SoilProfile1D soilProfile1D = CreateProfile(); soilProfile1D.GetLayerWithName("L2").WaterpressureInterpolationModel = WaterpressureInterpolationModel.Automatic; soilProfile1D.GetLayerWithName("L3").WaterpressureInterpolationModel = WaterpressureInterpolationModel.Hydrostatic; soilProfile1D.Name = "Test Profile"; var topLayerName = "L2"; Assert.That(() => SoilProfile1DAquiferLayerCombiner.CombineLayers(soilProfile1D, topLayerName), Throws.InstanceOf().With.Message.EqualTo("Bij het samenstellen van de aquifer laag voor 1D profiel Test Profile hebben de samen te voegen lagen verschillende interpolatie methoden hetgeen niet is toegestaan.")); } private static SoilProfile1D CreateProfile() { var soilProfile1D = new SoilProfile1D(); soilProfile1D.BottomLevel = -12.0; var soilLayer1 = new SoilLayer1D(); soilLayer1.Name = "L0"; soilLayer1.TopLevel = 13.0; soilLayer1.Soil = new Soil("Sandy stuff", 22.0, 20.0); soilLayer1.Soil.PermeabKx = 0.0004; soilLayer1.Soil.DiameterD70 = 0.0005; soilLayer1.IsAquifer = true; soilProfile1D.Layers.Add(soilLayer1); var soilLayer2 = new SoilLayer1D(); soilLayer2.Name = "L1"; soilLayer2.TopLevel = 10.0; soilLayer2.Soil = new Soil("Topmaterial", 1.0, 1.0); soilLayer2.Soil.PermeabKx = 0.0003; soilLayer2.Soil.DiameterD70 = 0.0003; soilLayer2.IsAquifer = false; soilProfile1D.Layers.Add(soilLayer2); var soilLayer3 = new SoilLayer1D(); soilLayer3.Name = "L2"; soilLayer3.TopLevel = -2.0; soilLayer3.Soil = new Soil("Sand", 22.0, 20.0); soilLayer3.Soil.PermeabKx = 0.0001; soilLayer3.Soil.DiameterD70 = 0.0002; soilLayer3.IsAquifer = true; soilProfile1D.Layers.Add(soilLayer3); var soilLayer4 = new SoilLayer1D(); soilLayer4.Name = "L3"; soilLayer4.TopLevel = -5.0; soilLayer4.Soil = new Soil("Also sand", 22.0, 20.0); soilLayer4.Soil.PermeabKx = 0.0006; soilLayer4.Soil.DiameterD70 = 0.0006; soilLayer4.IsAquifer = true; soilProfile1D.Layers.Add(soilLayer4); var soilLayer5 = new SoilLayer1D(); soilLayer5.Name = "L4"; soilLayer5.TopLevel = -7.0; soilLayer5.Soil = new Soil("clay or so", 1.0, 1.0); soilLayer5.Soil.PermeabKx = 0.0007; soilLayer5.Soil.DiameterD70 = 0.0008; soilLayer5.IsAquifer = false; soilProfile1D.Layers.Add(soilLayer5); var soilLayer6 = new SoilLayer1D(); soilLayer6.Name = "L4"; soilLayer6.TopLevel = -8.0; soilLayer6.Soil = new Soil("More sand", 22.0, 20.0); soilLayer6.Soil.PermeabKx = 0.0009; soilLayer6.Soil.DiameterD70 = 0.0010; soilLayer6.IsAquifer = true; soilProfile1D.Layers.Add(soilLayer6); return soilProfile1D; } }