aboutsummaryrefslogtreecommitdiff
path: root/tests/testthat/test_analytical.R
blob: e6cb7ed3bb9a262a0ef037a95e86457eb2c54cdb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
context("Analytical solutions for coupled models")

test_that("The analytical solutions for SFO-SFO are correct", {
  skip_on_cran()
  # No sink, no formation fractions
  SFO_SFO_nosink <- mkinmod(
    parent = mkinsub("SFO", to = "m1", sink = FALSE),
    m1 = mkinsub("SFO"),
    use_of_ff = "min", quiet = TRUE)
  f_sfo_sfo_nosink <- mkinfit(SFO_SFO_nosink, FOCUS_D, quiet = TRUE)
  f_sfo_sfo_nosink_deSolve <- mkinfit(SFO_SFO_nosink, FOCUS_D,
    solution_type = "deSolve", quiet = TRUE)
  expect_equal(
    parms(f_sfo_sfo_nosink),
    parms(f_sfo_sfo_nosink_deSolve)
  )

  # No sink, with formation fractions
  SFO_SFO.ff_nosink <- mkinmod(
    parent = mkinsub("SFO", to = "m1", sink = FALSE),
    m1 = mkinsub("SFO"),
    use_of_ff = "max", quiet = TRUE)
  f_sfo_sfo_nosink <- mkinfit(SFO_SFO.ff_nosink, FOCUS_D, quiet = TRUE)
  f_sfo_sfo_nosink_deSolve <- mkinfit(SFO_SFO.ff_nosink, FOCUS_D,
    solution_type = "deSolve", quiet = TRUE)
  expect_equal(
    parms(f_sfo_sfo_nosink),
    parms(f_sfo_sfo_nosink_deSolve)
  )

  # Without formation fraction
  f_sfo_sfo_analytical <- mkinfit(SFO_SFO, FOCUS_D,
    solution_type = "analytical", quiet = TRUE)
  expect_equal(
    parms(f_sfo_sfo_analytical),
    parms(f_sfo_sfo_desolve)
  )

  # With formation fraction
  f_sfo_sfo.ff_desolve <- mkinfit(SFO_SFO.ff, FOCUS_D,
    solution_type = "deSolve", quiet = TRUE)
  expect_equal(
    parms(f_sfo_sfo.ff),
    parms(f_sfo_sfo.ff_desolve),
    tolerance = 5e-6
  )

})

test_that("The analytical solution for DFOP-SFO are correct", {
  skip_on_cran()
  # With formation fraction
  f_dfop_sfo_analytical <- mkinfit(DFOP_SFO, FOCUS_D,
    solution_type = "analytical", quiet = TRUE)
  f_dfop_sfo_desolve <- mkinfit(DFOP_SFO, FOCUS_D,
    solution_type = "deSolve", quiet = TRUE)
  expect_equal(
    parms(f_dfop_sfo_analytical),
    parms(f_dfop_sfo_desolve),
    tolerance = 5e-6
  )
})

Contact - Imprint