Esempio n. 1
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));
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        private Model CreateHydroNetModel()
        {
            // Upper Lake configuration
            Lake upperLake = new Lake("Upper Lake", 1000);

            //Simple inflow boundary
            SinkSourceBoundary inflow = new SinkSourceBoundary(2);

            inflow.Name            = "Inflow to Upper lake";
            inflow.ContactGeometry = new HydroNumerics.Geometry.XYPoint(350, 625);
            upperLake.Sources.Add(inflow);

            //Ground water boundary
            HydroNumerics.Geometry.XYPolygon contactPolygon = new HydroNumerics.Geometry.XYPolygon();
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(350, 625));
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(447, 451));
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(715, 433));
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(863, 671));
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(787, 823));
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(447, 809));
            GroundWaterBoundary groundWaterBoundary = new GroundWaterBoundary();

            groundWaterBoundary.Connection            = upperLake;
            groundWaterBoundary.ContactGeometry       = contactPolygon;
            groundWaterBoundary.Distance              = 2.3;
            groundWaterBoundary.HydraulicConductivity = 1e-4;
            groundWaterBoundary.GroundwaterHead       = 3.4;
            groundWaterBoundary.Name = "Groundwater boundary under Upper Lake";
            upperLake.GroundwaterBoundaries.Add(groundWaterBoundary);

            //Stream between the lakes
            Stream stream = new Stream("stream", 2000, 2, 1.1);

            //Lower Lake configuration
            Lake lowerLake = new Lake("Lower Lake", 20);

            //Connecting the waterbodies.
            upperLake.AddDownStreamWaterBody(stream);
            stream.AddDownStreamWaterBody(lowerLake);

            //Creating the model
            Model model = new Model();

            model._waterBodies.Add(upperLake);
            model._waterBodies.Add(stream);
            model._waterBodies.Add(lowerLake);

            DateTime startTime = new DateTime(2010, 1, 1);

            model.SetState("MyState", startTime, new WaterPacket(1000));
            upperLake.SetState("MyState", startTime, new WaterPacket(2));
            model.Name = "HydroNet test model";
            model.Initialize();

            return(model);
        }
Esempio 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));
        }
Esempio 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");
        }
Esempio n. 6
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));

    }
Esempio n. 7
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));
    }
Esempio n. 8
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);

    }
        private Model CreateHydroNetModel()
        {
            // Upper Lake configuration
            Lake upperLake = new Lake("Upper Lake", 1000);

            //Simple inflow boundary
            SinkSourceBoundary inflow = new SinkSourceBoundary(2);
            inflow.Name = "Inflow to Upper lake";
            inflow.ContactGeometry = new HydroNumerics.Geometry.XYPoint(350, 625);
            upperLake.Sources.Add(inflow);

            //Ground water boundary
            HydroNumerics.Geometry.XYPolygon contactPolygon = new HydroNumerics.Geometry.XYPolygon();
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(350, 625));
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(447, 451));
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(715, 433));
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(863, 671));
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(787, 823));
            contactPolygon.Points.Add(new HydroNumerics.Geometry.XYPoint(447, 809));
            GroundWaterBoundary groundWaterBoundary = new GroundWaterBoundary();
            groundWaterBoundary.Connection = upperLake;
            groundWaterBoundary.ContactGeometry = contactPolygon;
            groundWaterBoundary.Distance = 2.3;
            groundWaterBoundary.HydraulicConductivity = 1e-4;
            groundWaterBoundary.GroundwaterHead = 3.4;
            groundWaterBoundary.Name = "Groundwater boundary under Upper Lake";
            upperLake.GroundwaterBoundaries.Add(groundWaterBoundary);

            //Stream between the lakes
            Stream stream = new Stream("stream", 2000, 2, 1.1);

            //Lower Lake configuration
            Lake lowerLake = new Lake("Lower Lake", 20);
 
            //Connecting the waterbodies.
            upperLake.AddDownStreamWaterBody(stream);
            stream.AddDownStreamWaterBody(lowerLake);

            //Creating the model
            Model model = new Model();          
            model._waterBodies.Add(upperLake);
            model._waterBodies.Add(stream);
            model._waterBodies.Add(lowerLake);

            DateTime startTime = new DateTime(2010, 1, 1);
            model.SetState("MyState", startTime, new WaterPacket(1000));
            upperLake.SetState("MyState", startTime, new WaterPacket(2));
            model.Name = "HydroNet test model";
            model.Initialize();

            return model;
        }