Beispiel #1
0
        public void TestRectangularBasinSerialization()
        {
            var c = Catchment.Make("TestRectBasin",
                                   InfiltrationTestProcedure.OpenPit,
                                   PRStatus.Fail, 3.56m,
                                   HierarchyLevel.DischargeToRiverSlough,
                                   23456, 45, 56, 6, 8,
                                   RectangularBasin.Make(true, 6.2m,
                                                         Configuration.ConfigA,
                                                         AboveGradeProperties.Make(234m, 8.9m,
                                                                                   70m, 0.23m, 6.7m, 5.34m,
                                                                                   4.5m, 9.0m, 7.6m),
                                                         BelowGradeProperties.Make(0.89m, 87.5m,
                                                                                   6m, 5.4m, .6m, 0.45m,
                                                                                   Orifice.Make(1.6m))));

            using (var sw = new StringWriter())
                using (var xwrtr = XmlWriter.Create(sw))
                {
                    var ser = new XmlSerializer(typeof(Catchment));
                    ser.Serialize(xwrtr, c);
                    var s = sw.ToString();
                    Assert.IsNotNull(s);
                }
        }
Beispiel #2
0
        public void TestUserDefinedBasinSerialization()
        {
            var c = Catchment.Make("TestUserDefined",
                                   InfiltrationTestProcedure.OpenPit,
                                   PRStatus.Fail, 3.56m,
                                   HierarchyLevel.DischargeToRiverSlough,
                                   23456, 45, 56, 6, 8,
                                   UserDefinedBasin.Make(true, Configuration.ConfigA, 6.2m,
                                                         AboveGradeProperties.Make(234m, 8.9m,
                                                                                   70m, 0.23m, 6.7m, 5.34m,
                                                                                   4.5m, 9.0m, 7.6m),
                                                         BelowGradeProperties.Make(0.76m, 87.5m,
                                                                                   5.2m, 223.4m, 6m, 0.56m,
                                                                                   Orifice.Make(1.6m))));
            var scenario = Scenario.Make("sloped", c, DateTime.UtcNow, ExpectedResult.Empty);

            using (var sw = new StringWriter())
                using (var xwrtr = XmlWriter.Create(sw))
                {
                    var ser = new XmlSerializer(typeof(Scenario));
                    ser.Serialize(xwrtr, scenario);
                    var s = sw.ToString();
                    Assert.IsNotNull(s);
                }
        }
Beispiel #3
0
        private Catchment MakeCatchment()
        {
            var segs = Segments.Empty;

            segs.Add(Segment.Make(1,
                                  12.7m, 7.5m, 0.25m,
                                  5.4m, 0.6m, 0.63m,
                                  13.5m, 11.7m));
            segs.Add(Segment.Make(2,
                                  42.1m, 5.6m, 0.25m,
                                  8.2m, 0.45m, 0.35m,
                                  10.9m, 11.7m));
            return(Catchment.Make("TestSlopedFacility",
                                  InfiltrationTestProcedure.OpenPit,
                                  PRStatus.Fail, 3.56m,
                                  HierarchyLevel.DischargeToRiverSlough,
                                  23456, 45, 56, 6, 8,
                                  SlopedFacility.Make(true,
                                                      Configuration.ConfigA, 5.2m,
                                                      AboveGradeProperties.Make(222m, 5.3m,
                                                                                187m, 0.9m, 7.2m, 4.5m,
                                                                                287m, 5.4m, 87m),
                                                      BelowGradeProperties.Make(56, 87.5m,
                                                                                11.2m, 6.9m, 5.5m, 0.23m,
                                                                                Orifice.Make(1.6m)),
                                                      segs)));
        }
Beispiel #4
0
        protected override void ValidateBGInputData(BelowGradeProperties bgDta, Configuration cfg)
        {
            var IsCfgD = cfg == cfgD;

            if (!IsCfgD && !bgDta.InfiltrationPercentage.HasValue)
            {
                throw new PACInputDataException(
                          "Infiltration Percentage is required for calculations",
                          "InfiltrationPercentage");
            }
        }
