Пример #1
0
 /// <summary> Called on the day of emergence to get the initials leaf cohorts to appear </summary>
 private void DoLeafInitilisation()
 {
     CohortToInitialise = leaf.CohortsAtInitialisation;
     for (int i = 1; i <= leaf.TipsAtEmergence; i++)
     {
         InitParams           = new CohortInitParams();
         PotLeafTipsAppeared += 1;
         CohortToInitialise  += 1;
         InitParams.Rank      = CohortToInitialise;
         AddLeafCohort?.Invoke(this, InitParams);
         DoLeafTipAppearance();
         leavesInitialised = true;
         firstPass         = true;
     }
 }
Пример #2
0
 /// <summary>
 /// Called on the day of emergence to get the initials leaf cohorts to appear
 /// </summary>
 public void DoEmergence()
 {
     CohortToInitialise = Leaf.CohortsAtInitialisation;
     for (int i = 1; i <= Leaf.TipsAtEmergence; i++)
     {
         InitParams           = new CohortInitParams();
         PotLeafTipsAppeared += 1;
         CohortToInitialise  += 1;
         InitParams.Rank      = CohortToInitialise;
         if (AddLeafCohort != null)
         {
             AddLeafCohort.Invoke(this, InitParams);
         }
         DoLeafTipAppearance();
     }
 }
Пример #3
0
        /// <summary>
        /// Removes nodes from main-stem in defoliation event
        /// </summary>
        /// <param name="NodesToRemove"></param>
        public void doNodeRemoval(int NodesToRemove)
        {
            //Remove nodes from Structure properties
            LeafTipsAppeared    = Math.Max(LeafTipsAppeared - NodesToRemove, 0);
            PotLeafTipsAppeared = Math.Max(PotLeafTipsAppeared - NodesToRemove, 0);

            //Remove corresponding cohorts from leaf
            int NodesStillToRemove = Math.Min(NodesToRemove + Leaf.ApicalCohortNo, Leaf.InitialisedCohortNo);

            while (NodesStillToRemove > 0)
            {
                TipToAppear        -= 1;
                CohortToInitialise -= 1;
                Leaf.RemoveHighestLeaf();
                NodesStillToRemove -= 1;
            }
            TipToAppear        = Math.Max(TipToAppear + Leaf.CohortsAtInitialisation, 1);
            CohortToInitialise = Math.Max(CohortToInitialise, 1);
            //Reinitiate apical cohorts ready for regrowth
            if (Leaf.InitialisedCohortNo > 0) //Sone cohorts remain after defoliation
            {
                for (int i = 1; i <= Leaf.CohortsAtInitialisation; i++)
                {
                    InitParams          = new CohortInitParams();
                    CohortToInitialise += 1;
                    InitParams.Rank     = CohortToInitialise;
                    if (AddLeafCohort != null)
                    {
                        AddLeafCohort.Invoke(this, InitParams);
                    }
                }
            }
            else   //If all nodes have been removed initalise again
            {
                Leaf.Reset();
                InitialiseLeafCohorts.Invoke(this, args);
                Initialised = true;
                DoEmergence();
            }
        }
Пример #4
0
        /// <summary> Removes nodes from main-stem in defoliation event  </summary>
        public void DoNodeRemoval(int NodesToRemove)
        {
            //Remove nodes from Structure properties
            LeafTipsAppeared    = Math.Max(LeafTipsAppeared - NodesToRemove, 0);
            PotLeafTipsAppeared = Math.Max(PotLeafTipsAppeared - NodesToRemove, 0);

            //Remove corresponding cohorts from leaf
            int NodesStillToRemove = Math.Min(NodesToRemove + leaf.ApicalCohortNo, leaf.InitialisedCohortNo);

            while (NodesStillToRemove > 0)
            {
                TipToAppear        -= 1;
                CohortToInitialise -= 1;
                leaf.RemoveHighestLeaf();
                NodesStillToRemove -= 1;
            }
            //TipToAppear = Math.Max(TipToAppear + leaf.CohortsAtInitialisation, 1);
            CohortToInitialise = Math.Max(CohortToInitialise, 1);
            if (CohortToInitialise == LeafTipsAppeared) // If leaf appearance had reached final leaf number need to add another cohort back to get things moving again.
            {
                CohortToInitialise += 1;
            }
            InitParams = new CohortInitParams()
            {
            };
            InitParams.Rank = CohortToInitialise;
            if (AddLeafCohort != null)
            {
                AddLeafCohort.Invoke(this, InitParams);
            }
            //Reinitiate apical cohorts ready for regrowth
            if (leaf.InitialisedCohortNo == 0) //If all nodes have been removed initalise again
            {
                leaf.Reset();
                InitialiseLeafCohorts.Invoke(this, new EventArgs());
                DoLeafInitilisation();
            }
        }
