library(ggplot2)
ana2CMToral <- function(Dose,pars,t){
  K10 <- pars['CL1']/pars['V1']
  K12 <- pars['CL2']/pars['V1']
  K21 <- pars['CL2']/pars['V2']
  A   <- K10 + K12 + K21
  L1  <- (A + sqrt(A * A - 4 * K10 * K21)) / 2
  L2  <- (A - sqrt(A * A - 4 * K10 * K21)) / 2
  C1  <- (K21 - L1) / (L2 - L1) / pars['V1']
  C2  <- (K21 - L2) / (L1 - L2) / pars['V1']
  KA <- pars['KA']

  (Dose * C1 * KA/(KA-L1) * (exp(-L1*t) - exp(-KA*t))) + (Dose * C2 * KA/(KA-L2) * (exp(-L2*t) - exp(-KA*t)))
}
pars   <- c(KA=0.1,CL1=10,V1=5,CL2=5,V2=100)
times  <- seq(0,24,length.out=200)
out    <- amp.sim::mdose(Dose=10,tau=24,ndose=1,t=times,func=ana2CMToral,pars=pars)
ggplot(out,aes(time,y)) + geom_line()