Beispiel #5
0
        private string MakeCatchmentString()
        {
            var segs = Segments.Empty;

            segs.AddSegment(Segment.Make(
                                12.7m, 7.5m, 0.25m,
                                5.4m, 0.6m, 0.63m,
                                13.5m, 11.7m));
            segs.AddSegment(Segment.Make(
                                42.1m, 5.6m, 0.25m,
                                8.2m, 0.45m, 0.35m,
                                10.9m, 11.7m));

            var c = Catchment.Make("TestSlopedFacility",
                                   InfiltrationTestProcedure.OpenPit,
                                   PRStatus.Fail, 3.56m,
                                   HierarchyLevel.DischargeToRiverSlough,
                                   23456, 45, 56, 6, 8,
                                   SlopedFacility.Make(true,
                                                       Configuration.ConfigA, 5.2m,
                                                       AboveGradeProperties.Make(222m, 5.3m,
                                                                                 187m, 0.9m, 7.2m, 4.5m,
                                                                                 287m, 5.4m, 87m),
                                                       BelowGradeProperties.Make(56, 87.5m,
                                                                                 11.2m, 6.9m, 5.5m, 0.23m,
                                                                                 Orifice.Make(1.6m)),
                                                       segs));

            using (var sw = new StringWriter())
                using (var xwrtr = XmlWriter.Create(sw))
                {
                    var ser = new XmlSerializer(typeof(Catchment));
                    ser.Serialize(xwrtr, c);
                    return(sw.ToString());
                }
        }
Beispiel #6
0
 private static Catchment MakeFlatPlanterCatchment(
     decimal blndSoilDepth, InfiltrationTestProcedure ift,
     decimal natInfRate, HierarchyLevel lvl, Configuration cfg,
     decimal impArea, int preCN, int postCn,
     int preTC, int postTC, decimal infPcnt, decimal botArea, decimal botWidth,
     decimal botPerimeter, decimal ss, decimal freeBrd, decimal ovflHgt,
     decimal ovflSA, decimal ovflEHgt, decimal ovflESA, decimal rockBotArea,
     decimal rockStrgDepth, decimal rockWidth, decimal porosity,
     decimal belowPipeStrgDepth, decimal?orificeDiameter, OrificeReason rsn)
 {
     return(Catchment.Make("FlatPlanterTestCatchment",
                           ift, PRStatus.Pass, natInfRate,
                           lvl, impArea, preCN, postCn, preTC, postTC,
                           FlatPlanter.Make(true, blndSoilDepth, cfg,
                                            AboveGradeProperties.Make(botArea,
                                                                      botWidth, botPerimeter, ss, freeBrd,
                                                                      ovflHgt, ovflSA,
                                                                      ovflEHgt, ovflESA),
                                            BelowGradeProperties.Make(infPcnt, rockBotArea,
                                                                      rockStrgDepth, rockWidth, porosity, belowPipeStrgDepth,
                                                                      orificeDiameter.HasValue?
                                                                      Orifice.Make(orificeDiameter.Value):
                                                                      Orifice.Make(rsn)))));
 }
Beispiel #7
0
        protected override void ValidateBGInputData(BelowGradeProperties bgDta, Configuration cfg)
        {
            var IsCfgA = cfg == cfgA;
            var IsCfgD = cfg == cfgD;

            if (!IsCfgD && !bgDta.InfiltrationPercentage.HasValue)
            {
                throw new PACInputDataException(
                          "Infiltration Percentage is required for calculations",
                          "InfiltrationPercentage");
            }
            // ----------------------------------------
            if (IsCfgA)
            {
                return;         // --------------------
            }
            // ----------------------------------------

            if (!bgDta.RockStorageDepth.HasValue)
            {
                throw new PACInputDataException(
                          "Rock Storage Depth is required for calculations",
                          "RockStorageDepth");
            }
            // ----------------------------------------
            if (!bgDta.RockPorosity.HasValue)
            {
                throw new PACInputDataException(
                          "Rock Porosity is required for calculations",
                          "RockPorosity");
            }
            // ----------------------------------------

            if (Configuration.ConfigBCEF.HasFlag(cfg))
            {
                if (!bgDta.RockBottomArea.HasValue)
                {
                    throw new PACInputDataException(
                              "Rock Bottom Area is required for calculations",
                              "RockBottomArea");
                }
                // ----------------------------------------
                if (!bgDta.RockWidth.HasValue)
                {
                    throw new PACInputDataException(
                              "Rock Width is required for calculations",
                              "RockWidth");
                }
            }
            // ----------------------------------------
            // ----------------------------------------
            if (!Configuration.ConfigCD.HasFlag(cfg))
            {
                return;
            }
            // ----------------------------------------------
            // ----------------------------------------------
            if (!bgDta.UnderdrainHeight.HasValue)
            {
                throw new PACInputDataException(
                          "Rock Storage Depth Below the Underdrain pipe is required for calculations",
                          "UnderdrainHeight");
            }
            if (bgDta.Orifice.HasOrifice && !bgDta.Orifice.Diameter.HasValue)
            {
                throw new PACInputDataException(
                          $"This facility is Configuration {cfg}, and " +
                          "has an Orifice, but no Orifice diameter has been specified.",
                          "Orifice.Diameter");
            }
            if (!bgDta.Orifice.HasOrifice && bgDta.Orifice.Reason == OrificeReason.Null)
            {
                throw new PACInputDataException(
                          $"This facility is Configuration {cfg}, and has no Orifice. " +
                          "In this case the user must specify the reason that No orifice was included.",
                          "Orifice.Reason");
            }
        }
