From 72c56f4246966c1bea627f601cf3cc457734f023 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 19 Feb 2019 12:27:00 +0100 Subject: Add German drainage calculations using Exposit 3.02 --- tests/testthat/test_PEC_soil.R | 14 +++++--- tests/testthat/test_exposit.R | 80 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 75 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/testthat/test_PEC_soil.R b/tests/testthat/test_PEC_soil.R index 6e4e30b..810389f 100644 --- a/tests/testthat/test_PEC_soil.R +++ b/tests/testthat/test_PEC_soil.R @@ -132,15 +132,21 @@ test_that("Long term FOMC PEC soil from ESCAPE can be reproduced", { # Application of 100 g/ha with 25% interception and FOMC degradation type a fomc_50_a <- PEC_soil(100, interception = 0.25, FOMC = c(alpha = 1, beta = 10), interval = 365, tillage_depth = 20, n_periods = 50) - fomc_long_a <- PEC_soil(100, interception = 0.25, FOMC = c(alpha = 1, beta = 10), - interval = 365, tillage_depth = 20) + expect_warning( + fomc_long_a <- PEC_soil(100, interception = 0.25, FOMC = c(alpha = 1, beta = 10), + interval = 365, tillage_depth = 20), + "pseudo-plateau" + ) # Application of 100 g/ha with 25% interception and FOMC degradation type b # The long term PEC is much lower than when adding FOMC curves for 50 years fomc_50_b <- PEC_soil(100, interception = 0.25, FOMC = c(alpha = 0.5, beta = 20), interval = 365, tillage_depth = 20, n_periods = 50) - fomc_long_b <- PEC_soil(100, interception = 0.25, FOMC = c(alpha = 0.5, beta = 20), - interval = 365, tillage_depth = 20) + expect_warning( + fomc_long_b <- PEC_soil(100, interception = 0.25, FOMC = c(alpha = 0.5, beta = 20), + interval = 365, tillage_depth = 20), + "pseudo-plateau" + ) expect_true(fomc_50_b > fomc_long_b) diff --git a/tests/testthat/test_exposit.R b/tests/testthat/test_exposit.R index 667b4ee..f6a2de4 100644 --- a/tests/testthat/test_exposit.R +++ b/tests/testthat/test_exposit.R @@ -1,25 +1,75 @@ library(pfm) -context("Exposit runoff calculations") +context("Exposit calculations") +# Expected results are from the Exposit 3.02, downloaded 2019-02-15 -test_that("Runoff PECsw are as in Exposit 3.01", { - # Expected results are from the Exposit 3.01, downloaded 2017-10-27 +test_that("Runoff PECsw are as in Exposit 3.02", { + # 100 g/ha, Koc = 1000 L/kg, DT50 = 1000 days + res_exposit_1 <- data.frame( + runoff = c(183.62, 110.17, 73.45, 36.72), + erosion = c(19.96, 11.98, 2.99, 1.00), + PEC_dissolved = c(0.71, 0.61, 0.52, 0.37), + PEC_total = c(0.78, 0.68, 0.55, 0.38)) + + res_1 <- PEC_sw_exposit_runoff(100, Koc = 1000, DT50 = 1000) + res_pfm_1 <- data.frame( + runoff = round(1000 * res_1$runoff["dissolved"], 2), + erosion = round(1000 * res_1$runoff["bound"], 2), + PEC_dissolved = round(res_1$PEC_sw_runoff, 2)["dissolved"], + PEC_total = round(res_1$PEC_sw_runoff["dissolved"] + res_1$PEC_sw_runoff["bound"], 2)) + expect_equivalent(res_exposit_1, res_pfm_1) + + # 10 g/ha, Koc = 300000 L/kg, DT50 = 10 days + res_exposit_2 <- data.frame( + runoff = c(0.08, 0.05, 0.03, 0.02), + erosion = c(36.63, 21.98, 5.49, 1.83), + PEC_dissolved = c(0, 0, 0, 0), + PEC_total = c(0.14, 0.12, 0.04, 0.02)) + res_2 <- PEC_sw_exposit_runoff(10, Koc = 300000, DT50 = 10) + res_pfm_2 <- data.frame( + runoff = round(1000 * res_2$runoff["dissolved"], 2), + erosion = round(1000 * res_2$runoff["bound"], 2), + PEC_dissolved = round(res_2$PEC_sw_runoff, 2)["dissolved"], + PEC_total = round(res_2$PEC_sw_runoff["dissolved"] + res_2$PEC_sw_runoff["bound"], 2)) + + expect_equivalent(res_exposit_2, res_pfm_2) + + # 200 g/ha, Koc = 30 L/kg, DT50 = 100 days + res_exposit_3 <- data.frame( + runoff = c(295.78, 177.47, 118.31, 59.16), + erosion = rep(0.00, 4), + PEC_dissolved = c(1.14, 0.99, 0.85, 0.59), + PEC_total = c(1.14, 0.99, 0.85, 0.59)) + + res_3 <- PEC_sw_exposit_runoff(200, Koc = 30, DT50 = 100) + res_pfm_3 <- data.frame( + runoff = round(1000 * res_3$runoff["dissolved"], 2), + erosion = round(1000 * res_3$runoff["bound"], 2), + PEC_dissolved = round(res_3$PEC_sw_runoff, 2)["dissolved"], + PEC_total = round(res_3$PEC_sw_runoff["dissolved"] + res_3$PEC_sw_runoff["bound"], 2)) + + expect_equivalent(res_exposit_3, res_pfm_3) +}) + +test_that("Drainage PECsw are as in Exposit 3.02", { # 100 g/ha, Koc = 1000 L/kg, DT50 = 1000 days - PEC_spreadsheet_1 <- data.frame(dissolved = c(0.706, 0.612, 0.525, 0.367), - total = c(0.783, 0.679, 0.546, 0.377)) + res_exposit_1 <- c(spring = 0.02, autumn = 0.05) - PEC_pfm_1 <- round(PEC_sw_exposit_runoff(100, Koc = 1000, DT50 = 1000)$PEC_sw_runoff, 3)[c("dissolved", "total")] - expect_equivalent(PEC_spreadsheet_1, PEC_pfm_1) + res_1 <- PEC_sw_exposit_drainage(100, Koc = 1000, DT50 = 1000) + res_pfm_1 <- round(res_1$PEC_sw_drainage, 2) + expect_equivalent(res_exposit_1, res_pfm_1) # 10 g/ha, Koc = 300000 L/kg, DT50 = 10 days - PEC_spreadsheet_2 <- data.frame(dissolved = c(0, 0, 0, 0), - total = c(0.141, 0.122, 0.039, 0.018)) - PEC_pfm_2 <- round(PEC_sw_exposit_runoff(10, Koc = 300000, DT50 = 10)$PEC_sw_runoff, 3)[c("dissolved", "total")] - expect_equivalent(PEC_spreadsheet_2, PEC_pfm_2) + res_exposit_2 <- c(spring = 0.00, autumn = 0.00) + + res_2 <- PEC_sw_exposit_drainage(10, Koc = 300000, DT50 = 10) + res_pfm_2 <- round(res_2$PEC_sw_drainage, 2) + expect_equivalent(res_exposit_2, res_pfm_2) # 200 g/ha, Koc = 30 L/kg, DT50 = 100 days - PEC_spreadsheet_3 <- data.frame(dissolved = c(1.138, 0.986, 0.845, 0.592), - total = c(1.138, 0.986, 0.845, 0.592)) - PEC_pfm_3 <- round(PEC_sw_exposit_runoff(200, Koc = 30, DT50 = 100)$PEC_sw_runoff, 3)[c("dissolved", "total")] - expect_equivalent(PEC_spreadsheet_3, PEC_pfm_3) + res_exposit_3 <- c(spring = 0.61, autumn = 1.88) + + res_3 <- PEC_sw_exposit_drainage(200, Koc = 30, DT50 = 100) + res_pfm_3 <- round(res_3$PEC_sw_drainage, 2) + expect_equivalent(res_exposit_3, res_pfm_3) }) -- cgit v1.2.1