示例#1
0
    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);
    
    
    }
示例#2
0
    public static void SaveModel(string FileName, Model M)
    {
      using (FileStream Fs = new FileStream(FileName, FileMode.Create))
      {
        DataContractSerializer ds = new DataContractSerializer(typeof(Model), KnownTypes, int.MaxValue, false, false, null);
        ds.WriteObject(Fs, M);
      }

    }
    public void ModelSaveTest()
    {
      Model M = new Model();
      M._waterBodies.Add(new Stream("S", 100, 1, 1));

      Model M2 = (Model)ReadWrite(M);

      Assert.AreEqual(M._waterBodies.Count, M2._waterBodies.Count);

      IWaterBody  L = new Lake("L", 1);
      
      

    }
示例#4
0
    public void MoveInTimeTest1()
    {
      var Network = NetworkBuilder.CreateBranch(10);


      Network.First().Sources.Add(new SinkSourceBoundary(1));

      Model target = new Model();
      target._waterBodies.AddRange(Network.Cast<IWaterBody>());

      DateTime Start = new DateTime(2010, 1, 1);
      DateTime End = new DateTime(2010, 1, 10);
      TimeSpan TimeStep = new TimeSpan(1, 0, 0, 0);

      target.SetState("Initial", Start, new WaterPacket(1));
      target.MoveInTime(End, TimeStep);

      Assert.AreEqual(Network.First().CurrentStoredWater.Volume, Network.Last().CurrentStoredWater.Volume,0.0001);
      Assert.AreEqual(End, Network.First().CurrentTime);

    }
    public void KrabbenhoftExample()
    {
      Lake L = new Lake("Sparkling Lake", XYPolygon.GetSquare(0.81e6));
      L.Depth = 8.84e6 / L.Area;
      L.Output.LogAllChemicals = true;

      IsotopeWater LakeWater = new IsotopeWater(1);
      LakeWater.SetIsotopeRatio(5.75);
      TimestampSeries EvapoConcentrations = new TimestampSeries();
      EvapoConcentrations.AddSiValue(new DateTime(1985, 4, 1), 3.95);
      EvapoConcentrations.AddSiValue(new DateTime(1985, 5, 1), 13.9);
      EvapoConcentrations.AddSiValue(new DateTime(1985, 6, 1), 25.24);
      EvapoConcentrations.AddSiValue(new DateTime(1985, 7, 1), 23.97);
      EvapoConcentrations.AddSiValue(new DateTime(1985, 8, 1), 17.13);
      EvapoConcentrations.AddSiValue(new DateTime(1985, 9, 1), 10.40);
      EvapoConcentrations.AddSiValue(new DateTime(1985, 10, 1), 6.12);
      EvapoConcentrations.AddSiValue(new DateTime(1985, 10, 1), 33.24);
      EvapoConcentrations.AllowExtrapolation = true;
      EvapoConcentrations.ExtrapolationMethod = ExtrapolationMethods.RecycleYear;
      LakeWater.EvaporationConcentration = EvapoConcentrations;

      TimestampSeries PrecipConcentrations = new TimestampSeries();
      PrecipConcentrations.AddSiValue(new DateTime(1985, 1, 1), 22.8);
      PrecipConcentrations.AddSiValue(new DateTime(1985, 2, 1), 22.8);
      PrecipConcentrations.AddSiValue(new DateTime(1985, 3, 1), 22.8);
      PrecipConcentrations.AddSiValue(new DateTime(1985, 4, 1), 14.8);
      PrecipConcentrations.AddSiValue(new DateTime(1985, 5, 1), 10.7);
      PrecipConcentrations.AddSiValue(new DateTime(1985, 6, 1), 6.3);
      PrecipConcentrations.AddSiValue(new DateTime(1985, 7, 1), 5.1);
      PrecipConcentrations.AddSiValue(new DateTime(1985, 8, 1), 8.4);
      PrecipConcentrations.AddSiValue(new DateTime(1985, 9, 1), 11.1);
      PrecipConcentrations.AddSiValue(new DateTime(1985, 10, 1), 13.8);
      PrecipConcentrations.AddSiValue(new DateTime(1985, 10, 1), 21.9);
      PrecipConcentrations.AllowExtrapolation = true;
      PrecipConcentrations.ExtrapolationMethod = ExtrapolationMethods.RecycleYear;

      TimespanSeries Precipitation = new TimespanSeries();
      Precipitation.Unit = new HydroNumerics.Core.Unit("cm/month", 1.0 / 100.0 / (86400.0 * 30.0), 0);
      Precipitation.AddValue(new DateTime(1985, 1, 1), new DateTime(1985, 3, 1), 0);
      Precipitation.AddValue(new DateTime(1985, 3, 1), new DateTime(1985, 3, 31), 12.5);
      Precipitation.AddValue(new DateTime(1985, 4, 1), new DateTime(1985, 4, 30), 7.1);
      Precipitation.AddValue(new DateTime(1985, 5, 1), new DateTime(1985, 5, 31), 7.6);
      Precipitation.AddValue(new DateTime(1985, 6, 1), new DateTime(1985, 6, 30), 8.8);
      Precipitation.AddValue(new DateTime(1985, 7, 1), new DateTime(1985, 7, 31), 8.6);
      Precipitation.AddValue(new DateTime(1985, 8, 1), new DateTime(1985, 8, 31), 12.7);
      Precipitation.AddValue(new DateTime(1985, 9, 1), new DateTime(1985, 9, 30), 11);
      Precipitation.AddValue(new DateTime(1985, 10, 1), new DateTime(1985, 10, 31), 6.2);
      Precipitation.AddValue(new DateTime(1985, 11, 1), new DateTime(1985, 11, 30), 4.8);
      Precipitation.AddValue(new DateTime(1985, 11, 30), new DateTime(1985, 12, 31), 0);
      Precipitation.AllowExtrapolation = true;
      Precipitation.ExtrapolationMethod = ExtrapolationMethods.RecycleYear;

      Assert.AreEqual(79, 12*Precipitation.GetValue(new DateTime(1985,1,1), new DateTime(1985,12,31)),3);

      SourceBoundary Precip = new SourceBoundary(Precipitation);
      Precip.WaterSample = new IsotopeWater(1);
      Precip.AddChemicalConcentrationSeries(ChemicalFactory.Instance.GetChemical(ChemicalNames.IsotopeFraction), PrecipConcentrations);

      TimespanSeries Evaporation = new TimespanSeries();
      Evaporation.Unit = new HydroNumerics.Core.Unit("cm/month", 1.0 / 100.0 / (86400.0 * 30.0), 0);
      Evaporation.AddValue(new DateTime(1985, 1, 1), new DateTime(1985, 4, 1), 0);
      Evaporation.AddValue(new DateTime(1985, 4, 1), new DateTime(1985, 4, 30), 2.8);
      Evaporation.AddValue(new DateTime(1985, 5, 1), new DateTime(1985, 5, 31), 7.0);
      Evaporation.AddValue(new DateTime(1985, 6, 1), new DateTime(1985, 6, 30), 10.5);
      Evaporation.AddValue(new DateTime(1985, 7, 1), new DateTime(1985, 7, 31), 11.1);
      Evaporation.AddValue(new DateTime(1985, 8, 1), new DateTime(1985, 8, 31), 10.0);
      Evaporation.AddValue(new DateTime(1985, 9, 1), new DateTime(1985, 9, 30), 7.0);
      Evaporation.AddValue(new DateTime(1985, 10, 1), new DateTime(1985, 10, 31), 4.7);
      Evaporation.AddValue(new DateTime(1985, 11, 1), new DateTime(1985, 11, 30), 0.6);
      Evaporation.AddValue(new DateTime(1985, 11, 30), new DateTime(1985, 12, 31), 0);
      Evaporation.AllowExtrapolation = true;
      Evaporation.ExtrapolationMethod = ExtrapolationMethods.RecycleYear;
      EvaporationRateBoundary erb = new EvaporationRateBoundary(Evaporation);

      Assert.AreEqual(54, 12*Evaporation.GetValue(new DateTime(1985,1,1), new DateTime(1985,12,31)),3);

      
      GroundWaterBoundary grb = new GroundWaterBoundary(L, 1e-7, 1, 1, (XYPolygon) L.Geometry);
      grb.FlowType = GWType.Flow;
      grb.WaterFlow = new TimespanSeries();
      grb.WaterFlow.AddSiValue(DateTime.MinValue,DateTime.MaxValue, Evaporation.Unit.ToSiUnit(29/12) * L.Area);
      IsotopeWater gwsp25 = new IsotopeWater(1);
      gwsp25.SetIsotopeRatio(11.5);
      grb.WaterSample = gwsp25;

      GroundWaterBoundary gout = new GroundWaterBoundary(L, 1e-7, 1, -1, (XYPolygon)L.Geometry);
      gout.FlowType = GWType.Flow;
      gout.WaterFlow = new TimespanSeries();
      gout.WaterFlow.AddSiValue(DateTime.MinValue, DateTime.MaxValue, - Evaporation.Unit.ToSiUnit(54/12) * L.Area);
      
      DateTime Start = new DateTime(1985,1,1);
      L.Precipitation.Add(Precip);
      Precip.ContactGeometry = L.Geometry;
      L.EvaporationBoundaries.Add(erb);
      erb.ContactGeometry = L.Geometry;
      L.GroundwaterBoundaries.Add(grb);
      L.GroundwaterBoundaries.Add(gout);

      Model M = new Model();
      M.WaterBodies.Add(L);
      M.SetState("Initial", Start, LakeWater);

      L.Depth *= 1.5;
      ((IsotopeWater)L.CurrentStoredWater).CurrentTime = Start;
      M.MoveInTime(new DateTime(1985, 12, 31), TimeSpan.FromDays(10));

      M.Save(@"..\..\..\TestData\Krabbenhoft.xml");
    }
