Plant-Food-Research-Open / FieldNBalance

Nitrogen balance model components and test procedures
https://plant-food-research-open.github.io/FieldNBalance/
GNU General Public License v3.0
2 stars 4 forks source link

Fix mass balance error if fertiliser entered after test #64

Closed HamishBrownPFR closed 4 months ago

HamishBrownPFR commented 4 months ago

Entering a soil test date that is prior to an actual fertiliser date breaks mass balance because the code was adding all fertiliser events and then doing all soil resets. The change in this PR combines doing actual fert applications and soil test resets into the same loop so they can be done sequentially.
Important Note. This change causes problems with the testing system because now the crop n uptake is done prior to fertiliser applicaiton which is a problem only for simulations run from the testing environment but makes the test results look bad because they now contain a know error (i.e crop N uptake is insufficient in many cases). I will keep a seperate branch for running tests but the simulation core needs to be refactored so the demands of the testing applicaiton and the schedulling applicaiton can both be met