aboutsummaryrefslogtreecommitdiff
path: root/pkg/tests
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/tests')
-rw-r--r--pkg/tests/testthat/test_PEC_sed.R2
-rw-r--r--pkg/tests/testthat/test_PEC_soil.R88
-rw-r--r--pkg/tests/testthat/test_PEC_sw_drift.R (renamed from pkg/tests/testthat/test_PEC_sw_drift_ini.R)4
-rw-r--r--pkg/tests/testthat/test_UK_drainage.R10
4 files changed, 93 insertions, 11 deletions
diff --git a/pkg/tests/testthat/test_PEC_sed.R b/pkg/tests/testthat/test_PEC_sed.R
index d83be0f..443f789 100644
--- a/pkg/tests/testthat/test_PEC_sed.R
+++ b/pkg/tests/testthat/test_PEC_sed.R
@@ -4,6 +4,6 @@ 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)
+ PEC_sw_100_1_m <- PEC_sw_drift(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_soil.R b/pkg/tests/testthat/test_PEC_soil.R
index 27b2eb7..0661a52 100644
--- a/pkg/tests/testthat/test_PEC_soil.R
+++ b/pkg/tests/testthat/test_PEC_soil.R
@@ -3,11 +3,93 @@ context("Simple PEC soil calculations")
test_that("PEC_soil calculates correctly", {
# Application of 100 g/ha gives 0.133 mg/kg under default assumptions
- expect_equal(PEC_soil(100), 0.1 * 4/3)
+ expect_equal(as.numeric(PEC_soil(100)), 0.1 * 4/3)
# or 0.1 mg/kg assuming 25% interception
- expect_equal(PEC_soil(100, interception = 0.25), 0.1)
+ expect_equal(as.numeric(PEC_soil(100, interception = 0.25)), 0.1)
# Mixing depth of 1 cm gives five-fold PEC
- expect_equal(PEC_soil(100, interception = 0.25, mixing_depth = 1), 0.5)
+ expect_equal(as.numeric(PEC_soil(100, interception = 0.25, mixing_depth = 1)), 0.5)
+})
+
+test_that("Tier 1 PEC soil example for Pesticide A in EFSA guidance can be reproduced", {
+ # Calculate total soil concentrations for tier 1 scenarios
+ results_pfm <- PEC_soil(1000, interval = 365, DT50 = 250, t_avg = c(0, 21),
+ scenarios = "EFSA_2015")
+
+ # From Table I.5, p. 80
+ results_guidance <- matrix(c(22.0, 11.5, 9.1, 21.8, 11.4, 9.0),
+ ncol = 3, byrow = TRUE)
+ dimnames(results_guidance) <- list(t_avg = c(0, 21),
+ scenario = c("CTN", "CTC", "CTS"))
+
+
+ expect_equal(round(results_pfm, 1), results_guidance)
+
+ # Calculate porewater soil concentrations for tier 1 scenarios
+ results_pfm_pw <- PEC_soil(1000, interval = 365, DT50 = 250, t_av = c(0, 21),
+ Kom = 1000, scenarios = "EFSA_2015", porewater = TRUE)
+
+ # From Table I.5, p. 80
+ results_guidance_pw <- matrix(c(0.76, 0.67, 0.91, 0.75, 0.66, 0.90),
+ ncol = 3, byrow = TRUE)
+ dimnames(results_guidance_pw) <- list(t_avg = c(0, 21),
+ scenario = c("CLN", "CLC", "CLS"))
+
+ expect_equal(round(results_pfm_pw, 2), results_guidance_pw)
+})
+
+test_that("Tier 1 PEC soil example for Pesticide F in EFSA guidance can be reproduced", {
+ # Parent F
+ # Calculate total and porewater soil concentrations for tier 1 scenarios
+ results_pfm <- PEC_soil(1000, interval = 365, DT50 = 25, t_avg = c(0, 21),
+ scenarios = "EFSA_2015")
+ results_pfm_pw <- PEC_soil(1000, interval = 365, DT50 = 25, t_av = c(0, 21),
+ Kom = 1000, scenarios = "EFSA_2015", porewater = TRUE)
+
+ # From Table I.14, p. 88
+ results_guidance <- matrix(c(12.8, 7.7, 6.6, 11.8, 6.8, 5.7),
+ ncol = 3, byrow = TRUE)
+ results_guidance_pw <- matrix(c(0.50, 0.46, 0.71, 0.45, 0.41, 0.60),
+ ncol = 3, byrow = TRUE)
+
+ # Skip checking dimnames by using expect_equivalent()
+ expect_equivalent(round(results_pfm, 1), results_guidance)
+ expect_equivalent(round(results_pfm_pw, 2), results_guidance_pw)
+
+ # Metabolite M1
+ # Calculate total and porewater soil concentrations for tier 1 scenarios
+ # Relative molar mass is 200/300, formation fraction is 0.7
+ results_pfm <- PEC_soil(200/300 * 0.7 * 1000, interval = 365, DT50 = 100, t_avg = c(0, 21),
+ scenarios = "EFSA_2015")
+ results_pfm_pw <- PEC_soil(200/300 * 0.7 * 1000, interval = 365, DT50 = 100, t_av = c(0, 21),
+ Kom = 10, scenarios = "EFSA_2015", porewater = TRUE)
+
+ # From Table I.15, p. 88
+ results_guidance <- matrix(c(7.27, 4.08, 3.38, 7.12, 3.97, 3.26),
+ ncol = 3, byrow = TRUE)
+ results_guidance_pw <- matrix(c(12.93, 10.42, 11.66, 12.58, 10.09, 11.15),
+ ncol = 3, byrow = TRUE)
+
+ # Skip checking dimnames by using expect_equivalent()
+ expect_equivalent(round(results_pfm, 2), results_guidance)
+ expect_equivalent(round(results_pfm_pw, 2), results_guidance_pw)
+
+ # Metabolite M2
+ # Calculate total and porewater soil concentrations for tier 1 scenarios
+ # Relative molar mass is 100/300, formation fraction is 0.7 * 1
+ results_pfm <- PEC_soil(100/300 * 0.7 * 1 * 1000, interval = 365, DT50 = 250, t_avg = c(0, 21),
+ scenarios = "EFSA_2015")
+ results_pfm_pw <- PEC_soil(100/300 * 0.7 * 1000, interval = 365, DT50 = 250, t_av = c(0, 21),
+ Kom = 100, scenarios = "EFSA_2015", porewater = TRUE)
+
+ # From Table I.16, p. 89
+ results_guidance <- matrix(c(5.13, 2.69, 2.13, 5.08, 2.66, 2.10),
+ ncol = 3, byrow = TRUE)
+ results_guidance_pw <- matrix(c(1.61, 1.39, 1.80, 1.60, 1.37, 1.77),
+ ncol = 3, byrow = TRUE)
+
+ # Skip checking dimnames by using expect_equivalent()
+ expect_equivalent(round(results_pfm, 2), results_guidance)
+ expect_equivalent(round(results_pfm_pw, 2), results_guidance_pw)
})
diff --git a/pkg/tests/testthat/test_PEC_sw_drift_ini.R b/pkg/tests/testthat/test_PEC_sw_drift.R
index 2480e5c..d09d578 100644
--- a/pkg/tests/testthat/test_PEC_sw_drift_ini.R
+++ b/pkg/tests/testthat/test_PEC_sw_drift.R
@@ -3,11 +3,11 @@ 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),
+ expect_equal(round(PEC_sw_drift(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),
+ expect_equal(round(PEC_sw_drift(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)
diff --git a/pkg/tests/testthat/test_UK_drainage.R b/pkg/tests/testthat/test_UK_drainage.R
index 3a57db8..859f145 100644
--- a/pkg/tests/testthat/test_UK_drainage.R
+++ b/pkg/tests/testthat/test_UK_drainage.R
@@ -21,13 +21,13 @@ test_that("UK drainflow PECs are correct", {
# 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)
+ expect_equal(round(PEC_sw_drainage_UK(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)
+ expect_equal(round(PEC_sw_drainage_UK(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)
+ expect_equal(round(PEC_sw_drainage_UK(60, interception = 0.5, Koc = 550,
+ latest_application = "01 July",
+ soil_DT50 = 200), 2), 0.84)
})

Contact - Imprint