示例#6
0
        public void Initialize(System.Collections.Hashtable properties)
        {
            if (!properties.Contains("InputFilename"))
            {
                throw new Exception("Missing key \"InputFilename\" in parameter to method HydroNumerics.HydroNet.OpenMI.EngineWrapper.Initialize(...)");
            }

            if (!properties.Contains("TimestepLength"))
            {
                throw new Exception("Missing key \"TimestepLength\" in parameter to method HydroNumerics.HydroNet.OpenMI.EngineWrapper.Initialize(...)");
            }


            inputFilename = (string)properties["InputFilename"];

            double dt = Convert.ToDouble((string)properties["TimestepLength"]);

            timestepLength = System.TimeSpan.FromSeconds(dt);


            // because the OpenMI configuration editor works makes paths relative to locations of OMI files or the configuration editor itselves, thigs may go wrong.
            // In order to overcome this problem, the full path for the input file is saves, so when the Finish method is invoked, the output is save to the input file again and not
            // a file at some random location :-). See below
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(inputFilename);
            inputFilename = fileInfo.FullName;

            model = HydroNumerics.HydroNet.Core.ModelFactory.GetModel(inputFilename);
            model.Initialize();
            //model = ModelFactory.GetModel(inputFilename);


            foreach (var wb in model._waterBodies)
            {
                //Build exchangeitems from groundwater boundaries
                foreach (var gwb in wb.GroundwaterBoundaries)
                {
                    GroundWaterBoundary GWB = gwb as GroundWaterBoundary;
                    if (GWB != null)
                    {
                        ElementSet elementSet = new ElementSet();
                        elementSet.ID               = GWB.Name;
                        elementSet.Description      = "Location: " + GWB.Name;
                        elementSet.SpatialReference = new SpatialReference("Undefined");
                        Element element = new Element();
                        element.ID = GWB.Name;

                        elementSet.ElementType = ElementType.XYPolygon;
                        foreach (XYPoint xyPoint in ((XYPolygon)GWB.ContactGeometry).Points)
                        {
                            element.AddVertex(new Vertex(xyPoint.X, xyPoint.Y, 0));
                        }

                        elementSet.AddElement(element);

                        //Head
                        HydroNumerics.OpenMI.Sdk.Backbone.Dimension dimension = new HydroNumerics.OpenMI.Sdk.Backbone.Dimension();
                        dimension.Length = 1;

                        HydroNumerics.OpenMI.Sdk.Backbone.Unit unit = new HydroNumerics.OpenMI.Sdk.Backbone.Unit();
                        unit.ID                   = "m";
                        unit.Description          = "meter";
                        unit.ConversionFactorToSI = 1;
                        unit.OffSetToSI           = 0;

                        Quantity quantity = new Quantity();
                        quantity.ID          = "Head";
                        quantity.Description = "Head at:" + GWB.Name;
                        quantity.Dimension   = dimension;
                        quantity.Unit        = unit;

                        InputExchangeItem inputExchangeItem = new InputExchangeItem();
                        inputExchangeItem.Quantity   = quantity;
                        inputExchangeItem.ElementSet = elementSet;
                        inputExchangeItems.Add(inputExchangeItem);

                        HeadBoundaries.Add(GWB.Name, GWB);

                        //Leakage
                        Quantity leakage = new Quantity("Leakage");
                        leakage.Description = "Leakage at:" + GWB.Name;
                        var leakageDimension = new HydroNumerics.OpenMI.Sdk.Backbone.Dimension();
                        leakageDimension.Length = 3;
                        leakageDimension.Time   = -1;
                        leakage.Dimension       = leakageDimension;
                        leakage.Unit            = new HydroNumerics.OpenMI.Sdk.Backbone.Unit("m3/s", 1, 0);

                        OutputExchangeItem outputitem = new OutputExchangeItem();
                        outputitem.Quantity   = leakage;
                        outputitem.ElementSet = elementSet;
                        outputExchangeItems.Add(outputitem);
                        LeakageBoundaries.Add(GWB.Name, GWB);
                    }
                }

                foreach (var S in wb.Sources)
                {
                    ElementSet elementSet = new ElementSet();
                    elementSet.ID               = S.Name;
                    elementSet.Description      = "Location: " + S.Name;
                    elementSet.SpatialReference = new SpatialReference("Undefined");
                    Element element = new Element();
                    element.ID = S.Name;

                    elementSet.ElementType = ElementType.IDBased;


                    //Flow
                    Quantity leakage = new Quantity("Flow");
                    leakage.Description = "Flow at:" + S.Name;
                    var leakageDimension = new HydroNumerics.OpenMI.Sdk.Backbone.Dimension();
                    leakageDimension.Length = 3;
                    leakageDimension.Time   = -1;
                    leakage.Dimension       = leakageDimension;
                    leakage.Unit            = new HydroNumerics.OpenMI.Sdk.Backbone.Unit("m3/s", 1, 0);

                    InputExchangeItem outputitem = new InputExchangeItem();
                    outputitem.Quantity   = leakage;
                    outputitem.ElementSet = elementSet;
                    inputExchangeItems.Add(outputitem);
                    FlowBoundaries.Add(S.Name, (SinkSourceBoundary)S);
                }
            }



            //foreach (var exchangeItem in model.ExchangeItems)
            //{
            //    HydroNumerics.OpenMI.Sdk.Backbone.Dimension dimention = new HydroNumerics.OpenMI.Sdk.Backbone.Dimension();
            //    dimention.AmountOfSubstance = exchangeItem.Unit.Dimension.AmountOfSubstance;
            //    dimention.Currency = exchangeItem.Unit.Dimension.Currency;
            //    dimention.ElectricCurrent = exchangeItem.Unit.Dimension.ElectricCurrent;
            //    dimention.Length = exchangeItem.Unit.Dimension.AmountOfSubstance;
            //    dimention.LuminousIntensity = exchangeItem.Unit.Dimension.Length;
            //    dimention.Mass = exchangeItem.Unit.Dimension.LuminousIntensity;
            //    dimention.AmountOfSubstance = exchangeItem.Unit.Dimension.Mass;
            //    dimention.Time = exchangeItem.Unit.Dimension.Time;

            //    HydroNumerics.OpenMI.Sdk.Backbone.Unit unit = new HydroNumerics.OpenMI.Sdk.Backbone.Unit();
            //    unit.ID = exchangeItem.Unit.ID;
            //    unit.Description = exchangeItem.Unit.Description;
            //    unit.ConversionFactorToSI = exchangeItem.Unit.ConversionFactorToSI;
            //    unit.OffSetToSI = unit.OffSetToSI;

            //    Quantity quantity = new Quantity();
            //    quantity.ID = exchangeItem.Quantity;
            //    quantity.Description = exchangeItem.Description;
            //    quantity.Dimension = dimention;
            //    quantity.Unit = unit;

            //    ElementSet elementSet = new ElementSet();
            //    elementSet.ID = exchangeItem.Location;
            //    elementSet.Description = "Location: " + exchangeItem.Location;
            //    elementSet.SpatialReference = new SpatialReference("Undefined");
            //    Element element = new Element();
            //    element.ID = exchangeItem.Location;

            //    if (exchangeItem.Geometry is XYPolygon)
            //    {
            //        elementSet.ElementType = ElementType.XYPolygon;
            //        foreach (XYPoint xyPoint in ((XYPolygon)exchangeItem.Geometry).Points)
            //        {
            //            element.AddVertex(new Vertex(xyPoint.X, xyPoint.Y, 0));
            //        }
            //    }
            //    else if (exchangeItem.Geometry is XYPoint)
            //    {
            //        throw new NotImplementedException();
            //    }
            //    else if (exchangeItem.Geometry is XYPolyline)
            //    {
            //        throw new NotImplementedException();
            //    }
            //    else
            //    {
            //        elementSet.ElementType = global::OpenMI.Standard.ElementType.IDBased;
            //    }


            //    elementSet.AddElement(element);


            //    if (exchangeItem.IsOutput)
            //    {
            //        OutputExchangeItem outputExchangeItem = new OutputExchangeItem();
            //        outputExchangeItem.Quantity = quantity;
            //        outputExchangeItem.ElementSet = elementSet;
            //        outputExchangeItems.Add(outputExchangeItem);
            //    }
            //    if (exchangeItem.IsInput)
            //    {
            //        InputExchangeItem inputExchangeItem = new InputExchangeItem();
            //        inputExchangeItem.Quantity = quantity;
            //        inputExchangeItem.ElementSet = elementSet;
            //        inputExchangeItems.Add(inputExchangeItem);
            //    }
            //}
        }
 public ModelViewModel(Model M)
 {
   _model = M;
   Initialize();
 }
 public ModelViewModel(string FileName)
 {
   _model = ModelFactory.GetModel(FileName);
 }
