Debian Codegraph @

man/ccl4model.Rd

raw
1 \name{ccl4model}
2 \alias{ccl4model}
3
4 \title{The CCl4 Inhalation Model}
5
6 \description{The CCl4 inhalation model implemented in \code{.Fortran}}
7
8 \usage{ccl4model(times, y, parms, ...)}
9 \arguments{
10 \item{times }{time sequence for which the model has to be integrated.}
11 \item{y }{the initial values for the state variables ("AI", "AAM",
12 "AT", "AF", "AL", "CLT" and "AM"), in that order.
13 }
14 \item{parms }{vector or list holding the ccl4 model parameters; see
15 the example for the order in which these have to be defined.
16 }
17 \item{... }{any other parameters passed to the integrator \code{ode}
18 (which solves the model).
19 }
20 }
21 \author{R. Woodrow Setzer <[email protected]>}
22 \examples{
23 ## =================
24 ## Parameter values
25 ## =================
26
27 Pm <- c(
28 ## Physiological parameters
29 BW = 0.182, # Body weight (kg)
30 QP = 4.0 , # Alveolar ventilation rate (hr^-1)
31 QC = 4.0 , # Cardiac output (hr^-1)
32 VFC = 0.08, # Fraction fat tissue (kg/(kg/BW))
33 VLC = 0.04, # Fraction liver tissue (kg/(kg/BW))
34 VMC = 0.74, # Fraction of muscle tissue (kg/(kg/BW))
35 QFC = 0.05, # Fractional blood flow to fat ((hr^-1)/QC
36 QLC = 0.15, # Fractional blood flow to liver ((hr^-1)/QC)
37 QMC = 0.32, # Fractional blood flow to muscle ((hr^-1)/QC)
38
39 ## Chemical specific parameters for chemical
40 PLA = 16.17, # Liver/air partition coefficient
41 PFA = 281.48, # Fat/air partition coefficient
42 PMA = 13.3, # Muscle/air partition coefficient
43 PTA = 16.17, # Viscera/air partition coefficient
44 PB = 5.487, # Blood/air partition coefficient
45 MW = 153.8, # Molecular weight (g/mol)
46 VMAX = 0.04321671, # Max. velocity of metabolism (mg/hr) -calibrated
47 KM = 0.4027255, # Michaelis-Menten constant (mg/l) -calibrated
48
49 ## Parameters for simulated experiment
50 CONC = 1000, # Inhaled concentration
51 KL = 0.02, # Loss rate from empty chamber /hr
52 RATS = 1.0, # Number of rats enclosed in chamber
53 VCHC = 3.8 # Volume of closed chamber (l)
54 )
55
56 ## ================
57 ## State variables
58 ## ================
59 y <- c(
60 AI = 21, # total mass , mg
61 AAM = 0,
62 AT = 0,
63 AF = 0,
64 AL = 0,
65 CLT = 0, # area under the conc.-time curve in the liver
66 AM = 0 # the amount metabolized (AM)
67 )
68
69 ## ==================
70 ## Model application
71 ## ==================
72
73 times <- seq(0, 6, by = 0.1)
74
75 ## initial inhaled concentration-calibrated
76 conc <- c(26.496, 90.197, 245.15, 951.46)
77
78 plot(ChamberConc ~ time, data = ccl4data, xlab = "Time (hours)",
79 xlim = range(c(0, ccl4data$time)),
80 ylab = "Chamber Concentration (ppm)",
81 log = "y", main = "ccl4model")
82
83 for (cc in conc) {
84 Pm["CONC"] <- cc
85
86 VCH <- Pm[["VCHC"]] - Pm[["RATS"]] * Pm[["BW"]]
87 AI0 <- VCH * Pm[["CONC"]] * Pm[["MW"]]/24450
88 y["AI"] <- AI0
89
90 ## run the model:
91 out <- as.data.frame(ccl4model(times, y, Pm))
92 lines(out$time, out$CP, lwd = 2)
93 }
94
95 legend("topright", lty = c(NA, 1), pch = c(1, NA), lwd = c(NA, 2),
96 legend = c("data", "model"))
97
98 ## ==================================
99 ## An example with tracer injection
100 ## ==================================
101 ## every day, a conc of 2 is added to AI.
102 ## 1. implemented as a data.frame
103 eventdat <- data.frame(var = rep("AI", 6), time = 1:6 ,
104 value = rep(1, 6), method = rep("add", 6))
105
106 eventdat
107
108 print(system.time(
109 out <-ccl4model(times, y, Pm, events = list(data = eventdat))
110 ))
111
112 plot(out, mfrow = c(3, 4), type = "l", lwd = 2)
113
114
115 # 2. implemented as a function in a DLL!
116 print(system.time(
117 out2 <-ccl4model(times, y, Pm, events = list(func = "eventfun", time = 1:6))
118 ))
119
120 plot(out2, mfrow=c(3, 4), type = "l", lwd = 2)
121 }
122
123 \details{
124 The model is implemented primarily to demonstrate the linking of FORTRAN
125 with R-code.
126
127 The source can be found in the \file{/doc/examples/dynload} subdirectory of the
128 package.
129 }
130 \seealso{
131 Try \code{demo(CCL4model)} for how this model has been fitted to the
132 dataset \code{\link{ccl4data},}
133
134 \code{\link{aquaphy}}, another FORTRAN model, describing growth in
135 aquatic phytoplankton.
136 }
137 \keyword{models}
138