aboutsummaryrefslogtreecommitdiff
path: root/pkg/tests
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2015-06-18 08:29:38 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2015-06-18 08:29:38 +0200
commit7faffad1907995f1b623ede8fc2e386693428e22 (patch)
tree6c68057b690daabf566a1d4825e177af1d8b9355 /pkg/tests
parent53099978c971ee8e5c94e67bf972f51629d67fd3 (diff)
parentfef0bb7fe916f91dcff089c17aa3290c0ea1ab1f (diff)
Merge branch 'master' into pfm_chent
Conflicts: pkg/DESCRIPTION pkg/NAMESPACE
Diffstat (limited to 'pkg/tests')
-rw-r--r--pkg/tests/testthat/test_PEC_sed.R9
-rw-r--r--pkg/tests/testthat/test_PEC_sw_drift_ini.R15
-rw-r--r--pkg/tests/testthat/test_SFO_actual_twa.R13
-rw-r--r--pkg/tests/testthat/test_UK_drainage.R33
4 files changed, 70 insertions, 0 deletions
diff --git a/pkg/tests/testthat/test_PEC_sed.R b/pkg/tests/testthat/test_PEC_sed.R
new file mode 100644
index 0000000..d83be0f
--- /dev/null
+++ b/pkg/tests/testthat/test_PEC_sed.R
@@ -0,0 +1,9 @@
+context("Simple PEC sediment calculations")
+
+test_that("PEC_sw_sed calculates correctly using the percentage method", {
+ # Application of 100 g/ha, 1 m spray drift distance (2.77% drift input), 50% in sediment,
+ # default assumptions of CRD spreadsheet (5 cm sediment depth, 1.3 kg/L sediment density)
+ # Reference value calculated with CRD spreadsheet
+ PEC_sw_100_1_m <- PEC_sw_drift_ini(100, distances = 1)
+ expect_equivalent(round(PEC_sw_sed(PEC_sw_100_1_m, percentage = 50), 3), 2.131)
+})
diff --git a/pkg/tests/testthat/test_PEC_sw_drift_ini.R b/pkg/tests/testthat/test_PEC_sw_drift_ini.R
new file mode 100644
index 0000000..2480e5c
--- /dev/null
+++ b/pkg/tests/testthat/test_PEC_sw_drift_ini.R
@@ -0,0 +1,15 @@
+library(pfm)
+context("Simple PEC surface water calculations with drift entry")
+
+test_that("PEC_sw_drift gives the same results as the CRD PEC calculator", {
+ # One application of 30 g/ha to field crops calculated with UK PEC calculator published by CRD
+ expect_equal(round(PEC_sw_drift_ini(30), 3),
+ c('1 m' = 0.277, '5 m' = 0.057, '10 m' = 0.029, '20 m' = 0.015))
+
+ # 7 applications of 30 g/ha to field crops calculated with UK PEC calculator, initial PEC
+ expect_equal(round(PEC_sw_drift_ini(30, 7), 3),
+ c('1 m' = 0.161, '5 m' = 0.033, '10 m' = 0.017, '20 m' = 0.008))
+
+ # 4 applications of 30 g/ha to late fruit crops calculated with UK PEC calculator published by CRD (uses different drift values from SANCO aquatic guidance)
+ #expect_equal(round(PEC_sw_drift(30, 4, crop = "Obstbau spät", distances = c(3, 20, 50)), 3), c('3 m' = 1.101, '20 m' = 0.080, '50 m' = 0.013))
+})
diff --git a/pkg/tests/testthat/test_SFO_actual_twa.R b/pkg/tests/testthat/test_SFO_actual_twa.R
new file mode 100644
index 0000000..b0a5537
--- /dev/null
+++ b/pkg/tests/testthat/test_SFO_actual_twa.R
@@ -0,0 +1,13 @@
+library(pfm)
+context("Actual and time weighted average concentrations for SFO kinetics")
+
+test_that("SFO_actual_twa calculates correctly", {
+ test_times <- c(0, 1, 7, 21, 42)
+ # This was calculated with the CRD spreadsheet for multiple applications
+ reference <- data.frame(
+ actual = c(10, 9.330, 6.156, 2.333, 0.544),
+ twa = c(NaN, 9.661, 7.923, 5.267, 3.248),
+ row.names = test_times)
+ result <- round(10 * SFO_actual_twa(10, times = test_times), 3)
+ expect_equal(result, reference)
+})
diff --git a/pkg/tests/testthat/test_UK_drainage.R b/pkg/tests/testthat/test_UK_drainage.R
new file mode 100644
index 0000000..3a57db8
--- /dev/null
+++ b/pkg/tests/testthat/test_UK_drainage.R
@@ -0,0 +1,33 @@
+library(pfm)
+context("UK drainage PEC calculations")
+
+test_that("The mobility classification and the drained percentage are correct", {
+ # Expected results are from the CRD drainage calculator, retrieved 2015-06-11
+
+ expect_equivalent(SSLRC_mobility_classification(1), list("Very mobile", 1.9))
+ expect_equivalent(SSLRC_mobility_classification(15), list("Mobile", 1.9))
+ expect_equivalent(SSLRC_mobility_classification(30), list("Mobile", 1.9))
+ expect_equivalent(SSLRC_mobility_classification(74.9), list("Mobile", 1.9))
+ expect_equivalent(SSLRC_mobility_classification(75), list("Moderately mobile", 0.7))
+ expect_equivalent(SSLRC_mobility_classification(100), list("Moderately mobile", 0.7))
+ expect_equivalent(SSLRC_mobility_classification(800), list("Slightly mobile", 0.5))
+ expect_equivalent(SSLRC_mobility_classification(2000), list("Slightly mobile", 0.02))
+ expect_equivalent(SSLRC_mobility_classification(5000), list("Non mobile", 0.01))
+})
+
+test_that("UK drainflow PECs are correct", {
+ # Expected results are from the CRD drainage calculator, retrieved 2015-06-11, except
+ # for the third example from the data requirements handbook
+
+ # This is the first example calculation from the data requirements handbook, where they give
+ # 8.07 µg/L as the result (obviously a rounding error).
+ expect_equal(round(PEC_sw_drainage_UK_ini(150, interception = 0, Koc = 100), 4), 8.0769)
+
+ # This is the second example calculation from the data requirements handbook
+ expect_equal(round(PEC_sw_drainage_UK_ini(90, interception = 0, Koc = 10), 4), 13.1538)
+
+ # This is the third example calculation from the data requirements handbook,
+ expect_equal(round(PEC_sw_drainage_UK_ini(60, interception = 0.5, Koc = 550,
+ latest_application = "01 July",
+ soil_DT50 = 200), 2), 0.84)
+})

Contact - Imprint