Ejemplo n.º 1
0
 /// <summary>
 /// Convert the dry matter pool
 /// </summary>
 /// <param name="Pool"></param>
 /// <param name="aValue"></param>
 /// <param name="bNPSVal"></param>
 public static void DMPool2Value(GrazType.DM_Pool Pool, TDMPoolHead aValue, bool bNPSVal = false)
 {
     if (!bNPSVal)
     {
         aValue.weight  = Pool.DM;                                         // Item[1] = "weight"   kg/head
         aValue.n       = Pool.Nu[(int)GrazType.TOMElement.N];             // Item[2] = "n"        kg/head
         aValue.p       = Pool.Nu[(int)GrazType.TOMElement.P];             // Item[3] = "p"        kg/head
         aValue.s       = Pool.Nu[(int)GrazType.TOMElement.S];             // Item[4] = "s"        kg/head
         aValue.ash_alk = Pool.AshAlk;                                     // Item[5] = "ash_alk"  mol/head
     }
     else
     {
         aValue.n = Pool.Nu[(int)GrazType.TOMElement.N];                   // Item[1] = "n"        kg/head
         aValue.p = Pool.Nu[(int)GrazType.TOMElement.P];                   // Item[2] = "p"        kg/head
         aValue.s = Pool.Nu[(int)GrazType.TOMElement.S];                   // Item[3] = "s"        kg/head
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Populate the dry matter pool
        /// </summary>
        /// <param name="Model"></param>
        /// <param name="iCode"></param>
        /// <param name="bUseYoung"></param>
        /// <param name="bUseAll"></param>
        /// <param name="bUseTag"></param>
        /// <param name="aValue"></param>
        /// <returns></returns>
        public static bool PopulateDMPoolValue(TStockList Model, int iCode, bool bUseYoung, bool bUseAll, bool bUseTag, ref TDMPoolHead[] aValue)
        {
            int          iNoPasses;
            TAnimalGroup aGroup;

            GrazType.DM_Pool Pool      = new GrazType.DM_Pool();
            GrazType.DM_Pool TotalPool = new GrazType.DM_Pool();
            int iDenom;
            int iPass, Idx;

            bool Result = true;

            for (int i = 0; i < aValue.Length; i++)
            {
                aValue[i] = new TDMPoolHead();
            }

            if (bUseTag)
            {
                iNoPasses = aValue.Length;
            }
            else
            {
                iNoPasses = 1;
            }

            for (iPass = 1; iPass <= iNoPasses; iPass++)
            {
                GrazType.ZeroDMPool(ref TotalPool);
                iDenom = 0;

                for (Idx = 1; Idx <= Model.Count(); Idx++)
                {
                    if (!bUseTag || (Model.getTag(Idx) == iPass))
                    {
                        if (!bUseYoung)
                        {
                            aGroup = Model.At(Idx);
                        }
                        else
                        {
                            aGroup = Model.At(Idx).Young;
                        }

                        GrazType.ZeroDMPool(ref Pool);
                        if (aGroup != null)
                        {
                            int N = (int)GrazType.TOMElement.N;
                            int P = (int)GrazType.TOMElement.P;
                            int S = (int)GrazType.TOMElement.S;

                            switch (iCode)
                            {
                            case StockProps.prpINTAKE:
                                Pool.DM     = aGroup.AnimalState.DM_Intake.Total;
                                Pool.Nu[N]  = aGroup.AnimalState.CP_Intake.Total / GrazType.N2Protein;
                                Pool.Nu[P]  = aGroup.AnimalState.Phos_Intake.Total;
                                Pool.Nu[S]  = aGroup.AnimalState.Sulf_Intake.Total;
                                Pool.AshAlk = aGroup.AnimalState.PaddockIntake.AshAlkalinity * aGroup.AnimalState.PaddockIntake.Biomass
                                              + aGroup.AnimalState.SuppIntake.AshAlkalinity * aGroup.AnimalState.SuppIntake.Biomass;
                                break;

                            case StockProps.prpINTAKE_PAST:
                                Pool.DM     = aGroup.AnimalState.DM_Intake.Herbage;
                                Pool.Nu[N]  = aGroup.AnimalState.CP_Intake.Herbage / GrazType.N2Protein;
                                Pool.Nu[P]  = aGroup.AnimalState.Phos_Intake.Herbage;
                                Pool.Nu[S]  = aGroup.AnimalState.Sulf_Intake.Herbage;
                                Pool.AshAlk = aGroup.AnimalState.PaddockIntake.AshAlkalinity * aGroup.AnimalState.PaddockIntake.Biomass;
                                break;

                            case StockProps.prpINTAKE_SUPP:
                                Pool.DM     = aGroup.AnimalState.DM_Intake.Supp;
                                Pool.Nu[N]  = aGroup.AnimalState.CP_Intake.Supp / GrazType.N2Protein;
                                Pool.Nu[P]  = aGroup.AnimalState.Phos_Intake.Supp;
                                Pool.Nu[S]  = aGroup.AnimalState.Sulf_Intake.Supp;
                                Pool.AshAlk = aGroup.AnimalState.SuppIntake.AshAlkalinity * aGroup.AnimalState.SuppIntake.Biomass;
                                break;

                            case StockProps.prpFAECES:
                                GrazType.AddDMPool(aGroup.AnimalState.OrgFaeces, Pool);
                                GrazType.AddDMPool(aGroup.AnimalState.InOrgFaeces, Pool);
                                break;

                            case StockProps.prpINORG_FAECES:
                                GrazType.AddDMPool(aGroup.AnimalState.InOrgFaeces, Pool);
                                break;

                            default:
                                Result = false;
                                break;
                            }
                        }

                        if (!bUseTag && !bUseAll)
                        {
                            DMPool2Value(Pool, aValue[Idx - 1], (iCode == StockProps.prpINORG_FAECES));
                        }
                        else if (aGroup != null)
                        {
                            GrazType.AddDMPool(GrazType.MultiplyDMPool(Pool, aGroup.NoAnimals), TotalPool);
                            iDenom = iDenom + aGroup.NoAnimals;
                        }
                    }
                } //_ loop over animal groups _

                if (bUseTag || bUseAll)
                {
                    if (iDenom > 0)
                    {
                        TotalPool = GrazType.PoolFraction(TotalPool, 1.0 / iDenom);
                    }
                    if (bUseAll)
                    {
                        DMPool2Value(TotalPool, aValue[0], (iCode == StockProps.prpINORG_FAECES));
                    }
                    else
                    {
                        DMPool2Value(TotalPool, aValue[iPass - 1], (iCode == StockProps.prpINORG_FAECES));
                    }
                }
            }
            return(Result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Populate the dry matter pool
        /// </summary>
        /// <param name="Model"></param>
        /// <param name="iCode"></param>
        /// <param name="bUseYoung"></param>
        /// <param name="bUseAll"></param>
        /// <param name="bUseTag"></param>
        /// <param name="aValue"></param>
        /// <returns></returns>
        public static bool PopulateDMPoolValue(TStockList Model, int iCode, bool bUseYoung, bool bUseAll, bool bUseTag, ref TDMPoolHead[] aValue)
        {
            int iNoPasses;
            TAnimalGroup aGroup;
            GrazType.DM_Pool Pool = new GrazType.DM_Pool();
            GrazType.DM_Pool TotalPool = new GrazType.DM_Pool();
            int iDenom;
            int iPass, Idx;

            bool Result = true;
            for (int i = 0; i < aValue.Length; i++)
                aValue[i] = new TDMPoolHead();

            if (bUseTag)
                iNoPasses = aValue.Length;
            else
                iNoPasses = 1;

            for (iPass = 1; iPass <= iNoPasses; iPass++)
            {
                GrazType.ZeroDMPool(ref TotalPool);
                iDenom = 0;

                for (Idx = 1; Idx <= Model.Count(); Idx++)
                {
                    if (!bUseTag || (Model.getTag(Idx) == iPass))
                    {
                        if (!bUseYoung)
                            aGroup = Model.At(Idx);
                        else
                            aGroup = Model.At(Idx).Young;

                        GrazType.ZeroDMPool(ref Pool);
                        if (aGroup != null)
                        {
                            int N = (int)GrazType.TOMElement.N;
                            int P = (int)GrazType.TOMElement.P;
                            int S = (int)GrazType.TOMElement.S;

                            switch (iCode)
                            {
                                case StockProps.prpINTAKE:
                                    Pool.DM = aGroup.AnimalState.DM_Intake.Total;
                                    Pool.Nu[N] = aGroup.AnimalState.CP_Intake.Total / GrazType.N2Protein;
                                    Pool.Nu[P] = aGroup.AnimalState.Phos_Intake.Total;
                                    Pool.Nu[S] = aGroup.AnimalState.Sulf_Intake.Total;
                                    Pool.AshAlk = aGroup.AnimalState.PaddockIntake.AshAlkalinity * aGroup.AnimalState.PaddockIntake.Biomass
                                                   + aGroup.AnimalState.SuppIntake.AshAlkalinity * aGroup.AnimalState.SuppIntake.Biomass;
                                    break;
                                case StockProps.prpINTAKE_PAST:
                                    Pool.DM = aGroup.AnimalState.DM_Intake.Herbage;
                                    Pool.Nu[N] = aGroup.AnimalState.CP_Intake.Herbage / GrazType.N2Protein;
                                    Pool.Nu[P] = aGroup.AnimalState.Phos_Intake.Herbage;
                                    Pool.Nu[S] = aGroup.AnimalState.Sulf_Intake.Herbage;
                                    Pool.AshAlk = aGroup.AnimalState.PaddockIntake.AshAlkalinity * aGroup.AnimalState.PaddockIntake.Biomass;
                                    break;
                                case StockProps.prpINTAKE_SUPP:
                                    Pool.DM = aGroup.AnimalState.DM_Intake.Supp;
                                    Pool.Nu[N] = aGroup.AnimalState.CP_Intake.Supp / GrazType.N2Protein;
                                    Pool.Nu[P] = aGroup.AnimalState.Phos_Intake.Supp;
                                    Pool.Nu[S] = aGroup.AnimalState.Sulf_Intake.Supp;
                                    Pool.AshAlk = aGroup.AnimalState.SuppIntake.AshAlkalinity * aGroup.AnimalState.SuppIntake.Biomass;
                                    break;
                                case StockProps.prpFAECES:
                                    GrazType.AddDMPool(aGroup.AnimalState.OrgFaeces, Pool);
                                    GrazType.AddDMPool(aGroup.AnimalState.InOrgFaeces, Pool);
                                    break;
                                case StockProps.prpINORG_FAECES:
                                    GrazType.AddDMPool(aGroup.AnimalState.InOrgFaeces, Pool);
                                    break;
                                default:
                                    Result = false;
                                    break;
                            }
                        }

                        if (!bUseTag && !bUseAll)
                        {
                            DMPool2Value(Pool, aValue[Idx - 1], (iCode == StockProps.prpINORG_FAECES));
                        }
                        else if (aGroup != null)
                        {
                            GrazType.AddDMPool(GrazType.MultiplyDMPool(Pool, aGroup.NoAnimals), TotalPool);
                            iDenom = iDenom + aGroup.NoAnimals;
                        }
                    }
                } //_ loop over animal groups _

                if (bUseTag || bUseAll)
                {
                    if (iDenom > 0)
                        TotalPool = GrazType.PoolFraction(TotalPool, 1.0 / iDenom);
                    if (bUseAll)
                    {
                        DMPool2Value(TotalPool, aValue[0], (iCode == StockProps.prpINORG_FAECES));
                    }
                    else
                    {
                        DMPool2Value(TotalPool, aValue[iPass - 1], (iCode == StockProps.prpINORG_FAECES));
                    }
                }
            }
            return Result;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Convert the dry matter pool
 /// </summary>
 /// <param name="Pool"></param>
 /// <param name="aValue"></param>
 /// <param name="bNPSVal"></param>
 public static void DMPool2Value(GrazType.DM_Pool Pool, TDMPoolHead aValue, bool bNPSVal = false)
 {
     if (!bNPSVal)
     {
         aValue.weight = Pool.DM;                                          // Item[1] = "weight"   kg/head          
         aValue.n = Pool.Nu[(int)GrazType.TOMElement.N];                   // Item[2] = "n"        kg/head          
         aValue.p = Pool.Nu[(int)GrazType.TOMElement.P];                   // Item[3] = "p"        kg/head          
         aValue.s = Pool.Nu[(int)GrazType.TOMElement.S];                   // Item[4] = "s"        kg/head          
         aValue.ash_alk = Pool.AshAlk;                                     // Item[5] = "ash_alk"  mol/head         
     }
     else
     {
         aValue.n = Pool.Nu[(int)GrazType.TOMElement.N];                   // Item[1] = "n"        kg/head          
         aValue.p = Pool.Nu[(int)GrazType.TOMElement.P];                   // Item[2] = "p"        kg/head          
         aValue.s = Pool.Nu[(int)GrazType.TOMElement.S];                   // Item[3] = "s"        kg/head          
     }
 }