From ea9b75183bcf41fcdd6f61ec6060e94c4bc321a2 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 11 Jun 2015 12:13:47 +0200 Subject: Add simple drift PEC ini calculations These are tested for field crops with the CRD spreadsheet --- pkg/tests/testthat/test_PEC_sw_drift.R | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 pkg/tests/testthat/test_PEC_sw_drift.R (limited to 'pkg/tests') diff --git a/pkg/tests/testthat/test_PEC_sw_drift.R b/pkg/tests/testthat/test_PEC_sw_drift.R new file mode 100644 index 0000000..390df34 --- /dev/null +++ b/pkg/tests/testthat/test_PEC_sw_drift.R @@ -0,0 +1,14 @@ +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(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(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)) +}) + -- cgit v1.2.1 From cb0d72e2c2d431bd32ffb129b62ea1a522cbdfeb Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 11 Jun 2015 13:09:10 +0200 Subject: Rename PEC_sw_drift() to PEC_sw_drift_ini() --- pkg/tests/testthat/test_PEC_sw_drift.R | 14 -------------- pkg/tests/testthat/test_PEC_sw_drift_ini.R | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) delete mode 100644 pkg/tests/testthat/test_PEC_sw_drift.R create mode 100644 pkg/tests/testthat/test_PEC_sw_drift_ini.R (limited to 'pkg/tests') diff --git a/pkg/tests/testthat/test_PEC_sw_drift.R b/pkg/tests/testthat/test_PEC_sw_drift.R deleted file mode 100644 index 390df34..0000000 --- a/pkg/tests/testthat/test_PEC_sw_drift.R +++ /dev/null @@ -1,14 +0,0 @@ -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(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(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_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)) +}) -- cgit v1.2.1 From 3aa5fb86772c28402047c7ebd07841061dbcdbba Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 11 Jun 2015 15:23:22 +0200 Subject: Add facilities to calculate decline curves --- pkg/tests/testthat/test_SFO_actual_twa.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 pkg/tests/testthat/test_SFO_actual_twa.R (limited to 'pkg/tests') 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) +}) -- cgit v1.2.1 From dd803b191062925eda830543236836e7822fd884 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 11 Jun 2015 16:57:43 +0200 Subject: Add UK tier 1 drainage PEC calculations --- pkg/tests/testthat/test_UK_drainage.R | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 pkg/tests/testthat/test_UK_drainage.R (limited to 'pkg/tests') 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) +}) -- cgit v1.2.1 From fef0bb7fe916f91dcff089c17aa3290c0ea1ab1f Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 12 Jun 2015 02:19:38 +0200 Subject: Add sediment PEC calculations using the percentage method --- pkg/tests/testthat/test_PEC_sed.R | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 pkg/tests/testthat/test_PEC_sed.R (limited to 'pkg/tests') 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) +}) -- cgit v1.2.1