# Auto-generated from a campsismod rxode_model
library(rxode2)

tmdd_qss <- rxode2::rxode2({
  # NOTE: dose is in mg
  MW=150000 # Molecular weight (g/mole)
  TVBIO=THETA_BIO
  TVKA=THETA_KA
  TVVC=THETA_VC
  TVCL=THETA_CL
  TVR0=THETA_R0
  TVKDEG=THETA_KDEG
  TVKSS=THETA_KSS
  TVKINT=THETA_KINT
  BIO=TVBIO
  KA=TVKA * exp(ETA_KA)
  VC=TVVC * exp(ETA_VC)
  CL=TVCL * exp(ETA_CL)
  R0=TVR0 * exp(ETA_R0)
  KDEG=TVKDEG * exp(ETA_KDEG)
  KSS=TVKSS * exp(ETA_KSS)
  KINT=TVKINT * exp(ETA_KINT)
  KSYN=KDEG*R0
  DELTA=pow(A_CENTRAL - A_RTOT - KSS, 2) + 4*KSS*A_CENTRAL
  L=0.5*(A_CENTRAL - A_RTOT - KSS + sqrt(DELTA))
  d/dt(A_ABS)=-KA*A_ABS
  d/dt(A_CENTRAL)=KA*A_ABS - (CL/VC - KINT)*L - KINT*A_CENTRAL
  d/dt(A_RTOT)=KSYN - (KINT - KDEG)*(A_CENTRAL - L) - KDEG*A_RTOT
  RTOT=A_RTOT
  COMPLEX=A_CENTRAL - L
  R=RTOT - COMPLEX
  RO=1-R/RTOT
  RR=R/R0
  f(A_CENTRAL)=(1/MW * 1000000)*1/VC
  f(A_ABS)=(BIO*(1/MW * 1000000))*1/VC
  A_RTOT(0)=R0
  DELTA_=pow(A_CENTRAL - A_RTOT - KSS, 2) + 4*KSS*A_CENTRAL
  L_=0.5*(A_CENTRAL - A_RTOT - KSS + sqrt(DELTA_))
  CONC=L_
  if (CONC <= 0.001) CONC=0.001
  CONC_ERR=CONC*(1 + EPS_PROP_RUV)
  CONC_mgL=MW/1000000 *CONC
  CONC_ngML=CONC_mgL*1000
})

tmdd_qss_theta <- 
c(THETA_BIO = 0.6, THETA_KA = 0.2, THETA_VC = 3, THETA_CL = 0.5, 
THETA_R0 = 20, THETA_KDEG = 2, THETA_KSS = 1, THETA_KINT = 1)

tmdd_qss_omega <- 
structure(c(0.0606246218164348, 0, 0, 0, 0, 0, 0, 0, 0.0606246218164348, 
0, 0, 0, 0, 0, 0, 0, 0.0606246218164348, 0, 0, 0, 0, 0, 0, 0, 
0.0606246218164348, 0, 0, 0, 0, 0, 0, 0, 0.0606246218164348, 
0, 0, 0, 0, 0, 0, 0, 0.0606246218164348, 0, 0, 0, 0, 0, 0, 0, 
0.0606246218164348), dim = c(7L, 7L), dimnames = list(c("ETA_KA", 
"ETA_VC", "ETA_CL", "ETA_R0", "ETA_KDEG", "ETA_KSS", "ETA_KINT"
), c("ETA_KA", "ETA_VC", "ETA_CL", "ETA_R0", "ETA_KDEG", "ETA_KSS", 
"ETA_KINT")))

tmdd_qss_sigma <- 
structure(0.01, dim = c(1L, 1L), dimnames = list("EPS_PROP_RUV", 
    "EPS_PROP_RUV"))