示例#9
0
        private Model CreateHydroNetModel()
        {
            
            DateTime startTime = new DateTime(2000, 1, 1);
          

            // -------------------- Polygons --------------------------------------
            HydroNumerics.Geometry.XYPolygon upperLakeGeometry = new HydroNumerics.Geometry.XYPolygon();
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(535.836, 2269.625));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(675.768, 2187.713));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(771.331, 2177.474));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(887.372, 2184.300));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(935.154, 2255.973));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(945.392, 2385.666));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(931.741, 2505.119));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(877.133, 2546.075));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(812.287, 2638.225));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(696.246, 2675.768));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(638.225, 2627.986));
            upperLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(573.379, 2587.031));

            HydroNumerics.Geometry.XYPolygon lowerLakeGeometry = new HydroNumerics.Geometry.XYPolygon();
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1935.154, 1150.171));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1901.024, 1058.020));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1877.133, 965.870));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1894.198, 897.611));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1938.567, 808.874));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2023.891, 761.092));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2116.041, 740.614));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2232.082, 747.440));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2327.645, 808.874));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2389.078, 969.283));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2372.014, 1109.215));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2262.799, 1218.430));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(2105.802, 1235.495));
            lowerLakeGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1982.935, 1225.256));

            HydroNumerics.Geometry.XYPolygon upperStreamGeometry = new HydroNumerics.Geometry.XYPolygon();
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(863.481, 2177.474));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(914.676, 2129.693));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(965.870, 2071.672));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(976.109, 2027.304));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(976.109, 1989.761));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1006.826, 1959.044));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1051.195, 1918.089));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1095.563, 1877.133));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1126.280, 1808.874));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1187.713, 1781.570));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1228.669, 1730.375));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1262.799, 1665.529));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1283.276, 1597.270));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1317.406, 1535.836));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1341.297, 1484.642));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1389.078, 1457.338));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1423.208, 1440.273));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1477.816, 1402.730));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1511.945, 1358.362));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1539.249, 1327.645));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1566.553, 1354.949));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1535.836, 1406.143));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1508.532, 1457.338));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1440.273, 1522.184));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1368.601, 1580.205));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1327.645, 1631.399));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1307.167, 1696.246));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1269.625, 1767.918));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1221.843, 1819.113));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1191.126, 1843.003));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1136.519, 1894.198));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1088.737, 1935.154));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1061.433, 1976.109));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1030.717, 2040.956));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1013.652, 2105.802));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(972.696, 2177.474));
            upperStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(918.089, 2228.669));

            HydroNumerics.Geometry.XYPolygon lowerStreamGeometry = new HydroNumerics.Geometry.XYPolygon();
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1904.437, 1081.911));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1921.502, 1153.584));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1771.331, 1255.973));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1573.379, 1354.949));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1542.662, 1324.232));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1597.270, 1273.038));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1709.898, 1215.017));
            lowerStreamGeometry.Points.Add(new HydroNumerics.Geometry.XYPoint(1839.590, 1143.345));

            // --- precipitation --------------------------------------------------

            const int numberOfTimesteps = 2190;
            double[] precipitation = new double[numberOfTimesteps] { 0.0000, 0.0000, 2.3000, 0.2000, 0.0000, 0.1000, 0.1000, 0.0000, 0.3000, 0.4000, 0.1000, 0.1000, 1.0000, 0.0000, 0.5000, 5.3000, 1.9000, 0.1000, 0.0000, 0.4000, 1.1000, 1.2000, 2.6000, 0.0000, 1.5000, 3.4000, 6.0000, 0.7000, 4.0000, 0.1000, 0.6000, 2.0000, 0.4000, 0.1000, 0.0000, 0.0000, 0.0000, 4.1000, 0.2000, 4.0000, 0.3000, 0.6000, 3.1000, 14.1000, 3.9000, 0.1000, 3.7000, 2.4000, 4.3000, 0.0000, 0.0000, 0.0000, 0.0000, 2.7000, 1.0000, 0.1000, 0.3000, 0.2000, 0.0000, 0.2000, 8.7000, 2.0000, 1.8000, 0.9000, 0.1000, 0.2000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 1.8000, 0.0000, 1.1000, 4.7000, 2.4000, 0.0000, 0.1000, 8.2000, 4.6000, 1.0000, 0.1000, 0.0000, 0.0000, 7.8000, 2.0000, 0.3000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.3000, 0.1000, 2.2000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 6.7000, 0.0000, 0.0000, 0.0000, 5.4000, 2.2000, 1.0000, 10.8000, 3.6000, 3.1000, 10.1000, 0.0000, 0.3000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.3000, 0.0000, 0.0000, 7.6000, 3.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 4.5000, 0.0000, 12.8000, 0.0000, 4.4000, 0.0000, 0.0000, 0.0000, 0.0000, 4.9000, 0.0000, 0.8000, 0.0000, 2.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 7.1000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.4000, 1.5000, 4.6000, 1.4000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 5.5000, 4.6000, 1.3000, 0.1000, 2.8000, 2.6000, 0.0000, 0.1000, 3.5000, 1.0000, 8.7000, 0.5000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 3.8000, 4.9000, 4.6000, 2.5000, 7.9000, 0.1000, 4.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 14.4000, 2.0000, 6.2000, 0.5000, 0.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 8.1000, 1.3000, 20.2000, 13.5000, 1.1000, 1.3000, 0.0000, 0.0000, 2.1000, 13.7000, 3.9000, 0.5000, 0.1000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.2000, 4.8000, 7.2000, 0.4000, 0.0000, 4.6000, 0.2000, 0.0000, 0.0000, 0.5000, 4.8000, 9.8000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 8.5000, 0.5000, 1.9000, 1.2000, 0.0000, 3.2000, 1.7000, 12.3000, 1.9000, 0.0000, 4.3000, 3.6000, 1.1000, 6.7000, 5.4000, 0.0000, 0.0000, 0.9000, 10.0000, 7.8000, 0.1000, 1.3000, 0.5000, 0.1000, 0.2000, 0.5000, 0.0000, 7.2000, 0.0000, 0.0000, 10.2000, 9.7000, 0.2000, 0.1000, 0.9000, 3.5000, 1.2000, 4.9000, 4.6000, 3.5000, 1.1000, 5.8000, 0.4000, 0.0000, 0.0000, 0.6000, 0.1000, 1.2000, 0.8000, 9.4000, 1.5000, 0.1000, 0.1000, 0.2000, 0.9000, 4.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.1000, 1.9000, 0.8000, 0.9000, 2.1000, 7.9000, 3.8000, 3.8000, 9.6000, 1.4000, 7.9000, 0.4000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 7.0000, 0.1000, 0.1000, 0.1000, 5.3000, 1.0000, 4.3000, 0.2000, 0.0000, 1.8000, 0.1000, 0.6000, 0.0000, 1.5000, 3.2000, 0.1000, 4.1000, 5.5000, 10.6000, 9.0000, 0.9000, 0.8000, 2.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 2.5000, 5.7000, 2.3000, 2.0000, 0.6000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.2000, 9.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 9.3000, 0.0000, 0.0000, 0.0000, 0.0000, 5.3000, 0.0000, 0.0000, 0.7000, 9.0000, 0.2000, 0.0000, 0.0000, 2.8000, 2.4000, 1.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 6.4000, 0.0000, 0.0000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 7.1000, 0.1000, 0.0000, 0.2000, 0.0000, 0.0000, 0.2000, 0.0000, 0.6000, 0.9000, 10.0000, 5.1000, 4.1000, 10.3000, 1.9000, 0.0000, 0.0000, 0.0000, 0.2000, 4.2000, 0.4000, 5.8000, 0.5000, 0.1000, 3.3000, 4.9000, 1.4000, 0.5000, 0.0000, 1.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000, 0.0000, 2.4000, 7.6000, 5.2000, 11.4000, 0.1000, 1.1000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 0.0000, 2.3000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 5.2000, 2.2000, 0.0000, 10.0000, 5.3000, 1.2000, 8.0000, 30.7000, 2.9000, 0.0000, 0.0000, 0.0000, 6.8000, 0.0000, 0.0000, 0.0000, 1.4000, 0.5000, 4.1000, 0.1000, 10.6000, 11.2000, 2.5000, 6.2000, 5.3000, 4.5000, 12.8000, 0.1000, 1.0000, 0.0000, 0.0000, 22.7000, 2.5000, 5.5000, 3.7000, 0.8000, 0.0000, 1.6000, 1.7000, 3.8000, 0.2000, 0.3000, 0.0000, 0.4000, 0.0000, 0.2000, 0.5000, 1.0000, 16.3000, 0.3000, 4.3000, 14.8000, 0.0000, 2.7000, 0.0000, 2.8000, 3.2000, 5.3000, 2.1000, 0.0000, 2.2000, 0.4000, 0.3000, 0.1000, 0.0000, 0.0000, 1.8000, 0.5000, 9.4000, 11.4000, 2.4000, 9.2000, 1.1000, 11.1000, 6.4000, 8.3000, 15.3000, 0.1000, 6.8000, 2.9000, 0.0000, 0.3000, 0.4000, 0.2000, 3.3000, 6.2000, 1.0000, 9.0000, 5.5000, 0.0000, 0.0000, 3.0000, 1.1000, 0.0000, 10.8000, 0.0000, 7.1000, 2.0000, 1.6000, 7.2000, 9.4000, 0.9000, 6.1000, 1.4000, 2.5000, 0.6000, 8.1000, 0.9000, 2.8000, 5.0000, 3.3000, 2.1000, 9.5000, 0.0000, 6.0000, 7.0000, 0.0000, 2.2000, 1.8000, 0.2000, 1.1000, 5.2000, 0.0000, 0.3000, 1.6000, 0.8000, 0.4000, 0.0000, 0.2000, 1.4000, 5.9000, 7.1000, 7.0000, 1.9000, 1.5000, 0.1000, 0.3000, 5.6000, 4.1000, 4.8000, 1.5000, 1.5000, 2.7000, 11.4000, 8.6000, 3.7000, 5.7000, 1.3000, 13.4000, 5.6000, 5.9000, 5.4000, 5.3000, 0.1000, 0.1000, 0.2000, 0.0000, 0.5000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 2.9000, 3.0000, 1.0000, 14.6000, 0.6000, 5.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.6000, 2.2000, 0.0000, 0.0000, 0.6000, 0.0000, 0.2000, 2.4000, 0.3000, 0.0000, 0.3000, 5.8000, 1.6000, 1.6000, 5.7000, 2.8000, 1.9000, 0.6000, 2.8000, 0.0000, 8.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.1000, 0.0000, 0.0000, 0.0000, 0.2000, 0.5000, 0.0000, 3.7000, 5.0000, 10.2000, 1.2000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.3000, 0.0000, 0.0000, 2.2000, 8.4000, 11.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 12.4000, 2.8000, 3.9000, 10.1000, 4.5000, 6.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 0.5000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 1.4000, 7.3000, 0.0000, 3.7000, 11.1000, 1.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 8.3000, 2.2000, 6.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 11.6000, 5.9000, 0.0000, 0.0000, 8.9000, 17.1000, 0.1000, 4.9000, 2.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 14.5000, 2.7000, 1.9000, 3.3000, 0.0000, 0.0000, 19.9000, 2.4000, 4.1000, 2.0000, 4.2000, 0.9000, 0.3000, 0.0000, 0.1000, 0.3000, 0.0000, 3.1000, 2.5000, 0.0000, 1.6000, 3.8000, 8.2000, 5.7000, 7.7000, 0.3000, 0.0000, 5.4000, 7.9000, 1.3000, 10.0000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 0.9000, 0.0000, 0.0000, 0.1000, 2.6000, 6.3000, 4.7000, 0.7000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 2.3000, 2.0000, 0.0000, 3.1000, 0.9000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.4000, 7.5000, 12.4000, 2.9000, 0.5000, 7.6000, 1.6000, 2.3000, 0.0000, 0.0000, 2.1000, 2.3000, 8.0000, 2.1000, 1.7000, 0.0000, 0.0000, 17.9000, 4.5000, 0.5000, 0.7000, 0.3000, 0.0000, 1.1000, 0.1000, 0.0000, 0.0000, 1.1000, 0.1000, 0.0000, 1.2000, 0.0000, 1.2000, 0.8000, 0.7000, 0.0000, 0.1000, 0.2000, 0.2000, 0.0000, 0.4000, 1.3000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000, 0.0000, 0.0000, 2.3000, 0.2000, 0.0000, 0.1000, 0.1000, 0.0000, 0.3000, 0.4000, 0.1000, 0.1000, 1.0000, 0.0000, 0.5000, 5.3000, 1.9000, 0.1000, 0.0000, 0.4000, 1.1000, 1.2000, 2.6000, 0.0000, 1.5000, 3.4000, 6.0000, 0.7000, 4.0000, 0.1000, 0.6000, 2.0000, 0.4000, 0.1000, 0.0000, 0.0000, 0.0000, 4.1000, 0.2000, 4.0000, 0.3000, 0.6000, 3.1000, 14.1000, 3.9000, 0.1000, 3.7000, 2.4000, 4.3000, 0.0000, 0.0000, 0.0000, 0.0000, 2.7000, 1.0000, 0.1000, 0.3000, 0.2000, 0.0000, 0.2000, 8.7000, 2.0000, 1.8000, 0.9000, 0.1000, 0.2000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 1.8000, 0.0000, 1.1000, 4.7000, 2.4000, 0.0000, 0.1000, 8.2000, 4.6000, 1.0000, 0.1000, 0.0000, 0.0000, 7.8000, 2.0000, 0.3000, 0.0000, 0.1000, 0.1000, 0.0000, 0.0000, 0.3000, 0.1000, 2.2000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 6.7000, 0.0000, 0.0000, 0.0000, 5.4000, 2.2000, 1.0000, 10.8000, 3.6000, 3.1000, 10.1000, 0.0000, 0.3000, 2.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.3000, 0.0000, 0.0000, 7.6000, 3.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 4.5000, 0.0000, 12.8000, 0.0000, 4.4000, 0.0000, 0.0000, 0.0000, 0.0000, 4.9000, 0.0000, 0.8000, 0.0000, 2.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 7.1000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.4000, 1.5000, 4.6000, 1.4000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 5.5000, 4.6000, 1.3000, 0.1000, 2.8000, 2.6000, 0.0000, 0.1000, 3.5000, 1.0000, 8.7000, 0.5000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 3.8000, 4.9000, 4.6000, 2.5000, 7.9000, 0.1000, 4.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 14.4000, 2.0000, 6.2000, 0.5000, 0.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 8.1000, 1.3000, 20.2000, 13.5000, 1.1000, 1.3000, 0.0000, 0.0000, 2.1000, 13.7000, 3.9000, 0.5000, 0.1000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.2000, 4.8000, 7.2000, 0.4000, 0.0000, 4.6000, 0.2000, 0.0000, 0.0000, 0.5000, 4.8000, 9.8000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 8.5000, 0.5000, 1.9000, 1.2000, 0.0000, 3.2000, 1.7000, 12.3000, 1.9000, 0.0000, 4.3000, 3.6000, 1.1000, 6.7000, 5.4000, 0.0000, 0.0000, 0.9000, 10.0000, 7.8000, 0.1000, 1.3000, 0.5000, 0.1000, 0.2000, 0.5000, 0.0000, 7.2000, 0.0000, 0.0000, 10.2000, 9.7000, 0.2000, 0.1000, 0.9000, 3.5000, 1.2000, 4.9000, 4.6000, 3.5000, 1.1000, 5.8000, 0.4000, 0.0000, 0.0000, 0.6000, 0.1000, 1.2000, 0.8000, 9.4000, 1.5000, 0.1000, 0.1000, 0.2000, 0.9000, 4.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.1000, 1.9000, 0.8000, 0.9000, 2.1000, 7.9000, 3.8000, 3.8000, 9.6000, 1.4000, 7.9000, 0.4000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 7.0000, 0.1000, 0.1000, 0.1000, 5.3000, 1.0000, 4.3000, 0.2000, 0.0000, 1.8000, 0.1000, 0.6000, 0.0000, 1.5000, 3.2000, 0.1000, 4.1000, 5.5000, 10.6000, 9.0000, 0.9000, 0.8000, 2.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.4000, 0.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.1000, 2.5000, 5.7000, 2.3000, 2.0000, 0.6000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.2000, 9.6000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 9.3000, 0.0000, 0.0000, 0.0000, 0.0000, 5.3000, 0.0000, 0.0000, 0.7000, 9.0000, 0.2000, 0.0000, 0.0000, 2.8000, 2.4000, 1.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 6.4000, 0.0000, 0.0000, 0.8000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 7.1000, 0.1000, 0.0000, 0.2000, 0.0000, 0.0000, 0.2000, 0.0000, 0.6000, 0.9000, 10.0000, 5.1000, 4.1000, 10.3000, 1.9000, 0.0000, 0.0000, 0.0000, 0.2000, 4.2000, 0.4000, 5.8000, 0.5000, 0.1000, 3.3000, 4.9000, 1.4000, 0.5000, 0.0000, 1.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000, 0.0000, 2.4000, 7.6000, 5.2000, 11.4000, 0.1000, 1.1000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 0.0000, 2.3000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 5.2000, 2.2000, 0.0000, 10.0000, 5.3000, 1.2000, 8.0000, 30.7000, 2.9000, 0.0000, 0.0000, 0.0000, 6.8000, 0.0000, 0.0000, 0.0000, 1.4000, 0.5000, 4.1000, 0.1000, 10.6000, 11.2000, 2.5000, 6.2000, 5.3000, 4.5000, 12.8000, 0.1000, 1.0000, 0.0000, 0.0000, 22.7000, 2.5000, 5.5000, 3.7000, 0.8000, 0.0000, 1.6000, 1.7000, 3.8000, 0.2000, 0.3000, 0.0000, 0.4000, 0.0000, 0.2000, 0.5000, 1.0000, 16.3000, 0.3000, 4.3000, 14.8000, 0.0000, 2.7000, 0.0000, 2.8000, 3.2000, 5.3000, 2.1000, 0.0000, 2.2000, 0.4000, 0.3000, 0.1000, 0.0000, 0.0000, 1.8000, 0.5000, 9.4000, 11.4000, 2.4000, 9.2000, 1.1000, 11.1000, 6.4000, 8.3000, 15.3000, 0.1000, 6.8000, 2.9000, 0.0000, 0.3000, 0.4000, 0.2000, 3.3000, 6.2000, 1.0000, 9.0000, 5.5000, 0.0000, 0.0000, 3.0000, 1.1000, 0.0000, 10.8000, 0.0000, 7.1000, 2.0000, 1.6000, 7.2000, 9.4000, 0.9000, 6.1000, 1.4000, 2.5000, 0.6000, 8.1000, 0.9000, 2.8000, 5.0000, 3.3000, 2.1000, 9.5000, 0.0000, 6.0000, 7.0000, 0.0000, 2.2000, 1.8000, 0.2000, 1.1000, 5.2000, 0.0000, 0.3000, 1.6000, 0.8000, 0.4000, 0.0000, 0.2000, 1.4000, 5.9000, 7.1000, 7.0000, 1.9000, 1.5000, 0.1000, 0.3000, 5.6000, 4.1000, 4.8000, 1.5000, 1.5000, 2.7000, 11.4000, 8.6000, 3.7000, 5.7000, 1.3000, 13.4000, 5.6000, 5.9000, 5.4000, 5.3000, 0.1000, 0.1000, 0.2000, 0.0000, 0.5000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 4.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 0.0000, 2.9000, 3.0000, 1.0000, 14.6000, 0.6000, 5.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 1.6000, 2.2000, 0.0000, 0.0000, 0.6000, 0.0000, 0.2000, 2.4000, 0.3000, 0.0000, 0.3000, 5.8000, 1.6000, 1.6000, 5.7000, 2.8000, 1.9000, 0.6000, 2.8000, 0.0000, 8.8000, 2.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.1000, 0.0000, 0.0000, 0.0000, 0.2000, 0.5000, 0.0000, 3.7000, 5.0000, 10.2000, 1.2000, 0.4000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6000, 0.3000, 0.0000, 0.0000, 2.2000, 8.4000, 11.5000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.8000, 12.4000, 2.8000, 3.9000, 10.1000, 4.5000, 6.6000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.5000, 0.5000, 0.0000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.7000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 3.2000, 1.4000, 7.3000, 0.0000, 3.7000, 11.1000, 1.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.1000, 8.3000, 2.2000, 6.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 11.6000, 5.9000, 0.0000, 0.0000, 8.9000, 17.1000, 0.1000, 4.9000, 2.3000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 14.5000, 2.7000, 1.9000, 3.3000, 0.0000, 0.0000, 19.9000, 2.4000, 4.1000, 2.0000, 4.2000, 0.9000, 0.3000, 0.0000, 0.1000, 0.3000, 0.0000, 3.1000, 2.5000, 0.0000, 1.6000, 3.8000, 8.2000, 5.7000, 7.7000, 0.3000, 0.0000, 5.4000, 7.9000, 1.3000, 10.0000, 0.6000, 0.7000, 0.0000, 0.0000, 0.0000, 0.9000, 0.0000, 0.0000, 0.1000, 2.6000, 6.3000, 4.7000, 0.7000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.2000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 2.3000, 2.0000, 0.0000, 3.1000, 0.9000, 0.1000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.3000, 0.4000, 7.5000, 12.4000, 2.9000, 0.5000, 7.6000, 1.6000, 2.3000, 0.0000, 0.0000, 2.1000, 2.3000, 8.0000, 2.1000, 1.7000, 0.0000, 0.0000, 17.9000, 4.5000, 0.5000, 0.7000, 0.3000, 0.0000, 1.1000, 0.1000, 0.0000, 0.0000, 1.1000, 0.1000, 0.0000, 1.2000, 0.0000, 1.2000, 0.8000, 0.7000, 0.0000, 0.1000, 0.2000, 0.2000, 0.0000, 0.4000, 1.3000, 0.0000, 0.0000, 0.0000, 0.1000, 1.4000 };
            HydroNumerics.Time.Core.TimestampSeries precipitationTs = new HydroNumerics.Time.Core.TimestampSeries("PrecipitationTS", startTime, numberOfTimesteps, 1, HydroNumerics.Time.Core.TimestepUnit.Days, -99999, new HydroNumerics.Core.Unit("m3PrSec", 1, 0));
            //HydroNumerics.Time.Core.TimestampSeries precipitationTs = new HydroNumerics.Time.Core.TimestampSeries("PrecipitationTS", startTime, numberOfTimesteps, 1, HydroNumerics.Time.Core.TimestepUnit.Days, -99999, new HydroNumerics.Core.Unit("mmPrDay", 1.0/(1000*24*3600), 0));
            for (int i = 0; i < numberOfTimesteps; i++)
            {
                precipitationTs.Items[i].Value = precipitation[i]  / (24 * 3600 * 1000);
                //precipitationTs.Items[i].Value = precipitation[i];
            }
            // --------------------------------------------------------------------


            // Upper Lake configuration
            //Lake upperLake = new Lake("Upper Lake", 2 * upperLakeGeometry.GetArea());
            Lake upperLake = new Lake("Upper Lake", upperLakeGeometry);
            upperLake.WaterLevel = 6.1;
            upperLake.Depth = 2;
            upperLake.Output.LogAllChemicals = true;
            

            //Lake lowerLake = new Lake("lower Lake", 2 * lowerLakeGeometry.GetArea());
            Lake lowerLake = new Lake("lower Lake", lowerLakeGeometry);
            lowerLake.Depth = 2;
            lowerLake.WaterLevel = 6.0;
            lowerLake.Output.LogAllChemicals = true;

            HydroNet.Core.Stream upperStream = new HydroNet.Core.Stream("The stream", 2000, 2, 1);
            upperStream.WaterLevel = 6.0;
            upperStream.Output.LogAllChemicals = true;
            
            HydroNet.Core.Stream lowerStream = new HydroNet.Core.Stream("Lower Stream", 1000, 2, 1);
            lowerStream.WaterLevel = 6.0;
            lowerStream.Output.LogAllChemicals = true;

            //SinkSourceBoundary upperLakePrecipitation = new SinkSourceBoundary(0.002 * contactPolygonUpperLake.GetArea() / (24 * 3600));
            SinkSourceBoundary upperLakePrecipitation = new SinkSourceBoundary(precipitationTs);
            upperLakePrecipitation.ContactGeometry = upperLakeGeometry;
            
            upperLakePrecipitation.Name = "Inflow to upperlake";


            //SinkSourceBoundary lowerLakePrecipitation = new SinkSourceBoundary(0.002 * contactPolygonLowerLake.GetArea()/ (24 * 3600));
            SinkSourceBoundary lowerLakePrecipitation = new SinkSourceBoundary(precipitationTs);
            lowerLakePrecipitation.ContactGeometry = lowerLakeGeometry;
            upperLakePrecipitation.Name = "Inflow to lowerlake";

            // -------- Groundwater boundary under upper lake ----------
            GroundWaterBoundary groundWaterBoundaryUpperLake = new GroundWaterBoundary();
            groundWaterBoundaryUpperLake.Connection = upperLake;
            groundWaterBoundaryUpperLake.ContactGeometry = upperLakeGeometry;
            groundWaterBoundaryUpperLake.Distance = 2.3;
            groundWaterBoundaryUpperLake.HydraulicConductivity = 1e-9;
            groundWaterBoundaryUpperLake.GroundwaterHead = 5.0;
            groundWaterBoundaryUpperLake.Name = "Groundwater boundary under UpperLake";
            groundWaterBoundaryUpperLake.Name = "UpperGWBoundary";
            ((WaterPacket)groundWaterBoundaryUpperLake.WaterSample).AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon), 2.3);
            ((WaterPacket)groundWaterBoundaryUpperLake.WaterSample).AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 2.3);

            // -------- Groundwater boundary under lower lake ----------
            GroundWaterBoundary groundWaterBoundaryLowerLake = new GroundWaterBoundary();
            groundWaterBoundaryLowerLake.Connection = lowerLake;
            groundWaterBoundaryLowerLake.ContactGeometry = lowerLakeGeometry;
            groundWaterBoundaryLowerLake.Distance = 2.3;
            groundWaterBoundaryLowerLake.HydraulicConductivity = 1e-12;
            groundWaterBoundaryLowerLake.GroundwaterHead = 5.0;
            groundWaterBoundaryLowerLake.Name = "Groundwater boundary under LowerLake";
            groundWaterBoundaryLowerLake.Name = "LowerGWBoundary";

            //--- Ground water boundary upper Stream ------
            GroundWaterBoundary groundWaterBoundaryUpperStream = new GroundWaterBoundary();
            groundWaterBoundaryUpperStream.Connection = upperStream;
            groundWaterBoundaryUpperStream.ContactGeometry = upperStreamGeometry;
            groundWaterBoundaryUpperStream.Distance = 2.3;
            groundWaterBoundaryUpperStream.HydraulicConductivity = 1e-12;
            groundWaterBoundaryUpperStream.GroundwaterHead = 5.0;
            groundWaterBoundaryUpperStream.Name = "Groundwater boundary Upper Stream";
            groundWaterBoundaryUpperStream.Name = "UpperStreamGWBoundary";
            
            // ---------  Ground water boundary lower stream ------------------------------------------
            GroundWaterBoundary groundWaterBoundaryLowerStream = new GroundWaterBoundary();
            groundWaterBoundaryLowerStream.Connection = lowerStream;
            groundWaterBoundaryLowerStream.ContactGeometry = lowerStreamGeometry;
            groundWaterBoundaryLowerStream.Distance = 2.3;
            groundWaterBoundaryLowerStream.HydraulicConductivity = 1e-12;
            groundWaterBoundaryLowerStream.GroundwaterHead = 5.0;
            groundWaterBoundaryLowerStream.Name = "Groundwater boundary Lower Stream";
            groundWaterBoundaryLowerStream.Name = "LowerStreamGWBoundary";
            // ------------------------------------------------------------------------------

            upperLake.SurfaceArea = upperLakeGeometry;
            lowerLake.SurfaceArea = lowerLakeGeometry;
            upperLake.Precipitation.Add(upperLakePrecipitation);
            lowerLake.Precipitation.Add(lowerLakePrecipitation);

            upperLake.GroundwaterBoundaries.Add(groundWaterBoundaryUpperLake);
            upperStream.GroundwaterBoundaries.Add(groundWaterBoundaryUpperStream);
            lowerStream.GroundwaterBoundaries.Add(groundWaterBoundaryLowerStream);
            lowerLake.GroundwaterBoundaries.Add(groundWaterBoundaryLowerLake);

 
            upperLake.DownStreamConnections.Add(upperStream);
            upperStream.DownStreamConnections.Add(lowerStream);
            lowerStream.DownStreamConnections.Add(lowerLake);

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

            WaterPacket waterPacket = new WaterPacket(1000);
            waterPacket.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 9.2);

            WaterPacket waterpacketLowerLake = new WaterPacket(lowerLake.Volume);
            waterpacketLowerLake.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 4.2);


            model.SetState("MyState", startTime, waterPacket);
            lowerLake.SetState("MyState", startTime, waterpacketLowerLake);
            
            //model.SetState("kkk", startTime, new 
            //upperLake.SetState("MyState", startTime, new WaterPacket(2));
            model.Name = "Lake model";
            model.Initialize();
            //model.Update(new DateTime(2001, 1, 1));
            return model;
        }
