/// <summary> /// The Stock class constructor /// </summary> public Stock() : base() { this.FUserForages = new List<string>(); this.FUserPaddocks = new List<string>(); this.FRandFactory = new TMyRandom(this.FRandSeed); // random number generator this.FModel = new TStockList(this.FRandFactory); Array.Resize(ref FGenotypeInits, 0); Array.Resize(ref FAnimalInits, 0); FSuppFed = new TSupplement(); FExcretion = new TExcretionInfo(); FPaddocksGiven = false; FFirstStep = true; FRandSeed = 0; }
/// <summary> /// Used by returnExcretion() /// </summary> /// <param name="destExcretion"></param> /// <param name="srcExcretion"></param> private void addExcretions(ref TExcretionInfo destExcretion, TExcretionInfo srcExcretion) { if (srcExcretion.dDefaecations > 0.0) { destExcretion.dDefaecationVolume = dWeightedMean(destExcretion.dDefaecationVolume, srcExcretion.dDefaecationVolume, destExcretion.dDefaecations, srcExcretion.dDefaecations); destExcretion.dDefaecationArea = dWeightedMean(destExcretion.dDefaecationArea, srcExcretion.dDefaecationArea, destExcretion.dDefaecations, srcExcretion.dDefaecations); destExcretion.dDefaecationEccentricity = dWeightedMean(destExcretion.dDefaecationEccentricity, srcExcretion.dDefaecationEccentricity, destExcretion.dDefaecations, srcExcretion.dDefaecations); destExcretion.dFaecalNO3Propn = dWeightedMean(destExcretion.dFaecalNO3Propn, srcExcretion.dFaecalNO3Propn, destExcretion.InOrgFaeces.Nu[(int)GrazType.TOMElement.N], srcExcretion.InOrgFaeces.Nu[(int)GrazType.TOMElement.N]); destExcretion.dDefaecations = destExcretion.dDefaecations + srcExcretion.dDefaecations; destExcretion.OrgFaeces = AddDMPool(destExcretion.OrgFaeces, srcExcretion.OrgFaeces); destExcretion.InOrgFaeces = AddDMPool(destExcretion.InOrgFaeces, srcExcretion.InOrgFaeces); } if (srcExcretion.dUrinations > 0.0) { destExcretion.dUrinationVolume = dWeightedMean(destExcretion.dUrinationVolume, srcExcretion.dUrinationVolume, destExcretion.dUrinations, srcExcretion.dUrinations); destExcretion.dUrinationArea = dWeightedMean(destExcretion.dUrinationArea, srcExcretion.dUrinationArea, destExcretion.dUrinations, srcExcretion.dUrinations); destExcretion.dUrinationEccentricity = dWeightedMean(destExcretion.dUrinationEccentricity, srcExcretion.dUrinationEccentricity, destExcretion.dUrinations, srcExcretion.dUrinations); destExcretion.dUrinations = destExcretion.dUrinations + srcExcretion.dUrinations; destExcretion.Urine = AddDMPool(destExcretion.Urine, srcExcretion.Urine); } }
/// <summary> /// Parameters: /// OrgFaeces kg/ha Excretion of organic matter in faeces /// InorgFaeces kg/ha Excretion of inorganic nutrients in faeces /// Urine kg/ha Excretion of nutrients in urine /// /// Note: TAnimalGroup.OrgFaeces returns the OM faecal excretion in kg, and /// is the total of mothers and young where appropriate; similarly for /// TAnimalGroup.InorgFaeces and TAnimalGroup.Urine. /// TAnimalGroup.FaecalAA and TAnimalGroup.UrineAAN return weighted /// averages over mothers and young where appropriate. As a result we /// don't need to concern ourselves with unweaned young in this /// particular calculation except when computing PatchFract. /// </summary> /// <param name="iPaddID"></param> /// <param name="Excretion"></param> public void ReturnExcretion(int iPaddID, out TExcretionInfo Excretion) { TPaddockInfo ThePadd; double fArea; int Idx; ThePadd = FPaddocks.byID(iPaddID); if (ThePadd != null) fArea = ThePadd.fArea; else if (FPaddocks.Count() == 0) fArea = 1.0; else { fArea = 0.0; for (Idx = 0; Idx <= FPaddocks.Count() - 1; Idx++) fArea = fArea + FPaddocks.byIndex(Idx).fArea; } Excretion = new TExcretionInfo(); for (Idx = 1; Idx <= Count(); Idx++) { if ((ThePadd == null) || (getPaddInfo(Idx) == ThePadd)) { addExcretions(ref Excretion, At(Idx).Excretion); if (At(Idx).Young != null) addExcretions(ref Excretion, At(Idx).Young.Excretion); } } // Convert values in kg to kg/ha Excretion.OrgFaeces = MultiplyDMPool(Excretion.OrgFaeces, 1.0 / fArea); Excretion.InOrgFaeces = MultiplyDMPool(Excretion.InOrgFaeces, 1.0 / fArea); Excretion.Urine = MultiplyDMPool(Excretion.Urine, 1.0 / fArea); }