本文整理汇总了C#中ICohort.ChangeANPP方法的典型用法代码示例。如果您正苦于以下问题:C# ICohort.ChangeANPP方法的具体用法?C# ICohort.ChangeANPP怎么用?C# ICohort.ChangeANPP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICohort
的用法示例。
在下文中一共展示了ICohort.ChangeANPP方法的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)
{
if (cohort.Data.LastBrowseProp > 0)
{
int t = 0;
t += 1;
}
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);
cohort.ChangeANPP((int)actualANPP);
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);
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;
}