Skip to content

Commit

Permalink
Fix fert requirement calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
HamishBrownPFR committed Jun 13, 2024
1 parent fce4192 commit 1c36faf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions SVSModel/Models/Fertiliser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void RemainingFertiliserSchedule(DateTime startSchedulleDate,DateT
for (int passes = 0; passes < 50; passes++)
{
double lastPassLossEst = losses;
double remainingReqN = remainingRequirement(d, endScheduleDate, thisSim, trigger) + losses;
double remainingReqN = remainingRequirement(d, endScheduleDate, thisSim, initialN) + losses;
NAppn = remainingReqN / remainingSplits;
SoilNitrogen.UpdateBalance(d, NAppn, initialN, initialLossEst, ref thisSim, true, new Dictionary<DateTime, double>(),true);
losses = anticipatedLosses(d, endScheduleDate, thisSim.NLost);
Expand All @@ -90,12 +90,12 @@ public static void RemainingFertiliserSchedule(DateTime startSchedulleDate,DateT
}
}

private static double remainingRequirement(DateTime startDate, DateTime endDate, SimulationType thisSim, double trigger)
private static double remainingRequirement(DateTime startDate, DateTime endDate, SimulationType thisSim, double initialN)
{
double remainingCropN = thisSim.CropN[endDate] - thisSim.CropN[startDate];
DateTime[] remainingDates = Functions.DateSeries(startDate, endDate);
double remainingOrgN = remainingMineralisation(remainingDates, thisSim.NResidues, thisSim.NSoilOM);
double surplussMineralN = Math.Max(0, trigger - Constants.Trigger);
double surplussMineralN = Math.Max(0, initialN - Constants.Trigger);
return Math.Max(0, remainingCropN - remainingOrgN - surplussMineralN);
}

Expand Down

0 comments on commit 1c36faf

Please sign in to comment.