Esempio n. 1
0
        public static void GrowCohorts(ActiveSite site,
                                       DateTime Time,
                                       DateTime ToTime,
                                       bool issuccessionTimestep)
        {
            if (PlugIn.Cohorts[site] == null)
            {
                return;
            }

            while (Time.CompareTo(ToTime) < 0)
            {
                if (Time.Month == 1)
                {
                    if (issuccessionTimestep && tstep > 1)//&& ClimateDependentData.Data[PlugIn.Date[site]] != null
                    {
                        PlugIn.Cohorts[site].CombineCohorts(site, tstep, Time.Year);
                    }

                    CanopyBiomass.SubCanopyPARmax[site] = float.MinValue;
                    Hydrology.AnnualTranspiration[site] = 0;

                    //CanopyBiomass.DefineAgeLayers(site);
                    CanopyBiomass.DefineBiomassLayers(site);

                    CanopyBiomass.CanopyLAI[site] = 0;
                    PlugIn.Cohorts[site].IncrementCohortsAge();
                }

                Hydrology.UpdateSiteHydrology(Time, site);

                CanopyBiomass.SimulateCanopy(Time, site);

                if (issuccessionTimestep)
                {
                    EstablishmentProbability.Compute(Time, site);
                }

                ForestFloor.Decomposition(site);

                SiteOutput.UpdateSiteData(Time, site);
                CanopyBiomass.GrossPsn[site] = 0;
                CanopyBiomass.NetPsn[site]   = 0;
                CanopyBiomass.AutotrophicRespiration[site] = 0;
                ForestFloor.HeterotrophicRespiration[site] = 0;
                Hydrology.Transpiration[site] = 0;

                Time = Time.AddMonths(1);
            }
            CanopyBiomass.RemoveDeadCohorts(site);

            PlugIn.Cohorts[site].UpdateMaturePresent();

            SiteOutput.WriteSiteData(site);

            DisturbanceDefoliation.Defoliate(site);
        }
