Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public void OutputTest()
        {
            TimeSpan ts = new TimeSpan(0, 1, 0);
            Stream   S  = new Stream("S", 10, 1, 1);

            S.SetState("Initial", DateTime.Now, new WaterPacket(1, 10));


            for (int i = 0; i < 10; i++)
            {
                S.AddWaterPacket(DateTime.Now, DateTime.Now.AddDays(1), new WaterPacket(25 * i));
                S.Update(S.CurrentTime.Add(ts));
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(i * 25.0 / ts.TotalSeconds, S.Output.Outflow.Items[i].Value);
            }
        }
Ejemplo n.º 4
0
        public void RoutingOfGroundwaterTest()
        {
            Stream S = new Stream("S", 100, 1, 1);

            S.SetState("Initial", DateTime.Now, new WaterPacket(100));

            TimeSpan ts = new TimeSpan(0, 1, 0);

            int          Id       = 2;
            IWaterPacket expected = new WaterPacket(Id, 200);
            IWaterPacket actual;

            S.WaterLevel = 8;
            GroundWaterBoundary b = new GroundWaterBoundary(S, 0.001, 10, 100, XYPolygon.GetSquare(250));

            b.WaterSample = expected;
            S.GroundwaterBoundaries.Add(b);
            S.Update(S.CurrentTime.Add(ts));

            actual = S.CurrentStoredWater;
            double ExpectedVolume = b.GetSourceWater(DateTime.Now, ts).Volume;

            Assert.AreEqual(expected.Composition.Keys.First(), actual.Composition.Keys.First());
            Assert.AreEqual(100, actual.Volume, 0.000001);

            S.Update(S.CurrentTime.Add(ts));

            actual = S.CurrentStoredWater;
            Assert.AreEqual(expected.Composition.Keys.First(), actual.Composition.Keys.First());
            Assert.AreEqual(100, actual.Volume, 0.000001);

            S.AddWaterPacket(DateTime.Now, DateTime.Now, expected);
            S.Update(S.CurrentTime.Add(ts));
            actual = S.CurrentStoredWater;

            Assert.AreEqual(100, actual.Volume, 0.000001);
        }
Ejemplo n.º 5
0
        public void TracerTest()
        {
            int      count  = 3;
            double   length = 10870;
            DateTime Start  = new DateTime(2000, 1, 1);

            List <Lake> lakes = NetworkBuilder.CreateConnectedLakes(count);

            foreach (Lake L in lakes)
            {
                L.SurfaceArea = XYPolygon.GetSquare(length / count);
                L.Depth       = 1;
                L.SetState("Initial", Start, new WaterPacket(L.Volume));
            }
            Chemical c = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl);

            SinkSourceBoundary fb = new SinkSourceBoundary(10870.0 / (8.49 * 3600));

            fb.WaterSample = new WaterPacket(1);
            lakes.First().Sources.Add(fb);

            WaterPacket plug = new WaterPacket(1);

            plug.AddChemical(c, 10000);
            lakes.First().AddWaterPacket(Start, Start.AddHours(1), plug.DeepClone());

            lakes.First().Output.LogChemicalConcentration(c);

            lakes.Last().Output.LogChemicalConcentration(c);


            Stream us = new Stream("us", 1, 1, 1);

            us.Sources.Add(fb);
            Stream s = new Stream("s", 1000, 1, 1);

            Lake L2 = new Lake("L2", 870);

            Stream s1 = new Stream("s1", 9000, 1, 1);

            s.AddWaterPacket(Start, Start.AddSeconds(1), plug.DeepClone());
            s1.Output.LogChemicalConcentration(c);

            us.AddDownStreamWaterBody(s);
            s.AddDownStreamWaterBody(L2);
            L2.AddDownStreamWaterBody(s1);


            Model m = new Model();

            m._waterBodies.AddRange(lakes.Cast <IWaterBody>());

            m._waterBodies.Add((IWaterBody)us);
            m._waterBodies.Add((IWaterBody)s);
            m._waterBodies.Add((IWaterBody)L2);
            m._waterBodies.Add((IWaterBody)s1);

            m.SetState("Initial", Start, new WaterPacket(1));



            m.MoveInTime(Start.AddHours(15), TimeSpan.FromMinutes(1));

            lakes.Last().Output.Save(@"C:\temp\LastLake.xts");
            s1.Output.Save(@"C:\temp\Stream.xts");


            int n = 15;
            List <IWaterBody> wbs = NetworkBuilder.CreateCombo(n, 10870 / n / 2.0);

            foreach (IWaterBody wb in wbs)
            {
                wb.SetState("Initial", Start, new WaterPacket(wb.Volume));
            }

            wbs.First().AddWaterPacket(Start, Start.AddHours(1), plug.DeepClone());
            us.AddDownStreamWaterBody(wbs.First());
            us.RestoreState("Initial");

            m._waterBodies.Clear();
            m._waterBodies.Add(us);
            m._waterBodies.AddRange(wbs);

            m.SetState("Initial", Start, new WaterPacket(1));

            ((Stream)wbs.Last()).Output.LogChemicalConcentration(c);

            m.MoveInTime(Start.AddHours(15), TimeSpan.FromMinutes(1));

            ((Stream)wbs.Last()).Output.Save(@"C:\temp\Stream.xts");
        }