Beispiel #8
0
        public void TestSlopedFacilitySerialization()
        {
            var segs = Segments.Empty;

            segs.AddSegment(Segment.Make(
                                12.7m, 7.5m, 0.25m,
                                5.4m, 0.6m, 0.63m,
                                13.5m, 11.7m));
            segs.AddSegment(Segment.Make(
                                21.7m, 5.6m, 0.25m,
                                8.2m, 0.45m, 0.35m,
                                10.9m, 11.7m));

            var c = Catchment.Make("TestSlopedFacility",
                                   InfiltrationTestProcedure.OpenPit,
                                   PRStatus.Fail, 3.56m,
                                   HierarchyLevel.DischargeToRiverSlough,
                                   23456, 45, 56, 6, 8,
                                   SlopedFacility.Make(true,
                                                       Configuration.ConfigA, 5.2m,
                                                       AboveGradeProperties.Make(222m, 5.3m,
                                                                                 187m, 0.9m, 7.2m, 4.5m,
                                                                                 287m, 5.4m, 87m),
                                                       BelowGradeProperties.Make(56, 87.5m,
                                                                                 223.4m, 11.2m,
                                                                                 6.9m, 6m,
                                                                                 Orifice.Make(1.6m)),
                                                       segs));
            var rslt = ExpectedResult.Make("sloped");

            rslt.StormResults = StormResults.Empty;
            rslt.StormResults.AddRange(new[]
            {
                StormResult.Make(DesignStorm.WQ, PRStatus.Pass),
                StormResult.Make(DesignStorm.TwoYear, PRStatus.Pass),
                //StormResult.Make(DesignStorm.HalfTwoYear,  PRStatus.Pass),
                StormResult.Make(DesignStorm.FivYear, PRStatus.Pass),
                StormResult.Make(DesignStorm.TenYear, PRStatus.Pass),
                StormResult.Make(DesignStorm.TwntyFiv, PRStatus.Pass)
            });
            foreach (var se in rslt.StormResults)
            {
                var rnd = new Random();
                se.Timesteps = Timesteps.Empty;
                for (var ts = 1; ts <= 144; ts++)
                {
                    se.Timesteps.AddTimestep(ts,
                                             2m * (decimal)rnd.NextDouble(),
                                             2m * (decimal)rnd.NextDouble(),
                                             2m * (decimal)rnd.NextDouble(),
                                             10.4m * (decimal)rnd.NextDouble(),
                                             10.4m * (decimal)rnd.NextDouble(),
                                             3.6m * (decimal)rnd.NextDouble(),
                                             12.6m * (decimal)rnd.NextDouble(),
                                             12.6m * (decimal)rnd.NextDouble(),
                                             23.1m * (decimal)rnd.NextDouble());
                }
            }
            var scenario = Scenario.Make("sloped", c, DateTime.UtcNow, rslt);

            using (var sw = new StringWriter())
                using (var xwrtr = XmlWriter.Create(sw))
                {
                    var ser = new XmlSerializer(typeof(Scenario));
                    ser.Serialize(xwrtr, scenario);
                    var s = sw.ToString();
                    Assert.IsNotNull(s);
                }
        }