Esempio n. 1
0
        public static AvailableToAnimalelementType[] AvailableToAnimal(string PlantName, string OrganName, double PlantHeight,
                                                                       Biomass Live, Biomass Dead)
        {
            AvailableToAnimalelementType[] Available = new AvailableToAnimalelementType[2];
            Available[0] = new AvailableToAnimalelementType();
            Available[0].CohortID = PlantName;
            Available[0].Organ = OrganName;
            Available[0].AgeID = "live";
            Available[0].Bottom = 0.0;
            Available[0].Top = PlantHeight;
            Available[0].Chem = "digestible";
            Available[0].Weight = Live.Wt * Conversions.gm2kg / Conversions.sm2ha;
            Available[0].N = Live.N * Conversions.gm2kg / Conversions.sm2ha;
            Available[0].P = 0.0; //Live.P * Conversions.gm2kg / Conversions.sm2ha;
            Available[0].S = 0.0;
            Available[0].AshAlk = 0.0;

            Available[1] = new AvailableToAnimalelementType();
            Available[1].CohortID = PlantName;
            Available[1].Organ = OrganName;
            Available[1].AgeID = "dead";
            Available[1].Bottom = 0.0;
            Available[1].Top = PlantHeight;
            Available[1].Chem = "digestible";
            Available[1].Weight = Dead.Wt * Conversions.gm2kg / Conversions.sm2ha;
            Available[1].N = Dead.N * Conversions.gm2kg / Conversions.sm2ha;
            Available[1].P = 0.0; //Dead.P * Conversions.gm2kg / Conversions.sm2ha;
            Available[1].S = 0.0;
            Available[1].AshAlk = 0.0;
            return Available;
        }
Esempio n. 2
0
 /// <summary>Initializes a new instance of the <see cref="Biomass"/> class.</summary>
 /// <param name="from">From.</param>
 public Biomass(Biomass from)
 {
     _StructuralWt = from.StructuralWt;
     _NonStructuralWt = from.NonStructuralWt;
     _MetabolicWt = from.MetabolicWt;
     _StructuralN = from.StructuralN;
     _NonStructuralN = from.NonStructuralN;
     _MetabolicN = from.MetabolicN;
 }
Esempio n. 3
0
 /// <summary>Sets to.</summary>
 /// <param name="a">a.</param>
 public void SetTo(Biomass a)
 {
     _StructuralWt    = a.StructuralWt;
     _StorageWt       = a.StorageWt;
     _MetabolicWt     = a.MetabolicWt;
     _StructuralN     = a.StructuralN;
     _StorageN        = a.StorageN;
     _MetabolicN      = a.MetabolicN;
     _DMDOfStructural = a._DMDOfStructural;
 }
Esempio n. 4
0
 /// <summary>Initializes a new instance of the <see cref="Biomass"/> class.</summary>
 /// <param name="from">From.</param>
 public Biomass(Biomass from)
 {
     _StructuralWt    = from.StructuralWt;
     _StorageWt       = from.StorageWt;
     _MetabolicWt     = from.MetabolicWt;
     _StructuralN     = from.StructuralN;
     _StorageN        = from.StorageN;
     _MetabolicN      = from.MetabolicN;
     _DMDOfStructural = from.DMDOfStructural;
 }
Esempio n. 5
0
 /// <summary>Adds the specified a.</summary>
 /// <param name="a">a.</param>
 public void Add(Biomass a)
 {
     _DMDOfStructural = MathUtilities.Divide(_DMDOfStructural * _StructuralWt + a._DMDOfStructural * a._StructuralWt
                                             , _StructuralWt + a._StructuralWt
                                             , 0);
     _StructuralWt += a._StructuralWt;
     _StorageWt    += a._StorageWt;
     _MetabolicWt  += a._MetabolicWt;
     _StructuralN  += a._StructuralN;
     _StorageN     += a._StorageN;
     _MetabolicN   += a._MetabolicN;
 }
Esempio n. 6
0
 /// <summary>Subtracts the specified a.</summary>
 /// <param name="a">a.</param>
 public void Subtract(Biomass a)
 {
     _DMDOfStructural = MathUtilities.Divide(_DMDOfStructural * _StructuralWt - a._DMDOfStructural * a._StructuralWt
                                             , _StructuralWt - a._StructuralWt
                                             , 0);
     _StructuralWt -= a._StructuralWt;
     _StorageWt    -= a._StorageWt;
     _MetabolicWt  -= a._MetabolicWt;
     _StructuralN  -= a._StructuralN;
     _StorageN     -= a._StorageN;
     _MetabolicN   -= a._MetabolicN;
 }
