/// <summary>
 /// Adds some biomass for a species to the WOODY pools at a site.
 /// </summary>
 public static void AddWoody(double     woodyBiomass,
                             ISpecies   species,
                             ActiveSite site)
 {
     SiteVars.WoodyDebris[site].AddMass(woodyBiomass,
                             SpeciesData.WoodyDebrisDecay[species]);
 }
		//---------------------------------------------------------------------

		public void Do(ActiveSite site)
		{
			foreach (ISpecies species in Model.Species) {
				if (seedingAlgorithm.Seeds(species, site))
					cohorts[site].AddNewCohort(species);
			}
		}
 public static List<Location> DurationBasedSize(ActiveSite site, double ROS)
 {
     List<Location> newFireList = new List<Location>(0);
     newFireList.Add(site.Location);  //Add ignition site first.
     
     return newFireList;
 }
Exemplo n.º 4
0
 //---------------------------------------------------------------------
 public void AddNewCohort(ISpecies   species,
     ActiveSite site)
 {
     cohorts[site].AddNewCohort(species,
                                CohortBiomass.InitialBiomass(cohorts[site],
                                                             site, species));
 }
 public static bool Algorithm(ISpecies   species,
     ActiveSite site)
 {
     return Reproduction.SufficientLight(species, site) &&
            Reproduction.Establish(species, site) &&
            Reproduction.MaturePresent(species, site);
 }
		//---------------------------------------------------------------------

		/// <summary>
		/// Records a species that should be checked for resprouting during
		/// reproduction.
		/// </summary>
		/// <param name="cohort">
		/// The cohort whose death triggered the current call to this method.
		/// </param>
		/// <param name="site">
		/// The site where the cohort died.
		/// </param>
		/// <remarks>
		/// If the cohort's age is within the species' age range for
		/// resprouting, then the species will be have additional resprouting
		/// criteria (light, probability) checked during reproduction.
		/// </remarks>
		public static void CheckForResprouting(AgeCohort.ICohort cohort,
		                                       ActiveSite        site)
		{
			ISpecies species = cohort.Species;
			if (species.MinSproutAge <= cohort.Age && cohort.Age <= species.MaxSproutAge)
				resprout[site].Set(species.Index, true);
		}
Exemplo n.º 7
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Adds yearly biomass addition to dead fine roots at a site.
        ///   Sums all species-cohort additions and adds as a single cohort.
        /// </summary>
        public static void AddYearDeadFineRoots(ActiveSite site)
        {
            double addMass = 0.0;
            double addC = 0.0;
            double addN = 0.0;
            double addP = 0.0;
            double addDecay = 0.0;
            double addLimit = 0.0;

            foreach (PoolD litter in SiteVars.DeadFineRootsAdd[site])
            {
                addMass += litter.Mass;
                addC += litter.ContentC;
                addN += litter.ContentN;
                addP += litter.ContentP;
                addDecay += (litter.DecayValue * litter.Mass);  //weighted avg
                addLimit += (litter.LimitValue * litter.Mass);  //weighted avg
            }

            PoolD LitterAddition = new PoolD();
            LitterAddition.Mass = addMass;
            LitterAddition.ContentC = addC;
            LitterAddition.ContentN = addN;
            LitterAddition.ContentP = addP;
            LitterAddition.DecayValue = addDecay / addMass;
            LitterAddition.LimitValue = addLimit / addMass;
            LitterAddition.InitialMass = addMass;

            SiteVars.DeadFineRoots[site].Add(LitterAddition);
            SiteVars.DeadFineRootsAdd[site].Clear();
            SiteVars.DeadFineRootsAdd[site].TrimExcess();
        }
Exemplo n.º 8
0
 //---------------------------------------------------------------------
 public void AddNewCohort(ISpecies   species,
     ActiveSite site)
 {
     SiteVars.Cohorts[site].AddNewCohort(species,
                                CohortBiomass.InitialBiomass(species, SiteVars.Cohorts[site],
                                                             site));
 }
