//--------------------------------------------------------------------- /// <summary> /// Computes how much a disturbance damages the cohorts by reducing /// their biomass. /// </summary> /// <returns> /// The total of all the cohorts' biomass reductions. /// </returns> public int MarkCohorts(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); //Console.WriteLine(" Reduction: {0}, {1} yrs, {2} Mg/ha, reduction={3}", cohort.Species.Name, cohort.Age, cohort.Biomass, reduction); if (reduction > 0) { totalReduction += reduction; if (reduction < cohort.Biomass) { ReduceCohort(cohort, disturbance.CurrentSite, disturbance.Type, reduction); cohort.ChangeBiomass(-reduction); cohortData[i] = cohort.Data; //Console.WriteLine(" Partial Reduction: {0}, {1} yrs, {2} Mg/ha", cohort.Species.Name, cohort.Age, cohort.Biomass); } else { RemoveCohort(i, cohort, disturbance.CurrentSite, disturbance.Type); cohort = null; } } if (cohort != null && cohort.Age >= species.Maturity) { isMaturePresent = true; } } return(totalReduction); }
public int ReduceOrKillDensityCohorts(IDisturbance disturbance) { List <int> reduction = new List <int>(); List <Cohort> ToRemove = new List <Cohort>(); double baCheck = 0; foreach (List <Cohort> species_cohort in cohorts.Values) { //Landis.Library.DensityCohorts.SpeciesCohorts species_cohorts = GetSpeciesCohort(cohorts[species_cohort[0].Species]); foreach (ICohort cohort in (IEnumerable <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 baCheck += cohort.ComputeCohortBasalArea(cohort); int _reduction = disturbance.ReduceOrKillMarkedCohort(cohort); //double reductionProp = _reduction / cohort.Biomass; // JSF - This works with removal from Landuse extension int treeRemoval = _reduction; //int treeRemoval = (int)Math.Round(cohort.Treenumber * reductionProp); reduction.Add(_reduction); if (reduction[reduction.Count() - 1] >= cohort.Treenumber) //Compare to aboveground biomass { 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); baCheck = cohort.ComputeCohortBasalArea(cohort); } baCheck = 0; foreach (List <Cohort> species_cohort in cohorts.Values) { //Landis.Library.DensityCohorts.SpeciesCohorts species_cohorts = GetSpeciesCohort(cohorts[species_cohort[0].Species]); foreach (ICohort cohort in (IEnumerable <ICohort>)species_cohort) //for (int c =0;c< species_cohort.Count(); c++) { baCheck += cohort.ComputeCohortBasalArea(cohort); } } return(reduction.Sum()); }
public float MarkCohorts(IDisturbance disturbance) { // Go backwards through list of cohort data, so the removal of an // item doesn't mess up the loop. isMaturePresent = false; for (int i = cohorts.Count - 1; i >= 0; i--) { Cohort cohort = new Cohort(species, cohorts[i]); disturbance.ReduceOrKillMarkedCohort(cohort); double defoliation = disturbance.CumulativeDefoliation(); cohort.Fol *= 1 - (float)defoliation; } return(0); }
//--------------------------------------------------------------------- /// <summary> /// Computes how much a disturbance damages the cohorts by reducing /// their biomass. /// </summary> /// <returns> /// The total of all the cohorts' biomass reductions. /// </returns> public int DamageBySpecies(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]); float[] reduction = disturbance.ReduceOrKillMarkedCohort(cohort); //int reduction = disturbance.ReduceOrKillMarkedCohort(cohort); totalReduction += (int)(reduction[0] + reduction[1]); float fRed = (totalReduction / (float)cohort.Biomass); if (totalReduction > 0) { if (totalReduction < cohort.Biomass) { //Console.WriteLine(" DamageBySpecies 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 if (reduction[1] < cohort.LeafBiomass) { cohort.ChangeLeafBiomass(-reduction[1]); cohortData[i] = cohort.Data; } if (reduction[0] < cohort.WoodBiomass) { cohort.ChangeWoodBiomass(-reduction[0]); cohortData[i] = cohort.Data; } } else { // Assume that if all wood biomass lost, the cohort is dead //Console.WriteLine(" DamageBySpecies Total mortality: {0}, {1} yrs, {2} Mg/ha", cohort.Species.Name, cohort.Age, cohort.Biomass); RemoveCohort(i, cohort, disturbance.CurrentSite, disturbance.Type); cohort = null; } } if (cohort != null) { if (cohort.Age >= species.Maturity) { isMaturePresent = true; } } } return(totalReduction); }
//--------------------------------------------------------------------- /// <summary> /// Computes how much a disturbance damages the cohorts by reducing /// their biomass. /// </summary> /// <returns> /// The total of all the cohorts' biomass reductions. /// </returns> public int DamageBySpecies(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]); float[] reduction = disturbance.ReduceOrKillMarkedCohort(cohort); if (reduction[0] + reduction[1] > 0) { totalReduction += (int)(reduction[0] + reduction[1]); if (reduction[1] < cohort.LeafBiomass) { cohort.ChangeLeafBiomass(-reduction[1]); cohortData[i] = cohort.Data; } if (reduction[0] < cohort.WoodBiomass) { cohort.ChangeWoodBiomass(-reduction[0]); cohortData[i] = cohort.Data; } else // Assume that if all wood biomass lost, the cohort is dead { RemoveCohort(i, cohort, disturbance.CurrentSite, disturbance.Type); cohort = null; } } if (cohort != null && cohort.Age >= species.Maturity) { isMaturePresent = true; } } return(totalReduction); }