当前位置: 首页>>代码示例>>C#>>正文


C# ICohort.ChangeTotalFoliage方法代码示例

本文整理汇总了C#中ICohort.ChangeTotalFoliage方法的典型用法代码示例。如果您正苦于以下问题:C# ICohort.ChangeTotalFoliage方法的具体用法?C# ICohort.ChangeTotalFoliage怎么用?C# ICohort.ChangeTotalFoliage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICohort的用法示例。


在下文中一共展示了ICohort.ChangeTotalFoliage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ComputeChange

        //---------------------------------------------------------------------
        /// <summary>
        /// Computes the change in a cohort's biomass due to Annual Net Primary
        /// Productivity (ANPP), age-related mortality (M_AGE), and development-
        /// related mortality (M_BIO).
        /// </summary>
        public int ComputeChange(ICohort cohort,
                                 ActiveSite site)
        {
            int siteBiomass = SiteVars.TotalBiomass[site];
            ecoregion = PlugIn.ModelCore.Ecoregion[site];

            // First, calculate age-related mortality.
            // Age-related mortality will include woody and standing leaf biomass (=0 for deciduous trees).
            double mortalityAge = ComputeAgeMortality(cohort);

            double actualANPP = ComputeActualANPP(cohort, site);

            //  Age mortality is discounted from ANPP to prevent the over-
            //  estimation of mortality.  ANPP cannot be negative.
            actualANPP = Math.Max(1, actualANPP - mortalityAge);

            SiteVars.AGNPP[site] += actualANPP;

            // ---------------------------------------------------------
            //  Growth-related mortality
            double mortalityGrowth = ComputeGrowthMortality(cohort, site);

            //  Age-related mortality is discounted from growth-related
            //  mortality to prevent the under-estimation of mortality.  Cannot be negative.
            mortalityGrowth = Math.Max(0, mortalityGrowth - mortalityAge);

            //  Also ensure that growth mortality does not exceed actualANPP.
            mortalityGrowth = Math.Min(mortalityGrowth, actualANPP);

            //  Total mortality for the cohort
            double totalMortality = mortalityAge + mortalityGrowth;

            if (totalMortality > cohort.Biomass)
                throw new ApplicationException("Error: Mortality exceeds cohort biomass");

            PlugIn.CurrentYearSiteMortality += totalMortality;

            // ---------------------------------------------------------
            // Defoliation ranges from 1.0 (total) to none (0.0).
            // Defoliation is calculated by an external function, typically an extension
            // with a defoliation calculator.  The method CohortDefoliation.Compute is a delegate method
            // and lives within the defoliating extension.

            defoliation = Landis.Library.Biomass.CohortDefoliation.Compute(site, cohort.Species, cohort.Biomass, siteBiomass);
            double defoliationLoss = 0.0;
            if (defoliation > 0)
            {
                double standing_nonwood = ComputeFractionANPPleaf(cohort.Species) * actualANPP;
                defoliationLoss = standing_nonwood * defoliation;
                SiteVars.Defoliation[site] += defoliationLoss;
            }
            // ---------------------------------------------------------

            int deltaBiomass = (int)(actualANPP - totalMortality - defoliationLoss);
            double newBiomass = cohort.Biomass + (double)deltaBiomass;

            double totalLitter = UpdateDeadBiomass(cohort, actualANPP, totalMortality, site, newBiomass);

            double leafFraction = ComputeFractionANPPleaf(cohort.Species);

            // Mortality reduces the amount of new foliage
            int annualLeafANPP = (int)((actualANPP - totalMortality) * leafFraction);
            cohort.ChangeCurrentFoliage(annualLeafANPP);
            int newTotalFoliage = (int)(annualLeafANPP + cohort.TotalFoliage * (1 - (1 /   SpeciesData.LeafLongevity[cohort.Species])));
            cohort.ChangeTotalFoliage(newTotalFoliage);

            if (PlugIn.CalibrateMode && PlugIn.ModelCore.CurrentTime > 0)
            {
                PlugIn.ModelCore.UI.WriteLine("Yr={0}. Calculate Delta Biomass...", (PlugIn.ModelCore.CurrentTime + SubYear));
                PlugIn.ModelCore.UI.WriteLine("Yr={0}.    Spp={1}, Age={2}.", (PlugIn.ModelCore.CurrentTime + SubYear), cohort.Species.Name, cohort.Age);
                PlugIn.ModelCore.UI.WriteLine("Yr={0}.    ANPPact={1:0.0}, Mtotal={2:0.0}, litter={3:0.00}.", (PlugIn.ModelCore.CurrentTime + SubYear), actualANPP, totalMortality, totalLitter);
                PlugIn.ModelCore.UI.WriteLine("Yr={0}.    DeltaB={1:0.0}, CohortB={2}, Bsite={3}", (PlugIn.ModelCore.CurrentTime + SubYear), deltaBiomass, cohort.Biomass, (int)siteBiomass);
            }

            return deltaBiomass;
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Succession,代码行数:82,代码来源:CohortBiomass.cs


注:本文中的ICohort.ChangeTotalFoliage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。