예제 #1
0
파일: BaseOrgan.cs 프로젝트: pre078/ApsimX
        /// <summary>Removes biomass from organs when harvest, graze or cut events are called.</summary>
        /// <param name="value">Biomass to remove</param>
        virtual public void DoRemoveBiomass(OrganBiomassRemovalType value)
        {
            double RemainFrac = 1 - (value.FractionToResidue + value.FractionRemoved);

            if (RemainFrac < 0)
            {
                throw new Exception("The sum of FractionToResidue and FractionRemoved sent with your " + "!!!!PLACE HOLDER FOR EVENT SENDER!!!!" + " is greater than 1.  Had this execption not triggered you would be removing more biomass from " + Name + " than there is to remove");
            }
            if (RemainFrac < 1)
            {
                double TotalFracRemoved = value.FractionRemoved + value.FractionToResidue;
                double PcToResidue      = value.FractionToResidue / TotalFracRemoved * 100;
                double PcRemoved        = value.FractionRemoved / TotalFracRemoved * 100;
                Summary.WriteMessage(this, "Removing " + TotalFracRemoved * 100 + "% of " + Name + " Biomass from " + Plant.Name + ".  Of this " + PcRemoved + "% is removed from the system and " + PcToResidue + "% is returned to the surface organic matter");

                SurfaceOrganicMatter.Add(Wt * 10 * value.FractionToResidue, N * 10 * value.FractionToResidue, 0, Plant.CropType, Name);
                if (Live.StructuralWt > 0)
                {
                    Live.StructuralWt *= RemainFrac;
                }
                if (Live.NonStructuralWt > 0)
                {
                    Live.NonStructuralWt *= RemainFrac;
                }
                if (Live.StructuralN > 0)
                {
                    Live.StructuralN *= RemainFrac;
                }
                if (Live.NonStructuralN > 0)
                {
                    Live.NonStructuralN *= RemainFrac;
                }
            }
        }
예제 #2
0
        /// <summary>Removes biomass from live and dead biomass pools and send to surface organic matter</summary>
        /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
        /// <param name="amount">The fractions of biomass to remove</param>
        /// <param name="Live">Live biomass pool</param>
        /// <param name="Dead">Dead biomass pool</param>
        /// <param name="Removed">The removed pool to add to.</param>
        /// <param name="Detached">The detached pool to add to.</param>
        /// <param name="writeToSummary">Write the biomass removal to summary file?</param>
        /// <returns>The remaining live fraction.</returns>
        public double RemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType amount, 
                                    Biomass Live, Biomass Dead, 
                                    Biomass Removed, Biomass Detached,
                                    bool writeToSummary = true)
        {
            if (amount == null)
                amount = FindDefault(biomassRemoveType);

            double totalFractionToRemove = amount.FractionLiveToRemove + amount.FractionDeadToRemove
                                           + amount.FractionLiveToResidue + amount.FractionDeadToResidue;

            if (totalFractionToRemove > 0.0)
            {
                Biomass detaching;
                double remainingLiveFraction = RemoveBiomassFromLiveAndDead(amount, Live, Dead, out Removed, Detached, out detaching);

                // Add the detaching biomass to surface organic matter model.
                //TODO: theoretically the dead material is different from the live, so it should be added as a separate pool to SurfaceOM
                surfaceOrganicMatter.Add(detaching.Wt * 10, detaching.N * 10, 0.0, plant.CropType, Name);

                if (writeToSummary)
                {
                    double toResidue = (amount.FractionLiveToResidue + amount.FractionDeadToResidue) / totalFractionToRemove * 100;
                    double removedOff = (amount.FractionLiveToRemove + amount.FractionDeadToRemove) / totalFractionToRemove * 100;
                    summary.WriteMessage(this, "Removing " + (totalFractionToRemove * 100).ToString("0.0")
                                             + "% of " + Parent.Name + " Biomass from " + plant.Name
                                             + ".  Of this " + removedOff.ToString("0.0") + "% is removed from the system and "
                                             + toResidue.ToString("0.0") + "% is returned to the surface organic matter");
                }
                return remainingLiveFraction;
            }

            return 1;
        }
        private void DoPestDiseaseDamage(object sender, EventArgs e)
        {
            OrganBiomassRemovalType consumption = new OrganBiomassRemovalType();

            consumption.FractionLiveToRemove = Math.Max(1, ParentStage.TotalPopulation * RateOfOrganConsumptionPerIndividual.Value() * HostOrgan.Live.Wt);
            HostPlant.RemoveBiomass(HostOrgan.Name, "Graze", consumption);
        }
