/// <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); } }
/// <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>Harvest the crop.</summary> public void Harvest(RemovalFractions removalData) { RemoveBiomass("Harvest", removalData); }
/// <summary>Removes part of the crop biomass.</summary> public void RemoveBiomass(string removalType, RemovalFractions removalData = null) { // Get the fractions to remove from leaves double[][] removalFractions = new double[4][]; removalFractions[0] = new double[2]; OrganBiomassRemovalType defaultFractions = leaves.GetRemovalFractions(removalType); OrganBiomassRemovalType userFractions = removalData.GetFractionsForOrgan("Leaves"); if (userFractions == null) { if (defaultFractions == null) throw new ApsimXException(this, "Could not find biomass removal defaults for " + removalType + " and no removal fractions were supplied for leaves"); else { removalFractions[0][0] = defaultFractions.FractionLiveToRemove + defaultFractions.FractionLiveToResidue; removalFractions[0][1] = defaultFractions.FractionDeadToRemove + defaultFractions.FractionDeadToResidue; } } else { removalFractions[0][0] = MathUtilities.Bound(userFractions.FractionLiveToRemove + userFractions.FractionLiveToResidue, 0.0, 1.0); removalFractions[0][1] = MathUtilities.Bound(userFractions.FractionDeadToRemove + userFractions.FractionDeadToResidue, 0.0, 1.0); } // Get the fractions to remove from stems removalFractions[1] = new double[2]; defaultFractions = stems.GetRemovalFractions(removalType); userFractions = removalData.GetFractionsForOrgan("Stems"); if (userFractions == null) { if (defaultFractions == null) throw new ApsimXException(this, "Could not find biomass removal defaults for " + removalType + " and no removal fractions were supplied for stems"); else { removalFractions[1][0] = defaultFractions.FractionLiveToRemove + defaultFractions.FractionLiveToResidue; removalFractions[1][1] = defaultFractions.FractionDeadToRemove + defaultFractions.FractionDeadToResidue; } } else { removalFractions[1][0] = MathUtilities.Bound(userFractions.FractionLiveToRemove + userFractions.FractionLiveToResidue, 0.0, 1.0); removalFractions[1][1] = MathUtilities.Bound(userFractions.FractionDeadToRemove + userFractions.FractionDeadToResidue, 0.0, 1.0); } // Get the fractions to remove from stolons removalFractions[2] = new double[2]; defaultFractions = stolons.GetRemovalFractions(removalType); userFractions = removalData.GetFractionsForOrgan("Stolons"); if (userFractions == null) { if (defaultFractions == null) throw new ApsimXException(this, "Could not find biomass removal defaults for " + removalType + " and no removal fractions were supplied for stolons"); else { removalFractions[2][0] = defaultFractions.FractionLiveToRemove + defaultFractions.FractionLiveToResidue; removalFractions[2][1] = defaultFractions.FractionDeadToRemove + defaultFractions.FractionDeadToResidue; } } else { removalFractions[2][0] = MathUtilities.Bound(userFractions.FractionLiveToRemove + userFractions.FractionLiveToResidue, 0.0, 1.0); removalFractions[2][1] = MathUtilities.Bound(userFractions.FractionDeadToRemove + userFractions.FractionDeadToResidue, 0.0, 1.0); } // Get the total amount required to remove double amountToRemove = (leaves.DMLiveHarvestable - leaves.MinimumLiveDM) * removalFractions[0][0]; amountToRemove += leaves.DMDeadHarvestable * removalFractions[0][1]; amountToRemove += (stems.DMLiveHarvestable - stems.MinimumLiveDM) * removalFractions[1][0]; amountToRemove += stems.DMDeadHarvestable * removalFractions[1][1]; amountToRemove += (stolons.DMLiveHarvestable - stolons.MinimumLiveDM * stolons.FractionStanding) * removalFractions[2][0]; amountToRemove += stolons.DMDeadHarvestable * removalFractions[2][1]; // get digestibility of DM being harvested (do this before updating pools) double greenDigestibility = (leaves.DigestibilityLive * removalFractions[0][0]) + (stems.DigestibilityLive * removalFractions[1][0]) + (stolons.DigestibilityLive * removalFractions[2][0]); double deadDigestibility = (leaves.DigestibilityDead * removalFractions[0][1]) + (stems.DigestibilityDead * removalFractions[1][1]); defoliatedDigestibility = greenDigestibility + deadDigestibility; // Remove the biomass double preRemovalDM = AboveGroundWt; double preRemovalN = AboveGroundN; DoRemoveBiomass(removalFractions); // Check balance and set outputs defoliatedDM = preRemovalDM - AboveGroundWt; defoliatedN = preRemovalN - AboveGroundN; if (Math.Abs(defoliatedDM - amountToRemove) > Epsilon) throw new Exception(" AgPasture - biomass removal resulted in loss of mass balance"); else mySummary.WriteMessage(this, "Biomass removed from " + Name + " by " + removalType + "ing: " + defoliatedDM.ToString("#0.0") + "kg/ha"); // Update LAI and herbage digestibility EvaluateLAI(); EvaluateDigestibility(); }
/// <summary>Harvests the crop.</summary> /// <param name="removalData">type and fraction to remove</param> public void Harvest(RemovalFractions removalData) { RemoveBiomass("Harvest", removalData); }
/// <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 + "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>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); } }
/// <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) { // Get the default removal fractions OrganBiomassRemovalType biomassRemoval = Apsim.Get(organ as IModel, "BiomassRemovalDefaults." + biomassRemoveType) as OrganBiomassRemovalType; if (biomassRemoval == null) throw new Exception("Cannot find biomass removal defaults: " + organ.Name + ".BiomassRemovalDefaults." + biomassRemoveType); // Override the defaults if values were supplied as arguments if (removalData != null) { OrganBiomassRemovalType userFractions = removalData.GetFractionsForOrgan(organ.Name); if (userFractions != null) { if(!MathUtilities.FloatsAreEqual(userFractions.FractionLiveToRemove, biomassRemoval.FractionLiveToRemove, 1E-9)) biomassRemoval.FractionLiveToRemove = userFractions.FractionLiveToRemove; if (!MathUtilities.FloatsAreEqual(userFractions.FractionDeadToRemove, biomassRemoval.FractionDeadToRemove, 1E-9)) biomassRemoval.FractionDeadToRemove = userFractions.FractionDeadToRemove; if (!MathUtilities.FloatsAreEqual(userFractions.FractionLiveToResidue, biomassRemoval.FractionLiveToResidue, 1E-9)) biomassRemoval.FractionLiveToResidue = userFractions.FractionLiveToResidue; if (!MathUtilities.FloatsAreEqual(userFractions.FractionDeadToResidue, biomassRemoval.FractionDeadToResidue, 1E-9)) biomassRemoval.FractionDeadToResidue = userFractions.FractionDeadToResidue; } } allData.removalData.Add(organ.Name, biomassRemoval); } 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); }