示例#10
0
    public void MoveInTimeTest2()
    {
      SinkSourceBoundary b1 = new SinkSourceBoundary(100);
      b1.WaterSample = new WaterPacket(1, 1);

      SinkSourceBoundary b2 = new SinkSourceBoundary(300);
      b2.WaterSample = new WaterPacket(2, 1);

      var Network = NetworkBuilder.CreateSortedYBranch(5, b1, b2);

      Model target = new Model();
      target._waterBodies.AddRange(Network.Cast<IWaterBody>());


      DateTime Start = new DateTime(2010, 1, 1);
      DateTime End = new DateTime(2010, 1, 3);
      TimeSpan TimeStep = new TimeSpan(1, 0, 0, 0);
      target.SetState("Initial", Start, new WaterPacket(1));
      target.MoveInTime(End, TimeStep);
      Assert.AreEqual(Network.First().Output.Outflow.Items.Last().Value * 4, Network.Last().Output.Outflow.Items.Last().Value,0.0001);
      Assert.AreEqual(End, Network.First().CurrentTime);

      Assert.AreEqual(0.25, Network.Last().CurrentStoredWater.Composition[b1.WaterSample.Composition.Keys.First()], 0.0001);
      Assert.AreEqual(0.75, Network.Last().CurrentStoredWater.Composition[b2.WaterSample.Composition.Keys.First()], 0.0001);

    }
 public void HydroNetExample01()
 {
     Lake lake = new Lake("L", 10000);
     SinkSourceBoundary flowBoundary = new SinkSourceBoundary(2);
     lake.Sources.Add(flowBoundary);
     Model model = new Model();
     model._waterBodies.Add(lake);
     model.SetState("Kurt", new DateTime(2010, 1, 1), new WaterPacket(1.2));
     
     for (int i = 0; i < 5; i++)
     {
         model.Update(model.CurrentTime.Add(new System.TimeSpan(0, 0, 1)));
     }
 }
        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;
        }
    public void RunOnstoredData()
    {
      Lake L = new Lake("Test", 1000);
      GroundWaterBoundary gwb = new GroundWaterBoundary(L, 14 - 5, 1, 10, (XYPolygon) L.Geometry);
      L.WaterLevel = 9;
      DateTime Start = new DateTime(2000, 1, 1);
      DateTime End = new DateTime(2000, 2, 1);
      L.GroundwaterBoundaries.Add(gwb);
      Model m = new Model();
      m._waterBodies.Add(L);
      m.SetState("Initial", Start, new WaterPacket(1));
      m.MoveInTime(End, TimeSpan.FromDays(1));

      DateTime Mid = new DateTime(2000,1,15);

      double flow = L.Output.GroundwaterInflow.GetValue(Mid);

      gwb.FlowType = GWType.Flow;
      gwb.HydraulicConductivity = 1;
      gwb.GroundwaterHead = 1;

      m.RestoreState("Initial");
      m.MoveInTime(End, TimeSpan.FromDays(1));
      Assert.AreEqual(flow, L.Output.GroundwaterInflow.GetValue(Mid));

    }
        private Model CreateHydroNetModel()
        {
            // Upper Lake configuration
            Lake lake = new Lake("The Lake", 1000);
            lake.WaterLevel = 5.1;
            
            SinkSourceBoundary inflow = new SinkSourceBoundary(2);
            inflow.Name = "Inflow to lake";

            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 = lake;
            groundWaterBoundary.ContactGeometry = contactPolygon;
            groundWaterBoundary.Distance = 2.3;
            groundWaterBoundary.HydraulicConductivity = 1e-9;
            groundWaterBoundary.GroundwaterHead = 5.0;
            groundWaterBoundary.Name = "Groundwater boundary under Lake";
            groundWaterBoundary.Name = "MyGWBoundary";

            lake.Sources.Add(inflow);
            lake.GroundwaterBoundaries.Add(groundWaterBoundary);

            //Creating the model
            Model model = new Model();
            model._waterBodies.Add(lake);

            DateTime startTime = new DateTime(2000, 1, 1);
            model.SetState("MyState", startTime, new WaterPacket(1000));
            lake.SetState("MyState", startTime, new WaterPacket(2));
            model.Name = "Lake model";
            model.Initialize();
            model.Update(new DateTime(2001, 1, 1));
            return model;
        }