예제 #4
0
        /// <summary>Checks whether specified biomass removal fractions are within limits</summary>
        /// <param name="name">Name of the removal type e.g. cut, prune etc.</param>
        /// <param name="amount">The removal amount fractions</param>
        /// <returns>Returns true if fractions are ok, false otherwise.</returns>
        public bool CheckRemoveFractions(string name, OrganBiomassRemovalType amount)
        {
            bool testFractions = true;

            if (amount == null)
            {
                testFractions = false;
                throw new Exception("Cannot test null biomass removal - " + Parent.Name + ".BiomassRemovalFractions." + name);
            }

            if (amount.FractionLiveToRemove + amount.FractionLiveToResidue > 1.0)
            {
                testFractions = false;

                throw new Exception("The sum of FractionToResidue and FractionToRemove for " + Parent.Name
                                    + " is greater than one for live biomass.  Had this exception not been triggered, the biomass for "
                                    + Name + " would go negative");
            }

            if (amount.FractionDeadToRemove + amount.FractionDeadToResidue > 1.0)
            {
                testFractions = false;
                throw new Exception("The sum of FractionToResidue and FractionToRemove for " + Parent.Name
                                    + " is greater than one for dead biomass.  Had this exception not been triggered, the biomass for "
                                    + Name + " would go negative");
            }

            return(testFractions);
        }
예제 #5
0
        /// <summary>Finds a specific biomass removal default for the specified name</summary>
        /// <param name="name">Name of the removal type e.g. cut, prune etc.</param>
        /// <returns>Returns the default or null if not found.</returns>
        public OrganBiomassRemovalType FindDefault(string name)
        {
            OrganBiomassRemovalType amount = defaults.Find(d => d.Name == name);

            CheckRemoveFractions(name, amount);

            return(amount);
        }
예제 #6
0
        /// <summary>Removes biomass from live and dead biomass pools, may send to surface organic matter</summary>
        /// <param name="biomassRemoveType">Name of event that triggered this biomass removal call.</param>
        /// <param name="amount">The fractions of biomass to remove</param>
        /// <param name="Live">Live biomass pool</param>
        /// <param name="Dead">Dead biomass pool</param>
        /// <param name="Removed">The removed pool to add to.</param>
        /// <param name="Detached">The detached pool to add to.</param>
        /// <param name="writeToSummary">Write the biomass removal to summary file?</param>
        /// <returns>The remaining live fraction.</returns>
        public double RemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType amount,
                                    Biomass Live, Biomass Dead,
                                    Biomass Removed, Biomass Detached,
                                    bool writeToSummary = true)
        {
            if (amount == null)
            {
                amount = FindDefault(biomassRemoveType);
            }
            else
            {
                CheckRemoveFractions(biomassRemoveType, amount);
            }

            double liveFractionToRemove = amount.FractionLiveToRemove + amount.FractionLiveToResidue;
            double deadFractionToRemove = amount.FractionDeadToRemove + amount.FractionDeadToResidue;

            if (liveFractionToRemove + deadFractionToRemove > 0.0)
            {
                Biomass removing;
                Biomass detaching;
                double  totalBiomass = Live.Wt + Dead.Wt;
                if (totalBiomass > 0)
                {
                    double remainingLiveFraction = RemoveBiomassFromLiveAndDead(amount, Live, Dead, out removing, out detaching);

                    // Add the detaching biomass to total removed and detached
                    Removed.Add(removing);
                    Detached.Add(detaching);

                    // Pass the detaching biomass to surface organic matter model.
                    //TODO: in reality, the dead material is different from the live, so it would be better to add them as separate pools to SurfaceOM
                    if (plant.PlantType == null)
                    {
                        throw new Exception($"PlantType is null in plant {plant.Name}. The most likely cause is the use of an unofficial/unreleased plant model.");
                    }
                    surfaceOrganicMatter.Add(detaching.Wt * 10.0, detaching.N * 10.0, 0.0, plant.PlantType, Name);

                    if (writeToSummary)
                    {
                        double totalFractionToRemove = (Removed.Wt + detaching.Wt) * 100.0 / totalBiomass;
                        double toResidue             = detaching.Wt * 100.0 / (Removed.Wt + detaching.Wt);
                        double removedOff            = Removed.Wt * 100.0 / (Removed.Wt + detaching.Wt);
                        summary.WriteMessage(Parent, "Removing " + totalFractionToRemove.ToString("0.0")
                                             + "% of " + Parent.Name.ToLower() + " biomass from " + plant.Name
                                             + ". Of this " + removedOff.ToString("0.0") + "% is removed from the system and "
                                             + toResidue.ToString("0.0") + "% is returned to the surface organic matter.", MessageType.Diagnostic);
                        summary.WriteMessage(Parent, "Removed " + Removed.Wt.ToString("0.0") + " g/m2 of dry matter weight and "
                                             + Removed.N.ToString("0.0") + " g/m2 of N.", MessageType.Diagnostic);
                    }
                    return(remainingLiveFraction);
                }
            }

            return(1.0);
        }
예제 #7
0
        /// <summary>
        /// Biomass removal logic for this organ.
        /// </summary>
        /// <param name="biomassToRemove">Biomass to remove</param>
        public void RemoveBiomass(OrganBiomassRemovalType biomassToRemove)
        {
            // Live removal
            for (int t = 0; t < Tissue.Length - 1; t++)
            {
                Tissue[t].RemoveBiomass(biomassToRemove.FractionLiveToRemove, biomassToRemove.FractionLiveToResidue);
            }

            // Dead removal
            Tissue[Tissue.Length - 1].RemoveBiomass(biomassToRemove.FractionDeadToRemove, biomassToRemove.FractionDeadToResidue);
        }