Esempio n. 2
0
        public SiteConditions(ActiveSite site, ICommunity initialCommunity)
        {
            cohorts = new SiteCohorts();

            canopy = new Canopy();
            if (PlugIn.HasSiteOutput[site] == true)
            {
                siteoutput = new SiteOutput(site);
                estoutput  = new EstablishmentOutput(site);
            }

            this.site = site;


            foreach (ISpecies spc in PlugIn.modelCore.Species)
            {
                deadcohortages[spc] = new List <int>();
            }

            uint key = ComputeKey(initialCommunity.MapCode, PlugIn.ModelCore.Ecoregion[site].MapCode);

            SiteConditions s = GetFromKey(key);

            if (s != null)
            {
                return;
            }

            //  If we don't have a sorted list of age cohorts for the initial
            //  community, make the list

            List <Landis.Library.AgeOnlyCohorts.ICohort> sortedAgeCohorts;

            if (!sortedCohorts.TryGetValue(initialCommunity.MapCode, out sortedAgeCohorts))
            {
                sortedAgeCohorts = PlugIn.RankCohortAgesOldToYoung(initialCommunity.Cohorts);
                sortedCohorts[initialCommunity.MapCode] = sortedAgeCohorts;
            }
            hydrology     = new Hydrology(PlugIn.modelCore.Ecoregion[site]);
            forestfloor   = new ForestFloor();
            cohorts       = new SiteCohorts();
            establishment = new EstablishmentProbability(site);


            if (sortedAgeCohorts.Count == 0)
            {
                return;
            }

            //PlugIn.ModelCore.UI.WriteLine("Making Biomass Cohorts "+ site);
            BiomassSpinUp(sortedAgeCohorts, site);

            initialSites[key] = this;
            return;
        }
        public SiteConditions(ActiveSite site, ICommunity initialCommunity)
        {
            cohorts = new SiteCohorts();

            canopy = new Canopy();
            if (PlugIn.HasSiteOutput[site] == true)
            {
                siteoutput = new SiteOutput(site);
                estoutput = new EstablishmentOutput(site);
            }

            this.site = site;

            foreach (ISpecies spc in PlugIn.modelCore.Species)
            {
                deadcohortages[spc] = new List<int>();
            }

            uint key = ComputeKey(initialCommunity.MapCode, PlugIn.ModelCore.Ecoregion[site].MapCode);

            SiteConditions s = GetFromKey(key);

            if (s != null) return;

            //  If we don't have a sorted list of age cohorts for the initial
            //  community, make the list

            List<Landis.Library.AgeOnlyCohorts.ICohort> sortedAgeCohorts;
            if (!sortedCohorts.TryGetValue(initialCommunity.MapCode, out sortedAgeCohorts))
            {
                sortedAgeCohorts = PlugIn.RankCohortAgesOldToYoung(initialCommunity.Cohorts);
                sortedCohorts[initialCommunity.MapCode] = sortedAgeCohorts;
            }
            hydrology = new Hydrology(PlugIn.modelCore.Ecoregion[site]);
            forestfloor = new ForestFloor();
            cohorts = new SiteCohorts();
            establishment = new EstablishmentProbability(site);

            if (sortedAgeCohorts.Count == 0) return;

            //PlugIn.ModelCore.UI.WriteLine("Making Biomass Cohorts "+ site);
            BiomassSpinUp(sortedAgeCohorts, site);

            initialSites[key] = this;
            return;
        }
        //---------------------------------------------------------------------

        /// <summary>
        /// Makes the set of biomass cohorts at a site based on the age cohorts
        /// at the site, using a specified method for computing a cohort's
        /// initial biomass.
        /// </summary>
        /// <param name="ageCohorts">
        /// A sorted list of age cohorts, from oldest to youngest.
        /// </param>
        /// <param name="site">
        /// Site where cohorts are located.
        /// </param>
        /// <param name="initialBiomassMethod">
        /// The method for computing the initial biomass for a new cohort.
        /// </param>

        public static ISiteCohorts MakeBiomassCohorts(List <Landis.Library.AgeOnlyCohorts.ICohort> ageCohorts, ActiveSite site)

        {
            PlugIn.Cohorts[site] = new Library.BiomassCohortsPnET.SiteCohorts();

            Hydrology.Initialize(site);

            Hydrology.AnnualTranspiration[site] = 0;
            CanopyBiomass.CanopyLAI[site]       = 0;

            if (ageCohorts.Count == 0)
            {
                return(PlugIn.Cohorts[site]);
            }

            System.DateTime SpinUpDate = PlugIn.StartDate.AddYears(-(ageCohorts[0].Age) + ((successionTimestep == 1) ? -1 : 0));

            while (SpinUpDate.CompareTo(PlugIn.StartDate) < 0)
            {
                CanopyBiomass.SubCanopyPAR[site] = Static.PAR0[SpinUpDate];

                //  Add those cohorts that were born at the current year
                foreach (Library.AgeOnlyCohorts.ICohort ageonlycohort in ageCohorts)
                {
                    if (PlugIn.StartDate.Year - SpinUpDate.Year == ageonlycohort.Age)
                    {
                        Cohort cohort = new Cohort(ageonlycohort.Species, 1, ConstantParameters.InitialFol, 0, 0, 0, 0, SpinUpDate.Year, true);
                        PlugIn.Cohorts[site].AddNewCohort(cohort);
                        CohortOutput.WriteHeader(site, cohort);
                        SiteOutput.WriteHeader(site);
                    }
                }

                PlugIn.GrowCohorts(site, SpinUpDate, SpinUpDate.AddYears(1), false);

                SpinUpDate = SpinUpDate.AddYears(1);
            }


            return(PlugIn.Cohorts[site]);
        }
 public void Grow(DateTime date, ActiveSite site, Hydrology hydrology, ForestFloor forestfloor, SiteCohorts Cohorts, SiteOutput siteoutput)
 {
     SetCanopyLayers(Cohorts, MaxAge, MaxBiom);
     CalculateRadiationProfile(site, date);
     CalculatePhotosynthesis(date, site, hydrology, forestfloor, siteoutput);
 }
        public void CalculatePhotosynthesis(DateTime date, ActiveSite site, Hydrology hydrology, ForestFloor forestfloor, SiteOutput siteoutput)
        {
            autotrophicrespiration = 0;
            grosspsn = 0;
            netpsn = 0;
            totalnsc = 0;
            totalroot = 0;
            totalfoliage=0;
            totalbiomass = 0;
            maxbiom = 0;
            maxage  = 0;
            for (int canopylayer = canopy.Length - 1; canopylayer >= 0; canopylayer--)
            {
                for (int ix = 0; ix < IMAX; ix++)
                {
                    if (canopy[canopylayer] == null) continue;

                    for (int coh = canopy[canopylayer].Count - 1; coh >= 0; coh--)
                    {
                        CohortBiomass CB = canopy[canopylayer][coh];

                        if (ix == 0)
                        {
                            forestfloor.WoodyDebris.AddMass(CB.WoodSenescence(), KWdLit[CB.Cohort.Species]);
                            forestfloor.Litter.AddMass(CB.FoliageSenescence(date, PlugIn.modelCore.Ecoregion[site], CB.Cohort.Species), ForestFloor.KNwdLitter[PlugIn.modelCore.Ecoregion[site], CB.Cohort.Species]);
                        }

                        float transpiration_lyr = 0;

                        bool cohortisalive = CB.ComputePhotosynthesis(date, PlugIn.modelCore.Ecoregion[site], ix, (int)IMAX, hydrology, ref transpiration_lyr);

                        if (CB.Cohort.Age > MaxAge) maxage  = CB.Cohort.Age;
                        if (MaxBiom < CB.Cohort.Biomass) maxbiom = CB.Cohort.Biomass;

                        autotrophicrespiration += CB.Autotrophicrespiration;
                        netpsn += CB.NetPsn;
                        grosspsn += CB.GrossPsn;

                        if (cohortisalive == false)
                        {
                            deadcohorts.Add(CB.Cohort);
                            forestfloor.WoodyDebris.AddMass(CB.Cohort.Biomass, KWdLit[CB.Cohort.Species]);
                            forestfloor.Litter.AddMass(CB.Cohort.Fol, ForestFloor.KNwdLitter[PlugIn.modelCore.Ecoregion[site], CB.Cohort.Species]);

                        }

                        transpiration += transpiration_lyr;

                        if (transpiration_lyr > hydrology.Water)
                        {
                            IncrementIMAX(site, date);

                            return;
                        }
                        else hydrology.SubtractTranspiration(date, transpiration_lyr);

                        if (ix == 0)
                        {
                            totalbiomass += CB.Cohort.Biomass;
                            totalfoliage += CB.Cohort.Fol;
                            totalnsc += CB.Cohort.NSC;
                            totalroot += CB.Cohort.Root;

                            CB.MaintenanceRespiration(PlugIn.modelCore.Ecoregion[site], date);

                            if (siteoutput != null)
                            {
                                //System.Console.WriteLine("WriteCohortData\t" + site.ToString() + "\t" + date.ToString());
                                CohortOutput.WriteCohortData(date, site, canopy[canopylayer][coh], hydrology.Water);
                            }
                        }
                    }

                }
            }//IMAX
        }
