/// <summary> /// /// </summary> public void CalculateTotalResidue() { if (CurrentCrop != null && UseLAIModel()) { total_crop_residue = 0; total_residue_cover = 0; LAIVegObjectController crop = (LAIVegObjectController)CurrentCrop; total_residue_cover = crop.residue_cover; int count = CropList.Count; for (int i = 1; i < count; ++i) { int index = GetCropIndex(crop) + 1; if (index == count) { index = 0; } crop = (LAIVegObjectController)CropList[index]; total_residue_cover = Math.Min(1.0, total_residue_cover + crop.residue_cover * (1 - total_residue_cover)); } for (int i = 0; i < count; ++i) { total_crop_residue += CropList[i].crop_residue; } } else { total_crop_residue = CropList[0].crop_residue; total_residue_cover = CropList[0].residue_cover; } total_residue_cover_percent = total_residue_cover * 100.0; }
/// <summary> /// /// </summary> public void CalculateTotalResidue() { //TODO: Make the crop residue function more generic -- remove type condition if (CurrentCrop != null && CurrentCrop.GetType() == typeof(LAIVegObjectController)) { TotalCropResidue = 0; TotalResidueCover = 0; LAIVegObjectController crop = (LAIVegObjectController)CurrentCrop; TotalResidueCover = crop.ResidueCover; crop.CalculateResidue(); int count = ChildControllers.Count; for (int i = 1; i < count; ++i) { int index = GetCropIndex(crop) + 1; if (index == count) { index = 0; } crop = (LAIVegObjectController)ChildControllers[index]; TotalResidueCover = Math.Min(1.0, TotalResidueCover + crop.ResidueCover * (1 - TotalResidueCover)); } for (int i = 0; i < count; ++i) { TotalCropResidue += ((VegObjectController)ChildControllers[i]).ResidueAmount; } } else { TotalCropResidue = ((VegObjectController)ChildControllers[0]).CropResidue; TotalResidueCover = ((VegObjectController)ChildControllers[0]).ResidueCover; } TotalResidueCoverPercent = TotalResidueCover * 100.0; }
/// <summary> /// /// </summary> /// <param name="crop"></param> public void CheckApplicationBasedOnGDD(LAIVegObjectController crop) { if (ApplicationIndex == 0 && crop.HeatUnits >= InputModel.TriggerGGDFirst) { ProductRateApplied = InputModel.ProductRate; ++ApplicationIndex; } else if (ApplicationIndex > 0 && crop.HeatUnits >= InputModel.TriggerGGDFirst + InputModel.TriggerGGDSubsequent * ApplicationIndex) { ProductRateApplied = InputModel.SubsequentProductRate; ++ApplicationIndex; } }
/// <summary> /// /// </summary> public void ApplyAnyNewPesticides() { AppliedPestOnVeg = 0; AppliedPestOnStubble = 0; AppliedPestOnSoil = 0; ResetPesticideInputs(); if (InputModel.ApplicationTiming == (int)EPestApplicationTiming.FixedDate) { if (Sim.Day == InputModel.ApplicationDate.Day && Sim.Month == InputModel.ApplicationDate.Month) { ProductRateApplied = InputModel.ProductRate; } } else if (InputModel.ApplicationTiming == (int)EPestApplicationTiming.FromSequenceFile) { int index = DateUtilities.isDateInSequenceList(Sim.Today, InputModel.PestApplicationDateList); if (index >= 0 && index < InputModel.PestApplicationValueList.Count) { ProductRateApplied = InputModel.PestApplicationValueList[index]; } } else { LAIVegObjectController crop = (LAIVegObjectController)Sim.VegetationController.CurrentCrop; if (crop != null) { if (crop.CropStatus != CropStatus.Fallow) { if (MathTools.DoublesAreEqual(crop.HeatUnitIndex, 0)) { ApplicationIndex = 0; } if (InputModel.ApplicationTiming == (int)EPestApplicationTiming.GDDCrop1 && crop == Sim.VegetationController.GetCrop(0)) { CheckApplicationBasedOnGDD(crop); } else if (InputModel.ApplicationTiming == (int)EPestApplicationTiming.GDDCrop2 && crop == Sim.VegetationController.GetCrop(1)) { CheckApplicationBasedOnGDD(crop); } else if (InputModel.ApplicationTiming == (int)EPestApplicationTiming.GDDCrop3 && crop == Sim.VegetationController.GetCrop(2)) { CheckApplicationBasedOnGDD(crop); } else if (InputModel.ApplicationTiming == (int)EPestApplicationTiming.DASCrop1 && crop == Sim.VegetationController.GetCrop(0)) { CheckApplicationBasedOnDAS(crop); } else if (InputModel.ApplicationTiming == (int)EPestApplicationTiming.DASCrop2 && crop == Sim.VegetationController.GetCrop(1)) { CheckApplicationBasedOnDAS(crop); } else if (InputModel.ApplicationTiming == (int)EPestApplicationTiming.DASCrop3 && crop == Sim.VegetationController.GetCrop(2)) { CheckApplicationBasedOnDAS(crop); } } else if (crop.CropStatus == CropStatus.Fallow && InputModel.ApplicationTiming == (int)EPestApplicationTiming.DaysSinceFallow) { CheckApplicationBasedOnDAH(); } } } if (ProductRateApplied > 0) { ApplyPesticide(); } }
/// <summary> /// /// </summary> public void ApplyAnyNewPesticides() { ResetPesticideInputs(); if (dataModel.ApplicationTiming == (int)EPestApplicationTiming.patFixedDate) { if (sim.day == dataModel.ApplicationDate.Day && sim.month == dataModel.ApplicationDate.Month) { ProductRateApplied = dataModel.ProductRate; } } else if (dataModel.ApplicationTiming == (int)EPestApplicationTiming.patFromSequenceFile) { int index = DateUtilities.isDateInSequenceList(sim.today, dataModel.PestApplicationDateList); if (index >= 0 && index < dataModel.PestApplicationValueList.Count) { ProductRateApplied = dataModel.PestApplicationValueList[index]; } } else { LAIVegObjectController crop = (LAIVegObjectController)sim.VegetationController.CurrentCrop; if (crop != null) { if (crop.CropStatus != CropStatus.csInFallow) { if (MathTools.DoublesAreEqual(crop.heat_unit_index, 0)) { ApplicationIndex = 0; } if (dataModel.ApplicationTiming == (int)EPestApplicationTiming.patGDDCrop1 && crop == sim.VegetationController.GetCrop(0)) { CheckApplicationBasedOnGDD(crop); } else if (dataModel.ApplicationTiming == (int)EPestApplicationTiming.patGDDCrop2 && crop == sim.VegetationController.GetCrop(1)) { CheckApplicationBasedOnGDD(crop); } else if (dataModel.ApplicationTiming == (int)EPestApplicationTiming.patGDDCrop3 && crop == sim.VegetationController.GetCrop(2)) { CheckApplicationBasedOnGDD(crop); } else if (dataModel.ApplicationTiming == (int)EPestApplicationTiming.patDASCrop1 && crop == sim.VegetationController.GetCrop(0)) { CheckApplicationBasedOnDAS(crop); } else if (dataModel.ApplicationTiming == (int)EPestApplicationTiming.patDASCrop2 && crop == sim.VegetationController.GetCrop(1)) { CheckApplicationBasedOnDAS(crop); } else if (dataModel.ApplicationTiming == (int)EPestApplicationTiming.patDASCrop3 && crop == sim.VegetationController.GetCrop(2)) { CheckApplicationBasedOnDAS(crop); } } else if (crop.CropStatus == CropStatus.csInFallow && dataModel.ApplicationTiming == (int)EPestApplicationTiming.patDaysSinceFallow) { CheckApplicationBasedOnDAH(); } } } if (ProductRateApplied > 0) { ApplyPesticide(); } }