private void OnAddUrine(AddUrineType UrineAdded) { // Starting with the minimalist version. To be updated by Val's group to include a urine patch algorithm // test for adding urine patches -RCichota // if VolumePerUrination = 0.0 then no patch will be added, otherwise a patch will be added (based on 'base' patch) // assuming new PatchArea is passed as a fraction and this will be subtracted from original // urea will be added to the top layer for now double[] newUrea = new double[dlayer.Length]; newUrea[0] = UrineAdded.Urea; if (UrineAdded.VolumePerUrination > 0.0) { SplitPatch(0); double oldArea = Patch[0].RelativeArea; double newArea = oldArea * (1 - UrineAdded.AreaPerUrination); Patch[0].RelativeArea = newArea; int k = Patch.Count - 1; Patch[k].RelativeArea = oldArea * UrineAdded.AreaPerUrination; Patch[k].PatchName = "Patch" + k.ToString(); if (UrineAdded.Urea > EPSILON) { Patch[k].dlt_urea = newUrea; } } else { for (int k = 0; k < Patch.Count; k++) { Patch[k].dlt_urea = newUrea; } } }
/// <summary> /// Copy the urine info into the AddUrineType /// </summary> /// <param name="iPaddID"></param> /// <param name="aValue"></param> /// <returns></returns> private bool PopulateUrine(int iPaddID, AddUrineType aValue) { int N = (int)GrazType.TOMElement.N; int P = (int)GrazType.TOMElement.P; int S = (int)GrazType.TOMElement.S; bool result = false; FModel.ReturnExcretion(iPaddID, out FExcretion); if (FExcretion.dUrinations > 0) { aValue.Urinations = FExcretion.dUrinations; aValue.VolumePerUrination = FExcretion.dUrinationVolume; aValue.AreaPerUrination = FExcretion.dUrinationArea; aValue.Eccentricity = FExcretion.dUrinationEccentricity; aValue.Urea = FExcretion.Urine.Nu[N]; aValue.POX = FExcretion.Urine.Nu[P]; aValue.SO4 = FExcretion.Urine.Nu[S]; aValue.AshAlk = FExcretion.Urine.AshAlk; result = true; } return result; }
/// <summary>Get the information about urine being added</summary> /// <param name="UrineAdded">Urine deposition data (includes urea N amount, volume, area affected, etc)</param> public void AddUrine(AddUrineType UrineAdded) { // Starting with the minimalist version. To be updated by Val's group to include a urine patch algorithm // test for adding urine patches -RCichota // if VolumePerUrination = 0.0 then no patch will be added, otherwise a patch will be added (based on 'base' patch) // assuming new PatchArea is passed as a fraction and this will be subtracted from original // urea will be added to the top layer for now double[] newUrea = new double[dlayer.Length]; newUrea[0] = UrineAdded.Urea; if (UrineAdded.VolumePerUrination > 0.0) { SplitPatch(0); double oldArea = Patch[0].RelativeArea; double newArea = oldArea * (1 - UrineAdded.AreaPerUrination); Patch[0].RelativeArea = newArea; int k = Patch.Count - 1; Patch[k].RelativeArea = oldArea * UrineAdded.AreaPerUrination; Patch[k].PatchName = "Patch" + k.ToString(); if (UrineAdded.Urea > EPSILON) Patch[k].dlt_urea = newUrea; } else for (int k = 0; k < Patch.Count; k++) Patch[k].dlt_urea = newUrea; }
private void OnDoStock(object sender, EventArgs e) { // Weather is retrieved at StartOfDay // for each paddock //FModel.Paddocks.byID(1).fWaterlog = 0.0; // TODO if (!FPaddocksGiven) { // update the paddock area as this can change during the simulation foreach (Zone zone in Apsim.FindAll(sim, typeof(Zone))) { FModel.Paddocks.byObj(zone).fArea = zone.Area; FModel.Paddocks.byObj(zone).Slope = zone.Slope; } RequestAvailableToAnimal(); // accesses each forage provider (crop) FModel.Paddocks.beginTimeStep(); SuppToStockType[] availSupp = Suppfeed.SuppToStock; for (int Idx = 0; Idx < availSupp.Length; Idx++) // each paddock { FSuppFed.SetSuppAttrs(availSupp[Idx]); FModel.PlaceSuppInPadd(availSupp[Idx].Paddock, availSupp[Idx].Amount, FSuppFed); } FWeather.MeanTemp = 0.5 * (FWeather.MaxTemp + FWeather.MinTemp); FModel.Weather = FWeather; // Do internal management tasks that are defined for the various // enterprises. This includes shearing, buying, selling... FModel.ManageInternalTasks(FWeather.TheDay); FModel.Dynamics(); TForageProvider forageProvider; // Return the amounts of forage removed for (int i = 0; i <= FModel.ForagesAll.Count() - 1; i++) { forageProvider = FModel.ForagesAll.ForageProvider(i); if (forageProvider.ForageObj != null) //if there is a pubevent or setter then { if (forageProvider.somethingRemoved()) { // TODO: forageProvider // Build "removedbyanimal" data // forageProvider.ForageObj // call property setter } } else throw new ApsimXException(this, "No destination for forage removal"); } //if destinations for the surface om and nutrients are known then //send the values to the components for (int Idx = 0; Idx <= FModel.Paddocks.Count() - 1; Idx++) { TPaddockInfo PaddInfo = FModel.Paddocks.byIndex(Idx); if (PaddInfo.AddFaecesObj != null) { SurfaceOrganicMatter.AddFaecesType faeces = new SurfaceOrganicMatter.AddFaecesType(); if (PopulateFaeces(PaddInfo.iPaddID, faeces)) { ((SurfaceOrganicMatter)PaddInfo.AddFaecesObj).AddFaeces(faeces); } } if (PaddInfo.AddUrineObj != null) { AddUrineType urine = new AddUrineType(); if (PopulateUrine(PaddInfo.iPaddID, urine)) { ((SoilNitrogen)PaddInfo.AddUrineObj).AddUrine(urine); } } } } }