예제 #8
0
        /// <summary>Removes biomass from live and dead biomass pools</summary>
        /// <param name="amount">The fractions of biomass to remove</param>
        /// <param name="Live">Live biomass pool</param>
        /// <param name="Dead">Dead biomass pool</param>
        /// <param name="removing">The removed pool to add to.</param>
        /// <param name="detaching">The amount of detaching material</param>
        private static double RemoveBiomassFromLiveAndDead(OrganBiomassRemovalType amount, Biomass Live, Biomass Dead, out Biomass removing, out Biomass detaching)
        {
            double remainingLiveFraction = 1.0 - (amount.FractionLiveToResidue + amount.FractionLiveToRemove);
            double remainingDeadFraction = 1.0 - (amount.FractionDeadToResidue + amount.FractionDeadToRemove);

            detaching = Live * amount.FractionLiveToResidue + Dead * amount.FractionDeadToResidue;
            removing  = Live * amount.FractionLiveToRemove + Dead * amount.FractionDeadToRemove;

            Live.Multiply(remainingLiveFraction);
            Dead.Multiply(remainingDeadFraction);
            return(remainingLiveFraction);
        }
예제 #9
0
        /// <summary>Removes biomass from organs when harvest, graze or cut events are called.</summary>
        /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
        /// <param name="amountToRemove">The fractions of biomass to remove</param>
        virtual public void RemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType amountToRemove)
        {
            Biomass liveAfterRemoval = Live;
            Biomass deadAfterRemoval = Dead;

            biomassRemovalModel.RemoveBiomass(biomassRemoveType, amountToRemove, liveAfterRemoval, deadAfterRemoval, Removed, Detached);

            double remainingLiveFraction = MathUtilities.Divide(liveAfterRemoval.Wt, Live.Wt, 0);
            double remainingDeadFraction = MathUtilities.Divide(deadAfterRemoval.Wt, Dead.Wt, 0);

            cohort.ReduceLeavesUniformly(remainingLiveFraction, remainingDeadFraction);
        }
예제 #10
0
        /// <summary>Removes biomass from root layers when harvest, graze or cut events are called.</summary>
        /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
        /// <param name="biomassToRemove">The fractions of biomass to remove</param>
        public void RemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType biomassToRemove)
        {
            // Remove live tissue
            Live.RemoveBiomass(biomassToRemove.FractionLiveToRemove, biomassToRemove.FractionLiveToResidue);

            // Remove dead tissue
            Dead.RemoveBiomass(biomassToRemove.FractionDeadToRemove, biomassToRemove.FractionDeadToResidue);

            if (biomassRemoveType != "Harvest" || biomassRemoveType != "Cut")
            {
                IsKLModiferDueToDamageActive = true;
            }
        }
예제 #11
0
        /// <summary>Removes biomass from root layers when harvest, graze or cut events are called.</summary>
        /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
        /// <param name="biomassToRemove">The fractions of biomass to remove</param>
        public void RemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType biomassToRemove)
        {
            // Live removal
            Live.RemoveBiomass(biomassToRemove.FractionLiveToRemove, sendToSoil: false);
            Live.RemoveBiomass(biomassToRemove.FractionLiveToResidue, sendToSoil: true);

            // Dead removal
            Dead.RemoveBiomass(biomassToRemove.FractionDeadToRemove, sendToSoil: false);
            Dead.RemoveBiomass(biomassToRemove.FractionDeadToResidue, sendToSoil: true);

            if (biomassRemoveType != "Harvest")
            {
                IsKLModiferDueToDamageActive = true;
            }
        }
예제 #12
0
        /// <summary>Removes biomass from root layers when harvest, graze or cut events are called.</summary>
        /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
        /// <param name="biomassToRemove">The fractions of biomass to remove</param>
        public void RemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType biomassToRemove)
        {
            // Live removal
            for (int t = 0; t < Tissue.Length - 1; t++)
            {
                Tissue[t].RemoveBiomass(biomassToRemove.FractionLiveToRemove, biomassToRemove.FractionLiveToResidue);
            }

            // Dead removal
            Tissue[Tissue.Length - 1].RemoveBiomass(biomassToRemove.FractionDeadToRemove, biomassToRemove.FractionDeadToResidue);

            if (biomassRemoveType != "Harvest")
            {
                IsKLModiferDueToDamageActive = true;
            }
        }
예제 #13
0
        private void DoPestDiseaseDamage(object sender, EventArgs e)
        {
            OrganBiomassRemovalType consumption = new OrganBiomassRemovalType();
            double organWtConsumed = 0;

            if ((ParentPhase.Cohorts != null) && (HostPlant.IsAlive))
            {
                foreach (Cohort c in ParentPhase.Cohorts)
                {
                    ParentPhase.CurrentCohort         = c;
                    organWtConsumed                  += c.Population * OrganWtConsumptionPerIndividual.Value();
                    consumption.FractionLiveToRemove += Math.Max(1, organWtConsumed / HostOrgan.Live.Wt);
                }
                HostPlant.RemoveBiomass(HostOrgan.Name, "Graze", consumption);
            }
        }
