aboutsummaryrefslogtreecommitdiff
path: root/R/mkinmod.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2014-07-14 19:07:54 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2014-07-14 19:07:54 +0200
commita69bf39427ff4f93eebdc8bceacb8174ff13c085 (patch)
treec5fcafef941417941db880b119a0452f19a3a51b /R/mkinmod.R
parent59f96473c7ee7b00f8b4fe5bd8d866ad6cadd048 (diff)
Nearly complete support for IORE, pending mkinerrmin
Diffstat (limited to 'R/mkinmod.R')
-rw-r--r--R/mkinmod.R26
1 files changed, 16 insertions, 10 deletions
diff --git a/R/mkinmod.R b/R/mkinmod.R
index 321887fc..8b86303f 100644
--- a/R/mkinmod.R
+++ b/R/mkinmod.R
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2013 Johannes Ranke {{{
+# Copyright (C) 2010-2014 Johannes Ranke {{{
# Contact: jranke@uni-bremen.de
# This file is part of the R package mkin
@@ -33,12 +33,10 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL)
stop("The use of formation fractions 'use_of_ff' can only be 'min' or 'max'")
# The returned model will be a list of character vectors, containing {{{
- # differential equations, parameter names and a mapping from model variables
- # to observed variables. If possible, a matrix representation of the
- # differential equations is included
+ # differential equations (if supported), parameter names and a mapping from
+ # model variables to observed variables. If possible, a matrix representation
+ # of the differential equations is included
parms <- vector()
- diffs <- vector()
- map <- list()
# }}}
# Do not return a coefficient matrix mat when FOMC, IORE, DFOP or HS is used for the parent {{{
@@ -49,6 +47,8 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL)
# Establish a list of differential equations as well as a map from observed {{{
# compartments to differential equations
+ diffs <- vector()
+ map <- list()
for (varname in obs_vars)
{
# Check the type component of the compartment specification {{{
@@ -59,7 +59,8 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL)
if(spec[[varname]]$type %in% c("FOMC", "DFOP", "HS") & match(varname, obs_vars) != 1) {
stop(paste("Types FOMC, DFOP and HS are only implemented for the first compartment,",
"which is assumed to be the source compartment"))
- } #}}}
+ }
+ #}}}
# New (sub)compartments (boxes) needed for the model type {{{
new_boxes <- switch(spec[[varname]]$type,
SFO = varname,
@@ -88,7 +89,11 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL)
if(spec[[varname]]$type %in% c("SFO", "IORE", "SFORB")) { # {{{ Add decline term
if (use_of_ff == "min") { # Minimum use of formation fractions
if(spec[[varname]]$sink) {
- # If sink is required, add first-order sink term
+ if(spec[[varname]]$type == "IORE" && length(spec[[varname]]$to) > 0) {
+ stop("Transformation reactions from compounds modelled with IORE\n",
+ "are only supported with formation fractions (use_of_ff = 'max')")
+ }
+ # If sink is required, add first-order/IORE sink term
k_compound_sink <- paste("k", box_1, "sink", sep = "_")
if(spec[[varname]]$type == "IORE") {
k_compound_sink <- paste("k.iore", box_1, "sink", sep = "_")
@@ -173,9 +178,10 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL)
for (target in to) {
target_box <- switch(spec[[target]]$type,
SFO = target,
+ IORE = target,
SFORB = paste(target, "free", sep = "_"))
- if (use_of_ff == "min" && spec[[varname]]$type %in% c("SFO",
- "SFORB")) {
+ if (use_of_ff == "min" && spec[[varname]]$type %in% c("SFO", "SFORB"))
+ {
k_from_to <- paste("k", origin_box, target_box, sep = "_")
parms <- c(parms, k_from_to)
diffs[[origin_box]] <- paste(diffs[[origin_box]], "-",

Contact - Imprint