示例#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);
        }
示例#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;
        }
示例#3
0
        public SiteConditions GetFromKey(uint key)
        {
            SiteConditions s = null;

            if (initialSites.TryGetValue(key, out s) && siteoutput == null)
            {
                hydrology     = s.hydrology;
                establishment = s.Establishment;

                cohorts = new SiteCohorts();
                foreach (ISpeciesCohorts speciesCohorts in s.cohorts)
                {
                    foreach (Cohort cohort in speciesCohorts)
                    {
                        Cohort newcohort = new Cohort(cohort);
                        cohorts.AddNewCohort(newcohort, PlugIn.TStep);
                    }
                }
                forestfloor  = s.forestfloor;
                canopylaimax = s.CanopyLAImax;
            }
            return(s);
        }
 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
        }
        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 GetFromKey(uint key)
        {
            SiteConditions s=null;
            if (initialSites.TryGetValue(key, out s) && siteoutput == null)
            {
                hydrology = s.hydrology;
                establishment = s.Establishment;

                cohorts = new SiteCohorts();
                foreach (ISpeciesCohorts speciesCohorts in s.cohorts)
                {
                    foreach (Cohort cohort in speciesCohorts)
                    {
                        Cohort newcohort = new Cohort(cohort);
                        cohorts.AddNewCohort(newcohort, PlugIn.TStep);
                    }
                }
                forestfloor = s.forestfloor;
                canopylaimax = s.CanopyLAImax;
            }
            return s;
        }
示例#8
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 override void Initialize()
        {
            PlugIn.ModelCore.UI.WriteLine("Initializing " + ExtensionName + " version " + typeof(PlugIn).Assembly.GetName().Version);

            /*Testing
             * Landis.Library.BiomassCohorts.Cohort C;
             * Cohort D;
             *
             * C = (Landis.Library.BiomassCohorts.Cohort)D;
             */


            hassiteoutput  = parameters.HasSiteOutput;
            siteconditions = PlugIn.ModelCore.Landscape.NewSiteVar <SiteConditions>();
            Edu.Wisc.Forest.Flel.Util.Directory.EnsureExists("output");

            //CohortOutput.Initialize(parameters);
            Hydrology.Initialize(parameters);
            StaticVariables.InitializeStatic(parameters);
            ForestFloor.Initialize(parameters);
            SiteConditions.Initialize(parameters);
            CohortBiomass.Initialize(parameters);

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

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

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

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

            InitializeSites(parameters.InitialCommunities, parameters.InitialCommunitiesMap, modelCore);

            EstablishmentProbability.Initialize(parameters);

            ISiteVar <ISiteCohorts> cohorts = PlugIn.ModelCore.Landscape.NewSiteVar <ISiteCohorts>();

            foreach (ActiveSite site in PlugIn.modelCore.Landscape)
            {
                cohorts[site] = siteconditions[site].Cohorts;
            }

            BiomassCohorts = new BiomassCohortsSiteVar(cohorts);
            baseCohorts    = new Landis.Library.Biomass.BaseCohortsSiteVar(BiomassCohorts);

            PlugIn.ModelCore.RegisterSiteVar(BiomassCohorts, "Succession.BiomassCohorts");

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


            ISiteVar <Pool> WoodyDebris = PlugIn.ModelCore.Landscape.NewSiteVar <Pool>();

            foreach (ActiveSite site in PlugIn.modelCore.Landscape)
            {
                WoodyDebris[site] = siteconditions[site].WoodyDebris;
            }
            PlugIn.ModelCore.RegisterSiteVar(WoodyDebris, "Succession.WoodyDebris");

            ISiteVar <Pool> Litter = PlugIn.ModelCore.Landscape.NewSiteVar <Pool>();

            foreach (ActiveSite site in PlugIn.modelCore.Landscape)
            {
                Litter[site] = siteconditions[site].WoodyDebris;
            }
            PlugIn.ModelCore.RegisterSiteVar(Litter, "Succession.Litter");
        }
示例#10
0
        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
        }
示例#11
0
 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);
 }