public void MalcolmKnappNelder() { using Model nelder1 = LandTest.LoadProject(LandTest.GetMalcolmKnappProjectPath(TestConstant.MalcolmKnapp.Nelder1)); ModelTest.VerifyMalcolmKnappResourceUnit(nelder1); for (int year = 0; year < 26; ++year) // age 25 to 51 { nelder1.RunYear(); } ModelTest.VerifyMalcolmKnappClimate(nelder1); ModelTest.VerifyMalcolmKnappModel(nelder1); ModelTest.VerifyMalcolmKnappDouglasFir(nelder1); }
public void MalcolmKnapp16() { using Model plot16 = LandTest.LoadProject(LandTest.GetMalcolmKnappProjectPath(TestConstant.MalcolmKnapp.Plot16)); // check soil properties at initial load ModelTest.VerifyMalcolmKnappResourceUnit(plot16); // 2019 - 1985 + 1 = 35 years of data available for (int year = 0; year < 35; ++year) { plot16.RunYear(); } ModelTest.VerifyMalcolmKnappClimate(plot16); ModelTest.VerifyMalcolmKnappModel(plot16); ModelTest.VerifyMalcolmKnappDouglasFir(plot16); }
public void MalcolmKnapp14() { // spacing trials using Model plot14 = LandTest.LoadProject(LandTest.GetMalcolmKnappProjectPath(TestConstant.MalcolmKnapp.Plot14)); // check soil properties at initial load ModelTest.VerifyMalcolmKnappResourceUnit(plot14); List <float> gppByYear = new(); List <float> nppByYear = new(); List <float> stemVolumeByYear = new(); for (int year = 0; year < 28; ++year) { plot14.RunYear(); Assert.IsTrue(plot14.Landscape.ResourceUnits.Count == 1); float gpp = 0.0F; float npp = 0.0F; foreach (ResourceUnitTreeSpecies treeSpecies in plot14.Landscape.ResourceUnits[0].Trees.SpeciesAvailableOnResourceUnit) { gpp += treeSpecies.BiomassGrowth.AnnualGpp; npp += treeSpecies.Statistics.TreeNpp; } gppByYear.Add(gpp); nppByYear.Add(npp); float volume = 0.0F; foreach (Trees treesOfSpecies in plot14.Landscape.ResourceUnits[0].Trees.TreesBySpeciesID.Values) { for (int treeIndex = 0; treeIndex < treesOfSpecies.Count; ++treeIndex) { volume += treesOfSpecies.GetStemVolume(treeIndex); } } stemVolumeByYear.Add(volume); Assert.IsTrue(plot14.Landscape.ResourceUnits[0].Trees.TreeStatisticsByStandID.Count == 1); Assert.IsTrue(plot14.Landscape.ResourceUnits[0].Trees.TreeStatisticsByStandID.ContainsKey(14)); } ModelTest.VerifyMalcolmKnappClimate(plot14); ModelTest.VerifyMalcolmKnappModel(plot14); ModelTest.VerifyMalcolmKnappDouglasFir(plot14); // regex for reformatting copy/paste of values from watch window: "\s+\[\d+]\s+(\d+.\d{1,3})\d*\s+float\r?\n" -> "$1F, " List <float> nominalGppByYear = new() { 10.331F, 11.133F, 14.020F, 11.316F, 13.527F, // 0...4 10.526F, 12.332F, 12.791F, 12.987F, 11.235F, // 5...9 11.608F, 10.062F, 11.081F, 9.992F, 12.681F, // 10...14 11.237F, 11.539F, 10.230F, 8.268F, 9.310F, // 15...19 11.888F, 8.964F, 11.145F, 10.091F, 13.221F, // 20...24 10.973F, 12.179F, 12.647F // 25...27 }; List <float> nominalNppByYear = new() { 13305.625F, 14514.859F, 18456.353F, 15041.932F, 18053.941F, 14110.686F, 16558.890F, 17210.685F, 17502.668F, 15159.530F, 15669.442F, 13588.600F, 14967.475F, 13497.672F, 17130.728F, 15179.787F, 15582.680F, 13804.854F, 11158.202F, 12561.510F, 16028.833F, 12079.922F, 15009.008F, 13583.033F, 17776.400F, 14749.142F, 16356.83F, 16963.591F }; List <float> nominalVolumeByYear = new() { 118.143F, 130.357F, 148.674F, 161.134F, 178.615F, 189.416F, 204.427F, 220.182F, 236.591F, 248.959F, 261.886F, 271.750F, 283.939F, 293.349F, 309.284F, 320.494F, 333.093F, 340.758F, 346.781F, 355.119F, 368.386F, 374.821F, 386.607F, 395.546F, 410.205F, 422.316F, 437.456F, 452.937F }; ResourceUnitTreeStatisticsWithPreviousYears plotStatistics = (ResourceUnitTreeStatisticsWithPreviousYears)plot14.Landscape.ResourceUnits[0].Trees.TreeStatisticsByStandID[14]; for (int year = 0; year < nominalVolumeByYear.Count; ++year) { float gpp = gppByYear[year]; float nominalGpp = nominalGppByYear[year]; float relativeGppError = MathF.Abs(1.0F - gpp / nominalGpp); float npp = nppByYear[year]; float nominalNpp = nominalNppByYear[year]; float plotNpp = plotStatistics.TreeNppByYear[year]; float relativeNppError = MathF.Abs(1.0F - npp / nominalNpp); float stemVolume = stemVolumeByYear[year]; float nominalVolume = nominalVolumeByYear[year]; float plotVolume = plotStatistics.LiveStemVolumeByYear[year]; float relativeVolumeError = MathF.Abs(1.0F - stemVolume / nominalVolume); Assert.IsTrue(relativeGppError < 0.02F, "Expected plot 14 to have a GPP of {0:0.000} kg/m² in simulation year {1} but the projected GPP was {2:0.000} kg/m², a {3:0.0%} difference.", nominalGpp, year, gpp, relativeGppError); Assert.IsTrue(relativeNppError < 0.02F, "Expected plot 14 to have an NPP of {0:0.000} kg/ha in simulation year {1} but the projected NPP was {2:0.000} kg/ha, a {3:0.0%} difference.", nominalNpp, year, npp, relativeNppError); Assert.IsTrue(relativeVolumeError < 0.02F, "Expected plot 14 to carry a standing volume of {0:0.000} m³ in simulation year {1} but the projected volume was {2:0.000} m³, a {3:0.0%} difference.", nominalVolume, year, stemVolume, relativeVolumeError); Assert.IsTrue(npp == plotNpp); Assert.IsTrue(MathF.Abs(stemVolume - plotVolume) < 0.0001F); // plot statistics are multiplied by expansion factor obtained from portion of resource unit occupied to obtain per hectare values if (year == 0) { // sanity checks on initial state Assert.IsTrue(plotStatistics.AverageDbhByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.AverageHeightByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.BasalAreaByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.LeafAreaIndexByYear[year] >= 1.0F); Assert.IsTrue(plotStatistics.LiveStemVolumeByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.LiveAndSnagStemVolumeByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.TreeNppAbovegroundByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.TreeNppByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.TreeCountByYear[year] == 222.0F); Assert.IsTrue(plotStatistics.CohortCountByYear[year] == 0); Assert.IsTrue(plotStatistics.MeanSaplingAgeByYear[year] == 0.0F); Assert.IsTrue(plotStatistics.SaplingNppByYear[year] == 0.0F); Assert.IsTrue(plotStatistics.BranchCarbonByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.BranchNitrogenByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.CoarseRootCarbonByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.CoarseRootNitrogenByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.FineRootCarbonByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.FineRootNitrogenByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.FoliageCarbonByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.FoliageNitrogenByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.RegenerationCarbonByYear[year] == 0.0F); Assert.IsTrue(plotStatistics.RegenerationNitrogenByYear[year] == 0.0F); Assert.IsTrue(plotStatistics.SaplingCountByYear[year] == 0); Assert.IsTrue(plotStatistics.StemCarbonByYear[year] > 0.0F); Assert.IsTrue(plotStatistics.StemNitrogenByYear[year] > 0.0F); } else { // sanity checks on growth int previousYear = year - 1; Assert.IsTrue(plotStatistics.AverageDbhByYear[year] > plotStatistics.AverageDbhByYear[previousYear]); Assert.IsTrue(plotStatistics.AverageHeightByYear[year] > plotStatistics.AverageHeightByYear[previousYear]); Assert.IsTrue(plotStatistics.BasalAreaByYear[year] > 0.95F * plotStatistics.BasalAreaByYear[previousYear]); Assert.IsTrue(plotStatistics.LeafAreaIndexByYear[year] > 0.95F * plotStatistics.LeafAreaIndexByYear[previousYear]); Assert.IsTrue(plotStatistics.LiveStemVolumeByYear[year] > 0.95F * plotStatistics.LiveStemVolumeByYear[previousYear]); Assert.IsTrue(plotStatistics.LiveAndSnagStemVolumeByYear[year] >= 0.95F * plotStatistics.LiveAndSnagStemVolumeByYear[previousYear]); Assert.IsTrue(plotStatistics.StemCarbonByYear[year] > 0.99F * plotStatistics.StemCarbonByYear[previousYear]); Assert.IsTrue(plotStatistics.StemNitrogenByYear[year] > 0.99F * plotStatistics.StemNitrogenByYear[previousYear]); Assert.IsTrue(plotStatistics.TreeCountByYear[year] <= plotStatistics.TreeCountByYear[previousYear]); Assert.IsTrue(plotStatistics.TreeNppAbovegroundByYear[year] > 0.67F * plotStatistics.TreeNppAbovegroundByYear[previousYear]); Assert.IsTrue(plotStatistics.TreeNppByYear[year] > 0.75F * plotStatistics.TreeNppByYear[previousYear]); Assert.IsTrue(plotStatistics.MeanSaplingAgeByYear[year] == 0.0F); // regeneration not enabled Assert.IsTrue(plotStatistics.RegenerationCarbonByYear[year] == 0.0F); Assert.IsTrue(plotStatistics.RegenerationNitrogenByYear[year] == 0.0F); Assert.IsTrue(plotStatistics.SaplingNppByYear[year] == 0.0F); // regeneration not enabled Assert.IsTrue(plotStatistics.SaplingCountByYear[year] == 0); Assert.IsTrue(plotStatistics.BranchCarbonByYear[year] > 0.95F * plotStatistics.BranchCarbonByYear[previousYear]); Assert.IsTrue(plotStatistics.BranchNitrogenByYear[year] > 0.95F * plotStatistics.BranchNitrogenByYear[previousYear]); Assert.IsTrue(plotStatistics.CoarseRootCarbonByYear[year] > 0.95F * plotStatistics.CoarseRootCarbonByYear[previousYear]); Assert.IsTrue(plotStatistics.CoarseRootNitrogenByYear[year] > 0.95F * plotStatistics.CoarseRootNitrogenByYear[previousYear]); Assert.IsTrue(plotStatistics.CohortCountByYear[year] == 0); // no saplings at initialization and regeneration not enabled Assert.IsTrue(plotStatistics.FineRootCarbonByYear[year] > 0.95F * plotStatistics.FineRootCarbonByYear[previousYear]); Assert.IsTrue(plotStatistics.FineRootNitrogenByYear[year] > 0.95F * plotStatistics.FineRootNitrogenByYear[previousYear]); Assert.IsTrue(plotStatistics.FoliageCarbonByYear[year] > 0.95F * plotStatistics.FoliageCarbonByYear[previousYear]); Assert.IsTrue(plotStatistics.FoliageNitrogenByYear[year] > 0.95F * plotStatistics.FoliageNitrogenByYear[previousYear]); // sanity checks on ranges Assert.IsTrue(plotStatistics.LiveStemVolumeByYear[year] >= plotStatistics.LiveAndSnagStemVolumeByYear[year]); Assert.IsTrue((plotStatistics.LeafAreaIndexByYear[year] > 1.0F) && (plotStatistics.LeafAreaIndexByYear[year] < 20.0F)); } } } [TestMethod]