Пример #5
0
        private void OnDoPotentialPlantGrowth(object sender, EventArgs e)
        {
            if (cohortsInitialised)
            {
                DeltaHaunStage = 0;
                if (phyllochron.Value() > 0)
                {
                    DeltaHaunStage = thermalTime.Value() / phyllochron.Value();
                }
                if (leavesInitialised)
                {
                    bool AllCohortsInitialised = (leaf.InitialisedCohortNo >= finalLeafNumber.Value());
                    AllLeavesAppeared = (leaf.AppearedCohortNo == leaf.InitialisedCohortNo);
                    bool LastLeafAppearing = ((Math.Truncate(LeafTipsAppeared) + 1) == leaf.InitialisedCohortNo);

                    if ((AllCohortsInitialised) && (LastLeafAppearing))
                    {
                        // fixme - this guard is really a bandaid over some problems in the leaf cohort code
                        // which seems to assume that growth duration is never 0. Can't set NextLeafProp to
                        // 0, because then GrowthDuration will be 0. However it can be close to 0 if final leaf #
                        // happens to have a very small fractional part (e.g. 14.00001).
                        // If your crop is never progressing to flag leaf, this might be why (try reducing epsilon).
                        NextLeafProportion = Math.Max(1e-10, 1 - (leaf.InitialisedCohortNo - finalLeafNumber.Value()));
                    }
                    else
                    {
                        NextLeafProportion = 1.0;
                    }

                    //Increment MainStemNode Number based on phyllochorn and theremal time
                    if (firstPass == true)
                    {
                        firstPass      = false;
                        DeltaTipNumber = 0; //Don't increment node number on day of emergence
                    }
                    else
                    {
                        DeltaTipNumber = DeltaHaunStage; //DeltaTipNumber is only positive after emergence whereas deltaHaunstage is positive from germination
                    }

                    PotLeafTipsAppeared += DeltaTipNumber;
                    LeafTipsAppeared     = Math.Min(PotLeafTipsAppeared, finalLeafNumber.Value());

                    TimeForAnotherLeaf = PotLeafTipsAppeared >= (leaf.AppearedCohortNo + 1);
                    int LeavesToAppear = (int)(LeafTipsAppeared - (leaf.AppearedCohortNo - (1 - NextLeafProportion)));

                    //Each time main-stem node number increases by one or more initiate the additional cohorts until final leaf number is reached
                    if (TimeForAnotherLeaf && (AllCohortsInitialised == false))
                    {
                        int i = 1;
                        for (i = 1; i <= LeavesToAppear; i++)
                        {
                            CohortToInitialise += 1;
                            InitParams          = new CohortInitParams()
                            {
                            };
                            InitParams.Rank = CohortToInitialise;
                            if (AddLeafCohort != null)
                            {
                                AddLeafCohort.Invoke(this, InitParams);
                            }
                        }
                    }

                    //Each time main-stem node number increases by one appear another cohort until all cohorts have appeared
                    if (TimeForAnotherLeaf && (AllLeavesAppeared == false))
                    {
                        int i = 1;
                        for (i = 1; i <= LeavesToAppear; i++)
                        {
                            TotalStemPopn += branchingRate.Value() * MainStemPopn;
                            BranchNumber  += branchingRate.Value();

                            TotalLeavesPerShoot += BranchNumber + 1;
                            DoLeafTipAppearance();
                        }
                    }

                    //Reduce population if there has been plant mortality
                    if (DeltaPlantPopulation > 0)
                    {
                        TotalStemPopn -= DeltaPlantPopulation * TotalStemPopn / plant.Population;
                    }

                    //Reduce stem number incase of mortality
                    double PropnMortality = 0;
                    PropnMortality = branchMortality.Value();
                    {
                        double DeltaPopn = Math.Min(PropnMortality * (TotalStemPopn - MainStemPopn), TotalStemPopn - plant.Population);
                        TotalStemPopn            -= DeltaPopn;
                        ProportionBranchMortality = PropnMortality;
                    }
                }
            }
        }