예제 #14
0
        /// <summary>Removes biomass from live and dead biomass pools and send to soil</summary>
        /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
        /// <param name="removal">The fractions of biomass to remove</param>
        /// <param name="Live">Live biomass pool</param>
        /// <param name="Dead">Dead biomass pool</param>
        /// <param name="Removed">The removed pool to add to.</param>
        /// <param name="Detached">The detached pool to add to.</param>
        public void RemoveBiomassToSoil(string biomassRemoveType, OrganBiomassRemovalType removal,
                                        Biomass[] Live, Biomass[] Dead,
                                        Biomass Removed, Biomass Detached)
        {
            if (removal == null)
            {
                removal = FindDefault(biomassRemoveType);
            }

            //NOTE: roots don't have dead biomass
            double totalFractionToRemove = removal.FractionLiveToRemove + removal.FractionLiveToResidue;

            if (totalFractionToRemove > 0)
            {
                //NOTE: at the moment Root has no Dead pool
                FOMLayerLayerType[] FOMLayers = new FOMLayerLayerType[Live.Length];
                double remainingFraction      = 1.0 - (removal.FractionLiveToResidue + removal.FractionLiveToRemove);
                for (int layer = 0; layer < Live.Length; layer++)
                {
                    Biomass removing;
                    Biomass detaching;
                    double  remainingLiveFraction = RemoveBiomassFromLiveAndDead(removal, Live[layer], Dead[layer], out removing, out detaching);

                    // Add the detaching biomass to total removed and detached
                    Removed.Add(removing);
                    Detached.Add(detaching);

                    // Pass the detaching biomass to surface organic matter model.
                    FOMType fom = new FOMType();
                    fom.amount = (float)(detaching.Wt * 10);
                    fom.N      = (float)(detaching.N * 10);
                    fom.C      = (float)(0.40 * detaching.Wt * 10);
                    fom.P      = 0.0;
                    fom.AshAlk = 0.0;

                    FOMLayerLayerType Layer = new FOMLayerLayerType();
                    Layer.FOM        = fom;
                    Layer.CNR        = 0.0;
                    Layer.LabileP    = 0.0;
                    FOMLayers[layer] = Layer;
                }
                FOMLayerType FomLayer = new FOMLayerType();
                FomLayer.Type  = plant.PlantType;
                FomLayer.Layer = FOMLayers;
                IncorpFOM.Invoke(FomLayer);
            }
        }
예제 #15
0
        /// <summary>Remove biomass from organ.</summary>
        /// <param name="biomassToRemove">The fraction of the harvestable biomass to remove</param>
        public void RemoveBiomass(OrganBiomassRemovalType biomassToRemove)
        {
            // The fractions passed in are based on the total biomass
            var dm = Tissue.Sum(t => t.DM.Wt);

            // Live removal
            for (int t = 0; t < Tissue.Length - 1; t++)
            {
                Tissue[t].RemoveBiomass(biomassToRemove.FractionLiveToRemove, biomassToRemove.FractionLiveToResidue);
            }

            // Dead removal
            Tissue[Tissue.Length - 1].RemoveBiomass(biomassToRemove.FractionDeadToRemove, biomassToRemove.FractionDeadToResidue);

            // Tissue states have changed so recalculate our states.
            CalculateStates();
        }
예제 #16
0
        /// <summary>
        /// Remove biomass from organ
        /// </summary>
        /// <param name="biomassToRemove">The fraction of the harvestable biomass to remove</param>
        public void RemoveBiomass(OrganBiomassRemovalType biomassToRemove)
        {
            // The fractions passed in are based on the harvestable biomass. Convert these to
            // fractions of total biomass so that we can pass these to the tissue RemoveBiomass methods.
            biomassToRemove.FractionLiveToRemove  = MathUtilities.Divide(biomassToRemove.FractionLiveToRemove * DMLiveHarvestable, DMLive, 0);
            biomassToRemove.FractionDeadToRemove  = MathUtilities.Divide(biomassToRemove.FractionDeadToRemove * DMDeadHarvestable, DMDead, 0);
            biomassToRemove.FractionLiveToResidue = MathUtilities.Divide(biomassToRemove.FractionLiveToResidue * DMLiveHarvestable, DMLive, 0);
            biomassToRemove.FractionDeadToResidue = MathUtilities.Divide(biomassToRemove.FractionDeadToResidue * DMDeadHarvestable, DMDead, 0);

            // Live removal
            for (int t = 0; t < Tissue.Length - 1; t++)
            {
                Tissue[t].RemoveBiomass(biomassToRemove.FractionLiveToRemove, biomassToRemove.FractionLiveToResidue);
            }

            // Dead removal
            Tissue[Tissue.Length - 1].RemoveBiomass(biomassToRemove.FractionDeadToRemove, biomassToRemove.FractionDeadToResidue);
        }
