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)); }
public void Vedsted3() { WaterPacket GroundWater = new WaterPacket(1); GroundWater.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon), 0.01); Model m = ModelFactory.GetModel(testDataPath + "VedstedNoGroundwater.xml"); Lake Vedsted = (Lake)m._waterBodies[0]; Vedsted.Precipitation.First().WaterSample.IDForComposition = 2; Vedsted.Sources.First().WaterSample.IDForComposition = 3; GroundWaterBoundary Inflow = new GroundWaterBoundary(Vedsted, 1e-6, 1, 46.7, XYPolygon.GetSquare(Vedsted.Area / 2)); Inflow.Name = "Inflow"; Inflow.ID = 4; Inflow.WaterSample = GroundWater; Inflow.WaterSample.IDForComposition = 4; GroundWaterBoundary Outflow = new GroundWaterBoundary(Vedsted, 1e-6, 1, 44.7, XYPolygon.GetSquare(Vedsted.Area / 2)); Outflow.Name = "Outflow"; Outflow.ID = 5; Outflow.WaterSample = GroundWater; Vedsted.GroundwaterBoundaries.Add(Inflow); Vedsted.GroundwaterBoundaries.Add(Outflow); DateTime End = new DateTime(2009, 12, 31); m.MoveInTime(End, TimeSpan.FromDays(30)); ModelFactory.SaveModel(testDataPath + "Vedsted3.xml", m); }
public void Run() { Engine.RestoreState("Initial"); if (Calibration != 1) { GroundWaterBoundary gwb = ((GroundWaterBoundary)_lake.GroundwaterBoundaries.First()); double WaterVolume = ((XYPolygon)gwb.ContactGeometry).GetArea() * gwb.HydraulicConductivity * (gwb.GroundwaterHead - WaterLevel) / gwb.Distance; HydraulicConductivity *= Calibration; EvaporationRateBoundary er = new EvaporationRateBoundary((Calibration - 1) * WaterVolume); _lake.EvaporationBoundaries.Add(er); } Engine.MoveInTime(new DateTime(2007, 12, 31), TimeSpan.FromDays(30)); _storageTimeEnd = new DateTime(2007, 12, 23); StorageTimeStart = new DateTime(2007, 1, 1); StorageTimeEnd = new DateTime(2007, 12, 24); if (Calibration != 1) { HydraulicConductivity /= Calibration; _lake.EvaporationBoundaries.RemoveAt(1); } }
public void RunModel() { Model model = CreateHydroNetModel(); model.MoveInTime(new DateTime(2005, 6, 1), new TimeSpan(3, 0, 0, 0)); model.Save(filename + ".xml"); }
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 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); } }
public void IsotopeTest() { DateTime Start = new DateTime(2007, 1, 1); DateTime End = new DateTime(2007, 12, 31); Model m = ModelFactory.GetModel(testDataPath + "VedstedNoGroundwater.xml"); Lake Vedsted = (Lake)m._waterBodies[0]; Vedsted.Sources.RemoveAt(0); Chemical cl = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl); 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); Assert.AreEqual(10, Iw.GetConcentration(ChemicalFactory.Instance.GetChemical(ChemicalNames.IsotopeFraction))); m.SetState("Initial", Start, Iw); Assert.AreEqual(10, ((WaterPacket)Vedsted.CurrentStoredWater).GetConcentration(ChemicalFactory.Instance.GetChemical(ChemicalNames.IsotopeFraction))); IsotopeWater precip = new IsotopeWater(1); precip.SetIsotopeRatio(5); m.MoveInTime(End, TimeSpan.FromDays(30)); foreach (var v in Vedsted.Output.Items[6].Values) { Console.WriteLine(v); } foreach (var v in Vedsted.Output.Items[5].Values) { Console.WriteLine(v); } Console.WriteLine(Vedsted.Output.GetStorageTime(Start.AddDays(40), End.AddDays(-40))); ModelFactory.SaveModel(testDataPath + "VedstedIso.xml", m); }
public void TestMethod1() { Lake L = new Lake("Deep lake", XYPolygon.GetSquare(10000)); L.Depth = 4; L.Output.LogAllChemicals = true; Lake L2 = new Lake("Shallow lake", XYPolygon.GetSquare(40000)); L2.Depth = 1; L2.Output.LogAllChemicals = true; SinkSourceBoundary flow = new SinkSourceBoundary(L.Volume / (15.0 * 86400.0)); L.Sources.Add(flow); L2.Sources.Add(flow); Chemical rn = ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon); Chemical cl = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl); WaterPacket groundwater = new WaterPacket(1); groundwater.SetConcentration(rn, 200); groundwater.SetConcentration(cl, 200); SinkSourceBoundary gwflow = new SinkSourceBoundary(L.Volume / (15.0 * 86400.0)); gwflow.WaterSample = groundwater; L.Sources.Add(gwflow); L2.Sources.Add(gwflow); Model M = new Model(); M.WaterBodies.Add(L); M.WaterBodies.Add(L2); DateTime start = new DateTime(2010, 1, 1); M.SetState("Initial", start, new WaterPacket(1)); M.MoveInTime(new DateTime(2010, 12, 31), TimeSpan.FromDays(5)); M.Save(@"..\..\..\TestData\Radon.xml"); }
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 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 TestMethod1() { Lake L = new Lake("Deep lake", XYPolygon.GetSquare(10000)); L.Depth = 4; L.Output.LogAllChemicals = true; Lake L2 = new Lake("Shallow lake", XYPolygon.GetSquare(40000)); L2.Depth = 1; L2.Output.LogAllChemicals = true; SinkSourceBoundary flow = new SinkSourceBoundary(L.Volume / (15.0 * 86400.0)); L.Sources.Add(flow); L2.Sources.Add(flow); Chemical rn = ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon); Chemical cl = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl); WaterPacket groundwater = new WaterPacket(1); groundwater.SetConcentration(rn, 200); groundwater.SetConcentration(cl, 200); SinkSourceBoundary gwflow = new SinkSourceBoundary(L.Volume / (15.0 * 86400.0)); gwflow.WaterSample = groundwater; L.Sources.Add(gwflow); L2.Sources.Add(gwflow); Model M = new Model(); M.WaterBodies.Add(L); M.WaterBodies.Add(L2); DateTime start = new DateTime(2010,1,1); M.SetState("Initial", start, new WaterPacket(1)); M.MoveInTime(new DateTime(2010, 12, 31), TimeSpan.FromDays(5)); M.Save(@"..\..\..\TestData\Radon.xml"); }
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"); }
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 TestMethod1() { Model M = new Model(); M.Name = "Cook"; WaterPacket HyporhericWater = new WaterPacket(1); HyporhericWater.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon), 0.6 / HyporhericWater.Volume); for (int i = 0; i < 10; i++) { Lake s1 = new Lake("s" + i, XYPolygon.GetSquare(50 * 2)); s1.Depth = 0.3; StagnantExchangeBoundary seb = new StagnantExchangeBoundary(s1.Volume / 20000); seb.WaterSample = HyporhericWater.DeepClone(s1.Area * 0.2 * 0.4); seb.Output.LogAllChemicals = true; s1.Output.LogAllChemicals = true; s1.Sinks.Add(seb); s1.Sources.Add(seb); if (i > 0) M._waterBodies[i - 1].AddDownStreamWaterBody(s1); M._waterBodies.Add(s1); } //Bromide injection TimespanSeries ts = new TimespanSeries(); ts.AddSiValue(DateTime.MinValue, new DateTime(2005, 10, 18, 12, 0, 0), 0); ts.AddSiValue(new DateTime(2005, 10, 18, 12, 0, 0), new DateTime(2005, 10, 18, 12, 40, 0), 0.001 * 60); ts.AddSiValue(new DateTime(2005, 10, 18, 12, 40, 0), DateTime.MaxValue, 0); SinkSourceBoundary Bromide = new SinkSourceBoundary(ts); WaterPacket P = new WaterPacket(1); P.AddChemical(new Chemical("Bromide", 1), 1.13); Bromide.WaterSample = P; //SF6 injection TimespanSeries ts2 = new TimespanSeries(); ts2.AddSiValue(DateTime.MinValue, new DateTime(2005, 10, 15, 12, 0, 0), 0); ts2.AddSiValue(new DateTime(2005, 10, 15, 12, 0, 0), new DateTime(2005, 10, 19, 12, 0, 0), 1e-6); ts2.AddSiValue(new DateTime(2005, 10, 19, 12, 0, 0), DateTime.MaxValue, 0); SinkSourceBoundary SF6 = new SinkSourceBoundary(ts2); WaterPacket SF6w = new WaterPacket(1); SF6w.AddChemical(new Chemical("SF6", 1), 1.13); SF6.WaterSample = SF6w; M._waterBodies.First().Sources.Add(Bromide); M._waterBodies.First().Sources.Add(SF6); M._waterBodies.First().Sources.Add(new SinkSourceBoundary(0.2)); DateTime Start = new DateTime(2005, 10, 13); DateTime End = new DateTime(2005, 10, 19); M.SetState("Initial", Start, new WaterPacket(1)); M.MoveInTime(new DateTime(2005, 10, 18, 12, 0, 0), TimeSpan.FromHours(2)); M.MoveInTime(new DateTime(2005, 10, 18, 13, 0, 0), TimeSpan.FromHours(0.02)); M.MoveInTime(End, TimeSpan.FromHours(2)); M.Save(@"..\..\..\TestData\CookEtAl.xml"); M.RestoreState("Initial"); TimespanSeries ts3 = new TimespanSeries(); ts3.AddSiValue(DateTime.MinValue, new DateTime(2005, 10, 16, 12, 0, 0), 0); ts3.AddSiValue(new DateTime(2005, 10, 16, 12, 0, 0), new DateTime(2005, 10, 17, 0, 0, 0), 0.4); ts3.AddSiValue(new DateTime(2005, 10, 17, 0, 0, 0), DateTime.MaxValue, 0); M._waterBodies.First().Sources.Add(new SinkSourceBoundary(ts3)); M.MoveInTime(new DateTime(2005, 10, 18, 12, 0, 0), TimeSpan.FromHours(2)); M.MoveInTime(new DateTime(2005, 10, 18, 13, 0, 0), TimeSpan.FromHours(0.02)); M.MoveInTime(End, TimeSpan.FromHours(2)); M.Save(@"..\..\..\TestData\CookEtAl2.xml"); }
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 TracerTest() { int count = 3; double length = 10870; DateTime Start = new DateTime(2000, 1, 1); List <Lake> lakes = NetworkBuilder.CreateConnectedLakes(count); foreach (Lake L in lakes) { L.SurfaceArea = XYPolygon.GetSquare(length / count); L.Depth = 1; L.SetState("Initial", Start, new WaterPacket(L.Volume)); } Chemical c = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl); SinkSourceBoundary fb = new SinkSourceBoundary(10870.0 / (8.49 * 3600)); fb.WaterSample = new WaterPacket(1); lakes.First().Sources.Add(fb); WaterPacket plug = new WaterPacket(1); plug.AddChemical(c, 10000); lakes.First().AddWaterPacket(Start, Start.AddHours(1), plug.DeepClone()); lakes.First().Output.LogChemicalConcentration(c); lakes.Last().Output.LogChemicalConcentration(c); Stream us = new Stream("us", 1, 1, 1); us.Sources.Add(fb); Stream s = new Stream("s", 1000, 1, 1); Lake L2 = new Lake("L2", 870); Stream s1 = new Stream("s1", 9000, 1, 1); s.AddWaterPacket(Start, Start.AddSeconds(1), plug.DeepClone()); s1.Output.LogChemicalConcentration(c); us.AddDownStreamWaterBody(s); s.AddDownStreamWaterBody(L2); L2.AddDownStreamWaterBody(s1); Model m = new Model(); m._waterBodies.AddRange(lakes.Cast <IWaterBody>()); m._waterBodies.Add((IWaterBody)us); m._waterBodies.Add((IWaterBody)s); m._waterBodies.Add((IWaterBody)L2); m._waterBodies.Add((IWaterBody)s1); m.SetState("Initial", Start, new WaterPacket(1)); m.MoveInTime(Start.AddHours(15), TimeSpan.FromMinutes(1)); lakes.Last().Output.Save(@"C:\temp\LastLake.xts"); s1.Output.Save(@"C:\temp\Stream.xts"); int n = 15; List <IWaterBody> wbs = NetworkBuilder.CreateCombo(n, 10870 / n / 2.0); foreach (IWaterBody wb in wbs) { wb.SetState("Initial", Start, new WaterPacket(wb.Volume)); } wbs.First().AddWaterPacket(Start, Start.AddHours(1), plug.DeepClone()); us.AddDownStreamWaterBody(wbs.First()); us.RestoreState("Initial"); m._waterBodies.Clear(); m._waterBodies.Add(us); m._waterBodies.AddRange(wbs); m.SetState("Initial", Start, new WaterPacket(1)); ((Stream)wbs.Last()).Output.LogChemicalConcentration(c); m.MoveInTime(Start.AddHours(15), TimeSpan.FromMinutes(1)); ((Stream)wbs.Last()).Output.Save(@"C:\temp\Stream.xts"); }
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 TracerTest() { int count = 3; double length = 10870; DateTime Start= new DateTime(2000,1,1); List<Lake> lakes = NetworkBuilder.CreateConnectedLakes(count); foreach (Lake L in lakes) { L.SurfaceArea = XYPolygon.GetSquare(length / count); L.Depth = 1; L.SetState("Initial",Start, new WaterPacket(L.Volume)); } Chemical c = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl); SinkSourceBoundary fb = new SinkSourceBoundary(10870.0 / (8.49 * 3600)); fb.WaterSample = new WaterPacket(1); lakes.First().Sources.Add(fb); WaterPacket plug = new WaterPacket(1); plug.AddChemical(c, 10000); lakes.First().AddWaterPacket(Start, Start.AddHours(1), plug.DeepClone()); lakes.First().Output.LogChemicalConcentration(c); lakes.Last().Output.LogChemicalConcentration(c); Stream us = new Stream("us",1, 1, 1); us.Sources.Add(fb); Stream s = new Stream("s",1000, 1, 1); Lake L2 = new Lake("L2",870); Stream s1 = new Stream("s1", 9000, 1, 1); s.AddWaterPacket(Start, Start.AddSeconds(1), plug.DeepClone()); s1.Output.LogChemicalConcentration(c); us.AddDownStreamWaterBody(s); s.AddDownStreamWaterBody(L2); L2.AddDownStreamWaterBody(s1); Model m = new Model(); m._waterBodies.AddRange(lakes.Cast<IWaterBody>()); m._waterBodies.Add((IWaterBody)us); m._waterBodies.Add((IWaterBody)s); m._waterBodies.Add((IWaterBody)L2); m._waterBodies.Add((IWaterBody)s1); m.SetState("Initial", Start, new WaterPacket(1)); m.MoveInTime(Start.AddHours(15), TimeSpan.FromMinutes(1)); lakes.Last().Output.Save(@"C:\temp\LastLake.xts"); s1.Output.Save(@"C:\temp\Stream.xts"); int n = 15; List<IWaterBody> wbs = NetworkBuilder.CreateCombo(n, 10870 / n/2.0); foreach (IWaterBody wb in wbs) { wb.SetState("Initial", Start, new WaterPacket(wb.Volume)); } wbs.First().AddWaterPacket(Start, Start.AddHours(1), plug.DeepClone()); us.AddDownStreamWaterBody(wbs.First()); us.RestoreState("Initial"); m._waterBodies.Clear(); m._waterBodies.Add(us); m._waterBodies.AddRange(wbs); m.SetState("Initial", Start, new WaterPacket(1)); ((Stream)wbs.Last()).Output.LogChemicalConcentration(c); m.MoveInTime(Start.AddHours(15), TimeSpan.FromMinutes(1)); ((Stream)wbs.Last()).Output.Save(@"C:\temp\Stream.xts"); }
public void TestMethod1() { Model M = new Model(); M.Name = "Cook"; WaterPacket HyporhericWater = new WaterPacket(1); HyporhericWater.AddChemical(ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon), 0.6 / HyporhericWater.Volume); for (int i = 0; i < 10; i++) { Lake s1 = new Lake("s" + i, XYPolygon.GetSquare(50 * 2)); s1.Depth = 0.3; StagnantExchangeBoundary seb = new StagnantExchangeBoundary(s1.Volume / 20000); seb.WaterSample = HyporhericWater.DeepClone(s1.Area * 0.2 * 0.4); seb.Output.LogAllChemicals = true; s1.Output.LogAllChemicals = true; s1.Sinks.Add(seb); s1.Sources.Add(seb); if (i > 0) { M._waterBodies[i - 1].AddDownStreamWaterBody(s1); } M._waterBodies.Add(s1); } //Bromide injection TimespanSeries ts = new TimespanSeries(); ts.AddSiValue(DateTime.MinValue, new DateTime(2005, 10, 18, 12, 0, 0), 0); ts.AddSiValue(new DateTime(2005, 10, 18, 12, 0, 0), new DateTime(2005, 10, 18, 12, 40, 0), 0.001 * 60); ts.AddSiValue(new DateTime(2005, 10, 18, 12, 40, 0), DateTime.MaxValue, 0); SinkSourceBoundary Bromide = new SinkSourceBoundary(ts); WaterPacket P = new WaterPacket(1); P.AddChemical(new Chemical("Bromide", 1), 1.13); Bromide.WaterSample = P; //SF6 injection TimespanSeries ts2 = new TimespanSeries(); ts2.AddSiValue(DateTime.MinValue, new DateTime(2005, 10, 15, 12, 0, 0), 0); ts2.AddSiValue(new DateTime(2005, 10, 15, 12, 0, 0), new DateTime(2005, 10, 19, 12, 0, 0), 1e-6); ts2.AddSiValue(new DateTime(2005, 10, 19, 12, 0, 0), DateTime.MaxValue, 0); SinkSourceBoundary SF6 = new SinkSourceBoundary(ts2); WaterPacket SF6w = new WaterPacket(1); SF6w.AddChemical(new Chemical("SF6", 1), 1.13); SF6.WaterSample = SF6w; M._waterBodies.First().Sources.Add(Bromide); M._waterBodies.First().Sources.Add(SF6); M._waterBodies.First().Sources.Add(new SinkSourceBoundary(0.2)); DateTime Start = new DateTime(2005, 10, 13); DateTime End = new DateTime(2005, 10, 19); M.SetState("Initial", Start, new WaterPacket(1)); M.MoveInTime(new DateTime(2005, 10, 18, 12, 0, 0), TimeSpan.FromHours(2)); M.MoveInTime(new DateTime(2005, 10, 18, 13, 0, 0), TimeSpan.FromHours(0.02)); M.MoveInTime(End, TimeSpan.FromHours(2)); M.Save(@"..\..\..\TestData\CookEtAl.xml"); M.RestoreState("Initial"); TimespanSeries ts3 = new TimespanSeries(); ts3.AddSiValue(DateTime.MinValue, new DateTime(2005, 10, 16, 12, 0, 0), 0); ts3.AddSiValue(new DateTime(2005, 10, 16, 12, 0, 0), new DateTime(2005, 10, 17, 0, 0, 0), 0.4); ts3.AddSiValue(new DateTime(2005, 10, 17, 0, 0, 0), DateTime.MaxValue, 0); M._waterBodies.First().Sources.Add(new SinkSourceBoundary(ts3)); M.MoveInTime(new DateTime(2005, 10, 18, 12, 0, 0), TimeSpan.FromHours(2)); M.MoveInTime(new DateTime(2005, 10, 18, 13, 0, 0), TimeSpan.FromHours(0.02)); M.MoveInTime(End, TimeSpan.FromHours(2)); M.Save(@"..\..\..\TestData\CookEtAl2.xml"); }