Example #1
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Removes the cohorts that are damaged by an age-only disturbance.
        /// </summary>
        /// <returns>
        /// The total biomass of all the cohorts damaged by the disturbance.
        /// </returns>
        public int MarkCohorts(AgeOnlyCohorts.ISpeciesCohortsDisturbance disturbance)
        {
            isSpeciesCohortDamaged.SetAllFalse(Count);
            disturbance.MarkCohortsForDeath(this, isSpeciesCohortDamaged);

            //  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]);
                    totalReduction += (int)(cohort.WoodBiomass + cohort.LeafBiomass);

                    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);
        }
Example #2
0
        //---------------------------------------------------------------------

        public float[] ReduceOrKillMarkedCohort(ICohort cohort)
        {
            float[] damage = new float[] { 0, 0 };
            if (ageCohortDisturbance.MarkCohortForDeath(cohort))
            {
                Cohort.KilledByAgeOnlyDisturbance(this, cohort,
                                                  ageCohortDisturbance.CurrentSite,
                                                  ageCohortDisturbance.Type);

                damage[0] = cohort.WoodBiomass;
                damage[1] = cohort.LeafBiomass;
                return(damage);
            }

            //else
            return(damage);
        }
Example #3
0
        //---------------------------------------------------------------------
        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);
        }