Esempio n. 7
0
        //---------------------------------------------------------------------
        public override void Initialize()
        {
            cohorts        = PlugIn.ModelCore.Landscape.NewSiteVar <ISiteCohorts>();
            BiomassCohorts = new BiomassCohortsSiteVar(cohorts);
            baseCohorts    = new Landis.Library.Biomass.BaseCohortsSiteVar(BiomassCohorts);

            // Counts added cohorts per site and per species
            newcohorts = PlugIn.ModelCore.Landscape.NewSiteVar <Landis.Library.Biomass.Species.AuxParm <int> >();
            foreach (ActiveSite site in PlugIn.ModelCore.Landscape)
            {
                newcohorts[site] = new Landis.Library.Biomass.Species.AuxParm <int>(PlugIn.ModelCore.Species);
            }


            PlugIn.ModelCore.RegisterSiteVar(NewCohorts, "Succession.NewCohorts");
            PlugIn.ModelCore.RegisterSiteVar(cohorts, "Succession.BiomassCohortsPnET");
            PlugIn.ModelCore.RegisterSiteVar(BiomassCohorts, "Succession.BiomassCohorts");

            PlugIn.ModelCore.RegisterSiteVar(baseCohorts, "Succession.AgeCohorts");

            Edu.Wisc.Forest.Flel.Util.Directory.EnsureExists("output");
            CohortOutput.Initialize(parameters);
            SiteOutput.Initialize(parameters);
            CohortBiomass.Initialize(parameters);
            EstablishmentProbability.Initialize(parameters);
            CanopyBiomass.Initialize(parameters);
            Static.Initialize(parameters);
            Hydrology.Initialize(parameters);

            Timestep = parameters.Timestep;
            tstep    = parameters.Timestep;



            // Initialize Reproduction routines:
            // Reproduction.SufficientResources = SufficientLight;
            Reproduction.Establish         = Establish;
            Reproduction.AddNewCohort      = AddNewCohort;
            Reproduction.MaturePresent     = MaturePresent;
            Reproduction.PlantingEstablish = PlantingEstablish;
            base.Initialize(modelCore, parameters.SeedAlgorithm);

            InitialBiomass.Initialize(parameters);

            Cohort.DeathEvent += CohortDied;

            // TODO ARJAN !!
            //Landis.Extension.Succession.Biomass.AgeOnlyDisturbances.Module.Initialize(parameters.AgeOnlyDisturbanceParms);

            ForestFloor.Initialize(parameters);

            SiteOutput.Initialize(parameters);



            StartDate = new System.DateTime(parameters.StartYear, 1, 15);

            year  = StartDate.Year;
            month = StartDate.Month;

            InitializeSites(parameters.InitialCommunities, parameters.InitialCommunitiesMap, modelCore);
        }
        public void CalculatePhotosynthesis(DateTime date, ActiveSite site, Hydrology hydrology, ForestFloor forestfloor, SiteOutput siteoutput)
        {
            autotrophicrespiration = 0;
            grosspsn     = 0;
            netpsn       = 0;
            totalnsc     = 0;
            totalroot    = 0;
            totalfoliage = 0;
            totalbiomass = 0;
            maxbiom      = 0;
            maxage       = 0;
            for (int canopylayer = canopy.Length - 1; canopylayer >= 0; canopylayer--)
            {
                for (int ix = 0; ix < IMAX; ix++)
                {
                    if (canopy[canopylayer] == null)
                    {
                        continue;
                    }

                    for (int coh = canopy[canopylayer].Count - 1; coh >= 0; coh--)
                    {
                        CohortBiomass CB = canopy[canopylayer][coh];

                        if (ix == 0)
                        {
                            forestfloor.WoodyDebris.AddMass(CB.WoodSenescence(), KWdLit[CB.Cohort.Species]);
                            forestfloor.Litter.AddMass(CB.FoliageSenescence(date, PlugIn.modelCore.Ecoregion[site], CB.Cohort.Species), ForestFloor.KNwdLitter[PlugIn.modelCore.Ecoregion[site], CB.Cohort.Species]);
                        }

                        float transpiration_lyr = 0;



                        bool cohortisalive = CB.ComputePhotosynthesis(date, PlugIn.modelCore.Ecoregion[site], ix, (int)IMAX, hydrology, ref transpiration_lyr);

                        if (CB.Cohort.Age > MaxAge)
                        {
                            maxage = CB.Cohort.Age;
                        }
                        if (MaxBiom < CB.Cohort.Biomass)
                        {
                            maxbiom = CB.Cohort.Biomass;
                        }

                        autotrophicrespiration += CB.Autotrophicrespiration;
                        netpsn   += CB.NetPsn;
                        grosspsn += CB.GrossPsn;

                        if (cohortisalive == false)
                        {
                            deadcohorts.Add(CB.Cohort);
                            forestfloor.WoodyDebris.AddMass(CB.Cohort.Biomass, KWdLit[CB.Cohort.Species]);
                            forestfloor.Litter.AddMass(CB.Cohort.Fol, ForestFloor.KNwdLitter[PlugIn.modelCore.Ecoregion[site], CB.Cohort.Species]);
                        }

                        transpiration += transpiration_lyr;

                        if (transpiration_lyr > hydrology.Water)
                        {
                            IncrementIMAX(site, date);

                            return;
                        }
                        else
                        {
                            hydrology.SubtractTranspiration(date, transpiration_lyr);
                        }

                        if (ix == 0)
                        {
                            totalbiomass += CB.Cohort.Biomass;
                            totalfoliage += CB.Cohort.Fol;
                            totalnsc     += CB.Cohort.NSC;
                            totalroot    += CB.Cohort.Root;

                            CB.MaintenanceRespiration(PlugIn.modelCore.Ecoregion[site], date);


                            if (siteoutput != null)
                            {
                                //System.Console.WriteLine("WriteCohortData\t" + site.ToString() + "\t" + date.ToString());
                                CohortOutput.WriteCohortData(date, site, canopy[canopylayer][coh], hydrology.Water);
                            }
                        }
                    }
                }
            }//IMAX
        }
 public void Grow(DateTime date, ActiveSite site, Hydrology hydrology, ForestFloor forestfloor, SiteCohorts Cohorts, SiteOutput siteoutput)
 {
     SetCanopyLayers(Cohorts, MaxAge, MaxBiom);
     CalculateRadiationProfile(site, date);
     CalculatePhotosynthesis(date, site, hydrology, forestfloor, siteoutput);
 }