Skip to content

Commit

Permalink
Change for new safeZero options
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Aug 29, 2024
1 parent 39e95f5 commit f85e135
Showing 1 changed file with 20 additions and 36 deletions.
56 changes: 20 additions & 36 deletions tests/testthat/test-rhs.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,29 @@ d/dt(y) = -1.0*(d/dt(x)+d/dt(z))
expect_warning(o1 <- rxSolve(orhs, et))

## expect_warning(rxSolve(orhs,et),"The initial conditions are at t = 0.4 instead of t = 0.")
expect_equal(round(as.data.frame(o1), 4),
structure(list(time = c(
0.4, 4, 40, 400, 4000, 40000, 4e+05,
4e+06, 4e+07, 4e+08, 4e+09, 4e+10
), x = c(
1, 0.9117, 0.7168,
0.4506, 0.1832, 0.039, 0.0049, -832.9988, -18106.8843, -190902.2423,
-1918897.229, -19198891.1895
), z = c(
0, 0.0882, 0.2831, 0.5494,
0.8168, 0.961, 0.9951, 833.9988, 18107.8843, 190903.2423, 1918898.229,
19198892.1895
), y = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), row.names = c(
NA,
-12L
), class = "data.frame"),
tolerance = 1e-4
)
df <- data.frame(time = c(0.4, 4, 40, 400, 4000, 40000, 4e+05, 4e+06, 4e+07,
4e+08, 4e+09, 4e+10),
x = c(1, 0.9117, 0.7168, 0.4506, 0.1832, 0.039, 0.0049, 5e-04,
1e-04, 0, 0, 0),
z = c(0, 0.0882, 0.2831, 0.5494, 0.8168, 0.961, 0.9951, 0.9995,
0.9999, 1, 1, 1),
y = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))

expect_equal(round(as.data.frame(o1), 4), df, tolerance = 1e-4)

o1$add.sampling(0)

expect_equal(round(as.data.frame(o1), 4),
structure(list(time = c(
0, 0.4, 4, 40, 400, 4000, 40000, 4e+05,
4e+06, 4e+07, 4e+08, 4e+09, 4e+10
), x = c(
1, 0.9852, 0.9055,
0.7158, 0.4505, 0.1832, 0.039, 0.0049, -832.9941, -18106.8732,
-190902.279, -1918898.6518, -19198893.9661
), z = c(
0, 0.0148,
0.0945, 0.2842, 0.5495, 0.8168, 0.961, 0.9951, 833.9941, 18107.8732,
190903.279, 1918899.6518, 19198894.9661
), y = c(
0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
)), row.names = c(NA, 13L), class = "data.frame"),
tolerance = 1e-4
)
df2 <- data.frame(time = c(0, 0.4, 4, 40, 400, 4000, 40000, 4e+05,
4e+06, 4e+07, 4e+08, 4e+09, 4e+10),
x = c(1, 0.9852, 0.9055, 0.7158, 0.4505, 0.1832,
0.039, 0.0049, 5e-04, 1e-04, 0, 0, 0),
z = c(0, 0.0148, 0.0945, 0.2842, 0.5495, 0.8168, 0.961,
0.9951, 0.9995, 0.9999, 1, 1, 1),
y = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))

expect_equal(round(as.data.frame(o1), 4), df2,
tolerance = 1e-4)

})

rxSetIni0(TRUE)
Expand Down

0 comments on commit f85e135

Please sign in to comment.