Exemple #1
0
        /// <summary>
        /// Calculates the assimilation values for each pathway
        /// </summary>
        private void UpdateAssimilation(Transpiration t, bool updateT)
        {
            foreach (var p in pathways)
            {
                t.Leaf.temperature = p.Temperature;
                t.Water.LeafTemp   = p.Temperature;

                var func = t.UpdateA(assimilation, p);
                assimilation.UpdatePartialPressures(p, t.Leaf, func);

                if (!(assimilation is AssimilationC3))
                {
                    t.UpdateA(assimilation, p);
                }

                if (updateT)
                {
                    t.UpdateTemperature(p);
                }

                if (double.IsNaN(p.CO2Rate) || double.IsNaN(p.WaterUse))
                {
                    p.CO2Rate  = 0;
                    p.WaterUse = 0;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Repeat the assimilation calculation to let the result converge
        /// </summary>
        private void DoIterations(Transpiration t, double airTemp, bool updateT)
        {
            pathways.ForEach(p => p.SetConditions(airTemp, LAI));
            t.SetConditions(At25C, PhotonCount, AbsorbedRadiation);

            for (int n = 0; n <= assimilation.Iterations; n++)
            {
                UpdateAssimilation(t, updateT);
            }
        }
Exemple #3
0
        /// <summary>
        /// Calculates the CO2 assimilated by the partial canopy during photosynthesis,
        /// and the water used by the process
        /// </summary>
        public void DoPhotosynthesis(ITemperature temperature, Transpiration transpiration)
        {
            CO2AssimilationRate = 0;
            WaterUse            = 0;

            // Do the initial iterations
            DoIterations(transpiration, temperature.AirTemperature, true);

            // If the result is not sensible, repeat the iterations without updating temperature
            if (GetCO2Rate() <= 0 || GetWaterUse() <= 0)
            {
                DoIterations(transpiration, temperature.AirTemperature, false);
            }

            // If the result is still not sensible, use default values (0's)
            if (GetCO2Rate() <= 0 || GetWaterUse() <= 0)
            {
                return;
            }

            // Update results only if convergence succeeds
            CO2AssimilationRate = GetCO2Rate();
            WaterUse            = GetWaterUse();
        }