/// <summary> /// Updates the Diameter and Biomass properties. /// </summary> /// <remarks> /// Should be called after all the species' cohorts have grown. /// </remarks> public void UpdateDiameterAndBiomass(IEcoregion ecoregion) { for (int i = 0; i < cohortData.Count; i++) { float diameter = 0; Dictionary <int, double> diameters = DiameterInputs.AllData[ecoregion.Name][species.Name].Diameters; if (diameters.ContainsKey(cohortData[i].Age)) { diameter = (float)diameters[cohortData[i].Age]; } else { for (int j = cohortData[i].Age; j > 0; j--) { if (diameters.ContainsKey(j)) { diameter = (float)diameters[j]; //FIXME JSF } } } ISpeciesDensity speciesdensity = SpeciesParameters.SpeciesDensity.AllSpecies[species.Index]; double biomass_dbl = Math.Exp(SpeciesParameters.biomass_util.GetBiomassData(speciesdensity.BiomassClass, 1) + SpeciesParameters.biomass_util.GetBiomassData(speciesdensity.BiomassClass, 2) * Math.Log(diameter)) * cohortData[i].Treenumber / 1000.00; // Mg/cell int biomass_int = System.Convert.ToInt32(biomass_dbl); double biomass_gm2 = biomass_dbl * 1000 * 1000 / (EcoregionData.ModelCore.CellLength * EcoregionData.ModelCore.CellLength); int biomass_gm2_int = System.Convert.ToInt32(biomass_gm2); CohortData newCohortData = new CohortData(cohortData[i].Age, cohortData[i].Treenumber); newCohortData.Biomass = biomass_gm2_int; newCohortData.Diameter = diameter; cohortData[i] = newCohortData; } }
//--------------------------------------------------------------------- /// <summary> /// Adds a new cohort. /// </summary> public void AddNewCohort(ushort age, int initialTrees) { CohortData newCohortData = new CohortData(age, initialTrees); Cohort cohort = new Cohort(species, age, initialTrees); this.cohortData.Add(newCohortData); }
//--------------------------------------------------------------------- /// <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 totalTrees = 0; for (int i = cohortData.Count - 1; i >= 0; i--) { CohortData data = cohortData[i]; if (data.Age <= Cohorts.SuccessionTimeStep) { youngCount++; totalTrees += data.Treenumber; } else { break; } } if (youngCount > 0) { cohortData.RemoveRange(cohortData.Count - youngCount, youngCount); cohortData.Add(new CohortData((ushort)(Cohorts.SuccessionTimeStep - 1), totalTrees)); } }
//--------------------------------------------------------------------- public Cohort(ISpecies species, CohortData cohortData) { this.species = (ISpecies)species; this.speciesDensity = SpeciesParameters.SpeciesDensity.AllSpecies[species.Index]; this.data = cohortData; }