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); }
public void RadonDeg() { var rn =ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon); var cl =ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl); DateTime Start = new DateTime(2005,1,1); Lake L = new Lake("test", 10); L.SetState("Initial", Start, new WaterPacket(0)); SinkSourceBoundary sb = new SinkSourceBoundary(10.0 / 86400); ((WaterPacket)sb.WaterSample).AddChemical(rn, 2.3); ((WaterPacket)sb.WaterSample).AddChemical(cl, 2.3); L.Sources.Add(sb); L.Output.LogAllChemicals = true; L.Output.LogComposition = true; Model M = new Model(); M._waterBodies.Add(L); M.Save("temp.xml"); L.Update(Start.AddDays(1)); Assert.AreEqual(2.3, L.Output.ChemicalsToLog[cl].GetSiValue(L.CurrentTime),1e-5); Assert.AreNotEqual(2.3, L.Output.ChemicalsToLog[rn].GetSiValue(L.CurrentTime), 1e-5); var M2 = ModelFactory.GetModel("temp.xml"); Lake L2 = M2._waterBodies.First() as Lake; L2.Update(Start.AddDays(1)); Assert.AreEqual(2.3, L2.Output.ChemicalsToLog[cl].GetSiValue(L2.CurrentTime), 1e-5); Assert.AreNotEqual(2.3, L2.Output.ChemicalsToLog[rn].GetSiValue(L2.CurrentTime), 1e-5); }
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); }