Ejemplo n.º 1
0
    /// <summary>
    /// Returns a clone of this object
    /// </summary>
    public virtual LeafCohort Clone()
    {
        LeafCohort NewLeaf = (LeafCohort)this.MemberwiseClone();

        NewLeaf.Live = new Biomass();
        NewLeaf.Dead = new Biomass();
        return(NewLeaf);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// TODO: This method needs documentation
        /// </summary>
        /// <param name="NewLeaf"></param>
        public void DoCalculations(LeafCohort NewLeaf)
        {
            // update age of cohorts
            for (int i = 0; i < apexGroupAge.Count; i++)
            {
                apexGroupAge[i]++;
            }

            // check for increase in apex size, add new group if needed
            // (ApexNum should be an integer, but need to check in case of flag leaf)
            double deltaApex = apexGroupSize.Sum() - Number;

            if (deltaApex < -1E-12)
            {
                if (apexGroupSize.Count == 0)
                {
                    apexGroupSize.Add(Number);
                }
                else
                {
                    apexGroupSize.Add(Number - apexGroupSize[apexGroupSize.Count - 1]);
                }
                apexGroupAge.Add(1);
            }

            // check for reduction in the apex size
            if ((apexGroupSize.Count > 0) && (deltaApex > 1E-12))
            {
                double remainingRemoveApex = deltaApex;
                for (int i = apexGroupSize.Count - 1; i > 0; i--)
                {
                    double remove = Math.Min(apexGroupSize[i], remainingRemoveApex);
                    apexGroupSize[i]    -= remove;
                    remainingRemoveApex -= remove;
                    if (remainingRemoveApex <= 0.0)
                    {
                        break;
                    }
                }

                if (remainingRemoveApex > 0.0)
                {
                    throw new Exception("There are not enough apex to remove from plant.");
                }
            }
        }
Ejemplo n.º 3
0
    public override void DoPotentialDM()
    {
        EP = 0;
        if ((AppearedCohortNo == (int)Structure.MainStemFinalNodeNo) && (AppearedCohortNo > 0.0) && (AppearedCohortNo < MaxNodeNo)) //If last interger leaf has appeared set the fraction of the final part leaf.
        {
            FinalLeafFraction = Structure.MainStemFinalNodeNo - AppearedCohortNo;
        }

        if (FrostFraction.Value > 0)
        {
            foreach (LeafCohort L in Leaves)
            {
                L.DoFrost(FrostFraction.Value);
            }
        }

        // On the initial day set up initial cohorts and set their properties
        if (Phenology.OnDayOf(Structure.InitialiseStage))
        {
            InitialiseCohorts();
        }

        //When primordia number is 1 more than current cohort number produce a new cohort
        if (Structure.MainStemPrimordiaNo >= Leaves.Count + FinalLeafFraction)
        {
            if (CohortsInitialised == false)
            {
                throw new Exception("Trying to initialse new cohorts prior to InitialStage.  Check the InitialStage parameter on the leaf object and the parameterisation of NodeInitiationRate.  Your NodeInitiationRate is triggering a new leaf cohort before leaves have been initialised.");
            }

            LeafCohort NewLeaf = InitialLeaves[0].Clone();
            NewLeaf.CohortPopulation = 0;
            NewLeaf.Age  = 0;
            NewLeaf.Rank = Math.Truncate(Structure.MainStemNodeNo);
            NewLeaf.Area = 0.0;
            NewLeaf.DoInitialisation();
            Leaves.Add(NewLeaf);
        }

        //When Node number is 1 more than current appeared leaf number make a new leaf appear and start growing
        if ((Structure.MainStemNodeNo >= AppearedCohortNo + FinalLeafFraction) && (FinalLeafFraction > 0.0))
        {
            if (CohortsInitialised == false)
            {
                throw new Exception("Trying to initialse new cohorts prior to InitialStage.  Check the InitialStage parameter on the leaf object and the parameterisation of NodeAppearanceRate.  Your NodeAppearanceRate is triggering a new leaf cohort before the initial leaves have been triggered.");
            }
            if (FinalLeafFraction != 1.0)
            {
                FinalLeafAppeared = true;
            }
            int    AppearingNode = (int)(Structure.MainStemNodeNo + (1 - FinalLeafFraction));
            double CohortAge     = (Structure.MainStemNodeNo - AppearingNode) * Structure.MainStemNodeAppearanceRate.Value * FinalLeafFraction;
            if (AppearingNode > InitialisedCohortNo)
            {
                throw new Exception("MainStemNodeNumber exceeds the number of leaf cohorts initialised.  Check primordia parameters to make sure primordia are being initiated fast enough and for long enough");
            }
            int i = AppearingNode - 1;
            Leaves[i].Rank             = AppearingNode;
            Leaves[i].CohortPopulation = Structure.TotalStemPopn;
            Leaves[i].Age = CohortAge;
            Leaves[i].DoAppearance(FinalLeafFraction);
            if (NewLeaf != null)
            {
                NewLeaf.Invoke();
            }
        }

        FractionNextleafExpanded = 0;
        bool NextExpandingLeaf = false;

        foreach (LeafCohort L in Leaves)
        {
            L.DoPotentialGrowth(_ThermalTime);
            if ((L.IsFullyExpanded == false) && (NextExpandingLeaf == false))
            {
                NextExpandingLeaf = true;
                if (CurrentExpandingLeaf != L.Rank)
                {
                    CurrentExpandingLeaf  = L.Rank;
                    StartFractionExpanded = L.FractionExpanded;
                }
                FractionNextleafExpanded = (L.FractionExpanded - StartFractionExpanded) / (1 - StartFractionExpanded);
            }
        }
        _ExpandedNodeNo = ExpandedCohortNo + FractionNextleafExpanded;
    }