Пример #1
0
        public void DeepCloneTest()
        {
            WaterPacket actual = (WaterPacket)WWC.DeepClone();

            Assert.AreEqual(WWC.GetConcentration(Na), actual.GetConcentration(Na));
            Assert.AreEqual(WWC.GetConcentration(Cl), actual.GetConcentration(Cl));

            actual = (WaterPacket)WWC.DeepClone(250);
            Assert.AreEqual(WWC.GetConcentration(Na), actual.GetConcentration(Na), 0.00001);
            Assert.AreEqual(2.5 * 3, actual.Chemicals[Na], 0.00001);
        }
Пример #2
0
        public void SubstractTest()
        {
            WaterPacket wwc2 = (WaterPacket)WWC.Substract(70);

            Assert.AreEqual(70, wwc2.Volume);

            Assert.IsTrue(wwc2.Chemicals.ContainsKey(Cl));
            Assert.IsTrue(wwc2.Chemicals.ContainsKey(Na));
            Assert.AreEqual(0.7 * 3.0, wwc2.Chemicals[Na], 0.0000001);
            Assert.AreEqual(0.3 * 3.0, WWC.Chemicals[Na], 0.0000001);

            Assert.AreEqual(WWC.GetConcentration(Cl), wwc2.GetConcentration(Cl));
        }
Пример #3
0
        public void RadonTest()
        {
            WaterPacket w  = new WaterPacket(12);
            Chemical    C  = ChemicalFactory.Instance.GetChemical(ChemicalNames.Radon);
            Chemical    cl = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl);

            //Checks old evaporation
            C.IsFirstOrderDegradable = false;

            w.AddChemical(C, 5);
            w.AddChemical(cl, 5);

            Assert.AreEqual(0.4167, w.GetConcentration(C), 0.001);

            w.MoveInTime(TimeSpan.FromDays(1), 6);
            Assert.AreEqual(0.3846, w.GetConcentration(C), 0.001);

            w.MoveInTime(TimeSpan.FromDays(1), 6);
            Assert.AreEqual(0.355, w.GetConcentration(C), 0.001);

            //Checks new Reactions

            double d = w.GetConcentration(C);

            w.MoveInTime(TimeSpan.FromDays(3.8), ChemicalFactory.Instance.LakeReactions, 0);
            Assert.AreEqual(d / 2, w.GetConcentration(C), 0.01);
            Assert.AreEqual(5.0 / 12, w.GetConcentration(cl), 0.01);
        }
Пример #4
0
        private void BuildChemicalView()
        {
            Chemicals = new ObservableCollection <Tuple <string, double> >();
            WaterPacket Wc = _water as WaterPacket;

            if (Wc != null)
            {
                foreach (var c in Wc.Chemicals)
                {
                    Chemicals.Add(new Tuple <string, double>(c.Key.Name, Wc.GetConcentration(c.Key)));
                }
            }
        }
Пример #5
0
        public void RoutingOfChemical()
        {
            Stream_Accessor s = new Stream_Accessor("s", 100, 1, 1);

            s.SetState("Initial", DateTime.Now, new WaterPacket(100));

            SinkSourceBoundary fb = new SinkSourceBoundary(50);

            s.Sources.Add(fb);
            WaterPacket Wcc = new WaterPacket(50);
            Chemical    c   = ChemicalFactory.Instance.GetChemical(ChemicalNames.Cl);

            Wcc.AddChemical(c, 1);

            fb.WaterSample = Wcc.DeepClone();

            double conc = Wcc.GetConcentration(c);

            Assert.AreEqual(1.0 / 50.0, conc, 0.000001);

            TimeSpan ts = new TimeSpan(0, 0, 1);

            s.Output.LogChemicalConcentration(c);

            s.AddWaterPacket(DateTime.Now, DateTime.Now.AddDays(1), Wcc.DeepClone());
            s.Update(s.CurrentTime.Add(ts));

            WaterPacket WccNew = (WaterPacket)s._waterInStream.Last();

            Assert.AreEqual(64.8721, WccNew.Volume, 0.0001);
            Assert.AreEqual(TimeSpan.FromSeconds(0.5), WccNew.WaterAge);
            Assert.AreEqual(conc, WccNew.GetConcentration(c));

            s.AddWaterPacket(DateTime.Now, DateTime.Now.AddDays(1), Wcc);
            s.Update(s.CurrentTime.Add(TimeSpan.FromDays(1)));

            Assert.AreEqual(0.0042, s.Output.ChemicalsToLog[c].Items[0].Value, 1e-4);
            Assert.AreEqual(0.0078, s.Output.ChemicalsToLog[c].Items[1].Value, 1e-4);
            Assert.AreEqual(conc, s.Output.ChemicalsToLog[c].Items[2].Value);
        }