diff options
author | Ranke Johannes <johannes.ranke@agroscope.admin.ch> | 2024-12-16 10:31:41 +0100 |
---|---|---|
committer | Ranke Johannes <johannes.ranke@agroscope.admin.ch> | 2024-12-16 10:31:41 +0100 |
commit | b0491cb4953ae752b7d14b1085222defee3b4505 (patch) | |
tree | 47e525db000778aee681faa32b6696376ae8cda1 /tests/testthat | |
parent | 72b426cc767e9737cc66e3d41edb064011ab009d (diff) |
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.
Diffstat (limited to 'tests/testthat')
-rw-r--r-- | tests/testthat/test_UK_drainage.R | 8 |
1 files changed, 8 insertions, 0 deletions
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)) + }) |