Beispiel #1
0
        //---------------------------------------------------------------------

        /// <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 float[] ComputeChange(ICohort cohort, ActiveSite site)
        {
            double defoliatedLeafBiomass;

            ecoregion = PlugIn.ModelCore.Ecoregion[site];

            // First call to the Calibrate Log:
            if (PlugIn.ModelCore.CurrentTime > 0 && OtherData.CalibrateMode)
            {
                Outputs.CalibrateLog.Write("{0},{1},{2},{3},{4},{5:0.0},{6:0.0},", PlugIn.ModelCore.CurrentTime, Century.Month + 1, ecoregion.Index, cohort.Species.Name, cohort.Age, cohort.WoodBiomass, cohort.LeafBiomass);
            }


            double siteBiomass = Century.ComputeLivingBiomass(SiteVars.Cohorts[site]);

            if (siteBiomass < 0)
            {
                throw new ApplicationException("Error: Site biomass < 0");
            }

            // ****** Mortality *******
            // Age-related mortality includes woody and standing leaf biomass.
            double[] mortalityAge = ComputeAgeMortality(cohort, site);

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

            double[] totalMortality = new double[2] {
                Math.Min(cohort.WoodBiomass, mortalityAge[0] + mortalityGrowth[0]), Math.Min(cohort.LeafBiomass, mortalityAge[1] + mortalityGrowth[1])
            };

            // ****** Growth *******
            double[] actualANPP = ComputeActualANPP(cohort, site, siteBiomass, mortalityAge);

            double scorch = 0.0;

            defoliatedLeafBiomass = 0.0;

            if (Century.Month == 6)  //July = 6
            {
                if (SiteVars.FireSeverity != null && SiteVars.FireSeverity[site] > 0)
                {
                    scorch = FireEffects.CrownScorching(cohort, SiteVars.FireSeverity[site]);
                }

                if (scorch > 0.0)  // NEED TO DOUBLE CHECK WHAT CROWN SCORCHING RETURNS
                {
                    totalMortality[1] = Math.Min(cohort.LeafBiomass, scorch + totalMortality[1]);
                }

                // Defoliation (index) ranges from 1.0 (total) to none (0.0).
                if (PlugIn.ModelCore.CurrentTime > 0) //Skip this during initialization
                {
                    int cohortBiomass = (int)(cohort.LeafBiomass + cohort.WoodBiomass);
                    defoliation = Landis.Library.Biomass.CohortDefoliation.Compute(site, cohort.Species, cohortBiomass, (int)siteBiomass);
                }

                if (defoliation > 1.0)
                {
                    defoliation = 1.0;
                }

                if (defoliation > 0.0)
                {
                    defoliatedLeafBiomass = (cohort.LeafBiomass) * defoliation;
                    if (totalMortality[1] + defoliatedLeafBiomass - cohort.LeafBiomass > 0.001)
                    {
                        defoliatedLeafBiomass = cohort.LeafBiomass - totalMortality[1];
                    }

                    ForestFloor.AddFrassLitter(defoliatedLeafBiomass, cohort.Species, site);
                }
            }
            else
            {
                defoliation           = 0.0;
                defoliatedLeafBiomass = 0.0;
            }

            // RMS 03/2016: Additional mortality as reaching capacity limit:  SAVE FOR NEXT RELEASE
            //double maxBiomass = SpeciesData.B_MAX_Spp[cohort.Species][ecoregion];
            //double limitCapacity = Math.Min(1.0, Math.Exp(siteBiomass / maxBiomass * 5.0) / Math.Exp(5.0));  // 1.0 = total limit; 0.0 = No limit
            //totalMortality[0] += (actualANPP[0] * limitCapacity); // totalMortality not to exceed ANPP allocation


            if (totalMortality[0] <= 0.0 || cohort.WoodBiomass <= 0.0)
            {
                totalMortality[0] = 0.0;
            }

            if (totalMortality[1] <= 0.0 || cohort.LeafBiomass <= 0.0)
            {
                totalMortality[1] = 0.0;
            }


            if ((totalMortality[0]) > cohort.WoodBiomass)
            {
                PlugIn.ModelCore.UI.WriteLine("Warning: WOOD Mortality exceeds cohort wood biomass. M={0:0.0}, B={1:0.0}", (totalMortality[0]), cohort.WoodBiomass);
                PlugIn.ModelCore.UI.WriteLine("Warning: If M>B, then list mortality. Mage={0:0.0}, Mgrow={1:0.0},", mortalityAge[0], mortalityGrowth[0]);
                throw new ApplicationException("Error: WOOD Mortality exceeds cohort biomass");
            }
            if ((totalMortality[1] + defoliatedLeafBiomass - cohort.LeafBiomass) > 0.01)
            {
                PlugIn.ModelCore.UI.WriteLine("Warning: LEAF Mortality exceeds cohort biomass. Mortality={0:0.000}, Leafbiomass={1:0.000}", (totalMortality[1] + defoliatedLeafBiomass), cohort.LeafBiomass);
                PlugIn.ModelCore.UI.WriteLine("Warning: If M>B, then list mortality. Mage={0:0.00}, Mgrow={1:0.00}, Mdefo={2:0.000},", mortalityAge[1], mortalityGrowth[1], defoliatedLeafBiomass);
                throw new ApplicationException("Error: LEAF Mortality exceeds cohort biomass");
            }
            float deltaWood = (float)(actualANPP[0] - totalMortality[0]);
            float deltaLeaf = (float)(actualANPP[1] - totalMortality[1] - defoliatedLeafBiomass);

            float[] deltas = new float[2] {
                deltaWood, deltaLeaf
            };

            UpdateDeadBiomass(cohort, site, totalMortality);

            CalculateNPPcarbon(site, cohort, actualANPP);

            AvailableN.AdjustAvailableN(cohort, site, actualANPP);

            if (OtherData.CalibrateMode && PlugIn.ModelCore.CurrentTime > 0)
            {
                Outputs.CalibrateLog.WriteLine("{0:0.00},{1:0.00},{2:0.00},{3:0.00},", deltaWood, deltaLeaf, totalMortality[0], totalMortality[1]);
            }

            return(deltas);
        }
        /// <summary>
        /// Grows all cohorts at a site for a specified number of years.
        /// Litter is decomposed following the Century model.
        /// </summary>
        public static ISiteCohorts Run(ActiveSite site,
                                       int years,
                                       bool isSuccessionTimeStep)
        {
            ISiteCohorts siteCohorts = SiteVars.Cohorts[site];
            IEcoregion   ecoregion   = PlugIn.ModelCore.Ecoregion[site];

            for (int y = 0; y < years; ++y)
            {
                Year = y + 1;

                if (Climate.Future_MonthlyData.ContainsKey(PlugIn.FutureClimateBaseYear + y + PlugIn.ModelCore.CurrentTime - years))
                {
                    ClimateRegionData.AnnualWeather[ecoregion] = Climate.Future_MonthlyData[PlugIn.FutureClimateBaseYear + y - years + PlugIn.ModelCore.CurrentTime][ecoregion.Index];
                }

                SiteVars.ResetAnnualValues(site);

                if (y == 0 && SiteVars.FireSeverity != null && SiteVars.FireSeverity[site] > 0)
                {
                    FireEffects.ReduceLayers(SiteVars.FireSeverity[site], site);
                }

                // Next, Grow and Decompose each month
                int[] months = new int[12] {
                    6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5
                };

                if (OtherData.CalibrateMode)
                {
                    //months = new int[12]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; This output will not match normal mode due to differences in initialization
                    months = new int[12] {
                        6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5
                    }
                }
                ;

                PlugIn.AnnualWaterBalance = 0;

                for (MonthCnt = 0; MonthCnt < 12; MonthCnt++)
                {
                    // Calculate mineral N fractions based on coarse root biomass.  Only need to do once per year.
                    if (MonthCnt == 0)
                    {
                        AvailableN.CalculateMineralNfraction(site);
                    }

                    Month = months[MonthCnt];

                    SiteVars.MonthlyAGNPPcarbon[site][Month] = 0.0;
                    SiteVars.MonthlyBGNPPcarbon[site][Month] = 0.0;
                    SiteVars.MonthlyNEE[site][Month]         = 0.0;
                    SiteVars.MonthlyResp[site][Month]        = 0.0;
                    SiteVars.MonthlyStreamN[site][Month]     = 0.0;
                    SiteVars.SourceSink[site].Carbon         = 0.0;
                    SiteVars.TotalWoodBiomass[site]          = Century.ComputeWoodBiomass(site);

                    double ppt = ClimateRegionData.AnnualWeather[ecoregion].MonthlyPrecip[Century.Month];

                    double monthlyNdeposition;
                    if (PlugIn.AtmosNintercept != -1 && PlugIn.AtmosNslope != -1)
                    {
                        monthlyNdeposition = PlugIn.AtmosNintercept + (PlugIn.AtmosNslope * ppt);
                    }
                    else
                    {
                        monthlyNdeposition = ClimateRegionData.AnnualWeather[ecoregion].MonthlyNDeposition[Century.Month];
                    }

                    ClimateRegionData.MonthlyNDeposition[ecoregion][Month] = monthlyNdeposition;
                    ClimateRegionData.AnnualNDeposition[ecoregion]        += monthlyNdeposition;
                    SiteVars.MineralN[site] += monthlyNdeposition;

                    double liveBiomass = (double)ComputeLivingBiomass(siteCohorts);
                    double baseFlow, stormFlow, AET;
                    SoilWater.Run(y, Month, liveBiomass, site, out baseFlow, out stormFlow, out AET);

                    PlugIn.AnnualWaterBalance += ppt - AET;

                    // Calculate N allocation for each cohort
                    AvailableN.SetMineralNallocation(site);

                    if (MonthCnt == 11)
                    {
                        siteCohorts.Grow(site, (y == years && isSuccessionTimeStep), true);
                    }
                    else
                    {
                        siteCohorts.Grow(site, (y == years && isSuccessionTimeStep), false);
                    }

                    WoodLayer.Decompose(site);
                    LitterLayer.Decompose(site);
                    SoilLayer.Decompose(site);

                    // Volatilization loss as a function of the mineral N which remains after uptake by plants.
                    // ML added a correction factor for wetlands since their denitrification rate is double that of wetlands
                    // based on a review paper by Seitziner 2006.

                    double volatilize = (SiteVars.MineralN[site] * PlugIn.DenitrificationRate);

                    SiteVars.MineralN[site]            -= volatilize;
                    SiteVars.SourceSink[site].Nitrogen += volatilize;
                    SiteVars.Nvol[site] += volatilize;

                    SoilWater.Leach(site, baseFlow, stormFlow);

                    SiteVars.MonthlyNEE[site][Month] -= SiteVars.MonthlyAGNPPcarbon[site][Month];
                    SiteVars.MonthlyNEE[site][Month] -= SiteVars.MonthlyBGNPPcarbon[site][Month];
                    SiteVars.MonthlyNEE[site][Month] += SiteVars.SourceSink[site].Carbon;
                    SiteVars.FineFuels[site]          = (SiteVars.SurfaceStructural[site].Carbon + SiteVars.SurfaceMetabolic[site].Carbon) * 2.0;
                }
            }

            ComputeTotalCohortCN(site, siteCohorts);

            return(siteCohorts);
        }
