public void RoutingOfRecievedWaterTest() { Lake S = new Lake("L",100); DateTime Start = new DateTime(2000, 1, 1); S.SetState("Initial", Start, new WaterPacket(100)); Lake storage = new Lake("storage", 10000); S.AddDownStreamWaterBody(storage); TimeSpan ts = new TimeSpan(1,0,0); WaterPacket WaterProvider = new WaterPacket(2, 200); IWaterPacket actual; S.AddWaterPacket(DateTime.Now, DateTime.Now, WaterProvider.DeepClone(200)); S.Update(S.CurrentTime.Add(ts)); actual = S.CurrentStoredWater; Assert.AreEqual(100, actual.Volume); Assert.AreEqual(200, storage.CurrentStoredWater.Volume); Assert.AreEqual(200.0/300.0, storage.CurrentStoredWater.Composition[2],0.000001); //In the next timestep there will be no water to route S.Update(S.CurrentTime.Add(ts)); Assert.AreEqual(200, storage.CurrentStoredWater.Volume); Assert.AreEqual(200.0 / 300.0, storage.CurrentStoredWater.Composition[2], 0.000001); Assert.AreEqual(1, S.Output.GetStorageTime(Start, Start.AddHours(2)).TotalHours,0.001); }
public void RoutingOfGroundwaterTest() { Lake S = new Lake("L",100); S.SetState("Initial", DateTime.Now, new WaterPacket(100)); Lake storage = new Lake("Storage",10000); S.AddDownStreamWaterBody(storage); TimeSpan ts = new TimeSpan(1,0,0); int Id = 2; IWaterPacket expected = new WaterPacket(Id, 200); IWaterPacket actual; S.WaterLevel = 8; GroundWaterBoundary b = new GroundWaterBoundary(S, 0.001, 100, 10, XYPolygon.GetSquare(2.5)); b.WaterSample = expected; S.GroundwaterBoundaries.Add(b); S.Update(S.CurrentTime.Add(ts)); actual = storage.CurrentStoredWater; double ExpectedVolume = b.GetSourceWater(DateTime.Now, ts).Volume; Assert.AreEqual(expected.Composition.Keys.First(), actual.Composition.Keys.First()); Assert.AreEqual(ExpectedVolume, actual.Volume, 0.000001); S.Update(S.CurrentTime.Add(new TimeSpan(2,0,0))); actual = storage.CurrentStoredWater; Assert.AreEqual(expected.Composition.Keys.First(), actual.Composition.Keys.First()); Assert.AreEqual(0.54, actual.Volume, 0.000001); S.AddWaterPacket(DateTime.Now, DateTime.Now, expected); S.Update(S.CurrentTime.Add(new TimeSpan(2, 0, 0))); actual = storage.CurrentStoredWater; Assert.AreEqual(200.9, actual.Volume, 0.000001); }
private Model CreateHydroNetModel() { // Upper Lake configuration Lake upperLake = new Lake("Upper Lake", 1000); //Simple inflow boundary SinkSourceBoundary inflow = new SinkSourceBoundary(2); inflow.Name = "Inflow to Upper lake"; inflow.ContactGeometry = new HydroNumerics.Geometry.XYPoint(350, 625); upperLake.Sources.Add(inflow); //Ground water boundary HydroNumerics.Geometry.XYPolygon contactPolygon = new HydroNumerics.Geometry.XYPolygon(); contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(350, 625)); contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(447, 451)); contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(715, 433)); contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(863, 671)); contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(787, 823)); contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(447, 809)); GroundWaterBoundary groundWaterBoundary = new GroundWaterBoundary(); groundWaterBoundary.Connection = upperLake; groundWaterBoundary.ContactGeometry = contactPolygon; groundWaterBoundary.Distance = 2.3; groundWaterBoundary.HydraulicConductivity = 1e-4; groundWaterBoundary.GroundwaterHead = 3.4; groundWaterBoundary.Name = "Groundwater boundary under Upper Lake"; upperLake.GroundwaterBoundaries.Add(groundWaterBoundary); //Stream between the lakes Stream stream = new Stream("stream", 2000, 2, 1.1); //Lower Lake configuration Lake lowerLake = new Lake("Lower Lake", 20); //Connecting the waterbodies. upperLake.AddDownStreamWaterBody(stream); stream.AddDownStreamWaterBody(lowerLake); //Creating the model Model model = new Model(); model._waterBodies.Add(upperLake); model._waterBodies.Add(stream); model._waterBodies.Add(lowerLake); DateTime startTime = new DateTime(2010, 1, 1); model.SetState("MyState", startTime, new WaterPacket(1000)); upperLake.SetState("MyState", startTime, new WaterPacket(2)); model.Name = "HydroNet test model"; model.Initialize(); return model; }