예제 #17
0
        /// <summary>Remove biomass from organ.</summary>
        /// <param name="biomassToRemove">The fraction of the harvestable biomass to remove</param>
        public void RemoveBiomass(OrganBiomassRemovalType biomassToRemove)
        {
            // The fractions passed in are based on the total biomass
            var previousDM = Tissue.Sum(tissue => tissue.DM.Wt);

            // Live removal
            for (int t = 0; t < Tissue.Length - 1; t++)
            {
                Tissue[t].RemoveBiomass(biomassToRemove.FractionLiveToRemove, biomassToRemove.FractionLiveToResidue);
            }

            // Dead removal
            Tissue[Tissue.Length - 1].RemoveBiomass(biomassToRemove.FractionDeadToRemove, biomassToRemove.FractionDeadToResidue);

            // Calculate the fraction of DM removed from this organ
            removedFraction = MathUtilities.Divide(Tissue.Sum(tissue => tissue.DMRemoved), previousDM, 0.0, Epsilon);

            // Tissue states have changed so recalculate our states.
            CalculateStates();
        }
예제 #18
0
        /// <summary>Removes biomass from organs when harvest, graze or cut events are called.</summary>
        /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
        /// <param name="value">The fractions of biomass to remove</param>
        public virtual void DoRemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType value)
        {
            Biomass liveAfterRemoval = Live;
            Biomass deadAfterRemoval = Dead;
            biomassRemovalModel.RemoveBiomass(biomassRemoveType, value, liveAfterRemoval, deadAfterRemoval, Removed, Detached);

            double remainingLiveFraction = MathUtilities.Divide(liveAfterRemoval.Wt, Live.Wt, 0);
            double remainingDeadFraction = MathUtilities.Divide(deadAfterRemoval.Wt,  Dead.Wt, 0);

            ReduceLeavesUniformly(remainingLiveFraction);
            ReduceDeadLeavesUniformly(remainingDeadFraction);
        }
예제 #19
0
파일: Root.cs 프로젝트: byzheng/ApsimX
 /// <summary>Removes biomass from root layers when harvest, graze or cut events are called.</summary>
 public override void DoRemoveBiomass(OrganBiomassRemovalType value)
 {
     //NOTE: roots don't have dead biomass
     double totalFractionToRemove = value.FractionLiveToRemove + value.FractionLiveToResidue;
     if (totalFractionToRemove > 1.0)
     {
         throw new Exception("The sum of FractionToResidue and FractionToRemove sent with your "
                             + "!!!!PLACE HOLDER FOR EVENT SENDER!!!!"
                             + " is greater than 1.  Had this execption not triggered you would be removing more biomass from "
                             + Name + " than there is to remove");
     }
     else if (totalFractionToRemove > 0.0)
     {
         DoRootBiomassRemoval(value.FractionLiveToResidue, value.FractionLiveToRemove);
     }
 }
예제 #20
0
파일: Leaf.cs 프로젝트: hol353/ApsimX
 /// <summary>
 /// remove biomass from the leaf.
 /// </summary>
 /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
 /// <param name="value">The frations of biomass to remove</param>
 public override void DoRemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType value)
 {
     bool writeToSummary = true;
     foreach (LeafCohort leaf in Leaves)
     {
         if (leaf.IsInitialised)
         {
             double remainingLiveFraction = biomassRemovalModel.RemoveBiomass(biomassRemoveType, value, leaf.Live, leaf.Dead, leaf.Removed, leaf.Detached, writeToSummary);
             leaf.LiveArea *= remainingLiveFraction;
             writeToSummary = false; // only want it written once.
             Detached.Add(leaf.Detached);
             Removed.Add(leaf.Removed);
         }
     }
 }
예제 #21
0
파일: LeafCohort.cs 프로젝트: hut104/ApsimX
        /// <summary>Removes leaf area and biomass on thinning event</summary>
        /// <param name="value">The fractions of biomass to remove.</param>
        public virtual void DoLeafBiomassRemoval(OrganBiomassRemovalType value)
        {
            if (IsInitialised)
            {
                double totalFractionBeingRemoved = value.FractionLiveToRemove + value.FractionDeadToRemove
                                                   + value.FractionLiveToResidue + value.FractionDeadToResidue;
                if (totalFractionBeingRemoved > 1.0)
                {
                    throw new Exception("The sum of FractionToResidue and FractionToRemove sent with your "
                                        + "!!!!PLACE HOLDER FOR EVENT SENDER!!!!"
                                        + " is greater than 1.  Had this execption not triggered you would be removing more biomass from "
                                        + Name + " than there is to remove");
                }
                else if (totalFractionBeingRemoved > 0.0)
                {
                    double RemainingLiveFraction = 1.0 - (value.FractionLiveToResidue + value.FractionLiveToRemove);
                    double RemainingDeadFraction = 1.0 - (value.FractionDeadToResidue + value.FractionDeadToRemove);

                    LiveArea *= RemainingLiveFraction;

                    RemovedWt += (Live.Wt * value.FractionLiveToRemove) + (Dead.Wt * value.FractionDeadToRemove);
                    RemovedN += (Live.N * value.FractionLiveToRemove) + (Dead.N * value.FractionDeadToRemove);
                    DetachedWt += (Live.Wt * value.FractionLiveToResidue) + (Dead.Wt * value.FractionDeadToResidue);
                    DetachedN += (Live.N * value.FractionLiveToResidue) + (Dead.N * value.FractionDeadToResidue);

                    Live.StructuralWt *= RemainingLiveFraction;
                    Live.NonStructuralWt *= RemainingLiveFraction;
                    Live.MetabolicWt *= RemainingLiveFraction;
                    Dead.StructuralWt *= RemainingDeadFraction;
                    Dead.NonStructuralWt *= RemainingDeadFraction;
                    Dead.MetabolicWt *= RemainingDeadFraction;

                    Live.StructuralN *= RemainingLiveFraction;
                    Live.NonStructuralN *= RemainingLiveFraction;
                    Live.MetabolicN *= RemainingLiveFraction;
                    Dead.StructuralN *= RemainingDeadFraction;
                    Dead.NonStructuralN *= RemainingDeadFraction;
                    Dead.MetabolicN *= RemainingDeadFraction;

                    SurfaceOrganicMatter.Add(DetachedWt * 10, DetachedN * 10, 0, Plant.CropType, Name);
                    //TODO: theoretically the dead material is different from the live, so it should be added as a separate pool to SurfaceOM
                }
            }
        }
