From b0491cb4953ae752b7d14b1085222defee3b4505 Mon Sep 17 00:00:00 2001 From: Ranke Johannes Date: Mon, 16 Dec 2024 10:31:41 +0100 Subject: Fix a bug in UK drainage calculations If a soil_DT50 was specified, and the application date was later than the beginning of the drainage period (1 October), PECsw would increase. Now the amount available at the time of the drainage period is equal to the applied amount (minus interception) if application is later than the beginning of the drainage period. Fixes #4. Thanks to @lutzeli for spotting the problem. --- tests/testthat/test_UK_drainage.R | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/testthat') diff --git a/tests/testthat/test_UK_drainage.R b/tests/testthat/test_UK_drainage.R index 2789819..05c59b2 100644 --- a/tests/testthat/test_UK_drainage.R +++ b/tests/testthat/test_UK_drainage.R @@ -33,4 +33,12 @@ test_that("UK drainflow PECs are correct", { expect_equal(round(PEC_sw_drainage_UK(60, interception = 0.5, Koc = 550, latest_application = "01 July", soil_DT50 = 200), 2), 0.84) + + # Test that PECsw do not increase if the application is after the beginning + # of the drainflow period + expect_equal( + PEC_sw_drainage_UK(60, interception = 0.5, Koc = 550), + PEC_sw_drainage_UK(60, interception = 0.5, Koc = 550, + latest_application = "01 November", soil_DT50 = 200)) + }) -- cgit v1.2.1