Пример #6
0
        private void OnDoPotentialPlantGrowth(object sender, EventArgs e)
        {
            if (Plant.IsGerminated)
            {
                DeltaHaunStage = 0;
                if (Phyllochron.Value() > 0)
                {
                    DeltaHaunStage = ThermalTime.Value() / Phyllochron.Value();
                }

                if (Germinated == false) // We have no leaves set up and nodes have just started appearing - Need to initialise Leaf cohorts
                {
                    Germinated = true;
                    //On the day of germination set up the first cohorts
                    if (InitialiseLeafCohorts != null)
                    {
                        InitialiseLeafCohorts.Invoke(this, args);
                    }
                    Initialised = true;
                }

                if (Plant.IsEmerged)
                {
                    if (Emerged == false)
                    {
                        NextLeafProportion = 1.0;
                        DoEmergence();
                    }

                    bool AllCohortsInitialised = (Leaf.InitialisedCohortNo >= FinalLeafNumber.Value());
                    bool AllLeavesAppeared     = (Leaf.AppearedCohortNo == Leaf.InitialisedCohortNo);
                    bool LastLeafAppearing     = ((Math.Truncate(LeafTipsAppeared) + 1) == Leaf.InitialisedCohortNo);

                    if ((AllCohortsInitialised) && (LastLeafAppearing))
                    {
                        NextLeafProportion = 1 - (Leaf.InitialisedCohortNo - FinalLeafNumber.Value());
                    }
                    else
                    {
                        NextLeafProportion = 1.0;
                    }

                    //Increment MainStemNode Number based on phyllochorn and theremal time
                    if (Emerged == false)
                    {
                        Emerged        = true;
                        DeltaTipNumber = 0; //Don't increment node number on day of emergence
                    }
                    else
                    {
                        DeltaTipNumber = DeltaHaunStage; //DeltaTipNumber is only positive after emergence whereas deltaHaunstage is positive from germination
                    }

                    PotLeafTipsAppeared += DeltaTipNumber;
                    //if (PotLeafTipsAppeared > MainStemFinalNodeNumber.Value)
                    //    FinalLeafDeltaTipNumberonDayOfAppearance = PotLeafTipsAppeared - MainStemFinalNodeNumber.Value;
                    LeafTipsAppeared = Math.Min(PotLeafTipsAppeared, FinalLeafNumber.Value());

                    bool TimeForAnotherLeaf = PotLeafTipsAppeared >= (Leaf.AppearedCohortNo + 1);
                    int  LeavesToAppear     = (int)(LeafTipsAppeared - (Leaf.AppearedCohortNo - (1 - NextLeafProportion)));

                    //Each time main-stem node number increases by one or more initiate the additional cohorts until final leaf number is reached
                    if (TimeForAnotherLeaf && (AllCohortsInitialised == false))
                    {
                        int i = 1;
                        for (i = 1; i <= LeavesToAppear; i++)
                        {
                            CohortToInitialise += 1;
                            InitParams          = new CohortInitParams()
                            {
                            };
                            InitParams.Rank = CohortToInitialise;
                            if (AddLeafCohort != null)
                            {
                                AddLeafCohort.Invoke(this, InitParams);
                            }
                        }
                    }

                    //Each time main-stem node number increases by one appear another cohort until all cohorts have appeared
                    if (TimeForAnotherLeaf && (AllLeavesAppeared == false))
                    {
                        int i = 1;
                        for (i = 1; i <= LeavesToAppear; i++)
                        {
                            TotalStemPopn += BranchingRate.Value() * MainStemPopn;
                            BranchNumber  += BranchingRate.Value();
                            DoLeafTipAppearance();
                        }
                        // Apex calculation
                        ApexNum += (BranchingRate.Value() - BranchMortality.Value()) * PrimaryBudNo;

                        if (Phenology.Stage > 4 & !SenescenceByAge)
                        {
                            double senescenceNum = Leaf.ApexNumByAge(StemSenescenceAge.Value());
                            ApexNum        -= senescenceNum;
                            SenescenceByAge = true;
                            TotalStemPopn  -= senescenceNum * Plant.Population;
                        }
                    }

                    //Reduce population if there has been plant mortality
                    if (DeltaPlantPopulation > 0)
                    {
                        TotalStemPopn -= DeltaPlantPopulation * TotalStemPopn / Plant.Population;
                    }

                    //Reduce stem number incase of mortality
                    double PropnMortality = 0;
                    PropnMortality = BranchMortality.Value();
                    {
                        double DeltaPopn = Math.Min(PropnMortality * (TotalStemPopn - MainStemPopn), TotalStemPopn - Plant.Population);
                        TotalStemPopn            -= DeltaPopn;
                        ProportionBranchMortality = PropnMortality;
                    }
                }
            }
        }
