• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SpatialModeling.Site类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Landis.SpatialModeling.Site的典型用法代码示例。如果您正苦于以下问题:C# Site类的具体用法?C# Site怎么用?C# Site使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Site类属于Landis.SpatialModeling命名空间,在下文中一共展示了Site类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CalculateDomAgeAgeOnly

 //---------------------------------------------------------------------
 public static int CalculateDomAgeAgeOnly(Site site)
 {
     Dictionary<int, int> ageDictionary = new Dictionary<int, int>();
     foreach (ISpeciesCohorts sppCohorts in SiteVars.AgeCohorts[site])
     {
         foreach (ICohort cohort in sppCohorts)
         {
             int age = cohort.Age;
             if (ageDictionary.ContainsKey(age))
             {
                 ageDictionary[age] = ageDictionary[age] + 1;
             }
             else
             {
                 ageDictionary[age] = 1;
             }
         }
     }
     int domAge = 0;
     int maxValue = 0;
     foreach (var i in ageDictionary)
     {
         if (i.Value > maxValue)
         {
             domAge = i.Key;
             maxValue = i.Value;
         }
     }
     return domAge;
 }
开发者ID:LANDIS-II-Foundation,项目名称:Extension-Output-Wildlife-Habitat,代码行数:31,代码来源:PlugIn.cs


示例2: ReduceLayers

        //---------------------------------------------------------------------

        /// <summary>
        /// Computes fire effects on litter, coarse woody debris, mineral soil, and charcoal.
        ///   No effects on soil organic matter (negligible according to Johnson et al. 2001).
        /// </summary>
        public static void ReduceLayers(byte severity, Site site)
        {
            //PlugIn.ModelCore.UI.WriteLine("   Calculating fire induced layer reductions...");
        
            double litterLossMultiplier = ReductionsTable[severity].LitterReduction;
            
            // Structural litter first
            
            double carbonLoss = SiteVars.SurfaceStructural[site].Carbon * litterLossMultiplier;
            double nitrogenLoss = SiteVars.SurfaceStructural[site].Nitrogen * litterLossMultiplier;
            double summaryNLoss = nitrogenLoss;
            
            SiteVars.SurfaceStructural[site].Carbon -= carbonLoss;
            SiteVars.SourceSink[site].Carbon        += carbonLoss;
            SiteVars.FireCEfflux[site]               += carbonLoss;
            
            SiteVars.SurfaceStructural[site].Nitrogen -= nitrogenLoss;
            SiteVars.SourceSink[site].Nitrogen += nitrogenLoss;
            SiteVars.FireNEfflux[site] += nitrogenLoss;
            
            // Metabolic litter

            carbonLoss = SiteVars.SurfaceMetabolic[site].Carbon * litterLossMultiplier;
            nitrogenLoss = SiteVars.SurfaceMetabolic[site].Nitrogen * litterLossMultiplier;
            summaryNLoss += nitrogenLoss;
            
            SiteVars.SurfaceMetabolic[site].Carbon  -= carbonLoss;
            SiteVars.SourceSink[site].Carbon        += carbonLoss;
            SiteVars.FireCEfflux[site]               += carbonLoss;
            
            SiteVars.SurfaceMetabolic[site].Nitrogen -= nitrogenLoss;
            SiteVars.SourceSink[site].Nitrogen        += nitrogenLoss;
            SiteVars.FireNEfflux[site] += nitrogenLoss;
            
            // Surface dead wood

            double woodLossMultiplier = ReductionsTable[severity].WoodReduction;
            
            carbonLoss   = SiteVars.SurfaceDeadWood[site].Carbon * woodLossMultiplier;
            nitrogenLoss = SiteVars.SurfaceDeadWood[site].Nitrogen * woodLossMultiplier;
            summaryNLoss += nitrogenLoss;
            
            SiteVars.SurfaceDeadWood[site].Carbon   -= carbonLoss;
            SiteVars.SourceSink[site].Carbon        += carbonLoss;
            SiteVars.FireCEfflux[site]               += carbonLoss;
            
            SiteVars.SurfaceDeadWood[site].Nitrogen -= nitrogenLoss;
            SiteVars.SourceSink[site].Nitrogen        += nitrogenLoss;
            SiteVars.FireNEfflux[site] += nitrogenLoss;

            //SiteVars.MineralN[site] += summaryNLoss * 0.01;  Need to substract N loss from Mineral N pool. -ML
            SiteVars.MineralN[site] -= summaryNLoss * 0.01;

        }