Esempio n. 7
0
        /// <summary>
        /// Remove some dm. The fraction removed is calculation and put into the RemovedPool so that
        /// later one it can be removed from the actual Pool in the update routine.
        /// Routine was called giveDMGreenRemoved and giveDMSenescedRemoved in old Plant.
        /// </summary>
        internal static Biomass RemoveDM(double delta, Biomass Pool, string OrganName)
        {
            double  fraction    = MathUtilities.Divide(delta, Pool.Wt, 0.0);
            Biomass RemovedPool = Pool * fraction;

            double error_margin = 1.0e-6f;

            if (delta > Pool.Wt + error_margin)
            {
                string msg;
                msg  = "Attempting to remove more green " + OrganName + " biomass than available:-\r\n";
                msg += "Removing -" + delta.ToString() + " (g/m2) from " + Pool.Wt.ToString() + " (g/m2) available.";
                throw new Exception(msg);
            }
            return(RemovedPool);
        }
Esempio n. 8
0
        public static void CalcNDemand(double dltDm, double dltDmPotRue, double n_conc_crit, double n_conc_max,
                                       Biomass Growth, Biomass Green, double RetranslocationN,
                                       double n_deficit_uptake_fraction,
                                       ref double NDemand, ref double NMax)
        {
            double part_fract = MathUtilities.Divide(Growth.Wt, dltDm, 0.0);
            double dlt_dm_pot = dltDmPotRue * part_fract;         // potential dry weight increase (g/m^2)

            dlt_dm_pot = MathUtilities.Constrain(dlt_dm_pot, 0.0, dltDmPotRue);

            if (Green.Wt > 0.0)
            {
                // get N demands due to difference between
                // actual N concentrations and critical N concentrations
                double N_crit      = Green.Wt * n_conc_crit;    // critical N amount (g/m^2)
                double N_potential = Green.Wt * n_conc_max;     // maximum N uptake potential (g/m^2)

                // retranslocation is -ve for outflows
                double N_demand_old = N_crit                       // demand for N by old biomass (g/m^2)
                                      - (Green.N + RetranslocationN);
                if (N_demand_old > 0.0)                            // Don't allow demand to satisfy all deficit
                {
                    N_demand_old *= n_deficit_uptake_fraction;
                }

                double N_max_old = N_potential                  // N required by old biomass to reach  N_conc_max  (g/m^2)
                                   - (Green.N + RetranslocationN);
                if (N_max_old > 0.0)
                {
                    N_max_old *= n_deficit_uptake_fraction;         // Don't allow demand to satisfy all deficit
                }
                // get potential N demand (critical N) of potential growth
                double N_demand_new = dlt_dm_pot * n_conc_crit;  // demand for N by new growth (g/m^2)
                double N_max_new    = dlt_dm_pot * n_conc_max;   // N required by new growth to reach N_conc_max  (g/m^2)

                NDemand = N_demand_old + N_demand_new;
                NMax    = N_max_old + N_max_new;

                NDemand = MathUtilities.Constrain(NDemand, 0.0, double.MaxValue);
                NMax    = MathUtilities.Constrain(NMax, 0.0, double.MaxValue);
            }
            else
            {
                NDemand = NMax = 0.0;
            }
        }
Esempio n. 9
0
        /// <summary>Removes a given amount of biomass (and N) from the plant.</summary>
        /// <param name="amountToRemove">The amount of biomass to remove (kg/ha)</param>
        public Biomass RemoveBiomass(double amountToRemove)
        {
            var defoliatedBiomass = new Biomass();
            var preRemovalBiomass = AboveGround.Wt * 10;

            foreach (var organ in Organs.Cast <IOrganDamage>())
            {
                if (organ.IsAboveGround)
                {
                    // These calculations convert organ live weight from g/m2 to kg/ha
                    var amountLiveToRemove      = organ.Live.Wt * 10 / preRemovalBiomass * amountToRemove;
                    var amountDeadToRemove      = organ.Dead.Wt * 10 / preRemovalBiomass * amountToRemove;
                    var fractionLiveToRemove    = MathUtilities.Divide(amountLiveToRemove, (organ.Live.Wt * 10), 0);
                    var fractionDeadToRemove    = MathUtilities.Divide(amountDeadToRemove, (organ.Dead.Wt * 10), 0);
                    var defoliatedDigestibility = organ.Live.DMDOfStructural * fractionLiveToRemove
                                                  + organ.Dead.DMDOfStructural * fractionDeadToRemove;
                    var defoliatedDM = amountLiveToRemove + amountDeadToRemove;
                    var defoliatedN  = organ.Live.N * 10 * fractionLiveToRemove + organ.Dead.N * 10 * fractionDeadToRemove;
                    if (defoliatedDM > 0)
                    {
                        RemoveBiomass(organ.Name, "Graze",
                                      new OrganBiomassRemovalType()
                        {
                            FractionLiveToRemove = fractionLiveToRemove,
                            FractionDeadToRemove = fractionDeadToRemove
                        });

                        defoliatedBiomass += new Biomass()
                        {
                            StructuralWt    = defoliatedDM,
                            StructuralN     = defoliatedN,
                            DMDOfStructural = defoliatedDigestibility
                        };
                    }
                }
            }
            return(defoliatedBiomass);
        }
