private static void VerifyMalcolmKnappResourceUnit(Model model) { foreach (ResourceUnit ru in model.Landscape.ResourceUnits) { // resource unit variables read from climate file which are aren't currently test accessible // ru.Snags: swdC, swdCount, swdCN, swdHalfLife, swdDecomRate, otherC, other CN // resource unit variables read from project file which are aren't currently test accessible // ru.Soil: qb, qh, el, er, leaching, nitrogenDeposition, soilDepth, // mKo (decomposition rate), mH (humification rate0 // ru.WaterCycle.Canopy: interceptionStorageNeedle, interceptionStorageBroadleaf, snowMeltTemperature, // waterUseSoilSaturation, pctSand, pctSilt, pctClay // ru.SpeciesSet: nitrogenResponseClasses 1a, 1b, 2a, 2b, 3a, 3b // CO2 baseConcentration, compensationPoint, beta0, p0 // lightResponse shadeIntolerant, shadeTolerant, LRImodifier //ru.Snags.ClimateFactor; //ru.Snags.FluxToAtmosphere; //ru.Snags.FluxToDisturbance; //ru.Snags.FluxToExtern; //ru.Snags.RefractoryFlux; //ru.Snags.RemoveCarbon; //ru.Soil.ClimateDecompositionFactor; //ru.Soil.FluxToAtmosphere; //ru.Soil.FluxToDisturbance; //ru.Soil.InputLabile; //ru.Soil.InputRefractory; AssertNullable.IsNotNull(ru.Soil); Assert.IsTrue(MathF.Abs(ru.Soil.OrganicMatter.C - 161.086F) < 0.001F, "Soil: organic carbon"); Assert.IsTrue(MathF.Abs(ru.Soil.OrganicMatter.N - 17.73954F) < 0.00001F, "Soil: organic nitrogen"); Assert.IsTrue(MathF.Abs(ru.Soil.PlantAvailableNitrogen - 56.186F) < 0.001F, "Soil: plant available nitrogen"); Assert.IsTrue(MathF.Abs(ru.Soil.YoungLabile.C - 4.8414983F) < 0.001F, "Soil: young labile carbon"); Assert.IsTrue(MathF.Abs(ru.Soil.YoungLabile.N - 0.2554353F) < 0.0001F, "Soil: young labile nitrogen"); Assert.IsTrue(ru.Soil.YoungLabile.DecompositionRate == 0.322F, "Soil: young labile decomposition rate"); Assert.IsTrue(MathF.Abs(ru.Soil.YoungRefractory.C - 45.97414F) < 0.001F, "Soil: young refractory carbon"); Assert.IsTrue(MathF.Abs(ru.Soil.YoungRefractory.N - 0.261731F) < 0.0001F, "Soil: young refractory nitrogen"); Assert.IsTrue(ru.Soil.YoungRefractory.DecompositionRate == 0.1790625F, "Soil: young refractory decomposition rate"); //ru.Variables.CarbonToAtm; //ru.Variables.CarbonUptake; //ru.Variables.CumCarbonToAtm; //ru.Variables.CumCarbonUptake; //ru.Variables.CumNep; //ru.Variables.Nep; Assert.IsTrue(ru.WaterCycle.CanopyConductance == 0.0F, "Water cycle: canopy conductance"); // initially zero Assert.IsTrue((ru.WaterCycle.CurrentSoilWaterContent >= 0.0) && (ru.WaterCycle.CurrentSoilWaterContent <= ru.WaterCycle.FieldCapacity), "Soil: current water content"); Assert.IsTrue(MathF.Abs(ru.WaterCycle.FieldCapacity - 29.2064552F) < 0.001F, "Soil: field capacity"); Assert.IsTrue(ru.WaterCycle.SoilWaterPsi.Length == Constant.DaysInLeapYear, "Water cycle: water potential length"); foreach (float psi in ru.WaterCycle.SoilWaterPsi) { Assert.IsTrue((psi <= 0.0F) && (psi > -6000.0F), "Water cycle: water potential"); } Assert.IsTrue((ru.WaterCycle.SnowDayRadiation >= 0.0F) && (ru.WaterCycle.SnowDayRadiation < 5000.0F), "Water cycle: snow radiation"); // TODO: linkt to snow days? Assert.IsTrue((ru.WaterCycle.SnowDays >= 0.0F) && (ru.WaterCycle.SnowDays <= Constant.DaysInLeapYear), "Water cycle: snow days"); Assert.IsTrue(Math.Abs(ru.WaterCycle.SoilDepth - 1340.0F) < 0.001F, "Soil: depth"); Assert.IsTrue(ru.WaterCycle.TotalEvapotranspiration == 0.0F, "Soil: evapotranspiration"); // zero at initialization Assert.IsTrue(ru.WaterCycle.TotalRunoff == 0.0F, "Soil: runoff"); // zero at initialization } Assert.IsTrue(model.Landscape.ResourceUnits.Count == 1); Assert.IsTrue(model.Landscape.ResourceUnitGrid.Count == 1); }
private static void VerifyNorwaySpruce(Model model) { TreeSpecies species = model.Landscape.ResourceUnits[0].Trees.TreeSpeciesSet["piab"]; AssertNullable.IsNotNull(species); // PIAB: 1/(1 + (x/0.55)^2) float youngAgingFactor = species.GetAgingFactor(10.0F, 10); float middleAgingFactor = species.GetAgingFactor(40.0F, 80); float oldAgingFactor = species.GetAgingFactor(55.5F, 575); Assert.IsTrue(MathF.Abs(youngAgingFactor - 0.964912F) < 0.001F); Assert.IsTrue(MathF.Abs(middleAgingFactor - 0.481931F) < 0.001F); Assert.IsTrue(MathF.Abs(oldAgingFactor - 0.2375708F) < 0.001F); // PIAB: mf = 0.095565 * dbh^1.56 // round(0.095565 * c(2, 20, 50, 100) ^ 1.56, 5) Assert.IsTrue(String.Equals(species.ID, "piab", StringComparison.Ordinal)); Assert.IsTrue(Math.Abs(species.GetBiomassFoliage(2) - 0.281777) < 0.001); Assert.IsTrue(Math.Abs(species.GetBiomassFoliage(20) - 10.23070) < 0.001); Assert.IsTrue(Math.Abs(species.GetBiomassFoliage(50) - 42.72598) < 0.001); Assert.IsTrue(Math.Abs(species.GetBiomassFoliage(100) - 125.97920) < 0.001); // PIAB: HDlow = 170*(1)*d^-0.5, HDhigh = (195.547*1.004*(-0.2396+1)*d^-0.2396)*1 // round(170*(1)*c(3.3, 10, 33)^-0.5, 2) // round((195.547*1.004*(-0.2396+1)*c(3.3, 10, 33)^-0.2396)*1, 2) species.GetHeightDiameterRatioLimits(3.3F, out float lowLimitSmall, out float highLimitSmall); species.GetHeightDiameterRatioLimits(10.0F, out float lowLimitMedium, out float highLimitMedium); species.GetHeightDiameterRatioLimits(33.0F, out float lowLimitLarge, out float highLimitLarge); Assert.IsTrue(MathF.Abs(lowLimitSmall - 93.58F) < 0.01F); Assert.IsTrue(MathF.Abs(lowLimitMedium - 53.76F) < 0.01F); Assert.IsTrue(MathF.Abs(lowLimitLarge - 29.59F) < 0.01F); Assert.IsTrue(MathF.Abs(highLimitSmall - 112.15F) < 0.01F); Assert.IsTrue(MathF.Abs(highLimitMedium - 85.99F) < 0.01F); Assert.IsTrue(MathF.Abs(highLimitLarge - 64.59F) < 0.01F); // PIAB: 44.7*(1-(1-(h/44.7)^(1/3))*exp(-0.044))^3 // round(44.7*(1-(1-(c(0.25, 1, 4.5)/44.7)^(1/3))*exp(-0.044))^3, 3) double shortPotential = species.SaplingGrowthParameters.HeightGrowthPotential.Evaluate(0.25); double mediumPotential = species.SaplingGrowthParameters.HeightGrowthPotential.Evaluate(1); double tallPotential = species.SaplingGrowthParameters.HeightGrowthPotential.Evaluate(4.5); Assert.IsTrue(Math.Abs(shortPotential - 0.431) < 0.01); Assert.IsTrue(Math.Abs(mediumPotential - 1.367) < 0.01); Assert.IsTrue(Math.Abs(tallPotential - 5.202) < 0.01); }