public TimestampSeries GetTimeStampSeries() { TimestampSeries ts = new TimestampSeries(); ts.Name = "Tidsserie1"; ts.AddSiValue(new DateTime(2000, 1, 1), 3); ts.AddSiValue(new DateTime(2000, 1, 2), 4); ts.AddSiValue(new DateTime(2000, 1, 3), 6); ts.AddSiValue(new DateTime(2000, 1, 4), 11); return ts; }
public void EvaporateTest() { IsotopeWater Iw = new IsotopeWater(100); Iw.SetIsotopeRatio(10); TimestampSeries ts = new TimestampSeries(); ts.AddSiValue(new DateTime(2000, 1, 1), 5); ts.AllowExtrapolation = true; ts.ExtrapolationMethod = ExtrapolationMethods.Linear; ts.RelaxationFactor = 1; Iw.EvaporationConcentration = ts; Iw.Evaporate(1); double v1 = Iw.GetIsotopeRatio(); Iw.Evaporate(2); double v2 = Iw.GetIsotopeRatio(); Iw.Evaporate(5); double v5 = Iw.GetIsotopeRatio(); Iw.Evaporate(90); double v90 = Iw.GetIsotopeRatio(); Assert.AreEqual(10.101, v1, 0.01); Assert.AreEqual(10.309, v2, 0.01); Assert.AreEqual(10.870, v5, 0.01); Assert.AreEqual(500, Iw.GetIsotopeRatio(), 0.01); }
public void AddSiValue() { TimestampSeries ts = new TimestampSeries(); ts.Unit = new HydroNumerics.Core.Unit("cm/sec", 0.01, 0.0); ts.AddSiValue(new DateTime(2010, 1, 1), 2); Assert.AreEqual(200, ts.Items[0].Value); }
public void GroundWaterTest() { WaterPacket GroundWater = new WaterPacket(1); // GroundWater.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon), 0.01); GroundWater.IDForComposition = 4; Lake Vedsted = LakeFactory.GetLake("Vedsted Sø"); Vedsted.Depth = 5; Vedsted.WaterLevel = 45.7; //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); Kilde.Name = "Small spring"; Kilde.ID = 3; Kilde.WaterSample.IDForComposition = 3; Vedsted.Sources.Add(Kilde); Vedsted.Output.LogAllChemicals = true; Vedsted.Output.LogComposition = true; //Add to an engine Model Engine = new Model(); Engine.Name = "Vedsted-opsætning"; Engine._waterBodies.Add(Vedsted); //Set initial state WaterPacket InitialStateWater = new WaterPacket(1); InitialStateWater.IDForComposition = 1; DateTime Start = new DateTime(2007, 1, 1); DateTime End = new DateTime(2007, 12, 31); Engine.SetState("Initial", Start, InitialStateWater); Engine.SimulationEndTime = End; Engine.TimeStep = TimeSpan.FromDays(30); Engine.MoveInTime(End, TimeSpan.FromDays(30)); Vedsted.Name = "Vedsted step 1"; Engine.Save(testDataPath + Vedsted.Name + ".xml"); Engine.RestoreState("Initial"); //Create and add precipitation boundary TimespanSeries Precipitation = new TimespanSeries(); Precipitation.ExtrapolationMethod = ExtrapolationMethods.RecycleYear; Precipitation.AllowExtrapolation = true; double[] values = new double[] { 108, 83, 73, 52, 61, 86, 99, 101, 75, 108, 85, 101 }; AddMonthlyValues(Precipitation, 2007, values); SinkSourceBoundary Precip = new SinkSourceBoundary(Precipitation); Precip.ContactGeometry = Vedsted.SurfaceArea; Precip.Name = "Precipitation"; Precip.ID = 2; Precip.WaterSample.IDForComposition = 2; Vedsted.Precipitation.Add(Precip); //Create and add evaporation boundary TimespanSeries Evaporation = new TimespanSeries(); Evaporation.AllowExtrapolation = true; Evaporation.ExtrapolationMethod = ExtrapolationMethods.RecycleYear; double[] values2 = new double[] { 4, 11, 34, 66, 110, 118, 122, 103, 61, 26, 7, 1 }; AddMonthlyValues(Evaporation, 2007, values2); EvaporationRateBoundary eva = new EvaporationRateBoundary(Evaporation); eva.ContactGeometry = Vedsted.SurfaceArea; eva.Name = "Evapo"; Vedsted.EvaporationBoundaries.Add(eva); Engine.MoveInTime(End, TimeSpan.FromDays(30)); Vedsted.Name = "Vedsted step 2"; Engine.Save(testDataPath + Vedsted.Name + ".xml"); Engine.RestoreState("Initial"); //To be used by other tests Engine.Save(testDataPath + "VedstedNoGroundwater.xml"); XYPolygon ContactArea = XYPolygon.GetSquare(Vedsted.Area / 10); #region Groundwater boundaries //Add groundwater boundaries GroundWaterBoundary B1 = new GroundWaterBoundary(Vedsted, 1.3e-4, 1, 45.47, ContactArea); B1.Name = "B1"; B1.ID = 4; B1.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(B1); GroundWaterBoundary B2 = new GroundWaterBoundary(Vedsted, 1e-6, 1, 44.96, ContactArea); B2.Name = "B2"; B2.ID = 5; B2.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(B2); GroundWaterBoundary B3 = new GroundWaterBoundary(Vedsted, 2e-6, 1, 44.63, ContactArea); B3.Name = "B3"; B3.ID = 6; B3.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(B3); GroundWaterBoundary B4 = new GroundWaterBoundary(Vedsted, 4.9e-7, 1, 44.75, ContactArea); B4.Name = "B4"; B4.ID = 7; B4.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(B4); GroundWaterBoundary B5 = new GroundWaterBoundary(Vedsted, 1.5e-8, 1, 44.27, ContactArea); B5.Name = "B5"; B5.ID = 8; B5.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(B5); GroundWaterBoundary B6 = new GroundWaterBoundary(Vedsted, 1.5e-8, 1, 44.16, ContactArea); B6.Name = "B6"; B6.ID = 9; B6.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(B6); GroundWaterBoundary B7 = new GroundWaterBoundary(Vedsted, 1.1e-6, 1, 45.15, ContactArea); B7.Name = "B7"; B7.ID = 10; B7.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(B7); GroundWaterBoundary B8 = new GroundWaterBoundary(Vedsted, 1.1e-6, 1, 44.54, ContactArea); B8.Name = "B8"; B8.ID = 11; B8.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(B8); GroundWaterBoundary B9 = new GroundWaterBoundary(Vedsted, 2.1e-8, 1, 45.4, ContactArea); B9.Name = "B9"; B9.ID = 12; B9.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(B9); GroundWaterBoundary B10 = new GroundWaterBoundary(Vedsted, 3.5e-6, 1, 45.16, ContactArea); B10.Name = "B10"; B10.ID = 13; B10.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(B10); #endregion Engine.MoveInTime(End, TimeSpan.FromDays(30)); Vedsted.Name = "Vedsted step 3"; Engine.Save(testDataPath + Vedsted.Name + ".xml"); Engine.RestoreState("Initial"); Vedsted.GroundwaterBoundaries.Clear(); var cl = ChemicalFactory.Instance.GetChemical(ChemicalNames.IsotopeFraction); GroundWaterBoundary Inflow = new GroundWaterBoundary(Vedsted, 1e-7, 1, 46.7, XYPolygon.GetSquare(Vedsted.Area / 2)); Inflow.Name = "Inflow"; GroundWater.AddChemical(cl, 3); Inflow.WaterSample = GroundWater; Vedsted.RealData.AddChemicalTimeSeries(cl); Vedsted.RealData.ChemicalConcentrations[cl].AddSiValue(new DateTime(2007, 8, 7), 2.5); ((WaterPacket)InitialStateWater).AddChemical(cl, 2.5 * InitialStateWater.Volume); Engine.SetState("Initial", Start, InitialStateWater); GroundWaterBoundary Outflow = new GroundWaterBoundary(Vedsted, 1e-7, 1, 44.7, XYPolygon.GetSquare(Vedsted.Area / 2)); Outflow.Name = "Outflow"; Vedsted.GroundwaterBoundaries.Add(Inflow); Vedsted.GroundwaterBoundaries.Add(Outflow); Engine.MoveInTime(End, TimeSpan.FromDays(30)); Vedsted.Name = "Vedsted step 4"; Engine.Save(testDataPath + Vedsted.Name + ".xml"); Engine.RestoreState("Initial"); #region ////Add seepage meter boundaries //GroundWaterBoundary S1 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46); //Vedsted.SinkSources.Add(S1); //GroundWaterBoundary S2 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46); //Vedsted.SinkSources.Add(S2); //GroundWaterBoundary S3 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46); //Vedsted.SinkSources.Add(S3); //GroundWaterBoundary I1 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46); //Vedsted.SinkSources.Add(I1); //GroundWaterBoundary I2 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46); //Vedsted.SinkSources.Add(I2); //GroundWaterBoundary I3 = new GroundWaterBoundary(Vedsted, 4e-5, 1, 2, 46); //Vedsted.SinkSources.Add(I3); #endregion Assert.AreEqual(Evaporation.EndTime, Engine.MaximumEndTime); Engine.Save(testDataPath + "Vedsted.xml"); Engine.MoveInTime(End, TimeSpan.FromDays(30)); double outflow2 = Vedsted.Output.Outflow.GetValue(Start, End.Subtract(TimeSpan.FromDays(5))); double evapo2 = Vedsted.Output.Evaporation.GetValue(Start, End.Subtract(TimeSpan.FromDays(5))); Engine.Save(testDataPath + "Vedsted2.xml"); }
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"); }
public void BuildConcFromCSV() { TimeSeriesGroup tsg = new TimeSeriesGroup(); TimestampSeries ts1 = new TimestampSeries(); ts1.Name = "Alkalinitet"; TimestampSeries ts2 = new TimestampSeries(); ts2.Name = "Nitrate"; TimestampSeries ts3 = new TimestampSeries(); ts3.Name = "Total nitrogen"; TimestampSeries ts4 = new TimestampSeries(); ts4.Name = "Chlorid"; TimestampSeries ts5 = new TimestampSeries(); ts5.Name = "Phosphor"; TimestampSeries ts6 = new TimestampSeries(); ts6.Name = "Suspenderet stof"; tsg.Items.Add(ts1); tsg.Items.Add(ts2); tsg.Items.Add(ts3); tsg.Items.Add(ts4); tsg.Items.Add(ts5); tsg.Items.Add(ts6); using (StreamReader sr = new StreamReader(@"..\..\..\TestData\gjeller_analyse.csv")) { sr.ReadLine(); sr.ReadLine(); sr.ReadLine(); sr.ReadLine(); sr.ReadLine(); sr.ReadLine(); while (!sr.EndOfStream) { var arr = sr.ReadLine().Split(';'); DateTime date = DateTime.Parse(arr[0]); double d; if (double.TryParse(arr[9], out d)) { ts6.AddSiValue(date, d); } if (double.TryParse(arr[15], out d)) { ts1.AddSiValue(date, d); } if (double.TryParse(arr[23], out d)) { ts2.AddSiValue(date, d); } if (double.TryParse(arr[25], out d)) { ts3.AddSiValue(date, d); } if (double.TryParse(arr[29], out d)) { ts4.AddSiValue(date, d); } if (double.TryParse(arr[31], out d)) { ts5.AddSiValue(date, d); } } } tsg.Save(@"..\..\..\TestData\GjellerObservations.xts"); }
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"); }
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(); }