예제 #22
0
 /// <summary>Removes biomass from organs when harvest, graze or cut events are called.</summary>
 /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
 /// <param name="value">The fractions of biomass to remove</param>
 virtual public void DoRemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType value)
 {
     throw new NotImplementedException();
 }
예제 #23
0
 /// <summary>
 /// Remove biomass from an organ.
 /// </summary>
 /// <param name="materialName">Name of organ.</param>
 /// <param name="biomassToRemove">Biomass to remove.</param>
 public void RemoveBiomass(string materialName, OrganBiomassRemovalType biomassToRemove)
 {
     forageModel.RemoveBiomass(materialName, "Graze", biomassToRemove);
 }
예제 #24
0
 /// <summary>Adds a removal type to the defaultRemovalFractions.</summary>
 /// <param name="typeName">The name of the removal type</param>
 /// <param name="removalFractions">The default removal fractions</param>
 public void SetRemovalFractions(string typeName, OrganBiomassRemovalType removalFractions)
 {
     defaultRemovalFractions.Add(typeName, removalFractions);
 }
예제 #25
0
파일: Root.cs 프로젝트: hol353/ApsimX
 /// <summary>Removes biomass from root layers when harvest, graze or cut events are called.</summary>
 /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
 /// <param name="removal">The fractions of biomass to remove</param>
 public override void DoRemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType removal)
 {
     biomassRemovalModel.RemoveBiomassToSoil(biomassRemoveType, removal, PlantZone.LayerLive, PlantZone.LayerDead, Removed, Detached);
 }
예제 #26
0
파일: MockForage.cs 프로젝트: hrpasl/ApsimX
 public void RemoveBiomass(string organName, string biomassRemoveType, OrganBiomassRemovalType biomassToRemove)
 {
     throw new NotImplementedException();
 }
예제 #27
0
파일: BaseOrgan.cs 프로젝트: byzheng/ApsimX
        /// <summary>Removes biomass from organs when harvest, graze or cut events are called.</summary>
        /// <param name="value">The fractions of biomass to remove</param>
        public virtual void DoRemoveBiomass(OrganBiomassRemovalType value)
        {
            double totalFractionToRemove = value.FractionLiveToRemove + value.FractionDeadToRemove
                                           + value.FractionLiveToResidue + value.FractionDeadToResidue;
            if (totalFractionToRemove > 1.0)
            {
                throw new Exception("The sum of FractionToResidue and FractionToRemove sent with your "
                                    + "!!!!PLACE HOLDER FOR EVENT SENDER!!!!"
                                    + " is greater than 1.  Had this execption not triggered you would be removing more biomass from "
                                    + Name + " than there is to remove");
            }
            else  if (totalFractionToRemove > 0.0)
            {
                double RemainingLiveFraction = 1.0 - (value.FractionLiveToResidue + value.FractionLiveToRemove);
                double RemainingDeadFraction = 1.0 - (value.FractionDeadToResidue + value.FractionDeadToRemove);

                double detachingWt = Live.Wt * value.FractionLiveToResidue + Dead.Wt * value.FractionDeadToResidue;
                double detachingN = Live.N * value.FractionLiveToResidue + Dead.N * value.FractionDeadToResidue;
                RemovedWt += Live.Wt * value.FractionLiveToRemove + Dead.Wt * value.FractionDeadToRemove;
                RemovedN += Live.N * value.FractionLiveToRemove + Dead.N * value.FractionDeadToRemove;
                DetachedWt += detachingWt;
                DetachedN += detachingN;

                Live.StructuralWt *= RemainingLiveFraction;
                Live.NonStructuralWt *= RemainingLiveFraction;
                Live.MetabolicWt *= RemainingLiveFraction;
                Dead.StructuralWt *= RemainingDeadFraction;
                Dead.NonStructuralWt *= RemainingDeadFraction;
                Dead.MetabolicWt *= RemainingDeadFraction;

                Live.StructuralN *= RemainingLiveFraction;
                Live.NonStructuralN *= RemainingLiveFraction;
                Live.MetabolicN *= RemainingLiveFraction;
                Dead.StructuralN *= RemainingDeadFraction;
                Dead.NonStructuralN *= RemainingDeadFraction;
                Dead.MetabolicN *= RemainingDeadFraction;

                SurfaceOrganicMatter.Add(detachingWt * 10, detachingN * 10, 0.0, Plant.CropType, Name);
                //TODO: theoretically the dead material is different from the live, so it should be added as a separate pool to SurfaceOM

                double toResidue = (value.FractionLiveToResidue + value.FractionDeadToResidue) / totalFractionToRemove * 100;
                double removedOff = (value.FractionLiveToRemove + value.FractionDeadToRemove) / totalFractionToRemove * 100;
                Summary.WriteMessage(this, "Removing " + (totalFractionToRemove * 100).ToString("0.0")
                                         + "% of " + Name + " Biomass from " + Plant.Name
                                         + ".  Of this " + removedOff.ToString("0.0") + "% is removed from the system and "
                                         + toResidue.ToString("0.0") + "% is returned to the surface organic matter");
            }
        }
