//--------------------------------------------------------------------- /// <summary> /// Combines all young cohorts into a single cohort whose age is the /// succession timestep - 1 and whose biomass is the sum of all the /// biomasses of the young cohorts. /// </summary> /// <remarks> /// The age of the combined cohort is set to the succession timestep - /// 1 so that when the combined cohort undergoes annual growth, its /// age will end up at the succession timestep. /// <p> /// For this method, young cohorts are those whose age is less than or /// equal to the succession timestep. We include the cohort whose age /// is equal to the timestep because such a cohort is generated when /// reproduction occurs during a succession timestep. /// </remarks> public void CombineYoungCohorts() { // Work from the end of cohort data since the array is in old-to- // young order. int youngCount = 0; int totalBiomass = 0; for (int i = cohortData.Count - 1; i >= 0; i--) { CohortData data = cohortData[i]; if (data.Age <= Cohorts.SuccessionTimeStep) { youngCount++; totalBiomass += data.Biomass; } else { break; } } if (youngCount > 0) { cohortData.RemoveRange(cohortData.Count - youngCount, youngCount); cohortData.Add(new CohortData((ushort)(Cohorts.SuccessionTimeStep - 1), (ushort)totalBiomass)); } }
public void Init() { betualle = Data.Species["betualle"]; const ushort age = 100; const int biomass = 500; CohortData data = new CohortData(age, biomass); myCohort = new Cohort(betualle, data); bool[,] grid = new bool[,]{ {true} }; DataGrid<bool> dataGrid = new DataGrid<bool>(grid); ILandscape landscape = new Landscape.Landscape(dataGrid); myActiveSite = landscape[1,1]; }
public void NonWoodyPercentage() { const ushort age = 100; const int biomass = 500; CohortData data = new CohortData(age, biomass); Cohort cohort = new Cohort(betualle, data); Percentage nonWoodyPercentage = Percentage.Parse("35%"); mockCalculator.NonWoodyPercentage = nonWoodyPercentage; int expectedNonWoody = (int) (biomass * nonWoodyPercentage); int nonWoody = cohort.ComputeNonWoodyBiomass(activeSite); Assert.AreEqual(expectedNonWoody, nonWoody); }
//--------------------------------------------------------------------- public Cohort(ISpecies species, CohortData cohortData) { this.species = species; this.data = cohortData; }