aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2015-04-17 16:42:33 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2015-04-17 16:54:42 +0200
commit558b96b4e3cfd1845677620976f09bad2c641ecb (patch)
tree7ad297cfb50b8da566ca2f6d0b4360ab4896a2b8 /R
parentf9198dc35109df526607df213ebefee182b5b24f (diff)
Make compiled FOMC and DFOP models work
- Many thanks @karlines for the hint in ccSolve#1 how to declare the time variable and for writing the ccSolve package in the first place - Add tests for the compiled versions of the FOMC and DFOP models
Diffstat (limited to 'R')
-rw-r--r--R/mkinmod.R9
1 files changed, 4 insertions, 5 deletions
diff --git a/R/mkinmod.R b/R/mkinmod.R
index e73c56c6..3fff0878 100644
--- a/R/mkinmod.R
+++ b/R/mkinmod.R
@@ -126,8 +126,8 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL)
}
} #}}}
if(spec[[varname]]$type == "FOMC") { # {{{ Add FOMC decline term
- # From p. 53 of the FOCUS kinetics report
- decline_term <- paste("(alpha/beta) * ((time/beta) + 1)^-1 *", box_1)
+ # From p. 53 of the FOCUS kinetics report, without the power function so it works in C
+ decline_term <- paste("(alpha/beta) * 1/((time/beta) + 1) *", box_1)
parms <- c(parms, "alpha", "beta")
} #}}}
if(spec[[varname]]$type == "DFOP") { # {{{ Add DFOP decline term
@@ -295,10 +295,9 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL)
replacement <- paste0("* y[", i - 1, "]")
diffs.C <- gsub(pattern, replacement, diffs.C)
}
- # Unfortunately, the models with time occuring in the diffs do not compile
- if (sum(sapply(spec, function(x) x$type %in% c("SFO", "SFORB"))) == length(spec)) {
+ if (sum(sapply(spec, function(x) x$type %in% c("SFO", "FOMC", "DFOP", "SFORB"))) == length(spec)) {
message("Compiling differential equation model from auto-generated C code...")
- model$compiled <- compile.ode(diffs.C, language = "C", parms = parms)
+ model$compiled <- compile.ode(diffs.C, language = "C", parms = parms, declaration = "double time = *t;")
}
}
# }}}

Contact - Imprint