Example #1
0
 /// <summary>
 /// The the forage data
 /// </summary>
 /// <param name="forageInputs">Forage inputs</param>
 public void SetAvailForage(GrazType.GrazingInputs forageInputs)
 {
     this.useForageData = true;
     this.forageData.CopyFrom(forageInputs);
 }
Example #2
0
        /// <summary>
        /// Copies a Plant/AgPasture object biomass organs into GrazingInputs object
        /// This object may then get scaled to kg/ha
        /// </summary>
        /// <param name="forageObj">The forage object - a Plant/AgPasture component</param>
        /// <returns>The grazing inputs</returns>
        private GrazType.GrazingInputs Crop2GrazingInputs(IPlantDamage forageObj)
        {
            GrazType.GrazingInputs result = new GrazType.GrazingInputs();
            GrazType.zeroGrazingInputs(ref result);

            result.TotalGreen = 0;
            result.TotalDead  = 0;

            double totalDMD = 0;
            double totalN   = 0;
            double nConc;
            double meanDMD;
            double dmd;

            // calculate the green available based on the total green in this paddock
            double greenPropn = 0;

            // ** should really take into account the height ratio here e.g. Params.HeightRatio
            if (this.PastureGreenDM > GrazType.Ungrazeable)
            {
                greenPropn = 1.0 - (GrazType.Ungrazeable / this.PastureGreenDM);
            }

            // calculate the total live and dead biomass
            foreach (IOrganDamage biomass in forageObj.Organs)
            {
                if (biomass.IsAboveGround)
                {
                    if (biomass.Live.Wt > 0 || biomass.Dead.Wt > 0)
                    {
                        result.TotalGreen += (greenPropn * biomass.Live.Wt);   // g/m^2
                        result.TotalDead  += biomass.Dead.Wt;

                        // we can find the dmd of structural, assume storage and metabolic are 100% digestible
                        dmd       = (biomass.Live.DMDOfStructural * greenPropn * biomass.Live.StructuralWt) + (1 * greenPropn * biomass.Live.StorageWt) + (1 * greenPropn * biomass.Live.MetabolicWt); // storage and metab are 100% dmd
                        dmd      += ((biomass.Dead.DMDOfStructural * biomass.Dead.StructuralWt) + (1 * biomass.Dead.StorageWt) + (1 * biomass.Dead.MetabolicWt));
                        totalDMD += dmd;
                        totalN   += (greenPropn * biomass.Live.N) + (biomass.Dead.Wt > 0 ? biomass.Dead.N : 0); // g/m^2
                    }
                }
            }

            // TODO: Improve this routine
            double availDM = result.TotalGreen + result.TotalDead;

            if (availDM > 0)
            {
                meanDMD = totalDMD / availDM; // calc the average dmd for the plant
                nConc   = totalN / availDM;   // N conc
                // get the dmd distribution
                double[] dmdPropns;           // = new double[GrazType.DigClassNo + 1];

                // green 0.85-0.45, dead 0.70-0.30
                dmdPropns = ForageInfo.CalcDMDDistribution(meanDMD, 0.85, 0.45);    // FIX ME: the DMD ranges should be organ- and development-specific values

                for (int idx = 1; idx <= GrazType.DigClassNo; idx++)
                {
                    result.Herbage[idx].Biomass       = dmdPropns[idx] * availDM;
                    result.Herbage[idx].CrudeProtein  = nConc * GrazType.N2Protein;
                    result.Herbage[idx].Digestibility = GrazType.ClassDig[idx];
                    result.Herbage[idx].Degradability = Math.Min(0.90, result.Herbage[idx].Digestibility + 0.10);
                    result.Herbage[idx].HeightRatio   = 1;
                    result.Herbage[idx].PhosContent   = 0;    // N * 0.05?
                    result.Herbage[idx].SulfContent   = 0;    // N * 0.07?
                    result.Herbage[idx].AshAlkalinity = 0.70; // TODO: use a modelled value
                }

                if (forageObj is IPlant plant)
                {
                    switch (plant.PlantType)
                    {
                    case "AGPLucerne":
                    case "AGPRedClover":
                    case "AGPWhiteClover":
                        result.LegumePropn = 1;
                        break;

                    default:
                        result.LegumePropn = 0;
                        break;
                    }
                }

                result.SelectFactor = 0;    // TODO: set from Plant model value

                // TODO: Store any seed pools
            }

            return(result);
        }