Пример #7
0
        private void OnDoPotentialPlantGrowth(object sender, EventArgs e)
        {
            if (cohortsInitialised)
            {
                DeltaHaunStage = 0;
                if (phyllochron.Value() > 0)
                {
                    DeltaHaunStage = thermalTime.Value() / phyllochron.Value();
                }
                if (leavesInitialised)
                {
                    bool AllCohortsInitialised = (leaf.InitialisedCohortNo >= finalLeafNumber.Value());
                    AllLeavesAppeared = (leaf.AppearedCohortNo == leaf.InitialisedCohortNo);
                    bool LastLeafAppearing = ((Math.Truncate(LeafTipsAppeared) + 1) == leaf.InitialisedCohortNo);

                    if ((AllCohortsInitialised) && (LastLeafAppearing))
                    {
                        NextLeafProportion = 1 - (leaf.InitialisedCohortNo - finalLeafNumber.Value());
                    }
                    else
                    {
                        NextLeafProportion = 1.0;
                    }

                    //Increment MainStemNode Number based on phyllochorn and theremal time
                    if (firstPass == true)
                    {
                        firstPass      = false;
                        DeltaTipNumber = 0; //Don't increment node number on day of emergence
                    }
                    else
                    {
                        DeltaTipNumber = DeltaHaunStage; //DeltaTipNumber is only positive after emergence whereas deltaHaunstage is positive from germination
                    }

                    PotLeafTipsAppeared += DeltaTipNumber;
                    LeafTipsAppeared     = Math.Min(PotLeafTipsAppeared, finalLeafNumber.Value());

                    TimeForAnotherLeaf = PotLeafTipsAppeared >= (leaf.AppearedCohortNo + 1);
                    int LeavesToAppear = (int)(LeafTipsAppeared - (leaf.AppearedCohortNo - (1 - NextLeafProportion)));

                    //Each time main-stem node number increases by one or more initiate the additional cohorts until final leaf number is reached
                    if (TimeForAnotherLeaf && (AllCohortsInitialised == false))
                    {
                        int i = 1;
                        for (i = 1; i <= LeavesToAppear; i++)
                        {
                            CohortToInitialise += 1;
                            InitParams          = new CohortInitParams()
                            {
                            };
                            InitParams.Rank = CohortToInitialise;
                            if (AddLeafCohort != null)
                            {
                                AddLeafCohort.Invoke(this, InitParams);
                            }
                        }
                    }

                    //Each time main-stem node number increases by one appear another cohort until all cohorts have appeared
                    if (TimeForAnotherLeaf && (AllLeavesAppeared == false))
                    {
                        int i = 1;
                        for (i = 1; i <= LeavesToAppear; i++)
                        {
                            TotalStemPopn += branchingRate.Value() * MainStemPopn;
                            BranchNumber  += branchingRate.Value();
                            DoLeafTipAppearance();
                        }
                    }

                    //Reduce population if there has been plant mortality
                    if (DeltaPlantPopulation > 0)
                    {
                        TotalStemPopn -= DeltaPlantPopulation * TotalStemPopn / plant.Population;
                    }

                    //Reduce stem number incase of mortality
                    double PropnMortality = 0;
                    PropnMortality = branchMortality.Value();
                    {
                        double DeltaPopn = Math.Min(PropnMortality * (TotalStemPopn - MainStemPopn), TotalStemPopn - plant.Population);
                        TotalStemPopn            -= DeltaPopn;
                        ProportionBranchMortality = PropnMortality;
                    }
                }
            }
        }