Exemplo n.º 9
0
        //---------------------------------------------------------------------
        /// <summary>
        /// Grows all cohorts at a site for a specified number of years.  The
        /// dead pools at the site also decompose for the given time period.
        /// </summary>
        public static void GrowCohorts(SiteCohorts cohorts,
            ActiveSite site,
            int years,
            bool isSuccessionTimestep)
        {
            if (SiteVars.Cohorts[site] == null)
                return;

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

                SpeciesData.ChangeDynamicParameters(Model.Core.CurrentTime + y - 1);

                SiteVars.ResetAnnualValues(site);
                CohortBiomass.SubYear = y - 1;
                CohortBiomass.CanopyLightExtinction = 0.0;

                // SiteVars.LAI[site] = 0.0;
                SiteVars.PercentShade[site] = 0.0;
                SiteVars.LightTrans[site] = 1.0;

                SiteVars.Cohorts[site].Grow(site, (y == years && isSuccessionTimestep));
                SiteVars.WoodyDebris[site].Decompose();
                SiteVars.Litter[site].Decompose();
            }
        }
 public static void Algorithm(//ISpecies   species,
     ActiveSite site)
 {
     return;//Reproduction.SufficientLight(species, site) &&
            //Reproduction.Establish(species, site) &&
            //Reproduction.MaturePresent(species, site);
 }
Exemplo n.º 11
0
		//---------------------------------------------------------------------

		/// <summary>
		/// Default seed dispersal method.
		/// </summary>
		public static float Default(ISpecies   species,
		                            ActiveSite sourceSite,
		                            ActiveSite destinationSite)
		{
			// TODO - Based on Brendan Ward's thesis
			return 0.0f;
		}
Exemplo n.º 12
0
		//---------------------------------------------------------------------

		/// <summary>
		/// Determines if there is sufficient light at a site for a species to
		/// germinate/resprout.
		/// </summary>
		public static bool SufficientLight(ISpecies   species,
		                                   ActiveSite site)
		{
			byte siteShade = SiteVars.Shade[site];
			return (species.ShadeTolerance <= 4 && species.ShadeTolerance > siteShade) ||
				   (species.ShadeTolerance == 5 && siteShade > 1);
			//  pg 14, Model description, this ----------------^ may be 2?
		}
Exemplo n.º 13
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Raises a Cohort.DeathEvent.
        /// </summary>
        public static void Died(object     sender,
                                ICohort    cohort,
                                ActiveSite site,
                                PlugInType disturbanceType)
        {
            if (DeathEvent != null)
                DeathEvent(sender, new DeathEventArgs(cohort, site, disturbanceType));
        }
        /// <summary>
        /// Decomposes Sturctural Litter
        /// </summary>
        public static void Decompose(ActiveSite site)
        {
            SiteVars.SurfaceStructural[site].DecomposeStructural(site);
            SiteVars.SurfaceMetabolic[site].DecomposeMetabolic(site);

            SiteVars.SoilStructural[site].DecomposeStructural(site);
            SiteVars.SoilMetabolic[site].DecomposeMetabolic(site);
        }
 //---------------------------------------------------------------------
 public void Do(ActiveSite site)
 {
     for (int i = 0; i < Model.Species.Count; i++) {
         ISpecies species = Model.Species[i];
         if (seedingAlgorithm(species, site))
             Reproduction.AddNewCohort(species, site);
     }
 }
Exemplo n.º 16
0
 	//---------------------------------------------------------------------
 
 	/// <summary>
 	/// Grows all cohorts at a site for a number of years.
 	/// </summary>
 	public static void Grow(SiteCohorts cohorts,
 	                        int         years,
 	                        ActiveSite  site,
 	                        bool        isSuccessionTimestep)
 	{
         for (int y = 1; y <= years; ++y)
             cohorts.Grow(site, (y == years && isSuccessionTimestep));
 	}
        //---------------------------------------------------------------------

        public int ComputeChange(ICohort    cohort,
                                 ActiveSite site,
                                 int        siteBiomass,
                                 int        prevYearSiteMortality)
        {
            CountCalled++;
            return Change;
        }
Exemplo n.º 18
0
		//---------------------------------------------------------------------

		/// <summary>
		/// Determines if a species resprouts when one of its cohorts dies.
		/// </summary>
		public static bool Resprout(AgeOnly.ICohort cohort,
		                            ActiveSite      site)
		{
			ISpecies species = cohort.Species;
			return (species.MinSproutAge <= cohort.Age) &&
			       (cohort.Age <= species.MaxSproutAge) &&
				   SufficientLight(species, site) &&
				   Establish(species, site);
		}