示例#15
0
    public void CompareStreamAndLakes()
    {
      var StreamNetwork =NetworkBuilder.CreateBranch(10);
      var LakeNetwork =NetworkBuilder.CreateConnectedLakes(10);

      Model Streams = new Model();
      Streams._waterBodies.AddRange(StreamNetwork.Cast<IWaterBody>());
      Model Lakes = new Model();
      Lakes._waterBodies.AddRange(LakeNetwork.Cast<IWaterBody>());

      SinkSourceBoundary b1 = new SinkSourceBoundary(100);
      StreamNetwork.First().Sources.Add(b1);
      LakeNetwork.First().Sources.Add(b1);

      Stopwatch SW = new Stopwatch();
      Stopwatch SW2 = new Stopwatch();


      DateTime Start = new DateTime(2000, 1, 1);
      DateTime End = new DateTime(2000, 1, 10);

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

      SW.Start();
      Streams.MoveInTime(End, TimeSpan.FromHours(5) );
      SW.Stop();
      SW2.Start();
      Lakes.MoveInTime(End, TimeSpan.FromHours(5));
      SW2.Stop();

      TimespanSeries TS1 = StreamNetwork.Last().Output.Items.First() as TimespanSeries;
      TimespanSeries TS2 = LakeNetwork.Last().Output.Items.First() as TimespanSeries;

      for (int i = 0; i < TS1.Items.Count; i++)
     {
       Assert.AreEqual(TS1.Items[i].Value, TS2.Items[i].Value, 0.000001);
       Assert.AreEqual(TS1.Items[i].StartTime, TS2.Items[i].StartTime);

     }


    }
