/// <summary> /// Summarize cohort C&N for output. /// </summary> private static void CalculateCohortCN(ActiveSite site, ICohort cohort) { ISpecies species = cohort.Species; double leafC = cohort.LeafBiomass * 0.47; double woodC = cohort.WoodBiomass * 0.47; double fRootC = Roots.CalculateFineRoot(cohort, leafC); double cRootC = Roots.CalculateCoarseRoot(cohort, woodC); double totalC = leafC + woodC + fRootC + cRootC; double leafN = leafC / (double)SpeciesData.LeafCN[species]; double woodN = woodC / (double)SpeciesData.WoodCN[species]; double cRootN = cRootC / (double)SpeciesData.CoarseRootCN[species]; double fRootN = fRootC / (double)SpeciesData.FineRootCN[species]; //double totalN = woodN + cRootN + leafN + fRootN; //PlugIn.ModelCore.UI.WriteLine("month={0}, species={1}, leafB={2:0.0}, leafC={3:0.00}, leafN={4:0.0}, woodB={5:0.0}, woodC={6:0.000}, woodN={7:0.0}", Month, cohort.Species.Name, cohort.LeafBiomass, leafC, leafN, cohort.WoodBiomass, woodC, woodN); SiteVars.CohortLeafC[site] += leafC; SiteVars.CohortFRootC[site] += fRootC; SiteVars.CohortLeafN[site] += leafN; SiteVars.CohortFRootN[site] += fRootN; SiteVars.CohortWoodC[site] += woodC; SiteVars.CohortCRootC[site] += cRootC; SiteVars.CohortWoodN[site] += woodN; SiteVars.CohortCRootN[site] += cRootN; return; }
//--------------------------------------------------------------------- /// <summary> /// Calculates cohort N demand depending upon how much N would be removed through growth (ANPP) of leaves, wood, coarse roots and fine roots. /// Demand is then used to determine the amount of N that a cohort "wants". /// </summary> public static double CalculateCohortNDemand(ISpecies species, ActiveSite site, ICohort cohort, double[] ANPP) { if (ANPP[1] <= 0.0) { return(0.0); } //return 0.01; if (SpeciesData.NFixer[species]) // We fix our own N! { return(0.0); } double ANPPwood = 0.0; double ANPPleaf = 0.0; double ANPPcoarseRoot = 0.0; double ANPPfineRoot = 0.0; double woodN = 0.0; double coarseRootN = 0.0; double leafN = 0.0; double fineRootN = 0.0; if (ANPP[0] > 0.0) // Wood { ANPPwood = ANPP[0]; ANPPcoarseRoot = Roots.CalculateCoarseRoot(cohort, ANPPwood); woodN = ANPPwood * 0.47 / SpeciesData.WoodCN[species]; coarseRootN = ANPPcoarseRoot * 0.47 / SpeciesData.CoarseRootCN[species]; } if (ANPP[1] > 0.0) // Leaf { ANPPleaf = ANPP[1]; ANPPfineRoot = Roots.CalculateFineRoot(cohort, ANPPleaf); leafN = ANPPleaf * 0.47 / SpeciesData.LeafCN[species]; fineRootN = ANPPfineRoot * 0.47 / SpeciesData.FineRootCN[species]; } double totalANPP_C = (ANPPleaf + ANPPwood + ANPPcoarseRoot + ANPPfineRoot) * 0.47; double Ndemand = leafN + woodN + coarseRootN + fineRootN; if (Ndemand < 0.0) { PlugIn.ModelCore.UI.WriteLine(" ERROR: TotalANPP-C={0:0.00} Nreduction={1:0.00}.", totalANPP_C, Ndemand); throw new ApplicationException("Error: N Reduction is < 0. See AvailableN.cs"); } return(Ndemand); }
//--------------------------------------------------------------------- /// <summary> /// Summarize NPP /// </summary> private static void CalculateNPPcarbon(ActiveSite site, ICohort cohort, double[] AGNPP) { double NPPwood = AGNPP[0] * 0.47; double NPPleaf = AGNPP[1] * 0.47; double NPPcoarseRoot = Roots.CalculateCoarseRoot(cohort, NPPwood); double NPPfineRoot = Roots.CalculateFineRoot(cohort, NPPleaf); if (Double.IsNaN(NPPwood) || Double.IsNaN(NPPleaf) || Double.IsNaN(NPPcoarseRoot) || Double.IsNaN(NPPfineRoot)) { PlugIn.ModelCore.UI.WriteLine(" EITHER WOOD or LEAF NPP or COARSE ROOT or FINE ROOT = NaN! Will set to zero."); PlugIn.ModelCore.UI.WriteLine(" Yr={0},Mo={1}. WoodNPP={0}, LeafNPP={1}, CRootNPP={2}, FRootNPP={3}.", NPPwood, NPPleaf, NPPcoarseRoot, NPPfineRoot); if (Double.IsNaN(NPPleaf)) { NPPleaf = 0.0; } if (Double.IsNaN(NPPwood)) { NPPwood = 0.0; } if (Double.IsNaN(NPPcoarseRoot)) { NPPcoarseRoot = 0.0; } if (Double.IsNaN(NPPfineRoot)) { NPPfineRoot = 0.0; } } SiteVars.AGNPPcarbon[site] += NPPwood + NPPleaf; SiteVars.BGNPPcarbon[site] += NPPcoarseRoot + NPPfineRoot; SiteVars.MonthlyAGNPPcarbon[site][Century.Month] += NPPwood + NPPleaf; SiteVars.MonthlyBGNPPcarbon[site][Century.Month] += NPPcoarseRoot + NPPfineRoot; if (PlugIn.ModelCore.CurrentTime > 0 && OtherData.CalibrateMode) { Outputs.CalibrateLog.Write("{0:0.00},{1:0.00},", NPPwood, NPPleaf); } }
/// <summary> /// Summarize cohort C&N for output. /// </summary> private static void CalculateCohortCN(ActiveSite site, ICohort cohort) { ISpecies species = cohort.Species; double leafC = cohort.LeafBiomass * 0.47; double woodC = cohort.WoodBiomass * 0.47; double fRootC = Roots.CalculateFineRoot(cohort, leafC); double cRootC = Roots.CalculateCoarseRoot(cohort, woodC); double leafN = leafC / SpeciesData.LeafCN[species]; double woodN = woodC / SpeciesData.WoodCN[species]; double cRootN = cRootC / SpeciesData.CoarseRootCN[species]; double fRootN = fRootC / SpeciesData.FineRootCN[species]; SiteVars.CohortLeafC[site] += leafC; SiteVars.CohortFRootC[site] += fRootC; SiteVars.CohortLeafN[site] += leafN; SiteVars.CohortFRootN[site] += fRootN; SiteVars.CohortWoodC[site] += woodC; SiteVars.CohortCRootC[site] += cRootC; SiteVars.CohortWoodN[site] += woodN; SiteVars.CohortCRootN[site] += cRootN; }