Esempio n. 1
0
        private void OnDoDCaPST(object sender, EventArgs args)
        {
            IPlant      plant          = FindInScope <IPlant>(CropName);
            double      rootShootRatio = GetRootShootRatio(plant);
            DCAPSTModel model          = SetUpModel(Parameters.Canopy,
                                                    Parameters.Pathway,
                                                    clock.Today.DayOfYear,
                                                    weather.Latitude,
                                                    weather.MaxT,
                                                    weather.MinT,
                                                    weather.Radn,
                                                    Parameters.Rpar);
            // From here, we can set additional options,
            // such as verbosity, BioLimit, Reduction, etc.

            // 0. Get SLN, LAI, total avail SW, root shoot ratio
            // 1. Perform internal calculations
            // 2. Set biomass production in leaf
            // 3. Set water demand and potential EP via ICanopy

            // fixme - are we using the right SW??
            ICanopy leaf = plant.FindChild <ICanopy>("Leaf");

            if (leaf == null)
            {
                throw new Exception($"Unable to run DCaPST on plant {plant.Name}: plant has no leaf which implements ICanopy");
            }
            if (leaf.LAI > 0)
            {
                double sln = GetSln(leaf);
                model.DailyRun(leaf.LAI, sln, soilWater.SW.Sum(), rootShootRatio);

                // Outputs
                SetBiomass(leaf, model.ActualBiomass);
                foreach (ICanopy canopy in plant.FindAllChildren <ICanopy>())
                {
                    canopy.LightProfile = new CanopyEnergyBalanceInterceptionlayerType[1]
                    {
                        new CanopyEnergyBalanceInterceptionlayerType()
                        {
                            AmountOnGreen = model.InterceptedRadiation,
                        }
                    };
                    canopy.PotentialEP = canopy.WaterDemand = model.WaterDemanded;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="CP"></param>
        /// <param name="PP"></param>
        /// <param name="DOY"></param>
        /// <param name="latitude"></param>
        /// <param name="maxT"></param>
        /// <param name="minT"></param>
        /// <param name="radn"></param>
        /// <param name="rpar"></param>
        /// <returns></returns>
        public static DCAPSTModel SetUpModel(
            ICanopyParameters CP,
            IPathwayParameters PP,
            int DOY,
            double latitude,
            double maxT,
            double minT,
            double radn,
            double rpar)
        {
            // Model the solar geometry
            var SG = new SolarGeometry
            {
                Latitude  = latitude.ToRadians(),
                DayOfYear = DOY
            };

            // Model the solar radiation
            var SR = new SolarRadiation(SG)
            {
                Daily = radn,
                RPAR  = rpar
            };

            // Model the environmental temperature
            var TM = new Temperature(SG)
            {
                MaxTemperature      = maxT,
                MinTemperature      = minT,
                AtmosphericPressure = 1.01325
            };

            // Model the pathways
            var SunlitAc1 = new AssimilationPathway(CP, PP);
            var SunlitAc2 = new AssimilationPathway(CP, PP);
            var SunlitAj  = new AssimilationPathway(CP, PP);

            var ShadedAc1 = new AssimilationPathway(CP, PP);
            var ShadedAc2 = new AssimilationPathway(CP, PP);
            var ShadedAj  = new AssimilationPathway(CP, PP);

            // Model the canopy
            IAssimilation A;

            if (CP.Type == CanopyType.C3)
            {
                A = new AssimilationC3(CP, PP);
            }
            else if (CP.Type == CanopyType.C4)
            {
                A = new AssimilationC4(CP, PP);
            }
            else
            {
                A = new AssimilationCCM(CP, PP);
            }

            var sunlit = new AssimilationArea(SunlitAc1, SunlitAc2, SunlitAj, A);
            var shaded = new AssimilationArea(ShadedAc1, ShadedAc2, ShadedAj, A);
            var CA     = new CanopyAttributes(CP, PP, sunlit, shaded);

            // Model the transpiration
            var WI = new WaterInteraction(TM);
            var TR = new TemperatureResponse(CP, PP);
            var TS = new Transpiration(CP, PP, WI, TR);

            // Model the photosynthesis
            var DM = new DCAPSTModel(SG, SR, TM, PP, CA, TS)
            {
                B = 0.409
            };

            return(DM);
        }