示例#16
0
    public void TestMethod1()
    {
      Lake Gjeller = LakeFactory.GetLake("Gjeller Sø");
      Gjeller.Depth = 1.2;
      Gjeller.WaterLevel = 0.4;

      WaterPacket GjellerWater = new WaterPacket(1, 1);
      GjellerWater.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl), 1);

      TimeSeriesGroup climate = TimeSeriesGroupFactory.Create("climate.xts");

      foreach (var I in climate.Items)
      {
        I.ExtrapolationMethod = ExtrapolationMethods.RecycleYear;
        I.AllowExtrapolation = true;
      }

      EvaporationRateBoundary evap = new EvaporationRateBoundary((TimespanSeries)climate.Items[1]);
      evap.ContactGeometry = Gjeller.Geometry;
      Gjeller.EvaporationBoundaries.Add(evap);

      SinkSourceBoundary precip = new SinkSourceBoundary(climate.Items[0]);
      precip.ContactGeometry = Gjeller.Geometry;
      Gjeller.Precipitation.Add(precip);
      precip.ID = 2;
      precip.WaterSample = GjellerWater.DeepClone();
      precip.WaterSample.IDForComposition = precip.ID; ;

      GroundWaterBoundary GWIN = new GroundWaterBoundary(Gjeller, 1e-5, 2, 0.45, XYPolygon.GetSquare(Gjeller.Area / 2));
      GWIN.WaterSample = GjellerWater.DeepClone();
      GWIN.ID = 3;
      GWIN.WaterSample.IDForComposition = GWIN.ID;
      GWIN.Name = "Inflow";
      Gjeller.GroundwaterBoundaries.Add(GWIN);

      GroundWaterBoundary GWout = new GroundWaterBoundary(Gjeller, 1e-5, 2, 0.35, XYPolygon.GetSquare(Gjeller.Area / 2));
      GWout.Name = "Outflow";
      Gjeller.GroundwaterBoundaries.Add(GWout);


      TimespanSeries pumping = new TimespanSeries();
      pumping.AddSiValue(new DateTime(1990, 01, 01), new DateTime(2010, 01, 01), 0);
      pumping.AddSiValue(new DateTime(2010, 01, 01), new DateTime(2010, 05, 01), 0.05);
      pumping.AddSiValue(new DateTime(2010, 05, 01), DateTime.Now, 0);


      SinkSourceBoundary DrainageWater = new SinkSourceBoundary(pumping);
      DrainageWater.ID = 4;
      DrainageWater.WaterSample = GjellerWater.DeepClone();
      DrainageWater.WaterSample.IDForComposition = DrainageWater.ID;
      DrainageWater.Name = "Indpumpet Drænvand";
      Gjeller.Sources.Add(DrainageWater);


      var tsg = TimeSeriesGroupFactory.Create(@"..\..\..\TestData\GjellerObservations.xts");

      foreach (var ts in tsg.Items)
      {
        Chemical c = new Chemical(ts.Name, 1);
        Gjeller.RealData.AddChemicalTimeSeries(c);
        Gjeller.RealData.ChemicalConcentrations[c] = (TimestampSeries) ts;


      }

      Model M = new Model();
      M._waterBodies.Add(Gjeller);
      Gjeller.Output.LogAllChemicals = true;
      Gjeller.Output.LogComposition = true;

      M.SetState("Initial", new DateTime(1995, 1, 1), GjellerWater);


      M.MoveInTime(DateTime.Now, TimeSpan.FromDays(10));
      M.Save(@"..\..\..\TestData\Gjeller.xml");

    }
    public void TestMethod1()
    {
      Lake Vedsted = LakeFactory.GetLake("Vedsted Sø");
      Vedsted.Depth = 5;
      Vedsted.WaterLevel = 45.7;
      

      //Create and add precipitation boundary
      TimespanSeries Precipitation = new TimespanSeries();
      double[] values = new double[] { 108, 83, 73, 52, 61, 86, 99, 101, 75, 108, 85, 101 };
      LakeVedsted.AddMonthlyValues(Precipitation, 2007, values);
      SinkSourceBoundary Precip = new SinkSourceBoundary(Precipitation);
      Precip.ContactGeometry = Vedsted.SurfaceArea;
      Vedsted.Sources.Add(Precip);

      //Create and add evaporation boundary
      TimespanSeries Evaporation = new TimespanSeries();
      double[] values2 = new double[] { 4, 11, 34, 66, 110, 118, 122, 103, 61, 26, 7, 1 };
      LakeVedsted.AddMonthlyValues(Evaporation, 2007, values2);
      EvaporationRateBoundary eva = new EvaporationRateBoundary(Evaporation);
      eva.ContactGeometry = Vedsted.SurfaceArea;
      Vedsted.EvaporationBoundaries.Add(eva);
       
      //Create and add a discharge boundary
      TimestampSeries Discharge = new TimestampSeries();
      Discharge.AddSiValue(new DateTime(2007, 3, 12), 6986 / TimeSpan.FromDays(365).TotalSeconds);
      Discharge.AddSiValue(new DateTime(2007, 4, 3), 5894 / TimeSpan.FromDays(365).TotalSeconds);
      Discharge.AddSiValue(new DateTime(2007, 4, 25), 1205 / TimeSpan.FromDays(365).TotalSeconds);
      Discharge.RelaxationFactor = 1;
      Discharge.AllowExtrapolation = true;
      Assert.AreEqual(Discharge.GetValue(new DateTime(2007, 4, 25)), Discharge.GetValue(new DateTime(2007, 6, 25)), 0.0000001);
      SinkSourceBoundary Kilde = new SinkSourceBoundary(Discharge);
      Vedsted.Sources.Add(Kilde);

      //Add a groundwater boundary
      GroundWaterBoundary gwb = new GroundWaterBoundary(Vedsted, 1e-5, 1, 46, (XYPolygon)Vedsted.Geometry);

      DateTime Start = new DateTime(2007, 1, 1);

      //Add the chemicals
      Chemical cl = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl);
      
      //Tell the lake to log the chemicals
      Vedsted.Output.LogChemicalConcentration(ChemicalFactory.Instance.GetChemical(ChemicalNames.IsotopeFraction));
      Vedsted.Output.LogChemicalConcentration(cl);

      IsotopeWater Iw = new IsotopeWater(1);
      Iw.SetIsotopeRatio(10);
      Iw.AddChemical(cl, 0.1);
      Precip.WaterSample = Iw.DeepClone();

      //Evaporate some of the water to get realistic initial conditions
      Iw.Evaporate(Iw.Volume / 2);
      Vedsted.SetState("Initial", Start, Iw.DeepClone());
      Kilde.WaterSample = Iw.DeepClone();

      Iw.Evaporate(Iw.Volume / 2);
      gwb.WaterSample = Iw.DeepClone();

      //Add to an engine
      Model Engine = new Model();
      Engine.Name = "Vedsted-opsætning";
      Engine._waterBodies.Add(Vedsted);

      //Set initial state
      Engine.SetState("Initial", Start, new WaterPacket(1));

      Engine.Save(@"c:\temp\setup.xml");


    }