Exemplo n.º 19
0
 //---------------------------------------------------------------------
 public static double ComputeWoodBiomass(ActiveSite site)
 {
     double woodBiomass = 0;
     if (SiteVars.SiteCohorts[site] != null)
         foreach (ISpeciesCohorts speciesCohorts in SiteVars.SiteCohorts[site])
             foreach (ICohort cohort in speciesCohorts)
                 woodBiomass += cohort.WoodBiomass;
     return woodBiomass;
 }
 public static void Algorithm(//ISpecies   species,
                              ActiveSite site)
 {
     foreach(ISpecies species in Model.Core.Species)
             if(Reproduction.SufficientLight(species, site) && Reproduction.Establish(species, site))
                 Reproduction.AddNewCohort(species, site);
     //return Reproduction.SufficientLight(species, site) &&
     //       Reproduction.Establish(species, site);
 }
Exemplo n.º 21
0
        //---------------------------------------------------------------------
        public void AddNewCohort(ISpecies species,
            ActiveSite site)
        {
            float[] initialBiomass = CohortBiomass.InitialBiomass(SiteVars.Cohorts[site], site, species);
            float initialWoodMass = initialBiomass[0];
            float initialLeafMass = initialBiomass[1];

            SiteVars.Cohorts[site].AddNewCohort(species, initialWoodMass, initialLeafMass);
        }
 //---------------------------------------------------------------------
 public override byte ComputeShade(ActiveSite site)
 {
     byte shade = 0;
     foreach (SpeciesCohorts speciesCohorts in cohorts[site]) {
         ISpecies species = speciesCohorts.Species;
         if (species.ShadeTolerance > shade)
             shade = species.ShadeTolerance;
     }
     return shade;
 }
        //---------------------------------------------------------------------

        public double MyCompute(ICohort    cohort,
                                ActiveSite site,
                                int        siteBiomass)
        {
            Assert.AreEqual(myCohort, cohort);
            Assert.AreEqual(myActiveSite, site);
            Assert.AreEqual(mySiteBiomass, siteBiomass);
            myComputeCalled = true;
            return myComputeResult;
        }
        //New method for calculating N limits, called from Century.cs Run method before calling Grow
        //Iterates through cohorts, assigning each a N gathering efficiency based on fine root biomass
        //and N tolerance.
        public static double CalculateNLimits(ActiveSite site)
        {
            // Iterate through the first time, assigning each cohort un un-normalized N multiplier
            double NMultTotal=0.0;
            foreach (ISpeciesCohorts speciesCohorts in SiteVars.SiteCohorts[site])
                foreach (ICohort cohort in speciesCohorts)
                {
                            int Ntolerance = SpeciesData.NTolerance[cohort.Species];

                            //NMultiplier is a measure of how much N a cohort can gather relative to other cohorts
                            double NMultiplier = CalculateNMultiplier(cohort.Biomass,Ntolerance);
                            NMultTotal += NMultiplier;
                            Dictionary<int,double> newEntry = new Dictionary<int,double>();
                            newEntry.Add(cohort.Age,NMultiplier);

                            if (CohortNlimits.ContainsKey(cohort.Species.Index))
                            {
                               CohortNlimits[cohort.Species.Index].Add(cohort.Age,NMultiplier);
                            }
                            else
                            {
                               CohortNlimits.Add(cohort.Species.Index,newEntry);
                            }

                }

            double availableN = SiteVars.MineralN[site];  // g/m2

            //Console.WriteLine("NMultTotal="+NMultTotal);

            //Iterate through a second time now that we have total N multiplier
            //Divide through by total and multiply by total available N so each cohort has a max N value
            //and the sum of cohort max N values is the site available N

            double totalNUptake = 0.0;
            foreach (ISpeciesCohorts speciesCohorts in SiteVars.SiteCohorts[site])
                        foreach (ICohort cohort in speciesCohorts)
                        {
                           double NMultiplier=CohortNlimits[cohort.Species.Index][cohort.Age];
                           double Nfrac=NMultiplier/NMultTotal;
                           CohortNlimits[cohort.Species.Index][cohort.Age] = Nfrac *availableN;

                           totalNUptake += Nfrac * availableN;
                           //Console.WriteLine("species={0} age={1} NMult={2:0.00} Nfrac={3:0.0000}",cohort.Species.Name,cohort.Age,NMultiplier,Nfrac);
                        }

            //Console.WriteLine("Total max N uptake = {0:0.0000}, availableN = {1:0.0000}, availableN-uptake={2:0.0000}", totalNUptake,availableN,availableN-totalNUptake);
            if ((availableN - totalNUptake) < -0.001 * availableN)
            {
                    UI.WriteLine("   ERROR:  Total max N uptake = {0:0.000}, availableN = {1:0.000}.", totalNUptake, availableN);
                    throw new ApplicationException("Error: Max N uptake > availableN.  See AvailableN.cs");
            }

            return 0.0;
        }
