Exemplo n.º 1
0
        public void EvapoAndSinks()
        {
            Stream_Accessor S = new Stream_Accessor("S", 100, 1, 1);

            DateTime Start = DateTime.Now;

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


            S.EvaporationBoundaries.Add(new EvaporationRateBoundary(1000));
            S.Sinks.Add(new SinkSourceBoundary(-500));
            S.Sources.Add(new SinkSourceBoundary(500));

            S.Update(S.CurrentTime.Add(TimeSpan.FromSeconds(1)));

            // Assert.AreEqual(0, S.CurrentStoredWater.Volume, 0.00001);
            Assert.AreEqual(1, S.CurrentStoredWater.WaterAge.TotalSeconds, 0.00001);
            S.Update(S.CurrentTime.Add(TimeSpan.FromSeconds(10)));
            Assert.AreEqual(11, S.CurrentStoredWater.WaterAge.TotalSeconds, 0.00001);

            S.Sources.Add(new SinkSourceBoundary(5000));
            S.Update(S.CurrentTime.Add(TimeSpan.FromSeconds(1)));
            Assert.AreEqual(100, S.CurrentStoredWater.Volume, 0.00001);
            Assert.AreEqual(0.013, S.CurrentStoredWater.WaterAge.TotalSeconds, 0.00001);
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 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));

    }
Exemplo n.º 5
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);


    }
Exemplo n.º 6
0
    public void EvapoAndSinks()
    {
      Stream_Accessor S = new Stream_Accessor("S", 100,1,1);

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


      S.EvaporationBoundaries.Add(new EvaporationRateBoundary(1000));
      S.Sinks.Add(new SinkSourceBoundary(-500));
      S.Sources.Add(new SinkSourceBoundary(500));

      S.Update(S.CurrentTime.Add(TimeSpan.FromSeconds(1)));

     // Assert.AreEqual(0, S.CurrentStoredWater.Volume, 0.00001);
      Assert.AreEqual(1, S.CurrentStoredWater.WaterAge.TotalSeconds, 0.00001);
      S.Update(S.CurrentTime.Add(TimeSpan.FromSeconds(10)));
      Assert.AreEqual(11, S.CurrentStoredWater.WaterAge.TotalSeconds, 0.00001);

      S.Sources.Add(new SinkSourceBoundary(5000));
      S.Update(S.CurrentTime.Add(TimeSpan.FromSeconds(1)));
      Assert.AreEqual(100, S.CurrentStoredWater.Volume, 0.00001);
      Assert.AreEqual(0.013, S.CurrentStoredWater.WaterAge.TotalSeconds, 0.00001);
    }