예제 #28
0
 /// <summary>Removes biomass from organs when harvest, graze or cut events are called.</summary>
 /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
 /// <param name="value">The fractions of biomass to remove</param>
 public void RemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType value)
 {
     biomassRemovalModel.RemoveBiomass(biomassRemoveType, value, Live, Dead, Removed, Detached);
 }
예제 #29
0
        /// <summary>Removes biomass from live and dead biomass pools and send to soil</summary>
        /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
        /// <param name="removal">The fractions of biomass to remove</param>
        /// <param name="Live">Live biomass pool</param>
        /// <param name="Dead">Dead biomass pool</param>
        /// <param name="Removed">The removed pool to add to.</param>
        /// <param name="Detached">The detached pool to add to.</param>
        public void RemoveBiomassToSoil(string biomassRemoveType, OrganBiomassRemovalType removal,
                                        Biomass[] Live, Biomass[] Dead,
                                        Biomass Removed, Biomass Detached)
        {
            if (removal == null)
                removal = FindDefault(biomassRemoveType);

            //NOTE: roots don't have dead biomass
            double totalFractionToRemove = removal.FractionLiveToRemove + removal.FractionLiveToResidue;

            if (totalFractionToRemove > 0)
            {
                //NOTE: at the moment Root has no Dead pool
                FOMLayerLayerType[] FOMLayers = new FOMLayerLayerType[Live.Length];
                double remainingFraction = 1.0 - (removal.FractionLiveToResidue + removal.FractionLiveToRemove);
                for (int layer = 0; layer < Live.Length; layer++)
                {
                    Biomass detaching;
                    double remainingLiveFraction = RemoveBiomassFromLiveAndDead(removal, Live[layer], Dead[layer], out Removed, Detached, out detaching);

                    FOMType fom = new FOMType();
                    fom.amount = (float)(detaching.Wt * 10);
                    fom.N = (float)(detaching.N * 10);
                    fom.C = (float)(0.40 * detaching.Wt * 10);
                    fom.P = 0.0;
                    fom.AshAlk = 0.0;

                    FOMLayerLayerType Layer = new FOMLayerLayerType();
                    Layer.FOM = fom;
                    Layer.CNR = 0.0;
                    Layer.LabileP = 0.0;
                    FOMLayers[layer] = Layer;
                }
                FOMLayerType FomLayer = new FOMLayerType();
                FomLayer.Type = plant.CropType;
                FomLayer.Layer = FOMLayers;
                IncorpFOM.Invoke(FomLayer);
            }
        }
예제 #30
0
        /// <summary>Removes biomass from live and dead biomass pools</summary>
        /// <param name="amount">The fractions of biomass to remove</param>
        /// <param name="Live">Live biomass pool</param>
        /// <param name="Dead">Dead biomass pool</param>
        /// <param name="Removed">The removed pool to add to.</param>
        /// <param name="Detached">The detached pool to add to.</param>
        /// <param name="detaching">The amount of detaching material</param>
        private static double RemoveBiomassFromLiveAndDead(OrganBiomassRemovalType amount, Biomass Live, Biomass Dead, out Biomass Removed, Biomass Detached, out Biomass detaching)
        {
            double remainingLiveFraction = 1.0 - (amount.FractionLiveToResidue + amount.FractionLiveToRemove);
            double remainingDeadFraction = 1.0 - (amount.FractionDeadToResidue + amount.FractionDeadToRemove);

            detaching = Live * amount.FractionLiveToResidue + Dead * amount.FractionDeadToResidue;
            Removed = Live * amount.FractionLiveToRemove + Dead * amount.FractionDeadToRemove;
            Detached.Add(detaching);

            Live.Multiply(remainingLiveFraction);
            Dead.Multiply(remainingDeadFraction);
            return remainingLiveFraction;
        }
예제 #31
0
파일: BaseOrgan.cs 프로젝트: hol353/ApsimX
 /// <summary>Removes biomass from organs when harvest, graze or cut events are called.</summary>
 /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
 /// <param name="value">The fractions of biomass to remove</param>
 public virtual void DoRemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType value)
 {
     throw new NotImplementedException();
 }
예제 #32
0
 /// <summary>Removes biomass from organs when harvest, graze or cut events are called.</summary>
 /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
 /// <param name="value">The fractions of biomass to remove</param>
 public override void DoRemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType value)
 {
     biomassRemovalModel.RemoveBiomass(biomassRemoveType, value, Live, Dead, Removed, Detached);
 }