Exemplo n.º 25
0
 /// <summary>
 /// Grows all cohorts at a site for a specified number of years.  The
 /// dead pools at the site also decompose for the given time period.
 /// </summary>
 public static void GrowCohorts(SiteCohorts cohorts,
     ActiveSite  site,
     int         years,
     bool        isSuccessionTimestep)
 {
     for (int y = 1; y <= years; ++y) {
         cohorts.Grow(site, (y == years && isSuccessionTimestep));
         Dead.Pools.Woody[site].Decompose();
         Dead.Pools.NonWoody[site].Decompose();
     }
 }
        //---------------------------------------------------------------------
        private static float ReduceInput(float     poolInput,
                                          Percentage reductionPercentage,
                                          ActiveSite site)
        {
            float reduction = (poolInput * (float) reductionPercentage);

            SiteVars.SourceSink[site].Carbon        += (double) reduction * 0.47;
            //SiteVars.FireEfflux[site]               += (double) reduction * 0.47;

            return (poolInput - reduction);
        }
 //---------------------------------------------------------------------
 public void Do(ActiveSite site)
 {
     for (int i = 0; i < Model.Core.Species.Count; i++) {
         ISpecies species = Model.Core.Species[i];
         if (seedingAlgorithm(species, site)) {
             Reproduction.AddNewCohort(species, site);
             if (isDebugEnabled)
                 log.DebugFormat("site {0}: seeded {1}",
                                 site.Location, species.Name);
         }
     }
 }
        //---------------------------------------------------------------------

        /// <summary>
        /// Grows the current cohort for one year.
        /// </summary>
        /// <param name="site">
        /// The site where the cohort is located.
        /// </param>
        /// <param name="siteBiomass">
        /// The total biomass at the site.  This parameter is changed by the
        /// same amount as the current cohort's biomass.
        /// </param>
        /// <param name="prevYearMortality">
        /// The total mortality at the site during the previous year.
        /// </param>
        /// <returns>
        /// The total mortality (excluding annual leaf litter) for the current
        /// cohort.
        /// </returns>
        public int GrowCurrentCohort(ActiveSite site,
                                     ref int    siteBiomass,
                                     int        prevYearMortality)
        {
            if (currentCohortAge == 0)
                throw new InvalidOperationException("Iterator has no current cohort");

            int cohortMortality;
            nextIndex = cohorts.GrowCohort(index, site, ref siteBiomass,
                                           prevYearMortality, out cohortMortality);
            return cohortMortality;
        }
Exemplo n.º 29
0
		//---------------------------------------------------------------------

		/// <summary>
		/// Determines if a species has at least one mature cohort at a site.
		/// </summary>
		public static bool MaturePresent(ISpecies   species,
		                                 ActiveSite site)
		{
			ISiteCohorts<AgeOnly.ICohort> cohorts = Model.GetSuccession<AgeOnly.ICohort>().Cohorts[site];
			ISpeciesCohorts<AgeOnly.ICohort> speciesCohorts = cohorts[species];
			if (speciesCohorts == null)
				return false;
			foreach (ushort age in speciesCohorts.Ages)
				if (age >= species.Maturity)
					return true;
			return false;
		}
Exemplo n.º 30
0
 /// <summary>
 /// Adds some biomass for a species to the WOOD litter pools at a site.
 /// </summary>
 public static void AddWoodLitter(double woodBiomass, 
     ISpecies   species,
     ActiveSite site)
 {
     if(woodBiomass > 0)
     WoodLayer.PartitionResidue(woodBiomass,
                     FunctionalType.Table[SpeciesData.FuncType[species]].WoodDecayRate,
                     SpeciesData.WoodCN[species],
                     SpeciesData.WoodLignin[species],
                     LayerName.Wood,
                     LayerType.Surface,
                     site);
 }