コード例 #1
0
        //---------------------------------------------------------------------

        public void CohortPartialMortality(object sender, Landis.Library.BiomassCohorts.PartialDeathEventArgs eventArgs)
        {
            ExtensionType disturbanceType = eventArgs.DisturbanceType;
            ActiveSite    site            = eventArgs.Site;
            double        reduction       = eventArgs.Reduction;

            ICohort cohort = (Landis.Library.LeafBiomassCohorts.ICohort)eventArgs.Cohort;

            float fractionPartialMortality = (float)eventArgs.Reduction;

            //PlugIn.ModelCore.UI.WriteLine("Cohort experienced partial mortality: species={0}, age={1}, wood_biomass={2}, fraction_mortality={3:0.0}.", cohort.Species.Name, cohort.Age, cohort.WoodBiomass, fractionPartialMortality);

            AgeOnlyDisturbances.PoolPercentages cohortReductions = AgeOnlyDisturbances.Module.Parameters.CohortReductions[disturbanceType];

            float foliar = cohort.LeafBiomass * fractionPartialMortality;
            float wood   = cohort.WoodBiomass * fractionPartialMortality;

            float foliarInput = AgeOnlyDisturbances.Events.ReduceInput(foliar, cohortReductions.Foliar, site);
            float woodInput   = AgeOnlyDisturbances.Events.ReduceInput(wood, cohortReductions.Wood, site);

            ForestFloor.AddWoodLitter(woodInput, cohort.Species, site);
            ForestFloor.AddFoliageLitter(foliarInput, cohort.Species, site);

            Roots.AddCoarseRootLitter(woodInput, cohort, cohort.Species, site);  // All of cohorts roots are killed.
            Roots.AddFineRootLitter(foliarInput, cohort, cohort.Species, site);

            //PlugIn.ModelCore.UI.WriteLine("EVENT: Cohort Partial Mortality: species={0}, age={1}, disturbance={2}.", cohort.Species.Name, cohort.Age, disturbanceType);
            //PlugIn.ModelCore.UI.WriteLine("       Cohort Reductions:  Foliar={0:0.00}.  Wood={1:0.00}.", cohortReductions.Foliar, cohortReductions.Wood);
            //PlugIn.ModelCore.UI.WriteLine("       InputB/TotalB:  Foliar={0:0.00}/{1:0.00}, Wood={2:0.0}/{3:0.0}.", foliarInput, foliar, woodInput, wood);

            return;
        }
コード例 #2
0
        public static void CohortTotalMortality(object sender,
                                                Landis.Library.BiomassCohorts.DeathEventArgs eventArgs)
        {
            ExtensionType disturbanceType = eventArgs.DisturbanceType;

            PoolPercentages cohortReductions = Module.Parameters.CohortReductions[disturbanceType];

            ICohort    cohort = (Landis.Library.LeafBiomassCohorts.ICohort)eventArgs.Cohort;
            ActiveSite site   = eventArgs.Site;
            float      foliar = cohort.LeafBiomass;
            float      wood   = cohort.WoodBiomass;


            float foliarInput = ReduceInput(foliar, cohortReductions.Foliar, site);
            float woodInput   = ReduceInput(wood, cohortReductions.Wood, site);

            //PlugIn.ModelCore.UI.WriteLine("EVENT: Cohort Died: species={0}, age={1}, disturbance={2}.", cohort.Species.Name, cohort.Age, eventArgs.DisturbanceType);
            //PlugIn.ModelCore.UI.WriteLine("       Cohort Reductions:  Foliar={0:0.00}.  Wood={1:0.00}.", cohortReductions.Foliar, cohortReductions.Wood);
            //PlugIn.ModelCore.UI.WriteLine("       InputB/TotalB:  Foliar={0:0.00}/{1:0.00}, Wood={2:0.0}/{3:0.0}.", foliarInput, foliar, woodInput, wood);

            ForestFloor.AddWoodLitter(woodInput, cohort.Species, site);
            ForestFloor.AddFoliageLitter(foliarInput, cohort.Species, site);

            Roots.AddCoarseRootLitter(wood, cohort, cohort.Species, site);  // All of cohorts roots are killed.
            Roots.AddFineRootLitter(foliar, cohort, cohort.Species, site);
        }