예제 #33
0
 /// <summary>Removes biomass from organs when harvest, graze or cut events are called.</summary>
 /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
 /// <param name="amountToRemove">The fractions of biomass to remove</param>
 public virtual void RemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType amountToRemove)
 {
     biomassRemovalModel.RemoveBiomass(biomassRemoveType, amountToRemove, Live, Dead, Removed, Detached);
 }
예제 #34
0
파일: Leaf.cs 프로젝트: byzheng/ApsimX
        /// <summary>
        /// remove biomass from the leaf.
        /// </summary>
        /// <param name="value">The frations of biomass to remove</param>
        public override void DoRemoveBiomass(OrganBiomassRemovalType value)
        {
            foreach (LeafCohort leaf in Leaves)
            {
                leaf.DoLeafBiomassRemoval(value);
                DetachedWt += leaf.DetachedWt;
                DetachedN += leaf.DetachedN;
                RemovedWt += leaf.RemovedWt;
                RemovedN += leaf.RemovedN;
            }

            double totalFractionToRemove = value.FractionLiveToRemove + value.FractionLiveToResidue;
            double toResidue = (value.FractionLiveToResidue + value.FractionDeadToResidue) / totalFractionToRemove * 100;
            double removedOff = (value.FractionLiveToRemove + value.FractionDeadToRemove) / totalFractionToRemove * 100;
            Summary.WriteMessage(this, "Removing " + (totalFractionToRemove * 100).ToString("0.0")
                                     + "% of " + Name + " Biomass from " + Plant.Name
                                     + ".  Of this " + removedOff.ToString("0.0") + "% is removed from the system and "
                                     + toResidue.ToString("0.0") + "% is returned to the surface organic matter");
        }
예제 #35
0
파일: Root.cs 프로젝트: m8harrison/ApsimX-1
 /// <summary>Removes biomass from root layers when harvest, graze or cut events are called.</summary>
 /// <param name="biomassRemoveType">Name of event that triggered this biomass remove call.</param>
 /// <param name="removal">The fractions of biomass to remove</param>
 public void RemoveBiomass(string biomassRemoveType, OrganBiomassRemovalType removal)
 {
     biomassRemovalModel.RemoveBiomassToSoil(biomassRemoveType, removal, PlantZone.LayerLive, PlantZone.LayerDead, Removed, Detached);
 }
예제 #36
0
파일: Root.cs 프로젝트: hol353/ApsimX
        /// <summary>Removes biomass from root layers when harvest, graze or cut events are called.</summary>
        public override void DoRemoveBiomass(OrganBiomassRemovalType removal)
        {
            //NOTE: roots don't have dead biomass
            double totalFractionToRemove = removal.FractionLiveToRemove + removal.FractionLiveToResidue;
            if (totalFractionToRemove > 1.0 || totalFractionToRemove < 0)
                throw new Exception("The sum of FractionToResidue and FractionToRemove is greater than 1 or less than 0.");

            if (totalFractionToRemove > 0)
            {
                //NOTE: at the moment Root has no Dead pool
                FOMLayerLayerType[] FOMLayers = new FOMLayerLayerType[PlantZone.soil.Thickness.Length];
                double remainingFraction = 1.0 - (removal.FractionLiveToResidue + removal.FractionLiveToRemove);
                double detachingWt = 0.0;
                double detachingN = 0.0;
                for (int layer = 0; layer < PlantZone.soil.Thickness.Length; layer++)
                {
                    detachingWt = PlantZone.LayerLive[layer].Wt * removal.FractionLiveToResidue;
                    detachingN = PlantZone.LayerLive[layer].N * removal.FractionLiveToResidue;
                    RemovedWt += PlantZone.LayerLive[layer].Wt * removal.FractionLiveToRemove;
                    RemovedN += PlantZone.LayerLive[layer].N * removal.FractionLiveToRemove;
                    DetachedWt += detachingWt;
                    DetachedN += detachingN;

                    PlantZone.LayerLive[layer].StructuralWt *= remainingFraction;
                    PlantZone.LayerLive[layer].NonStructuralWt *= remainingFraction;
                    PlantZone.LayerLive[layer].MetabolicWt *= remainingFraction;

                    PlantZone.LayerLive[layer].StructuralN *= remainingFraction;
                    PlantZone.LayerLive[layer].NonStructuralN *= remainingFraction;
                    PlantZone.LayerLive[layer].MetabolicN *= remainingFraction;

                    FOMType fom = new FOMType();
                    fom.amount = (float)(detachingWt * 10);
                    fom.N = (float)(detachingN * 10);
                    fom.C = (float)(0.40 * detachingWt * 10);
                    fom.P = 0.0;
                    fom.AshAlk = 0.0;

                    FOMLayerLayerType Layer = new FOMLayerLayerType();
                    Layer.FOM = fom;
                    Layer.CNR = 0.0;
                    Layer.LabileP = 0.0;
                    FOMLayers[layer] = Layer;
                }
                FOMLayerType FomLayer = new FOMLayerType();
                FomLayer.Type = Plant.CropType;
                FomLayer.Layer = FOMLayers;
                IncorpFOM.Invoke(FomLayer);
            }
        }