示例#18
0
    public void TestMethod1()
    {
      Lake Hampen = LakeFactory.GetLake("Hampen Sø");
      Hampen.Depth = 3.2e6 / 760000/1000;

      DateTime start = new DateTime(2008, 1, 1);
      DateTime end = new DateTime(2008, 12, 31);

      Assert.AreEqual(Hampen.Area, 722200,1);

      EvaporationRateBoundary er = new EvaporationRateBoundary(407.0 / 1000 / 365 / 86400);
      er.ContactGeometry = Hampen.Geometry;
      er.Name = "Fordampning";
      Hampen.EvaporationBoundaries.Add(er);

      SourceBoundary pr = new SourceBoundary(901.0 / 1000 / 365 / 86400);
      pr.ContactGeometry = Hampen.Geometry;
      pr.Name = "Nedbør";
      Hampen.Precipitation.Add(pr);

      SinkSourceBoundary outlet = new SinkSourceBoundary(-200.0 / 1000 / 365 / 86400);
      outlet.ContactGeometry = Hampen.Geometry;
      outlet.Name = "Udløb";
      Hampen.Sinks.Add(outlet);

      GroundWaterBoundary gwb = new GroundWaterBoundary();
      gwb.FlowType = GWType.Flow;
      gwb.Name = "Ud";
      gwb.WaterFlow = new HydroNumerics.Time.Core.TimespanSeries("inflow", new DateTime(2008, 1, 1), 2, 1, HydroNumerics.Time.Core.TimestepUnit.Years, -294.0 / 1000 / 365 / 86400*Hampen.Area);
      Hampen.GroundwaterBoundaries.Add(gwb);


      Model m = new Model();
      m._waterBodies.Add(Hampen);

      m.SetState("start", start , new WaterPacket(1));
      m.SimulationStartTime = start;
      m.SimulationEndTime = end;
      m.MoveInTime(end,TimeSpan.FromDays(30));
      m.Save(@"..\..\..\TestData\Hampen1.xml");

      WaterPacket ChlorideWater = new WaterPacket(1);
      ChlorideWater.SetConcentration(ChemicalNames.Cl, 20);
      ChlorideWater.SetConcentration(ChemicalNames.IsotopeFraction, 4);
      ChlorideWater.SetConcentration(ChemicalNames.Nitrate, 0.2);
      ChlorideWater.SetConcentration(ChemicalNames.Phosphate, 0.02);

      m.SetState("start", start, ChlorideWater);
      Hampen.Output.LogAllChemicals = true;

      double gwinflow = 1000.0;


      gwb.WaterFlow = new HydroNumerics.Time.Core.TimespanSeries("inflow", new DateTime(2008, 1, 1), 2, 1, HydroNumerics.Time.Core.TimestepUnit.Years, -(294.0 + gwinflow) / 1000 / 365 / 86400 * Hampen.Area);

      GroundWaterBoundary gwbin = new GroundWaterBoundary();
      gwbin.FlowType = GWType.Flow;
      gwbin.WaterFlow = new HydroNumerics.Time.Core.TimespanSeries("inflow", new DateTime(2008, 1, 1), 2, 1, HydroNumerics.Time.Core.TimestepUnit.Years, 0.955*gwinflow / 1000 / 365 / 86400 * Hampen.Area);
      ChlorideWater.SetConcentration(ChemicalNames.Cl, 30);
      ChlorideWater.SetConcentration(ChemicalNames.IsotopeFraction, 8);
      ChlorideWater.SetConcentration(ChemicalNames.Nitrate, 1.6);
      ChlorideWater.SetConcentration(ChemicalNames.Phosphate, 0.017);
      gwbin.Name = "Ind Skov";
      gwbin.WaterSample = ChlorideWater.DeepClone();
      Hampen.GroundwaterBoundaries.Add(gwbin);

      GroundWaterBoundary gwbin2 = new GroundWaterBoundary();
      gwbin2.FlowType = GWType.Flow;
      gwbin2.WaterFlow = new HydroNumerics.Time.Core.TimespanSeries("inflow", new DateTime(2008, 1, 1), 2, 1, HydroNumerics.Time.Core.TimestepUnit.Years, 0.045 * gwinflow / 1000 / 365 / 86400 * Hampen.Area);
      ChlorideWater.SetConcentration(ChemicalNames.Nitrate, 65.3);
      gwbin2.Name = "Ind Landbrug";
      gwbin2.WaterSample = ChlorideWater.DeepClone();

      Hampen.GroundwaterBoundaries.Add(gwbin2);
      ChlorideWater.SetConcentration(ChemicalNames.Cl, 10);
      ChlorideWater.SetConcentration(ChemicalNames.Phosphate, 0);
      ChlorideWater.SetConcentration(ChemicalNames.Nitrate, 1.7);
      pr.WaterSample = ChlorideWater.DeepClone();

      m.MoveInTime(end, TimeSpan.FromDays(30));
      m.Save(@"..\..\..\TestData\Hampen2.xml");
    
    }
