Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Add tests for 1 cmt bolus 1 cmt oral
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Nov 10, 2023
1 parent f1c48e1 commit 9fcdb99
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion tests/testthat/test-sol1pt.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ test_that("single point 2-cmt linCmt rate", {
})

test_that("single point 2-cmt linCmt oral bolus + iv rate", {

.v <- .solComp2(k10=0.1, k12=3, k21=1)

pX <- c(10, 0, 0)
Expand Down Expand Up @@ -343,7 +344,53 @@ test_that("single point 2-cmt linCmt oral bolus + iv rate", {

Xo <- c(pX[1] * Ea, Xo)

pX2 <- .solve1pt(pX, ka=ka, t=1, k10=0.1, k12=3, k21=1, k13=2, k31=0.5, rate=c(0, rate))
pX2 <- .solve1pt(pX, ka=ka, t=1, k10=0.1, k12=3, k21=1, rate=c(0, rate))

expect_equal(Xo, pX2)

})


test_that("1 compartment linCmt() bolus", {

k10 <- 0.1
pX <- 10
dT <- 1
Xo <- pX * exp(-k10 * dT)

pX2 <- .solve1pt(pX, t=1, k10=0.1, rate=0)

expect_equal(pX2, Xo)

pX <- pX2
Xo <- pX * exp(-k10 * dT)

pX2 <- .solve1pt(pX, t=1, k10=0.1, rate=0)

expect_equal(pX2, Xo)

})

test_that("1 compartment linCmt() oral bolus", {

k10 <- 0.1
pX <- c(10, 0)
dT <- 1
ka <- 1
Xo <- c(pX[1] *exp(-ka * dT),
pX[2] * exp(-k10 * dT) + pX[1] * ka / (ka - k10) * (exp(-k10 * dT) - exp(-ka * dT)))

pX2 <- .solve1pt(pX, t=1, ka=ka, k10=0.1, rate=c(0, 0))

expect_equal(pX2, Xo)

pX <- pX2

Xo <- c(pX[1] *exp(-ka * dT),
pX[2] * exp(-k10 * dT) + pX[1] * ka / (ka - k10) * (exp(-k10 * dT) - exp(-ka * dT)))

pX2 <- .solve1pt(pX, t=1, ka=ka, k10=0.1, rate=c(0, 0))

expect_equal(pX2, Xo)

})

0 comments on commit 9fcdb99

Please sign in to comment.