コード例 #1
0
ファイル: Cohorts.cs プロジェクト: lie112/ApsimX
        /// <summary>
        /// Senesce any leaves matching the given condition.
        /// </summary>
        /// <param name="predicate">Any leaves matching this predicate will be senesced.</param>
        public void SenesceWhere(Func <PerennialLeafCohort, bool> predicate)
        {
            foreach (PerennialLeafCohort leaf in leaves.Where(predicate))
            {
                leaf.IsSenesced = true;

                if (leaf.Live.Wt > 0)
                {
                    // Move leaf biomass from live to dead pool.
                    live.Subtract(leaf.Live);
                    dead.Add(leaf.Live);

                    // Update the leaf's internal biomass pools.
                    leaf.Dead.Add(leaf.Live);
                    leaf.Senesced.SetTo(leaf.Live);
                    leaf.Live.Clear();

                    // Move leaf area into dead area.
                    leaf.AreaDead += leaf.Area;
                    LaiDead       += leaf.Area;
                    Lai           -= leaf.Area;
                    leaf.Area      = 0;
                }
            }
        }
コード例 #2
0
ファイル: Cohorts.cs プロジェクト: lie112/ApsimX
        /// <summary>
        /// Detach any leaves older than the specified age.
        /// </summary>
        /// <param name="predicate">Any leaves matching this predicate will be deatched..</param>
        public Biomass DetachWhere(Func <PerennialLeafCohort, bool> predicate)
        {
            Biomass detached = new Biomass();

            foreach (PerennialLeafCohort leaf in leaves.Where(predicate))
            {
                detached.Add(leaf.Dead);

                // Need to check this. The assumption here is that leaves will
                // be senesced before they are detached. If this assumption
                // doesn't hold up, mass balance will be violated.
                if (leaf.IsSenesced)
                {
                    LaiDead -= leaf.AreaDead;
                    dead.Subtract(leaf.Senesced);
                }
            }
            leaves.RemoveAll(l => predicate(l));
            return(detached);
        }
コード例 #3
0
ファイル: GenericOrgan.cs プロジェクト: MarkLieffering/ApsimX
        protected void OnDoActualPlantGrowth(object sender, EventArgs e)
        {
            if (Plant.IsAlive)
            {
                // Do senescence
                double senescedFrac = SenescenceRate.Value();
                if (Live.Wt * (1.0 - senescedFrac) < BiomassToleranceValue)
                {
                    senescedFrac = 1.0;  // remaining amount too small, senesce all
                }
                Biomass Loss = Live * senescedFrac;
                Live.Subtract(Loss);
                Dead.Add(Loss);
                Senesced.Add(Loss);

                // Do detachment
                double detachedFrac = DetachmentRateFunction.Value();
                if (Dead.Wt * (1.0 - detachedFrac) < BiomassToleranceValue)
                {
                    detachedFrac = 1.0;  // remaining amount too small, detach all
                }
                Biomass detaching = Dead * detachedFrac;
                Dead.Multiply(1.0 - detachedFrac);
                if (detaching.Wt > 0.0)
                {
                    Detached.Add(detaching);
                    SurfaceOrganicMatter.Add(detaching.Wt * 10, detaching.N * 10, 0, Plant.CropType, Name);
                }

                // Do maintenance respiration
                MaintenanceRespiration += Live.MetabolicWt * MaintenanceRespirationFunction.Value();
                Live.MetabolicWt       *= (1 - MaintenanceRespirationFunction.Value());
                MaintenanceRespiration += Live.StorageWt * MaintenanceRespirationFunction.Value();
                Live.StorageWt         *= (1 - MaintenanceRespirationFunction.Value());
            }
        }