Beispiel #3
0
        //---------------------------------------------------------------------

        public override void Initialize()
        {
            PlugIn.ModelCore.UI.WriteLine("Initializing {0} ...", ExtensionName);
            Timestep            = parameters.Timestep;
            SuccessionTimeStep  = Timestep;
            sufficientLight     = parameters.LightClassProbabilities;
            ProbEstablishAdjust = parameters.ProbEstablishAdjustment;
            MetadataHandler.InitializeMetadata(Timestep, modelCore, SoilCarbonMapNames, SoilNitrogenMapNames, ANPPMapNames, ANEEMapNames, TotalCMapNames); //,LAIMapNames, ShadeClassMapNames);
            //CohortBiomass.SpinupMortalityFraction = parameters.SpinupMortalityFraction;

            //Initialize climate.
            Climate.Initialize(parameters.ClimateConfigFile, false, modelCore);
            FutureClimateBaseYear = Climate.Future_MonthlyData.Keys.Min();

            ClimateRegionData.Initialize(parameters);
            SpeciesData.Initialize(parameters);
            Util.ReadSoilDepthMap(parameters.SoilDepthMapName);
            Util.ReadSoilDrainMap(parameters.SoilDrainMapName);
            Util.ReadSoilBaseFlowMap(parameters.SoilBaseFlowMapName);
            Util.ReadSoilStormFlowMap(parameters.SoilStormFlowMapName);
            Util.ReadFieldCapacityMap(parameters.SoilFieldCapacityMapName);
            Util.ReadWiltingPointMap(parameters.SoilWiltingPointMapName);
            Util.ReadPercentSandMap(parameters.SoilPercentSandMapName);
            Util.ReadPercentClayMap(parameters.SoilPercentClayMapName);
            Util.ReadSoilCNMaps(parameters.InitialSOM1CSurfaceMapName,
                                parameters.InitialSOM1NSurfaceMapName,
                                parameters.InitialSOM1CSoilMapName,
                                parameters.InitialSOM1NSoilMapName,
                                parameters.InitialSOM2CMapName,
                                parameters.InitialSOM2NMapName,
                                parameters.InitialSOM3CMapName,
                                parameters.InitialSOM3NMapName);
            Util.ReadDeadWoodMaps(parameters.InitialDeadSurfaceMapName, parameters.InitialDeadSoilMapName);

            AtmosNslope         = parameters.AtmosNslope;
            AtmosNintercept     = parameters.AtmosNintercept;
            Latitude            = parameters.Latitude;
            DenitrificationRate = parameters.Denitrif;
            DecayRateSurf       = parameters.DecayRateSurf;
            DecayRateSOM1       = parameters.DecayRateSOM1;
            DecayRateSOM2       = parameters.DecayRateSOM2;
            DecayRateSOM3       = parameters.DecayRateSOM3;

            ShadeLAI = parameters.MaximumShadeLAI; //.MinRelativeBiomass;
            OtherData.Initialize(parameters);
            FunctionalType.Initialize(parameters);
            FireEffects.Initialize(parameters);

            //  Cohorts must be created before the base class is initialized
            //  because the base class' reproduction module uses the core's
            //  SuccessionCohorts property in its Initialization method.
            Library.LeafBiomassCohorts.Cohorts.Initialize(Timestep, new CohortBiomass());

            // Initialize Reproduction routines:
            Reproduction.SufficientResources = SufficientLight;
            Reproduction.Establish           = Establish;
            Reproduction.AddNewCohort        = AddNewCohort;
            Reproduction.MaturePresent       = MaturePresent;
            base.Initialize(modelCore, parameters.SeedAlgorithm);
            Landis.Library.LeafBiomassCohorts.Cohort.PartialDeathEvent += CohortPartialMortality;
            Landis.Library.BiomassCohorts.Cohort.DeathEvent            += CohortDied;
            AgeOnlyDisturbances.Module.Initialize(parameters.AgeOnlyDisturbanceParms);

            //InitialBiomass.Initialize(Timestep);
            InitializeSites(parameters.InitialCommunities, parameters.InitialCommunitiesMap, modelCore);

            if (parameters.CalibrateMode)
            {
                Outputs.CreateCalibrateLogFile();
            }
            Establishment.InitializeLogFile();

            B_MAX = 0;
            foreach (ISpecies species in ModelCore.Species)
            {
                if (SpeciesData.Max_Biomass[species] > B_MAX)
                {
                    B_MAX = SpeciesData.Max_Biomass[species];
                }
            }

            foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
            {
                Century.ComputeTotalCohortCN(site, SiteVars.Cohorts[site]);
            }

            Outputs.WritePrimaryLogFile(0);
            Outputs.WriteShortPrimaryLogFile(0);
        }