Beispiel #1
0
        public void SortingOfIncomingWater()
        {
            Stream_Accessor s = new Stream_Accessor("s", 100, 1, 1);


            WaterPacket wp1 = new WaterPacket(1, 50);
            WaterPacket wp2 = new WaterPacket(2, 100);

            s.AddWaterPacket(new DateTime(2000, 1, 1), new DateTime(2000, 1, 11), wp1);
            s.AddWaterPacket(new DateTime(2000, 1, 6), new DateTime(2000, 1, 11), wp2);

            s.PrePareIncomingWater();

            Assert.AreEqual(2, s._incomingWater.Count);

            IWaterPacket iwp = s._incomingWater.Dequeue();

            Assert.AreEqual(25, iwp.Volume);
            Assert.AreEqual(1, iwp.Composition[1]);

            iwp = s._incomingWater.Dequeue();
            Assert.AreEqual(125, iwp.Volume);
            Assert.AreEqual(25.0 / 125.0, iwp.Composition[1]);
            Assert.AreEqual(100.0 / 125.0, iwp.Composition[2]);

            WaterPacket wp3 = new WaterPacket(3, 100);
            WaterPacket wp4 = new WaterPacket(4, 200);
            WaterPacket wp5 = new WaterPacket(5, 300);

            s.AddWaterPacket(new DateTime(2000, 1, 1), new DateTime(2000, 1, 3), wp3);
            s.AddWaterPacket(new DateTime(2000, 1, 2), new DateTime(2000, 1, 3), wp4);
            s.AddWaterPacket(new DateTime(2001, 1, 1, 12, 0, 0), new DateTime(2001, 1, 5), wp5);

            s.PrePareIncomingWater();
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
    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));

    }
Beispiel #5
0
    public void SortingOfIncomingWater()
    {
      Stream_Accessor s = new Stream_Accessor("s", 100,1,1);

      
      WaterPacket wp1 = new WaterPacket(1, 50);
      WaterPacket wp2 = new WaterPacket(2,100);

      s.AddWaterPacket(new DateTime(2000, 1, 1), new DateTime(2000, 1, 11), wp1);
      s.AddWaterPacket(new DateTime(2000, 1, 6), new DateTime(2000, 1, 11), wp2);

      s.PrePareIncomingWater();

      Assert.AreEqual(2, s._incomingWater.Count);
      
      IWaterPacket iwp = s._incomingWater.Dequeue();
      Assert.AreEqual(25, iwp.Volume);
      Assert.AreEqual(1, iwp.Composition[1]);

      iwp = s._incomingWater.Dequeue();
      Assert.AreEqual(125, iwp.Volume);
      Assert.AreEqual(25.0 / 125.0, iwp.Composition[1]);
      Assert.AreEqual(100.0 / 125.0, iwp.Composition[2]);
      
      WaterPacket wp3 = new WaterPacket(3,100);
      WaterPacket wp4 = new WaterPacket(4, 200);
      WaterPacket wp5 = new WaterPacket(5, 300);

      s.AddWaterPacket(new DateTime(2000, 1, 1), new DateTime(2000, 1, 3), wp3);
      s.AddWaterPacket(new DateTime(2000, 1, 2), new DateTime(2000, 1, 3), wp4);
      s.AddWaterPacket(new DateTime(2001, 1, 1, 12, 0, 0), new DateTime(2001, 1, 5), wp5);

      s.PrePareIncomingWater();

     

    }
Beispiel #6
0
    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);


    }