Esempio n. 10
0
        /// <summary>
        /// Remove some dm. The fraction removed is calculation and put into the RemovedPool so that
        /// later one it can be removed from the actual Pool in the update routine.
        /// Routine was called giveDMGreenRemoved and giveDMSenescedRemoved in old Plant.
        /// </summary>
        internal static Biomass RemoveDM(double delta, Biomass Pool, string OrganName)
        {
            double fraction = MathUtilities.Divide(delta, Pool.Wt, 0.0);
            Biomass RemovedPool = Pool * fraction;

            double error_margin = 1.0e-6f;
            if (delta > Pool.Wt + error_margin)
            {
                string msg;
                msg = "Attempting to remove more green " + OrganName + " biomass than available:-\r\n";
                msg += "Removing -" + delta.ToString() + " (g/m2) from " + Pool.Wt.ToString() + " (g/m2) available.";
                throw new Exception(msg);
            }
            return RemovedPool;
        }
Esempio n. 11
0
        public static void CalcNDemand(double dltDm, double dltDmPotRue, double n_conc_crit, double n_conc_max,
                                         Biomass Growth, Biomass Green, double RetranslocationN,
                                         double n_deficit_uptake_fraction,
                                         ref double NDemand, ref double NMax)
        {
            double part_fract = MathUtilities.Divide(Growth.Wt, dltDm, 0.0);
            double dlt_dm_pot = dltDmPotRue * part_fract;         // potential dry weight increase (g/m^2)
            dlt_dm_pot = MathUtilities.Constrain(dlt_dm_pot, 0.0, dltDmPotRue);

            if (Green.Wt > 0.0)
            {
                // get N demands due to difference between
                // actual N concentrations and critical N concentrations
                double N_crit = Green.Wt * n_conc_crit;         // critical N amount (g/m^2)
                double N_potential = Green.Wt * n_conc_max;     // maximum N uptake potential (g/m^2)

                // retranslocation is -ve for outflows
                double N_demand_old = N_crit                       // demand for N by old biomass (g/m^2)
                                   - (Green.N + RetranslocationN);
                if (N_demand_old > 0.0)                             // Don't allow demand to satisfy all deficit
                    N_demand_old *= n_deficit_uptake_fraction;

                double N_max_old = N_potential                  // N required by old biomass to reach  N_conc_max  (g/m^2)
                                   - (Green.N + RetranslocationN);
                if (N_max_old > 0.0)
                    N_max_old *= n_deficit_uptake_fraction;         // Don't allow demand to satisfy all deficit

                // get potential N demand (critical N) of potential growth
                double N_demand_new = dlt_dm_pot * n_conc_crit;     // demand for N by new growth (g/m^2)
                double N_max_new = dlt_dm_pot * n_conc_max;      // N required by new growth to reach N_conc_max  (g/m^2)

                NDemand = N_demand_old + N_demand_new;
                NMax = N_max_old + N_max_new;

                NDemand = MathUtilities.Constrain(NDemand, 0.0, double.MaxValue);
                NMax = MathUtilities.Constrain(NMax, 0.0, double.MaxValue);
            }
            else
                NDemand = NMax = 0.0;
        }
Esempio n. 12
0
 /// <summary>Sets to.</summary>
 /// <param name="a">a.</param>
 public void SetTo(Biomass a)
 {
     _StructuralWt = a.StructuralWt;
     _NonStructuralWt = a.NonStructuralWt;
     _MetabolicWt = a.MetabolicWt;
     _StructuralN = a.StructuralN;
     _NonStructuralN = a.NonStructuralN;
     _MetabolicN = a.MetabolicN;
 }
Esempio n. 13
0
 /// <summary>Adds the specified a.</summary>
 /// <param name="a">a.</param>
 public void Add(Biomass a)
 {
     _StructuralWt += a._StructuralWt;
     _NonStructuralWt += a._NonStructuralWt;
     _MetabolicWt += a._MetabolicWt;
     _StructuralN += a._StructuralN;
     _NonStructuralN += a._NonStructuralN;
     _MetabolicN += a._MetabolicN;
 }
Esempio n. 14
0
 /// <summary>Subtracts the specified a.</summary>
 /// <param name="a">a.</param>
 public void Subtract(Biomass a)
 {
     _StructuralWt -= a._StructuralWt;
     _NonStructuralWt -= a._NonStructuralWt;
     _MetabolicWt -= a._MetabolicWt;
     _StructuralN -= a._StructuralN;
     _NonStructuralN -= a._NonStructuralN;
     _MetabolicN -= a._MetabolicN;
 }