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");


    }
Ejemplo n.º 2
0
    public DemoViewModel(string Name, XYPolygon SurfaceArea, TimespanSeries Evaporation, TimespanSeries Precipitation)
    {
      Calibration = 1;
      _lake = new Lake(Name, SurfaceArea);
      _lake.Depth = 5;
      _lake.WaterLevel = 45.7;

      //Create and add precipitation boundary
      SinkSourceBoundary Precip = new SinkSourceBoundary(Precipitation);
      Precip.ContactGeometry = _lake.SurfaceArea;
      _lake.Sources.Add(Precip);

      //Create and add evaporation boundary
      EvaporationRateBoundary eva = new EvaporationRateBoundary(Evaporation);
      eva.ContactGeometry = _lake.SurfaceArea;
      _lake.EvaporationBoundaries.Add(eva);

      //Create and add a discharge boundary
      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;
      Discharge.Name = "Inflow";
      SinkSourceBoundary Kilde = new SinkSourceBoundary(Discharge);
      _lake.Sources.Add(Kilde);

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

      DateTime Start = new DateTime(2007, 1, 1);
      //Add to an engine
      Engine = new Model();
      Engine._waterBodies.Add(_lake);

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

      //Add the chemicals
      Chemical cl = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl);

      //Tell the lake to log the chemicals
      _lake.Output.LogChemicalConcentration(ChemicalFactory.Instance.GetChemical(ChemicalNames.IsotopeFraction));
      _lake.Output.LogChemicalConcentration(cl);

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

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

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