Ejemplo n.º 1
0
 private double GetSln(ICanopy leaf)
 {
     if (leaf is SorghumLeaf sorghumLeaf)
     {
         return(sorghumLeaf.SLN);
     }
     if (leaf is IArbitration arbitration)
     {
         return(arbitration.Live.N / leaf.LAI);
     }
     throw new InvalidOperationException($"Unable to calculate SLN from leaf type {leaf.GetType()}");
 }
Ejemplo n.º 2
0
 private void SetBiomass(ICanopy leaf, double actualBiomass)
 {
     if (leaf is SorghumLeaf sorghumLeaf)
     {
         sorghumLeaf.BiomassRUE = actualBiomass;
         sorghumLeaf.BiomassTE  = actualBiomass;
     }
     else if (leaf is Leaf complexLeaf)
     {
         complexLeaf.DMSupply.Fixation = actualBiomass;
     }
     else
     {
         throw new InvalidOperationException($"Unable to set biomass from unknown leaf type {leaf.GetType()}");
     }
 }
Ejemplo n.º 3
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;
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>Constructor</summary>
 /// <param name="canopy">The canopy to wrap.</param>
 public CanopyType(ICanopy canopy)
 {
     Canopy = canopy;
 }
Ejemplo n.º 5
0
 /// <summary>Constructor</summary>
 /// <param name="canopy">The canopy to wrap.</param>
 public CanopyType(ICanopy canopy)
 {
     Canopy = canopy;
 }
Ejemplo n.º 6
0
 /// <summary>Constructor</summary>
 /// <param name="canopy">The canopy to wrap.</param>
 public MicroClimateCanopy(ICanopy canopy)
 {
     Canopy = canopy;
 }