コード例 #3
0
        //---------------------------------------------------------------------

        public void CohortPartialMortality(object sender, Landis.Library.BiomassCohorts.PartialDeathEventArgs eventArgs)
        {
            ExtensionType disturbanceType = eventArgs.DisturbanceType;
            ActiveSite    site            = eventArgs.Site;
            double        reduction       = eventArgs.Reduction;

            ICohort cohort = (Landis.Library.LeafBiomassCohorts.ICohort)eventArgs.Cohort;

            float fractionPartialMortality = (float)eventArgs.Reduction;

            AgeOnlyDisturbances.PoolPercentages cohortReductions = AgeOnlyDisturbances.Module.Parameters.CohortReductions[disturbanceType];

            float foliar = cohort.LeafBiomass * fractionPartialMortality;
            float wood   = cohort.WoodBiomass * fractionPartialMortality;

            float foliarInput = AgeOnlyDisturbances.Events.ReduceInput(foliar, cohortReductions.Foliar, site);
            float woodInput   = AgeOnlyDisturbances.Events.ReduceInput(wood, cohortReductions.Wood, site);

            ForestFloor.AddWoodLitter(woodInput, cohort.Species, site);
            ForestFloor.AddFoliageLitter(foliarInput, cohort.Species, site);

            Roots.AddCoarseRootLitter(woodInput, cohort, cohort.Species, site);  // All of cohorts roots are killed.
            Roots.AddFineRootLitter(foliarInput, cohort, cohort.Species, site);

            return;
        }
コード例 #4
0
        //---------------------------------------------------------------------

        public static void SiteDisturbed(object sender,
                                         Landis.Library.BiomassCohorts.DisturbanceEventArgs eventArgs)
        {
            ExtensionType disturbanceType = eventArgs.DisturbanceType;

            if (disturbanceType.ToString() == "disturbance:fire")
            {
                return;
            }

            PoolPercentages poolReductions = Module.Parameters.PoolReductions[disturbanceType];

            ActiveSite site = eventArgs.Site;

            SiteVars.SurfaceDeadWood[site].ReduceMass(poolReductions.Wood);
            SiteVars.SurfaceStructural[site].ReduceMass(poolReductions.Foliar);
            SiteVars.SurfaceMetabolic[site].ReduceMass(poolReductions.Foliar);
        }
コード例 #5
0
        //---------------------------------------------------------------------

        private void ParseTable(IPercentageTable table,
                                string tableName,
                                string nextTableName)
        {
            ReadName(tableName);

            PlugIn.ModelCore.UI.WriteLine("      Reading {0}.", tableName);

            InputVar <string>     disturbance      = new InputVar <string>("Disturbance");
            InputVar <Percentage> woodPercentage   = new InputVar <Percentage>("Woody");
            InputVar <Percentage> foliarPercentage = new InputVar <Percentage>("Non-Woody");
            string lastColumn = "the " + foliarPercentage.Name + " column";

            const string defaultName  = "(default)";
            bool         defaultFound = false;

            lineNums.Clear();
            while (!AtEndOfInput && CurrentName != nextTableName)
            {
                StringReader currentLine = new StringReader(CurrentLine);

                ReadValue(disturbance, currentLine);
                int lineNum;
                if (lineNums.TryGetValue(disturbance.Value.Actual, out lineNum))
                {
                    throw new InputValueException(disturbance.Value.Actual,
                                                  "The value \"{0}\" was previously used on line {1}",
                                                  disturbance.Value.Actual,
                                                  lineNum);
                }
                lineNums[disturbance.Value.String] = LineNumber;

                PoolPercentages percentages;
                if (disturbance.Value.Actual == defaultName)
                {
                    defaultFound = true;
                    percentages  = table.Default;
                }
                else
                {
                    ExtensionType disturbanceType = new ExtensionType("disturbance:" + disturbance.Value.Actual);

                    //if(disturbance.Value.Actual == "Fire" || disturbance.Value.Actual == "fire")
                    //    throw new InputValueException(disturbance.Value.Actual,
                    //                              "\"{0}\" is not an allowable disturbance type, line {1}",
                    //                              disturbance.Value.Actual,
                    //                              lineNum);

                    //percentages = table[disturbanceType];
                    table[disturbanceType] = new PoolPercentages();
                    percentages            = table[disturbanceType];
                    PlugIn.ModelCore.UI.WriteLine("         Adding {0}...", disturbanceType);
                }

                ReadValue(woodPercentage, currentLine);
                percentages.Wood = woodPercentage.Value;

                ReadValue(foliarPercentage, currentLine);
                percentages.Foliar = foliarPercentage.Value;

                CheckNoDataAfter(lastColumn, currentLine);
                GetNextLine();
            }

            if (!defaultFound)
            {
                throw NewParseException("Missing the \"{0}\" row in the percentage table",
                                        defaultName);
            }
        }
コード例 #6
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance.
        /// </summary>

/*        public PercentageTable(IDictionary<ExtensionType, PoolPercentages> percentages,
 *                             PoolPercentages                          defaultPercentages)
 *      {
 *          this.percentages = percentages;
 *          this.defaultPercentages = defaultPercentages;
 *      }*/
        //---------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        public PercentageTable()
        {
            this.percentages        = new Dictionary <ExtensionType, PoolPercentages>();
            this.defaultPercentages = new PoolPercentages();
        }