Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the potential and actual biomass growth of a canopy across the span of a day,
        /// as well as the water requirements for both cases.
        /// </summary>
        public void DailyRun(
            double lai,
            double SLN,
            double soilWater,
            double RootShootRatio
            )
        {
            for (double x = start; x <= end; x += timestep)
            {
                Intervals.Add(new IntervalValues()
                {
                    Time = x
                });
            }

            Solar.Initialise();
            Canopy.InitialiseDay(lai, SLN);

            // UNLIMITED POTENTIAL CALCULATIONS
            // Note: In the potential case, we assume unlimited water and therefore supply = demand
            transpiration.Limited = false;
            var potential    = CalculatePotential();
            var waterDemands = Intervals.Select(i => i.Sunlit.E + i.Shaded.E).ToList();

            // BIO-LIMITED CALCULATIONS

            transpiration.Limited = true;

            // Check if the plant is biologically self-limiting
            if (Biolimit > 0)
            {
                // Percentile reduction
                if (Reduction > 0)
                {
                    waterDemands = waterDemands.Select(w => ReductionFunction(w, Biolimit, Reduction)).ToList();
                }
                // Truncation
                else
                {
                    // Reduce to the flat biological limit
                    waterDemands = waterDemands.Select(w => Math.Min(w, Biolimit)).ToList();
                }

                potential = CalculateLimited(waterDemands);
            }

            if (PrintIntervalValues)
            {
                IntervalResults  = Solar.DayOfYear.ToString() + ",";
                IntervalResults += string.Join(",", Intervals.Select(i => i.ToString()));
            }

            // ACTUAL CALCULATIONS
            var totalDemand   = waterDemands.Sum();
            var limitedSupply = CalculateWaterSupplyLimits(soilWater, waterDemands);

            var actual = (soilWater > totalDemand) ? potential : CalculateActual(limitedSupply.ToArray());

            var hrs_to_seconds = 3600;

            // 1,000,000 mmol to mol
            // 44 mol wt CO2
            var mmolToMol = 1000000;
            var molWtCO2  = 44;

            ActualBiomass    = actual * hrs_to_seconds / mmolToMol * molWtCO2 * B / (1 + RootShootRatio);
            PotentialBiomass = potential * hrs_to_seconds / mmolToMol * molWtCO2 * B / (1 + RootShootRatio);
            WaterDemanded    = totalDemand;
            WaterSupplied    = (soilWater < totalDemand) ? limitedSupply.Sum() : waterDemands.Sum();

            if (PrintIntervalValues)
            {
                IntervalResults += "," + string.Join(",", Intervals.Select(i => i.ToString()));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculates the potential and actual biomass growth of a canopy across the span of a day,
        /// as well as the water requirements for both cases.
        /// </summary>
        public void DailyRun(
            double lai,
            double sln,
            double soilWater,
            double RootShootRatio
            )
        {
            var steps = (end - start) / timestep;

            if (steps % 1 == 0)
            {
                steps++;
            }

            Intervals = Enumerable.Range(0, (int)Math.Ceiling(steps))
                        .Select(i => new IntervalValues()
            {
                Time = start + i * timestep
            })
                        .ToArray();


            Solar.Initialise();
            Canopy.InitialiseDay(lai, sln);

            // UNLIMITED POTENTIAL CALCULATIONS
            // Note: In the potential case, we assume unlimited water and therefore supply = demand
            transpiration.Limited = false;
            var potential    = CalculatePotential();
            var waterDemands = Intervals.Select(i => i.Sunlit.Water + i.Shaded.Water).ToList();

            // BIO-LIMITED CALCULATIONS

            transpiration.Limited = true;

            // Check if the plant is biologically self-limiting
            if (Biolimit > 0)
            {
                // Percentile reduction
                if (Reduction > 0)
                {
                    waterDemands = waterDemands.Select(w => ReductionFunction(w, Biolimit, Reduction)).ToList();
                }
                // Truncation
                else
                {
                    // Reduce to the flat biological limit
                    waterDemands = waterDemands.Select(w => Math.Min(w, Biolimit)).ToList();
                }

                potential = CalculateLimited(waterDemands);
            }

            // ACTUAL CALCULATIONS
            var totalDemand   = waterDemands.Sum();
            var limitedSupply = CalculateWaterSupplyLimits(soilWater, waterDemands);

            var actual = (soilWater > totalDemand) ? potential : CalculateActual(limitedSupply.ToArray());

            var hrs_to_seconds = 3600;

            // 1,000,000 mmol to mol
            // 44 mol wt CO2
            var mmolToMol = 1000000;
            var molWtCO2  = 44;

            ActualBiomass    = actual * hrs_to_seconds / mmolToMol * molWtCO2 * B / (1 + RootShootRatio);
            PotentialBiomass = potential * hrs_to_seconds / mmolToMol * molWtCO2 * B / (1 + RootShootRatio);
            WaterDemanded    = totalDemand;
            WaterSupplied    = (soilWater < totalDemand) ? limitedSupply.Sum() : waterDemands.Sum();
        }