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

        int IDisturbance.ReduceOrKillMarkedCohort(ICohort cohort)
        {
            int currentDefol = 0;

            if (PlugIn.Parameters.SBWHost[cohort.Species] && (cohort.Age >= PlugIn.Parameters.MinSusceptibleAge))
            {
                // assign defoliation to cohorts skewed by species and age (12a)
                // These species names are hard-wired
                // FIXME
                double sppConvert = 0.0;
                if (cohort.Species.Name == "abiebals")
                {
                    sppConvert = 1.0;
                }
                else if (cohort.Species.Name == "piceglau")
                {
                    sppConvert = 0.75;
                }
                else if (cohort.Species.Name == "picemari")
                {
                    sppConvert = 0.375;
                }
                double cohortDefol = SiteVars.PctDefoliation[currentSite] * sppConvert * cohort.Age / SiteVars.MaxHostAge[currentSite];
                if (cohortDefol > 100)
                {
                    cohortDefol = 100;
                }
                cohort.UpdateDefoliationHistory(cohortDefol / 100.0);
                currentDefol = (int)Math.Round((cohort.CurrentFoliage * (cohortDefol / 100)));      // Assumes all defoliation comes out of current year foliage, convert percentage to proportion

                SiteVars.TotalDefoliation[currentSite] += currentDefol;
            }


            if (currentDefol > cohort.Biomass || currentDefol < 0)
            {
                PlugIn.ModelCore.UI.WriteLine("Cohort Total Mortality={0}. Cohort Biomass={1}. Site R/C={2}/{3}.", currentDefol, cohort.Biomass, currentSite.Location.Row, currentSite.Location.Column);
                throw new System.ApplicationException("Error: Total Mortality is not between 0 and cohort biomass");
            }

            double cohortPctMortality    = Impacts.CohortMortality(cohort);
            int    cohortMortality       = (int)(cohortPctMortality * (cohort.Biomass - currentDefol));
            int    totalBiomassReduction = currentDefol + cohortMortality;

            SiteVars.BiomassRemoved[currentSite] += totalBiomassReduction;

            return(totalBiomassReduction);
        }
Example #2
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Initializes the plug-in with a data file.
        /// </summary>
        /// <param name="dataFile">
        /// Path to the file with initialization data.
        /// </param>
        /// <param name="startTime">
        /// Initial timestep (year): the timestep that will be passed to the
        /// first call to the component's Run method.
        /// </param>
        public override void Initialize()
        {
            Timestep = parameters.Timestep;

            SiteVars.Initialize(parameters);
            Impacts.Initialize();
            Outputs.Initialize();
            Dispersal.Initialize();

            /*
             * //Debug distribution
             * StreamWriter randLog = Landis.Data.CreateTextFile("G:/Budworm_model/TEST/E_TEST/rand.csv");
             * randLog.AutoFlush = true;
             * randLog.WriteLine("Rand1, Rand2");
             * //Troschuetz.Random.NormalDistribution r1 = new Troschuetz.Random.NormalDistribution();
             * for (int i = 0; i < 10000; i++)
             * {
             *
             * r1.Mu = 1;
             * r1.Sigma = 0.01;
             * double rand = r1.NextDouble();
             * rand = r1.NextDouble();
             *
             * r1.Mu = 2;
             * r1.Sigma = 0.01;
             * double rand2 = r1.NextDouble();
             * rand2 = r1.NextDouble();
             *
             *  PlugIn.ModelCore.NormalDistribution.Mu = 1;
             *  PlugIn.ModelCore.NormalDistribution.Sigma = 0.01;
             *  double rand = PlugIn.ModelCore.NormalDistribution.NextDouble();
             *  //rand = PlugIn.ModelCore.NormalDistribution.NextDouble();
             *
             *  PlugIn.ModelCore.NormalDistribution.Mu = 2;
             *  PlugIn.ModelCore.NormalDistribution.Sigma = 0.01;
             *  double rand2 = PlugIn.ModelCore.NormalDistribution.NextDouble();
             *  //rand2 = PlugIn.ModelCore.NormalDistribution.NextDouble();
             *
             *  randLog.Write("{0:0.000}, {1:0.000}",
             *           rand,rand2);
             *  randLog.WriteLine("");
             * }
             */
        }
Example #3
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Calculate cohort mortality (proportion)
        /// </summary>
        /// <param name="cohort"></param>
        /// <returns></returns>
        public static double CohortMortality(Landis.Library.BiomassCohorts.ICohort cohort)
        {
            // Calculate cumulative defoliation (13)
            // Cumulative Annual Weighted Defoliation (Hennigar)
            double annWtDefol0   = cohort.DefoliationHistory[0] * 0.28;
            double annWtDefol1   = cohort.DefoliationHistory[1] * 0.26;
            double annWtDefol2   = cohort.DefoliationHistory[2] * 0.22;
            double annWtDefol3   = cohort.DefoliationHistory[3] * 0.13;
            double annWtDefol4   = cohort.DefoliationHistory[4] * 0.08;
            double annWtDefol5   = cohort.DefoliationHistory[5] * 0.03;
            double cumAnnWtDefol = annWtDefol0 + annWtDefol1 + annWtDefol2 + annWtDefol3 + annWtDefol4 + annWtDefol5;

            // Allocate impacts to cohorts (10a)
            // Mortality
            // Hennigar method
            double       percentMortality    = 0;
            const double CD_ScaleFactor      = 0.952;
            double       periodicDefoliation = cumAnnWtDefol * CD_ScaleFactor;

            percentMortality = Impacts.GetMortalityRate_AGE(cohort.Species, periodicDefoliation, cohort.Age);

            return(percentMortality);
        }