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 TestMethod1() { Lake Hampen = LakeFactory.GetLake("Hampen Sø"); Hampen.Depth = 3.2e6 / 760000/1000; DateTime start = new DateTime(2008, 1, 1); DateTime end = new DateTime(2008, 12, 31); Assert.AreEqual(Hampen.Area, 722200,1); EvaporationRateBoundary er = new EvaporationRateBoundary(407.0 / 1000 / 365 / 86400); er.ContactGeometry = Hampen.Geometry; er.Name = "Fordampning"; Hampen.EvaporationBoundaries.Add(er); SourceBoundary pr = new SourceBoundary(901.0 / 1000 / 365 / 86400); pr.ContactGeometry = Hampen.Geometry; pr.Name = "Nedbør"; Hampen.Precipitation.Add(pr); SinkSourceBoundary outlet = new SinkSourceBoundary(-200.0 / 1000 / 365 / 86400); outlet.ContactGeometry = Hampen.Geometry; outlet.Name = "Udløb"; Hampen.Sinks.Add(outlet); GroundWaterBoundary gwb = new GroundWaterBoundary(); gwb.FlowType = GWType.Flow; gwb.Name = "Ud"; gwb.WaterFlow = new HydroNumerics.Time.Core.TimespanSeries("inflow", new DateTime(2008, 1, 1), 2, 1, HydroNumerics.Time.Core.TimestepUnit.Years, -294.0 / 1000 / 365 / 86400*Hampen.Area); Hampen.GroundwaterBoundaries.Add(gwb); Model m = new Model(); m._waterBodies.Add(Hampen); m.SetState("start", start , new WaterPacket(1)); m.SimulationStartTime = start; m.SimulationEndTime = end; m.MoveInTime(end,TimeSpan.FromDays(30)); m.Save(@"..\..\..\TestData\Hampen1.xml"); WaterPacket ChlorideWater = new WaterPacket(1); ChlorideWater.SetConcentration(ChemicalNames.Cl, 20); ChlorideWater.SetConcentration(ChemicalNames.IsotopeFraction, 4); ChlorideWater.SetConcentration(ChemicalNames.Nitrate, 0.2); ChlorideWater.SetConcentration(ChemicalNames.Phosphate, 0.02); m.SetState("start", start, ChlorideWater); Hampen.Output.LogAllChemicals = true; double gwinflow = 1000.0; gwb.WaterFlow = new HydroNumerics.Time.Core.TimespanSeries("inflow", new DateTime(2008, 1, 1), 2, 1, HydroNumerics.Time.Core.TimestepUnit.Years, -(294.0 + gwinflow) / 1000 / 365 / 86400 * Hampen.Area); GroundWaterBoundary gwbin = new GroundWaterBoundary(); gwbin.FlowType = GWType.Flow; gwbin.WaterFlow = new HydroNumerics.Time.Core.TimespanSeries("inflow", new DateTime(2008, 1, 1), 2, 1, HydroNumerics.Time.Core.TimestepUnit.Years, 0.955*gwinflow / 1000 / 365 / 86400 * Hampen.Area); ChlorideWater.SetConcentration(ChemicalNames.Cl, 30); ChlorideWater.SetConcentration(ChemicalNames.IsotopeFraction, 8); ChlorideWater.SetConcentration(ChemicalNames.Nitrate, 1.6); ChlorideWater.SetConcentration(ChemicalNames.Phosphate, 0.017); gwbin.Name = "Ind Skov"; gwbin.WaterSample = ChlorideWater.DeepClone(); Hampen.GroundwaterBoundaries.Add(gwbin); GroundWaterBoundary gwbin2 = new GroundWaterBoundary(); gwbin2.FlowType = GWType.Flow; gwbin2.WaterFlow = new HydroNumerics.Time.Core.TimespanSeries("inflow", new DateTime(2008, 1, 1), 2, 1, HydroNumerics.Time.Core.TimestepUnit.Years, 0.045 * gwinflow / 1000 / 365 / 86400 * Hampen.Area); ChlorideWater.SetConcentration(ChemicalNames.Nitrate, 65.3); gwbin2.Name = "Ind Landbrug"; gwbin2.WaterSample = ChlorideWater.DeepClone(); Hampen.GroundwaterBoundaries.Add(gwbin2); ChlorideWater.SetConcentration(ChemicalNames.Cl, 10); ChlorideWater.SetConcentration(ChemicalNames.Phosphate, 0); ChlorideWater.SetConcentration(ChemicalNames.Nitrate, 1.7); pr.WaterSample = ChlorideWater.DeepClone(); m.MoveInTime(end, TimeSpan.FromDays(30)); m.Save(@"..\..\..\TestData\Hampen2.xml"); }
public void RoutingOfRecievedWaterTest() { Stream_Accessor S = new Stream_Accessor("S", 25,1,1); DateTime Start = DateTime.Now; S.SetState("Initial", Start, new WaterPacket(1, 25)); Stream s2 = new Stream("s2", 50,1,1); s2.SetState("Initial", Start, new WaterPacket(50)); Stream s3 = new Stream("s3", 300,1,1); s3.SetState("Initial", Start, new WaterPacket(300)); S.AddDownStreamWaterBody(s2); s2.AddDownStreamWaterBody(s3); TimeSpan ts = new TimeSpan(1,0,0); WaterPacket WaterProvider = new WaterPacket(2, 200); S.AddWaterPacket(Start, Start.AddDays(1), WaterProvider.DeepClone(200)); S.Update(S.CurrentTime.Add(ts)); Assert.AreEqual(0, S._incomingWater.Count); Assert.AreEqual(1, S.CurrentStoredWater.Composition[2]); s2.Update(S.CurrentTime.Add(ts)); s3.Update(S.CurrentTime.Add(ts)); Assert.AreEqual(1, s2.CurrentStoredWater.Composition[2]); //In the next timestep there will be no water to route S.Update(S.CurrentTime.Add(ts)); }
public void RoutingOfChemical() { Stream_Accessor s = new Stream_Accessor("s", 100, 1, 1); s.SetState("Initial", DateTime.Now, new WaterPacket(100)); SinkSourceBoundary fb = new SinkSourceBoundary(50); s.Sources.Add(fb); WaterPacket Wcc = new WaterPacket(50); Chemical c = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl); Wcc.AddChemical(c, 1); fb.WaterSample = Wcc.DeepClone(); double conc = Wcc.GetConcentration(c); Assert.AreEqual(1.0 / 50.0, conc, 0.000001); TimeSpan ts = new TimeSpan(0, 0, 1); s.Output.LogChemicalConcentration(c); s.AddWaterPacket(DateTime.Now, DateTime.Now.AddDays(1), Wcc.DeepClone()); s.Update(s.CurrentTime.Add(ts)); WaterPacket WccNew = (WaterPacket)s._waterInStream.Last(); Assert.AreEqual(64.8721, WccNew.Volume, 0.0001); Assert.AreEqual(TimeSpan.FromSeconds(0.5), WccNew.WaterAge); Assert.AreEqual(conc, WccNew.GetConcentration(c)); s.AddWaterPacket(DateTime.Now, DateTime.Now.AddDays(1), Wcc); s.Update(s.CurrentTime.Add(TimeSpan.FromDays(1))); Assert.AreEqual(0.0042, s.Output.ChemicalsToLog[c].Items[0].Value,1e-4); Assert.AreEqual(0.0078, s.Output.ChemicalsToLog[c].Items[1].Value, 1e-4); Assert.AreEqual(conc, s.Output.ChemicalsToLog[c].Items[2].Value); }
public void RoutingOfInflow2() { Stream S = new Stream("S", 25,1,1); DateTime Start = DateTime.Now; S.SetState("Initial", Start, new WaterPacket(1, 25)); Stream s2 = new Stream("s2", 50,1,1); s2.SetState("Initial", Start, new WaterPacket(50)); Stream s3 = new Stream("s3", 300,1,1); s3.SetState("Initial", Start, new WaterPacket(300)); S.AddDownStreamWaterBody(s2); s2.AddDownStreamWaterBody(s3); SinkSourceBoundary FB = new SinkSourceBoundary(0.0005); FB.WaterSample = new WaterPacket(5, 5); S.Sources.Add(FB); TimeSpan ts = new TimeSpan(1, 0, 0); WaterPacket WaterProvider = new WaterPacket(2, 200); S.AddWaterPacket(DateTime.Now, DateTime.Now, WaterProvider.DeepClone(200)); S.Update(S.CurrentTime.Add(ts)); }
public void RoutingOfInflow() { Stream S = new Stream("S", 10,1,1); DateTime Start = DateTime.Now; S.SetState("Initial", Start, new WaterPacket(1, 10)); Stream s2 = new Stream("s2", 10,1,1); Lake Storage = new Lake("storage", 100000); S.AddDownStreamWaterBody(s2); s2.AddDownStreamWaterBody(Storage); SinkSourceBoundary FB = new SinkSourceBoundary(5.0 / 60); FB.WaterSample = new WaterPacket(5, 5); S.Sources.Add(FB); TimeSpan ts = new TimeSpan(0, 1, 0); WaterPacket WaterProvider = new WaterPacket(2, 5); S.AddWaterPacket(Start, Start.AddDays(1), WaterProvider.DeepClone(15)); S.Update(S.CurrentTime.Add(ts)); s2.Update(S.CurrentTime.Add(ts)); Assert.AreEqual(10, S.CurrentStoredWater.Volume, 0.00001); Assert.AreEqual(0.137, S.CurrentStoredWater.Composition[5], 0.001); Assert.AreEqual(0.863, S.CurrentStoredWater.Composition[2], 0.001); Assert.AreEqual(0.1309, s2.CurrentStoredWater.Composition[1], 0.001); }
public void TestMethod1() { Lake Gjeller = LakeFactory.GetLake("Gjeller Sø"); Gjeller.Depth = 1.2; Gjeller.WaterLevel = 0.4; WaterPacket GjellerWater = new WaterPacket(1, 1); GjellerWater.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 1); TimeSeriesGroup climate = TimeSeriesGroupFactory.Create("climate.xts"); foreach (var I in climate.Items) { I.ExtrapolationMethod = ExtrapolationMethods.RecycleYear; I.AllowExtrapolation = true; } EvaporationRateBoundary evap = new EvaporationRateBoundary((TimespanSeries)climate.Items[1]); evap.ContactGeometry = Gjeller.Geometry; Gjeller.EvaporationBoundaries.Add(evap); SinkSourceBoundary precip = new SinkSourceBoundary(climate.Items[0]); precip.ContactGeometry = Gjeller.Geometry; Gjeller.Precipitation.Add(precip); precip.ID = 2; precip.WaterSample = GjellerWater.DeepClone(); precip.WaterSample.IDForComposition = precip.ID; ; GroundWaterBoundary GWIN = new GroundWaterBoundary(Gjeller, 1e-5, 2, 0.45, XYPolygon.GetSquare(Gjeller.Area / 2)); GWIN.WaterSample = GjellerWater.DeepClone(); GWIN.ID = 3; GWIN.WaterSample.IDForComposition = GWIN.ID; GWIN.Name = "Inflow"; Gjeller.GroundwaterBoundaries.Add(GWIN); GroundWaterBoundary GWout = new GroundWaterBoundary(Gjeller, 1e-5, 2, 0.35, XYPolygon.GetSquare(Gjeller.Area / 2)); GWout.Name = "Outflow"; Gjeller.GroundwaterBoundaries.Add(GWout); TimespanSeries pumping = new TimespanSeries(); pumping.AddSiValue(new DateTime(1990, 01, 01), new DateTime(2010, 01, 01), 0); pumping.AddSiValue(new DateTime(2010, 01, 01), new DateTime(2010, 05, 01), 0.05); pumping.AddSiValue(new DateTime(2010, 05, 01), DateTime.Now, 0); SinkSourceBoundary DrainageWater = new SinkSourceBoundary(pumping); DrainageWater.ID = 4; DrainageWater.WaterSample = GjellerWater.DeepClone(); DrainageWater.WaterSample.IDForComposition = DrainageWater.ID; DrainageWater.Name = "Indpumpet Drænvand"; Gjeller.Sources.Add(DrainageWater); var tsg = TimeSeriesGroupFactory.Create(@"..\..\..\TestData\GjellerObservations.xts"); foreach (var ts in tsg.Items) { Chemical c = new Chemical(ts.Name, 1); Gjeller.RealData.AddChemicalTimeSeries(c); Gjeller.RealData.ChemicalConcentrations[c] = (TimestampSeries) ts; } Model M = new Model(); M._waterBodies.Add(Gjeller); Gjeller.Output.LogAllChemicals = true; Gjeller.Output.LogComposition = true; M.SetState("Initial", new DateTime(1995, 1, 1), GjellerWater); M.MoveInTime(DateTime.Now, TimeSpan.FromDays(10)); M.Save(@"..\..\..\TestData\Gjeller.xml"); }