public int MarkCohorts(Landis.Library.BiomassCohorts.IDisturbance disturbance) { // Go backwards through list of cohort data, so the removal of an // item doesn't mess up the loop. isMaturePresent = false; int totalReduction = 0; for (int i = cohorts.Count - 1; i >= 0; i--) { Cohort cohort = cohorts[i]; int reduction = disturbance.ReduceOrKillMarkedCohort(cohort); if (reduction > 0) { totalReduction += reduction; if (reduction < cohort.Biomass) { float fRed = reduction / cohort.Biomass; cohort.Wood *= fRed; cohort.Fol *= fRed; } else { RemoveCohort(cohort, disturbance.CurrentSite, disturbance.Type); cohort = null; } } if (cohort != null && cohort.Age >= species.Maturity) { isMaturePresent = true; } } return(totalReduction); }
//--------------------------------------------------------------------- public int MarkCohorts(Landis.Library.BiomassCohorts.IDisturbance disturbance) { // Go backwards through list of cohort data, so the removal of an // item doesn't mess up the loop. isMaturePresent = false; int totalReduction = 0; for (int i = cohortData.Count - 1; i >= 0; i--) { Cohort cohort = new Cohort(species, cohortData[i]); int reduction = disturbance.ReduceOrKillMarkedCohort(cohort); if (reduction > 0) { totalReduction += reduction; if (reduction < cohort.Biomass) { float fRed = (float)reduction / (float)cohort.Biomass; //Console.WriteLine(" MarkCohorts Partial mortality: {0}, {1} yrs, {2} Mg/ha", cohort.Species.Name, cohort.Age, cohort.Biomass); ReduceCohort(i, cohort, disturbance.CurrentSite, disturbance.Type, fRed); //RMS 12/2016 float deltaWood = (-1) * fRed * (float)cohort.Data.WoodBiomass; cohort.ChangeWoodBiomass(deltaWood); float deltaLeaf = (-1) * fRed * (float)cohort.Data.LeafBiomass; cohort.ChangeLeafBiomass(deltaLeaf); if (cohortData[i].Age >= species.Maturity) { isMaturePresent = true; } } else { //Console.WriteLine(" MarkCohorts Total mortality: {0}, {1} yrs, {2} Mg/ha", cohort.Species.Name, cohort.Age, cohort.Biomass); RemoveCohort(i, cohort, disturbance.CurrentSite, disturbance.Type); cohort = null; } } else { if (cohortData[i].Age >= species.Maturity) { isMaturePresent = true; } } } return(totalReduction); }
//--------------------------------------------------------------------- public int MarkCohorts(Landis.Library.BiomassCohorts.IDisturbance disturbance) { isSpeciesCohortDamaged.SetAllFalse(Count); // Go backwards through list of cohort data, so the removal of an // item doesn't mess up the loop. isMaturePresent = false; int totalReduction = 0; for (int i = cohortData.Count - 1; i >= 0; i--) { if (isSpeciesCohortDamaged[i]) { Cohort cohort = new Cohort(species, cohortData[i]); int reduction = disturbance.ReduceOrKillMarkedCohort(cohort); if (reduction > 0) { totalReduction += reduction; if (reduction < cohort.Biomass) { float fRed = reduction / cohort.Biomass; float deltaWood = (-1) * fRed * (float)cohort.Data.WoodBiomass; cohort.ChangeWoodBiomass(deltaWood); float deltaLeaf = (-1) * fRed * (float)cohort.Data.LeafBiomass; cohort.ChangeLeafBiomass(deltaLeaf); } else { Cohort.KilledByAgeOnlyDisturbance(disturbance, cohort, disturbance.CurrentSite, disturbance.Type); RemoveCohort(i, cohort, disturbance.CurrentSite, disturbance.Type); cohort = null; } } } else if (cohortData[i].Age >= species.Maturity) { isMaturePresent = true; } } return(totalReduction); }
public int ReduceOrKillBiomassCohorts(Landis.Library.BiomassCohorts.IDisturbance disturbance) { List <int> reduction = new List <int>(); List <Cohort> ToRemove = new List <Cohort>(); foreach (List <Cohort> species_cohort in cohorts.Values) { //Landis.Library.DensityCohorts.SpeciesCohorts species_cohorts = GetSpeciesCohort(cohorts[species_cohort[0].Species]); foreach (Landis.Library.DensityCohorts.ICohort cohort in (IEnumerable <Landis.Library.DensityCohorts.ICohort>)species_cohort) //for (int c =0;c< species_cohort.Count(); c++) { //FIXME - JSF //Landis.Library.BiomassCohorts.ICohort biocohort = (Library.BiomassCohorts.ICohort) cohort; //int _reduction = disturbance.ReduceOrKillMarkedCohort(biocohort); // Disturbances return reduction in aboveground biomass int _reduction = disturbance.ReduceOrKillMarkedCohort(cohort); double reductionProp = (double)_reduction / (double)cohort.Biomass; int treeRemoval = (int)Math.Round(cohort.Treenumber * reductionProp); reduction.Add(treeRemoval); if (reduction[reduction.Count() - 1] >= cohort.Treenumber) //Compare to existing number of trees { ToRemove.Add((Cohort)cohort); // Edited by BRM - 090115 } else { //FIXME compute treenumber reduction from disturbance reduction //Proportion of aboveground biomass cohort.ChangeTreenumber(-treeRemoval); // Reduction applies to all biomass } // } } foreach (Cohort cohort in ToRemove) { RemoveCohort(cohort, disturbance.Type); } return(reduction.Sum()); }
public int ReduceOrKillBiomassCohorts(Landis.Library.BiomassCohorts.IDisturbance disturbance) { int totalReduction = 0; for (int i = cohorts.Count - 1; i >= 0; i--) { int reduction = disturbance.ReduceOrKillMarkedCohort(cohorts[i]); if (reduction > 0) { totalReduction += reduction; if (reduction < cohorts[i].Biomass) { cohorts[i].Wood -= (ushort)reduction; } else { //cohorts[i].IsAlive = false; Cohort.Died(this, cohorts[i], disturbance.CurrentSite, disturbance.Type); cohorts.Remove(cohorts[i]); } } } return(totalReduction); }