コード例 #1
0
        public void CalcMaxRootLayerTest()
        {
            SoilArbitrator_Accessor target = new SoilArbitrator_Accessor();
            double root_depth = 100;

            double[] dlayer   = new double[] { 50, 100, 200 };
            int      expected = 1;
            int      actual;

            actual = target.CalcMaxRootLayer(root_depth, dlayer);
            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void RootProportionTest()
        {
            SoilArbitrator_Accessor target = new SoilArbitrator_Accessor();
            int    layer      = 1;
            double root_depth = 100;

            double[] dlayer   = new double[] { 50, 100, 200 };
            double   expected = 0.5;
            double   actual;

            actual = target.RootProportion(layer, root_depth, dlayer);
            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void CalcCropSWLayerUptakeTest()
        {
            DataTable AllRootSystems = new DataTable();

            AllRootSystems.Columns.Add("ZoneName", typeof(string));
            AllRootSystems.Columns.Add("CropType", typeof(string));
            AllRootSystems.Columns.Add("SWDemand", typeof(double));
            AllRootSystems.Columns.Add("ZoneStrength", typeof(Dictionary <string, double>)); //KVP of zones and relative strengths for water extraction
            AllRootSystems.Columns.Add("RootSystemZone", typeof(RootSystemZoneType));
            AllRootSystems.Columns.Add("HasRootSystem", typeof(bool));
            Dictionary <string, double> ZoneStrength = new Dictionary <string, double>();

            ZoneStrength.Add("Testfield1", 0.5);
            ZoneStrength.Add("Testfield2", 0.5);
            RootSystemType rsz = new RootSystemType();

            rsz.SWDemand          = 5;
            rsz.Zone              = new RootSystemZoneType[2];
            rsz.Zone[0]           = new RootSystemZoneType();
            rsz.Zone[1]           = new RootSystemZoneType();
            rsz.Zone[0].dlayer    = new double[] { 50, 100, 200 };
            rsz.Zone[0].kl        = new double[] { 0.05, 0.05, 0.05 };
            rsz.Zone[0].ll        = new double[] { 0.15, 0.15, 0.15 };
            rsz.Zone[0].RootDepth = 100;
            rsz.Zone[1].dlayer    = new double[] { 50, 100, 200 };
            rsz.Zone[1].kl        = new double[] { 0.05, 0.05, 0.05 };
            rsz.Zone[1].ll        = new double[] { 0.15, 0.15, 0.15 };
            rsz.Zone[1].RootDepth = 100;
            AllRootSystems.Rows.Add("Testfield1", "Crop1", 2, ZoneStrength, rsz.Zone[0], true);
            AllRootSystems.Rows.Add("Testfield2", "Crop2", 4, ZoneStrength, rsz.Zone[1], true);

            SoilArbitrator_Accessor target = new SoilArbitrator_Accessor();

            double[] CropSWDemand = new double[] { 2, 4 };
            double[,] RelSWLayerStrength = new double[, ] {
                { 0.5, 0.5, 0 }, { 0.5, 0.5, 0 }
            };
            int NumLayers = 3;
            IEnumerable <DataRow> RootZones = AllRootSystems.AsEnumerable();

            double[] dlayer = new double[] { 50, 100, 200 };;
            double[,] expected = new double[, ] {
                { 1, .5, 0 }, { 2, 1, 0 }
            };
            double[,] actual;
            actual = target.CalcCropSWLayerUptake(CropSWDemand, RelSWLayerStrength, NumLayers, RootZones, dlayer);
            Assert.AreEqual(Compare2DArrays(actual, expected), true);
        }