开发者ID:LANDIS-II-Foundation,项目名称:Extension-Century-Succession,代码行数:60,代码来源:FireEffects.cs


示例3: CalculateNLimits

        //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 void CalculateNLimits(Site site)
        {
            // Iterate through the first time, assigning each cohort un un-normalized N multiplier
            double NMultTotal=0.0;
            foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[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

            //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.Cohorts[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;
                }
            }
            if (totalNUptake > availableN)
            {
                totalNUptake = availableN;
                //PlugIn.ModelCore.Log.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;
        }
开发者ID:YongLuo007,项目名称:Extensions-Succession,代码行数:54,代码来源:AvailableN.cs


示例4: Leach

        //--------------------------------------------------------------------------
        public static void Leach(Site site, double baseFlow, double stormFlow)
        {
            //  double minlch, double frlech[3], double stream[8], double basef, double stormf)
            //Originally from leach.f of CENTURY model
            //...This routine computes the leaching of inorganic nitrogen (potential for use with phosphorus, and sulfur)
            //...Written 2/92 -rm. Revised on 12/11 by ML
            // ML left out leaching intensity factor.  Cap on MAX leaching (MINLECH/OMLECH3) is poorly defined in CENTURY manual. Added a NO3frac factor to account
            //for the fact that only NO3 (not NH4) is leached from soils.

            //...Called From:   SIMSOM

            //...amtlea:    amount leached
            //...linten:    leaching intensity
            //...strm:      storm flow
            //...base:      base flow

            //Outputs:
            //minerl and stream are recomputed
            IEcoregion ecoregion = PlugIn.ModelCore.Ecoregion[site];
            double waterMove = SiteVars.WaterMovement[site];

            double amtNLeached = 0.0;

            //PlugIn.ModelCore.UI.WriteLine("WaterMove={0:0}, ", waterMove);

             //...waterMove > 0. indicates a saturated water flow out of layer lyr
            if (waterMove > 0.0 && SiteVars.MineralN[site] > 0.0)
            {
                double textureEffect = OtherData.MineralLeachIntercept + OtherData.MineralLeachSlope * EcoregionData.PercentSand[ecoregion];
                //double leachIntensity = (1.0 - (OtherData.OMLeachWater - waterMove) / OtherData.OMLeachWater);
                //amtNLeached = textureEffect * SiteVars.MineralN[site] * OtherData.NfracLeachWater * OtherData.NO3frac;
                amtNLeached = textureEffect * SiteVars.MineralN[site] *  OtherData.NO3frac;

                //PlugIn.ModelCore.UI.WriteLine("amtNLeach={0:0.0}, textureEffect={1:0.0}, waterMove={2:0.0}, MineralN={3:0.00}", amtNLeached, textureEffect, waterMove, SiteVars.MineralN[site]);
            }

            double totalNleached = (baseFlow * amtNLeached) + (stormFlow * amtNLeached);

            SiteVars.MineralN[site] -= totalNleached;
            //PlugIn.ModelCore.UI.WriteLine("AfterSoilWaterLeaching. totalNLeach={0:0.0}, MineralN={1:0.00}", totalNleached, SiteVars.MineralN[site]);

            SiteVars.Stream[site].Nitrogen += totalNleached;
            SiteVars.MonthlyStreamN[site][Century.Month] += totalNleached;
            //PlugIn.ModelCore.UI.WriteLine("AfterSoilWaterLeaching. totalNLeach={0:0.0}, MineralN={1:0.00}", totalNleached, SiteVars.MineralN[site]);

            return;
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Succession,代码行数:48,代码来源:SoilWater.cs


示例5: GetOrganicCarbon

        //---------------------------------------------------------------------
        public static double GetOrganicCarbon(Site site)
        {
            double totalC =

                    SiteVars.SurfaceStructural[site].Carbon
                    + SiteVars.SoilStructural[site].Carbon
                    + SiteVars.SurfaceMetabolic[site].Carbon
                    + SiteVars.SoilMetabolic[site].Carbon

                    + SiteVars.SOM1surface[site].Carbon
                    + SiteVars.SOM1soil[site].Carbon
                    + SiteVars.SOM2[site].Carbon
                    + SiteVars.SOM3[site].Carbon
                    ;

            return totalC;
        }
开发者ID:YongLuo007,项目名称:Extensions-Succession,代码行数:18,代码来源:Outputs.cs


示例6: GetAgeRichness

        //---------------------------------------------------------------------
        // Number of age classes, an indicator of structural complexity.
        public static int GetAgeRichness(Site site)
        {
            int age_richness = 0;
            List<int> ages = new List<int>();
            if (SiteVars.Cohorts[site] == null)
                return 0;
            foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
            {
                foreach (ICohort cohort in speciesCohorts)
                {
                    if (!ages.Contains(cohort.Age))
                    {
                        ages.Add(cohort.Age);
                        age_richness++;
                    }
                }
            }

            return age_richness;
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Output,代码行数:22,代码来源:CohortUtils.cs


示例7: GetAgeEvenness

        //---------------------------------------------------------------------
        //Use E = Hprime / ln S   where S apparently is # species)
        //where Hprime = -sum (pI * ln(pI))   where pI is proportion of individuals found in Ith species
        //from Magurran, A.  1988.  Ecological diversity and its measurements.  Princeton, NJ: Princeton University Press.  Pp 35-37)
        //Return E * 100 to fit within uint range
        public static int GetAgeEvenness(Site site)
        {
            double E = 0;
            double Hprime = 0;
            double proportion=0;
            int evenness = 0;
            int total_count = 0;
            Dictionary<int, int> cohort_counts = new Dictionary<int, int>();
            if (SiteVars.Cohorts[site] == null)
                return 0;
            foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
            {
                foreach (ICohort cohort in speciesCohorts)
                {
                    total_count++;
                    if (!cohort_counts.ContainsKey((int) cohort.Age))
                    {
                        cohort_counts.Add((int) cohort.Age, 1);
                    }
                    else
                    {
                        cohort_counts[(int) cohort.Age]++;
                    }
                }
            }

            foreach (KeyValuePair<int,int> cohortIter in cohort_counts)
            {
                proportion = (double)cohortIter.Value / (double)total_count;
                Hprime += proportion * System.Math.Log(proportion);
            }
            Hprime = - Hprime;
            E = Hprime / System.Math.Log(cohort_counts.Count);
            evenness = (int)(E * 100.0);

            return evenness;
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Output,代码行数:42,代码来源:CohortUtils.cs


示例8: GetSppMaxAge

        //---------------------------------------------------------------------
        public static ushort GetSppMaxAge(Site site, ISpecies spp)
        {
            if (!site.IsActive)
                return 0;

            if (SiteVars.Cohorts[site] == null)
            {
                PlugIn.ModelCore.UI.WriteLine("Cohort are null.");
                return 0;
            }
            ushort max = 0;

            foreach (ISpeciesCohorts sppCohorts in SiteVars.Cohorts[site])
            {
                if (sppCohorts.Species == spp)
                {
                    //ModelCore.UI.WriteLine("cohort spp = {0}, compare species = {1}.", sppCohorts.Species.Name, spp.Name);
                    foreach (ICohort cohort in sppCohorts)
                        if (cohort.Age > max)
                            max = cohort.Age;
                }
            }
            return max;
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Output,代码行数:25,代码来源:PlugIn.cs


示例9: GetSppRichness

 //---------------------------------------------------------------------
 public static int GetSppRichness(Site site)
 {
     //return total count of species
     int count = 0;
     if (SiteVars.Cohorts[site] == null)
         return 0;
     foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
     {
         count++;
     }
     return count;
 }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Output,代码行数:13,代码来源:CohortUtils.cs


示例10: CalcFuelType

        //---------------------------------------------------------------------

        private int CalcFuelType(Site site,
                                        IEnumerable<IFuelType> FuelTypes,
                                        IEnumerable<IDisturbanceType> DisturbanceTypes)
        {

            double[] forTypValue = new double[100];  //Maximum of 100 fuel types
            double sumConifer = 0.0;
            double sumDecid = 0.0;
            IEcoregion ecoregion = modelCore.Ecoregion[(ActiveSite) site];

            foreach(ISpecies species in modelCore.Species)
            {

                ISpeciesCohorts speciesCohorts = (Landis.Library.BiomassCohorts.ISpeciesCohorts) SiteVars.Cohorts[site][species];

                if(speciesCohorts == null)
                    continue;

                foreach(IFuelType ftype in FuelTypes)
                {
                    if(ftype.Ecoregions[ecoregion.Index])
                    {

                        if(ftype[species.Index] != 0)
                        {
                            int sppValue = 0;

                            foreach(ICohort cohort in speciesCohorts)
                                if(cohort.Age >= ftype.MinAge && cohort.Age <= ftype.MaxAge)
                                    sppValue += cohort.Biomass;

                            //modelCore.UI.WriteLine("sppVaue={0}, spp={1}, cohortB={2}.", sppValue, cohort.Species.Name, cohort.Biomass);

                            if(ftype[species.Index] == -1)
                                forTypValue[ftype.Index] -= sppValue;

                            if(ftype[species.Index] == 1)
                                forTypValue[ftype.Index] += sppValue;
                        }
                    }
                }

            }



            int finalFuelType = 0;
            int decidFuelType = 0;
            int coniferFuelType = 0;
            int openFuelType = 0;
            int slashFuelType = 0;
            double maxValue = 0.0;
            double maxDecidValue = 0.0;
            double maxConiferValue = 0.0;
            double maxConPlantValue = 0.0;
            double maxOpenValue = 0.0;
            double maxSlashValue = 0.0;

            //Set the PERCENT CONIFER DOMINANCE:
            int coniferDominance = 0;
            int hardwoodDominance = 0;


            //First accumulate data for the various Base Fuel Types:
            foreach(IFuelType ftype in FuelTypes)
            {
                if(ftype != null)
                {

                    // Sum for the Conifer and Deciduous dominance
                    if ((ftype.BaseFuel == BaseFuelType.Conifer || ftype.BaseFuel == BaseFuelType.ConiferPlantation)
                        && forTypValue[ftype.Index] > 0)
                    {
                        sumConifer += forTypValue[ftype.Index];
                    }

                    //This is calculated for the mixed types:
                    if ((ftype.BaseFuel == BaseFuelType.Deciduous)
                        && forTypValue[ftype.Index] > 0)
                    {
                        sumDecid += forTypValue[ftype.Index];
                    }

                    // CONIFER
                    if(forTypValue[ftype.Index] > maxConiferValue && ftype.BaseFuel == BaseFuelType.Conifer)
                    {

                        maxConiferValue = forTypValue[ftype.Index];
                        if(maxConiferValue > maxConPlantValue)
                            coniferFuelType = ftype.Index;
                    }
                    // CONIFER PLANTATION
                    if (forTypValue[ftype.Index] > maxConPlantValue && ftype.BaseFuel == BaseFuelType.ConiferPlantation)
                    {

                        maxConPlantValue = forTypValue[ftype.Index];
                        if(maxConPlantValue > maxConiferValue)
                            coniferFuelType = ftype.Index;
//.........这里部分代码省略.........
开发者ID:pjbitterman,项目名称:Extensions-Disturbance,代码行数:101,代码来源:PlugIn.cs


示例11: GetTotalSoilNitrogen

        private static double GetTotalSoilNitrogen(Site site)
        {
            double totalsoilN =

                    +SiteVars.MineralN[site]

                   //+ SiteVars.SurfaceDeadWood[site].Nitrogen
                   //+ SiteVars.SoilDeadWood[site].Nitrogen

                    + SiteVars.SurfaceStructural[site].Nitrogen
                    + SiteVars.SoilStructural[site].Nitrogen
                    + SiteVars.SurfaceMetabolic[site].Nitrogen
            +SiteVars.SoilMetabolic[site].Nitrogen

            + SiteVars.SOM1surface[site].Nitrogen
            + SiteVars.SOM1soil[site].Nitrogen
            + SiteVars.SOM2[site].Nitrogen
            + SiteVars.SOM3[site].Nitrogen;
                    ;

            return totalsoilN;
        }
开发者ID:YongLuo007,项目名称:Extensions-Succession,代码行数:22,代码来源:Outputs.cs


示例12: GetCohortCount

 //---------------------------------------------------------------------
 public static int GetCohortCount(Site site)
 {
     //return total count of cohorts
     int count = 0;
     if (SiteVars.Cohorts[site] == null)
         return 0;
     foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
     {
         foreach (ICohort cohort in speciesCohorts)
         {
             count++;
         }
     }
     return count;
 }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Output,代码行数:16,代码来源:CohortUtils.cs


示例13: GetAvgAge

        //---------------------------------------------------------------------
        public static int GetAvgAge(Site site)
        {
            if (SiteVars.Cohorts[site] == null)
                return 0;
            int avg = 0;
            int sum = 0;
            int count = 0;

            foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
            {
                foreach (ICohort cohort in speciesCohorts)
                {
                    sum += cohort.Age;
                    count++;
                }
            }

            if (count == 0)
            {
                return 0;
            }

            avg = (int)(sum / count);
            return avg;
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Output,代码行数:26,代码来源:CohortUtils.cs


示例14: ResetAnnualValues

        //---------------------------------------------------------------------
        public static void ResetAnnualValues(Site site)
        {
            // Reset these accumulators to zero:
            SiteVars.CohortLeafN[site] = 0.0;
            SiteVars.CohortLeafC[site] = 0.0;
            SiteVars.CohortWoodN[site] = 0.0;
            SiteVars.CohortWoodC[site] = 0.0;
            SiteVars.GrossMineralization[site] = 0.0;
            SiteVars.AGNPPcarbon[site] = 0.0;
            SiteVars.BGNPPcarbon[site] = 0.0;
            SiteVars.LitterfallC[site] = 0.0;

            SiteVars.Stream[site]          = new Layer(LayerName.Other, LayerType.Other);
            SiteVars.SourceSink[site]      = new Layer(LayerName.Other, LayerType.Other);

            SiteVars.SurfaceDeadWood[site].NetMineralization = 0.0;
            SiteVars.SurfaceStructural[site].NetMineralization = 0.0;
            SiteVars.SurfaceMetabolic[site].NetMineralization = 0.0;

            SiteVars.SoilDeadWood[site].NetMineralization = 0.0;
            SiteVars.SoilStructural[site].NetMineralization = 0.0;
            SiteVars.SoilMetabolic[site].NetMineralization = 0.0;

            SiteVars.SOM1surface[site].NetMineralization = 0.0;
            SiteVars.SOM1soil[site].NetMineralization = 0.0;
            SiteVars.SOM2[site].NetMineralization = 0.0;
            SiteVars.SOM3[site].NetMineralization = 0.0;
            SiteVars.AnnualNEE[site] = 0.0;
            SiteVars.Nvol[site] = 0.0;
            SiteVars.AnnualNEE[site] = 0.0;
            SiteVars.TotalNuptake[site] = 0.0;
            SiteVars.ResorbedN[site] = 0.0;
            SiteVars.FrassC[site] = 0.0;
            SiteVars.LAI[site] = 0.0;
            SiteVars.AgeMortality[site] = 0.0;

            //SiteVars.FireEfflux[site] = 0.0;
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Succession,代码行数:39,代码来源:SiteVars.cs


示例15: SetMineralNallocation

        // Calculates how much N a cohort gets, based on the amount of N available.
        public static void SetMineralNallocation(Site site)
        {
            AvailableN.CohortMineralNallocation = new Dictionary<int, Dictionary<int, double>>();

               double availableN = SiteVars.MineralN[site];  // g/m2
               Math.Max(availableN, 0.01);

            foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
            {
                foreach (ICohort cohort in speciesCohorts)
                {
                    int cohortAddYear = GetAddYear(cohort);
                    if (Century.MonthCnt == 11)
                        cohortAddYear--;
                    //PlugIn.ModelCore.UI.WriteLine("SETMineralNallocation: year={0}, mo={1}, species={2}, cohortAge={3}, cohortAddYear={4}.", PlugIn.ModelCore.CurrentTime, Century.Month, cohort.Species.Name, cohort.Age, cohortAddYear);

                    double Nfraction = 0.05;  //even a new cohort gets a little love
                    Dictionary<int, double> cohortDict = new Dictionary<int,double>();

                    if (AvailableN.CohortMineralNfraction.TryGetValue(cohort.Species.Index, out cohortDict))
                        cohortDict.TryGetValue(cohortAddYear, out Nfraction);

                    double Nallocation = Nfraction * availableN;
                    //PlugIn.ModelCore.UI.WriteLine("  NallocationlimitedbymineralN={0:0.00}, Nfraction={1:0.00}, availableN={2:0.00}.", Nallocation, Nfraction, availableN);

                    if (Double.IsNaN(Nallocation) || Double.IsNaN(Nfraction) || Double.IsNaN(availableN))
                    {
                        PlugIn.ModelCore.UI.WriteLine("  LIMIT N CALCULATION = NaN!  ");
                        PlugIn.ModelCore.UI.WriteLine("  Nallocation={0:0.00}, Nfraction={1:0.00}, availableN={2:0.00}.", Nallocation, Nfraction, availableN);
                    }

                    Dictionary<int, double> newEntry = new Dictionary<int, double>();
                    newEntry.Add(cohortAddYear, Nallocation);

                    if (CohortMineralNallocation.ContainsKey(cohort.Species.Index))
                    {
                        CohortMineralNallocation[cohort.Species.Index].Add(cohortAddYear, Nallocation);
                    }
                    else
                    {
                        CohortMineralNallocation.Add(cohort.Species.Index, newEntry);
                    }
                }
            }
            /*if (totalNUptake > availableN)
            {
                totalNUptake = availableN;
                //PlugIn.ModelCore.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");
            }
            SiteVars.TotalNuptake[site] = totalNUptake;*/
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Succession,代码行数:53,代码来源:AvailableN.cs


示例16: Run

        public static void Run(int year, int month, double liveBiomass, Site site)
        {
            //PlugIn.ModelCore.Log.WriteLine("year = {0}, month = {1}", year, month);

            //Originally from h2olos.f of CENTURY model

            //Water Submodel for Century - written by Bill Parton
            //     Updated from Fortran 4 - rm 2/92
            //     Rewritten by Bill Pulliam - 9/94

            //...Description of variables
            //
            //   deadBiomass        the average monthly standing dead biomass(gm/m..2)
            //   soilDepth          depth of the ith soil layer(cm)
            //   fieldCapacity      the field capacity of the ith soil layer(fraction)
            //   litterBiomass      the average monthly litter biomass(gm/m..2)
            //   liveBiomass        the average monthly live plant biomass(gm/m..2)
            //   waterMovement      the index for water movement(0-no flow,1-satruated flow)
            //   soilWaterContent   the soil water content of the ith soil layer(cm h2o)
            //   asnow              the snow pack water contint(cm-h2o)
            //   avh2o (1)          NA water available to plants for growth
            //   avh2o (2)          NA water available to plants for survival
            //                      (available water in the whole soil profile)
            //   availableWater     available water in current soil layer
            //   wiltingPoint       the wilting point of the  ith soil layer(fraction)
            //   transpLossFactor   the weight factor for transpiration water loss
            //   totalEvaporated               the water evaporated from the  soil and vegetation(cm/mon)
            //   evaporatedSnow             snow evaporated
            //   inputs             rain + irrigation
            //   H2Oinputs            inputs which are water (not converted to snow)
            //   nlayer             NA number of soil layers with water available for plant survival
            //   nlaypg             NA number of soil layers with water available for plant growth
            //   remainingPET       remaining pet, updated after each incremental h2o loss
            //   potentialEvapTop               the potential evaporation rate from the top  soil layer (cm/day)
            //   rain               the total monthly rainfall (cm/month)
            //   relativeWaterContent        the relative water content of the ith soil layer(0-1)
            //   liquidSnowpack               the liquid water in the snow pack
            //   tav                average monthly air temperature (2m-        //)
            //   tran               transpriation water loss(cm/mon)
            //   transpirationLoss  transpiration water loss

            //...Initialize Local Variables
            double addToSoil = 0.0;
            double bareSoilEvap = 0.0;
            double baseFlow = 0.0;
            double totalEvaporated = 0.0;
            double evaporativeLoss = 0.0;
            double potentialTrans = 0.0;
            double relativeWaterContent = 0.0;
            //double rwc1 = 0.0;
            double snow = 0.0;
            double liquidSnowpack = 0.0;
            double stormFlow = 0.0;
            //double tot = 0.0;
            //double tot2 = 0.0;
            //double totalAvailableWater = 0.0;
            double tran = 0.0;
            //double transpirationLoss = 0.0;
            double transpiration = 0.01;

            //...Calculate external inputs
            IEcoregion ecoregion    = PlugIn.ModelCore.Ecoregion[site];

            double litterBiomass    = (SiteVars.SurfaceStructural[site].Carbon + SiteVars.SurfaceMetabolic[site].Carbon) * 2.0;
            double deadBiomass = SiteVars.SurfaceDeadWood[site].Carbon * 2.0;
            double soilWaterContent = SiteVars.SoilWaterContent[site] ;

            double H2Oinputs        = EcoregionData.AnnualWeather[ecoregion].MonthlyPrecip[month]; //rain + irract;
            double tave             = EcoregionData.AnnualWeather[ecoregion].MonthlyTemp[month];
            double tmax             = EcoregionData.AnnualWeather[ecoregion].MonthlyMaxTemp[month];
            double tmin             = EcoregionData.AnnualWeather[ecoregion].MonthlyMinTemp[month];
            double pet              = EcoregionData.AnnualWeather[ecoregion].MonthlyPET[month];
            //double soilTemp         = tave;

            double wiltingPoint     = EcoregionData.WiltingPoint[ecoregion];
            double soilDepth        = EcoregionData.SoilDepth[ecoregion];
            double fieldCapacity    = EcoregionData.FieldCapacity[ecoregion];
            double stormFlowFraction= EcoregionData.StormFlowFraction[ecoregion];
            double baseFlowFraction = EcoregionData.BaseFlowFraction[ecoregion];
            double drain            = EcoregionData.Drain[ecoregion];

            deadBiomass = 0.0;

            //...Throughout, uses remainingPET as remaining energy for pet after
            //     each melting and evaporation step.  Initially calculated
            //     pet is not modified.  Pulliam 9/94
            double remainingPET = pet;

            //...Determine the snow pack, melt snow, and evaporate from the snow pack
            //...When mean monthly air temperature is below freezing,
            //     precipitation is in the form of snow.
            if (tave < 0.0)
            {
                snow = H2Oinputs; //snow + inputs;
                H2Oinputs = 0.0;
            }

            //...Melt snow if air temperature is above minimum (tmelt(1))
            if (tave > OtherData.TMelt1)
            {
//.........这里部分代码省略.........
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Succession,代码行数:101,代码来源:SoilWater.cs


示例17: CalcFuelType

        //---------------------------------------------------------------------

        private int CalcFuelType(Site site,
                                        IEnumerable<IFuelType> FuelTypes,
                                        IEnumerable<IDisturbanceType> DisturbanceTypes)
        {

            double[] forTypValue = new double[100];  //Maximum of 100 fuel types
            double sumConifer = 0.0;
            double sumDecid = 0.0;

            ISpeciesDataset SpeciesDataset = modelCore.Species;
            foreach(ISpecies species in SpeciesDataset)
            {

                // This is the new algorithm, based on where a cohort is within it's age range.
                // This algorithm is less biased towards older cohorts.
                ISpeciesCohorts speciesCohorts = SiteVars.Cohorts[site][species];

                if(speciesCohorts == null)
                    continue;

                foreach(IFuelType ftype in FuelTypes)
                {

                    if(ftype[species.Index] != 0)
                    {
                        double sppValue = 0.0;

                        foreach(ICohort cohort in speciesCohorts)
                        {
                            double cohortValue =0.0;


                            if(cohort.Age >= ftype.MinAge && cohort.Age <= ftype.MaxAge)
                            {
                                // Adjust max range age to the spp longevity
                                double maxAge = System.Math.Min(ftype.MaxAge, (double) species.Longevity);

                                // The fuel type range must be at least 5 years:
                                double ftypeRange = System.Math.Max(1.0, maxAge - (double) ftype.MinAge);

                                // The cohort age relative to the fuel type range:
                                double relativeCohortAge = System.Math.Max(1.0, (double) cohort.Age - ftype.MinAge);

                                cohortValue = relativeCohortAge / ftypeRange * fuelCoefs[species.Index];

                                // Use the one cohort with the largest value:
                                //sppValue += System.Math.Max(sppValue, cohortValue);  // A BUG, should be...
                                sppValue = System.Math.Max(sppValue, cohortValue);
                            }
                        }

                        if(ftype[species.Index] == -1)
                            forTypValue[ftype.FuelIndex] -= sppValue;
                        if(ftype[species.Index] == 1)
                            forTypValue[ftype.FuelIndex] += sppValue;
                    }
                }

            }

            int finalFuelType = 0;
            int decidFuelType = 0;
            double maxValue = 0.0;
            double maxDecidValue = 0.0;

            //Set the PERCENT CONIFER DOMINANCE:
            int coniferDominance = 0;
            int hardwoodDominance = 0;


            //First accumulate data for the BASE fuel types:
            foreach(IFuelType ftype in FuelTypes)
            {
                if(ftype != null)
                {

                    if ((ftype.BaseFuel == BaseFuelType.Conifer || ftype.BaseFuel == BaseFuelType.ConiferPlantation)
                        && forTypValue[ftype.FuelIndex] > 0)
                    {
                        sumConifer += forTypValue[ftype.FuelIndex];
                    }

                    //This is calculated for the mixed types:
                    if ((ftype.BaseFuel == BaseFuelType.Deciduous)
                        && forTypValue[ftype.FuelIndex] > 0)
                    {
                        sumDecid += forTypValue[ftype.FuelIndex];
                    }

                    if(forTypValue[ftype.FuelIndex] > maxValue)
                    {
                        maxValue = forTypValue[ftype.FuelIndex];
                        finalFuelType = ftype.FuelIndex;
                    }

                    if(ftype.BaseFuel == BaseFuelType.Deciduous && forTypValue[ftype.FuelIndex] > maxDecidValue)
                    {
                        maxDecidValue = forTypValue[ftype.FuelIndex];
//.........这里部分代码省略.........
开发者ID:pjbitterman,项目名称:Extensions-Disturbance,代码行数:101,代码来源:PlugIn.cs


示例18: GetMaxAge

 public static int GetMaxAge(Site site)
 {
     if (SiteVars.Cohorts[site] == null)
         return 0;
     int max = 0;
     foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
     {
         int maxSpeciesAge = GetMaxAge(speciesCohorts.Species, site);
         if (maxSpeciesAge > max)
             max = maxSpeciesAge;
     }
     return max;
 }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Output,代码行数:13,代码来源:CohortUtils.cs


示例19: GetMinAge

        //---------------------------------------------------------------------
        public static int GetMinAge(ISpecies species, Site site)
        {
            if (SiteVars.Cohorts[site] == null)
            {
                PlugIn.ModelCore.UI.WriteLine("Cohort are null.");
                return 0;
            }
            int min = 32767;//maxof uint

            foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
            {
                if (speciesCohorts.Species == species)
                    foreach (ICohort cohort in speciesCohorts)
                    {
                        if (cohort.Age < min)
                            min = (int) cohort.Age;
                    }
            }
            return min;
        }
开发者ID:LANDIS-II-Foundation,项目名称:Extensions-Output,代码行数:21,代码来源:CohortUtils.cs


示例20: foreach

 /*public static uint GetMaxAge(ISpecies species, ActiveSite site) //Cohorts speciesCohorts)
 {
     //if (speciesCohorts == null)
     //    return 0;
     uint max = 0;
     foreach (ICohort cohort in speciesCohorts)
     {
         //  First cohort is the oldest
         max = cohort.Age;
         break;
     }
     return max;
 }*/
 //---------------------------------------------------------------------
 public static int GetMinAge(Site site)
 {
     if (SiteVars.Cohorts[site] == null)
         return 0;
     int min = 32767;//maxof uint
     foreach (ISpeciesCohorts speciesCohorts in SiteVars.Cohorts[site])
     {
          

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LanguageExt.ProcessId类代码示例发布时间:2022-05-26
下一篇:
C# SpatialModeling.ActiveSite类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap