예제 #1
0
        /// <summary>Harvest the crop.</summary>
        public void RemoveBiomass(string biomassRemoveType, RemovalFractions removalData = null)
        {
            summary.WriteMessage(this, string.Format("Biomass removed from crop " + Name + " by " + biomassRemoveType.TrimEnd('e') + "ing"));

            // Invoke specific defoliation events.
            if (biomassRemoveType == "Harvest" && Harvesting != null)
            {
                Harvesting.Invoke(this, new EventArgs());
            }

            if (biomassRemoveType == "Prune" && Pruning != null)
            {
                Pruning.Invoke(this, new EventArgs());
            }

            if (biomassRemoveType == "LeafPluck" && LeafPlucking != null)
            {
                LeafPlucking.Invoke(this, new EventArgs());
            }

            if (biomassRemoveType == "Cut" && Cutting != null)
            {
                Cutting.Invoke(this, new EventArgs());
            }

            if (biomassRemoveType == "Graze" && Grazing != null)
            {
                Grazing.Invoke(this, new EventArgs());
            }

            // Set up the default BiomassRemovalData values
            foreach (IOrgan organ in Organs)
            {
                // Get the default removal fractions
                OrganBiomassRemovalType biomassRemoval = null;
                if (removalData != null)
                {
                    biomassRemoval = removalData.GetFractionsForOrgan(organ.Name);
                }
                organ.RemoveBiomass(biomassRemoveType, biomassRemoval);
            }

            // Reset the phenology if SetPhenologyStage specified.
            if (removalData != null && removalData.SetPhenologyStage != 0 && Phenology is Phenology phenology)
            {
                phenology.SetToStage(removalData.SetPhenologyStage);
            }

            // Reduce plant and stem population if thinning proportion specified
            if (removalData != null && removalData.SetThinningProportion != 0 && structure != null)
            {
                structure.DoThin(removalData.SetThinningProportion);
            }

            // Remove nodes from the main-stem
            if (removalData != null && removalData.NodesToRemove > 0)
            {
                structure.DoNodeRemoval(removalData.NodesToRemove);
            }
        }
예제 #2
0
        /// <summary>
        /// Remove biomass from an organ.
        /// </summary>
        /// <param name="organName">Name of organ.</param>
        /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
        /// <param name="biomassToRemove">Biomass to remove.</param>
        public void RemoveBiomass(string organName, string biomassRemoveType, OrganBiomassRemovalType biomassToRemove)
        {
            var organ = Organs.FirstOrDefault(o => o.Name.Equals(organName, StringComparison.InvariantCultureIgnoreCase));

            if (organ == null)
            {
                throw new Exception("Cannot find organ to remove biomass from. Organ: " + organName);
            }
            organ.RemoveBiomass(biomassRemoveType, biomassToRemove);

            // Also need to reduce LAI if canopy.
            if (organ is ICanopy)
            {
                var totalFractionToRemove = biomassToRemove.FractionLiveToRemove + biomassToRemove.FractionLiveToResidue;
                var leaf = Organs.FirstOrDefault(o => o is ICanopy) as ICanopy;
                var lai  = leaf.LAI;
                ReduceCanopy(lai * totalFractionToRemove);
            }
        }
예제 #3
0
파일: Plant.cs 프로젝트: cla473/ApsimX
        /// <summary>Harvest the crop.</summary>
        public void RemoveBiomass(string biomassRemoveType, RemovalFractions removalData = null)
        {
            // Invoke an event.
            if (biomassRemoveType == "Harvest" && Harvesting != null)
            {
                Harvesting.Invoke(this, new EventArgs());
            }
            Summary.WriteMessage(this, string.Format("Biomass removed from crop " + Name + " by " + biomassRemoveType.TrimEnd('e') + "ing"));

            // Set up the default BiomassRemovalData values
            foreach (IOrgan organ in Organs)
            {
                // Get the default removal fractions
                OrganBiomassRemovalType biomassRemoval = null;
                if (removalData != null)
                {
                    biomassRemoval = removalData.GetFractionsForOrgan(organ.Name);
                }
                organ.DoRemoveBiomass(biomassRemoveType, biomassRemoval);
            }

            // Reset the phenology if SetPhenologyStage specified.
            if (removalData != null && removalData.SetPhenologyStage != 0)
            {
                Phenology.ReSetToStage(removalData.SetPhenologyStage);
            }

            // Reduce plant and stem population if thinning proportion specified
            if (removalData != null && removalData.SetThinningProportion != 0)
            {
                Structure.doThin(removalData.SetThinningProportion);
            }

            // Pruning event (winter pruning, summer pruning is called as cut) reset the phenology if SetPhenologyStage specified.
            if (biomassRemoveType == "Prune" && Pruning != null)
            {
                Pruning.Invoke(this, new EventArgs());
            }
        }
 /// <summary>Adds a removal type to the defaultRemovalFractions</summary>
 /// <param name="typeName">The name of the removal type</param>
 /// <param name="removalFractions">Default removal fractions</param>
 internal void SetRemovalFractions(string typeName, OrganBiomassRemovalType removalFractions)
 {
     defaultRemovalFractions.Add(typeName, removalFractions);
 }
예제 #5
0
        /// <summary>Initialises the default biomass removal fractions</summary>
        private void InitBiomassRemovals()
        {
            // leaves, harvest
            OrganBiomassRemovalType removalFractions = new OrganBiomassRemovalType();
            removalFractions.FractionLiveToRemove = 0.5;
            removalFractions.FractionDeadToRemove = 0.5;
            removalFractions.FractionLiveToResidue = 0.0;
            removalFractions.FractionDeadToResidue = 0.0;
            leaves.SetRemovalFractions("Harvest", removalFractions);
            // graze
            removalFractions.FractionLiveToRemove = 0.5;
            removalFractions.FractionDeadToRemove = 0.5;
            removalFractions.FractionLiveToResidue = 0.0;
            removalFractions.FractionDeadToResidue = 0.0;
            leaves.SetRemovalFractions("Graze", removalFractions);
            // Cut
            removalFractions.FractionLiveToRemove = 0.5;
            removalFractions.FractionDeadToRemove = 0.5;
            removalFractions.FractionLiveToResidue = 0.0;
            removalFractions.FractionDeadToResidue = 0.0;
            leaves.SetRemovalFractions("Cut", removalFractions);

            // stems, harvest
            removalFractions.FractionLiveToRemove = 0.5;
            removalFractions.FractionDeadToRemove = 0.5;
            removalFractions.FractionLiveToResidue = 0.0;
            removalFractions.FractionDeadToResidue = 0.0;
            stems.SetRemovalFractions("Harvest", removalFractions);
            // graze
            removalFractions.FractionLiveToRemove = 0.5;
            removalFractions.FractionDeadToRemove = 0.5;
            removalFractions.FractionLiveToResidue = 0.0;
            removalFractions.FractionDeadToResidue = 0.0;
            stems.SetRemovalFractions("Graze", removalFractions);
            // Cut
            removalFractions.FractionLiveToRemove = 0.5;
            removalFractions.FractionDeadToRemove = 0.5;
            removalFractions.FractionLiveToResidue = 0.0;
            removalFractions.FractionDeadToResidue = 0.0;
            stems.SetRemovalFractions("Cut", removalFractions);

            // Stolons, harvest
            removalFractions.FractionLiveToRemove = 0.5;
            removalFractions.FractionDeadToRemove = 0.0;
            removalFractions.FractionLiveToResidue = 0.0;
            removalFractions.FractionDeadToResidue = 0.0;
            stolons.SetRemovalFractions("Harvest", removalFractions);
            // graze
            removalFractions.FractionLiveToRemove = 0.5;
            removalFractions.FractionDeadToRemove = 0.0;
            removalFractions.FractionLiveToResidue = 0.0;
            removalFractions.FractionDeadToResidue = 0.0;
            stolons.SetRemovalFractions("Graze", removalFractions);
            // Cut
            removalFractions.FractionLiveToRemove = 0.5;
            removalFractions.FractionDeadToRemove = 0.0;
            removalFractions.FractionLiveToResidue = 0.0;
            removalFractions.FractionDeadToResidue = 0.0;
            stolons.SetRemovalFractions("Cut", removalFractions);
        }
예제 #6
0
        /// <summary>Harvest the crop.</summary>
        public void RemoveBiomass(string biomassRemoveType, RemovalFractions removalData = null)
        {
            // Set up the default BiomassRemovalData values
            RemovingBiomassArgs allData = new RemovingBiomassArgs();

            allData.biomassRemoveType = biomassRemoveType;
            foreach (IOrgan organ in Organs)
            {
                OrganBiomassRemovalType biomassRemoved = Apsim.Get(organ as IModel, "BiomassRemovalDefaults." + biomassRemoveType) as OrganBiomassRemovalType;
                if (biomassRemoved == null)
                {
                    throw new Exception("Cannot find biomass removal defaults: " + organ.Name + ".BiomassRemovalDefaults.Harvest");
                }

                // Override the defaults if values were supplied as arguments.
                if (removalData != null)
                {
                    OrganBiomassRemovalType userFractions = removalData.GetFractionsForOrgan(organ.Name);
                    if (userFractions != null)
                    {
                        if (userFractions.FractionRemoved >= 0)
                        {
                            biomassRemoved.FractionRemoved = userFractions.FractionRemoved;
                        }
                        if (userFractions.FractionToResidue >= 0)
                        {
                            biomassRemoved.FractionToResidue = userFractions.FractionToResidue;
                        }
                    }
                }
                allData.removalData.Add(organ.Name, biomassRemoved);
            }

            Summary.WriteMessage(this, string.Format("Biomass removed from crop " + Name + " by " + biomassRemoveType + "ing"));

            // Invoke an event.
            if (biomassRemoveType == "Harvest" && Harvesting != null)
            {
                Harvesting.Invoke(this, new EventArgs());
            }
            else if (RemovingBiomass != null)
            {
                RemovingBiomass.Invoke(this, allData);
            }

            // Remove the biomass
            foreach (IOrgan organ in Organs)
            {
                organ.DoRemoveBiomass(allData.removalData[organ.Name]);
            }

            // Reset the phenology if SetPhenologyStage specified.
            if (removalData != null && removalData.SetPhenologyStage != 0)
            {
                Phenology.ReSetToStage(removalData.SetPhenologyStage);
            }

            // Reduce plant and stem population if thinning proportion specified
            if (removalData != null && removalData.SetThinningProportion != 0)
            {
                Structure.doThin(removalData.SetThinningProportion);
            }
        }