示例#19
0
        public void Initialize(System.Collections.Hashtable properties)
        {

            if (!properties.Contains("InputFilename"))
            {
                throw new Exception("Missing key \"InputFilename\" in parameter to method HydroNumerics.HydroNet.OpenMI.EngineWrapper.Initialize(...)");
            }

            if (!properties.Contains("TimestepLength"))
            {
                throw new Exception("Missing key \"TimestepLength\" in parameter to method HydroNumerics.HydroNet.OpenMI.EngineWrapper.Initialize(...)");
            }


            inputFilename = (string)properties["InputFilename"];

            double dt = Convert.ToDouble((string)properties["TimestepLength"]);
            timestepLength = System.TimeSpan.FromSeconds(dt);

            
            // because the OpenMI configuration editor works makes paths relative to locations of OMI files or the configuration editor itselves, thigs may go wrong.
            // In order to overcome this problem, the full path for the input file is saves, so when the Finish method is invoked, the output is save to the input file again and not
            // a file at some random location :-). See below
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(inputFilename);
            inputFilename = fileInfo.FullName;

            model = HydroNumerics.HydroNet.Core.ModelFactory.GetModel(inputFilename);
            model.Initialize();
            //model = ModelFactory.GetModel(inputFilename);


            foreach (var wb in model._waterBodies)
            {
              //Build exchangeitems from groundwater boundaries
              foreach (var gwb in wb.GroundwaterBoundaries)
              {
                GroundWaterBoundary GWB = gwb as GroundWaterBoundary;
                if (GWB != null)
                {
                  ElementSet elementSet = new ElementSet();
                  elementSet.ID = GWB.Name;
                  elementSet.Description = "Location: " + GWB.Name;
                  elementSet.SpatialReference = new SpatialReference("Undefined");
                  Element element = new Element();
                  element.ID = GWB.Name;

                  elementSet.ElementType = ElementType.XYPolygon;
                  foreach (XYPoint xyPoint in ((XYPolygon)GWB.ContactGeometry).Points)
                  {
                    element.AddVertex(new Vertex(xyPoint.X, xyPoint.Y, 0));
                  }

                  elementSet.AddElement(element);

                  //Head
                  HydroNumerics.OpenMI.Sdk.Backbone.Dimension dimension = new HydroNumerics.OpenMI.Sdk.Backbone.Dimension();
                  dimension.Length = 1;

                  HydroNumerics.OpenMI.Sdk.Backbone.Unit unit = new HydroNumerics.OpenMI.Sdk.Backbone.Unit();
                  unit.ID = "m";
                  unit.Description = "meter";
                  unit.ConversionFactorToSI = 1;
                  unit.OffSetToSI = 0;

                  Quantity quantity = new Quantity();
                  quantity.ID = "Head";
                  quantity.Description = "Head at:" + GWB.Name;
                  quantity.Dimension = dimension;
                  quantity.Unit = unit;
                  
                  InputExchangeItem inputExchangeItem = new InputExchangeItem();
                  inputExchangeItem.Quantity = quantity;
                  inputExchangeItem.ElementSet = elementSet;
                  inputExchangeItems.Add(inputExchangeItem);

                  HeadBoundaries.Add(GWB.Name, GWB);

                  //Leakage
                  Quantity leakage = new Quantity("Leakage");
                  leakage.Description = "Leakage at:" + GWB.Name;
                  var leakageDimension = new HydroNumerics.OpenMI.Sdk.Backbone.Dimension();
                  leakageDimension.Length = 3;
                  leakageDimension.Time = -1;
                  leakage.Dimension = leakageDimension;
                  leakage.Unit = new HydroNumerics.OpenMI.Sdk.Backbone.Unit("m3/s", 1, 0);

                  OutputExchangeItem outputitem = new OutputExchangeItem();
                  outputitem.Quantity = leakage;
                  outputitem.ElementSet = elementSet;
                  outputExchangeItems.Add(outputitem);
                  LeakageBoundaries.Add(GWB.Name, GWB);

                }
              }

              foreach (var S in wb.Sources)
              {
                ElementSet elementSet = new ElementSet();
                elementSet.ID = S.Name;
                elementSet.Description = "Location: " + S.Name;
                elementSet.SpatialReference = new SpatialReference("Undefined");
                Element element = new Element();
                element.ID = S.Name;

                elementSet.ElementType = ElementType.IDBased;


                //Flow
                Quantity leakage = new Quantity("Flow");
                leakage.Description = "Flow at:" + S.Name;
                var leakageDimension = new HydroNumerics.OpenMI.Sdk.Backbone.Dimension();
                leakageDimension.Length = 3;
                leakageDimension.Time = -1;
                leakage.Dimension = leakageDimension;
                leakage.Unit = new HydroNumerics.OpenMI.Sdk.Backbone.Unit("m3/s", 1, 0);

                InputExchangeItem outputitem = new InputExchangeItem();
                outputitem.Quantity = leakage;
                outputitem.ElementSet = elementSet;
                inputExchangeItems.Add(outputitem);
                FlowBoundaries.Add(S.Name, (SinkSourceBoundary)S);
                


              }
            }

            

            //foreach (var exchangeItem in model.ExchangeItems)
            //{
            //    HydroNumerics.OpenMI.Sdk.Backbone.Dimension dimention = new HydroNumerics.OpenMI.Sdk.Backbone.Dimension();
            //    dimention.AmountOfSubstance = exchangeItem.Unit.Dimension.AmountOfSubstance;
            //    dimention.Currency = exchangeItem.Unit.Dimension.Currency;
            //    dimention.ElectricCurrent = exchangeItem.Unit.Dimension.ElectricCurrent;
            //    dimention.Length = exchangeItem.Unit.Dimension.AmountOfSubstance;
            //    dimention.LuminousIntensity = exchangeItem.Unit.Dimension.Length;
            //    dimention.Mass = exchangeItem.Unit.Dimension.LuminousIntensity;
            //    dimention.AmountOfSubstance = exchangeItem.Unit.Dimension.Mass;
            //    dimention.Time = exchangeItem.Unit.Dimension.Time;

            //    HydroNumerics.OpenMI.Sdk.Backbone.Unit unit = new HydroNumerics.OpenMI.Sdk.Backbone.Unit();
            //    unit.ID = exchangeItem.Unit.ID;
            //    unit.Description = exchangeItem.Unit.Description;
            //    unit.ConversionFactorToSI = exchangeItem.Unit.ConversionFactorToSI;
            //    unit.OffSetToSI = unit.OffSetToSI;
                                
            //    Quantity quantity = new Quantity();
            //    quantity.ID = exchangeItem.Quantity;
            //    quantity.Description = exchangeItem.Description;
            //    quantity.Dimension = dimention;
            //    quantity.Unit = unit;

            //    ElementSet elementSet = new ElementSet();
            //    elementSet.ID = exchangeItem.Location;
            //    elementSet.Description = "Location: " + exchangeItem.Location;
            //    elementSet.SpatialReference = new SpatialReference("Undefined");
            //    Element element = new Element();
            //    element.ID = exchangeItem.Location;

            //    if (exchangeItem.Geometry is XYPolygon)
            //    {
            //        elementSet.ElementType = ElementType.XYPolygon;
            //        foreach (XYPoint xyPoint in ((XYPolygon)exchangeItem.Geometry).Points)
            //        {
            //            element.AddVertex(new Vertex(xyPoint.X, xyPoint.Y, 0));
            //        }
            //    }
            //    else if (exchangeItem.Geometry is XYPoint)
            //    {
            //        throw new NotImplementedException();
            //    }
            //    else if (exchangeItem.Geometry is XYPolyline)
            //    {
            //        throw new NotImplementedException();
            //    }
            //    else
            //    {
            //        elementSet.ElementType = global::OpenMI.Standard.ElementType.IDBased;
            //    }
                
                
            //    elementSet.AddElement(element);


            //    if (exchangeItem.IsOutput)
            //    {
            //        OutputExchangeItem outputExchangeItem = new OutputExchangeItem();
            //        outputExchangeItem.Quantity = quantity;
            //        outputExchangeItem.ElementSet = elementSet;
            //        outputExchangeItems.Add(outputExchangeItem);
            //    }
            //    if (exchangeItem.IsInput)
            //    {
            //        InputExchangeItem inputExchangeItem = new InputExchangeItem();
            //        inputExchangeItem.Quantity = quantity;
            //        inputExchangeItem.ElementSet = elementSet;
            //        inputExchangeItems.Add(inputExchangeItem);
            //    }
            //}

        }