C.from.slv: Create .C code from ruSlv object

View source: R/read.slv.R

C.from.slvR Documentation

Create .C code from ruSlv object

Description

The function creates deSolve-compatible C code from .SLV image and save it to a file.

Usage

C.from.slv(slv, file = "model.c",
            output = slv$output.on, dbs.compatibility = FALSE)

Arguments

slv

object of ruSlv class, model image.

file

filename to save .C code.

output

character vector with names of additional output values.

dbs.compatibility

logical value to use DBSolve-like method of parameters updates.

See Also

import.slv
deSolve
ode

Examples

### create and compile C code for 'example1.slv', Rtools may be reqired
C.from.slv(example1_ruSlv, output="D")
## Not run: 
system("R CMD SHLIB model.c") # compilation for .DLL
library(deSolve)
dyn.load(paste0("model", .Platform$dynlib.ext))
res<-ode(y=example1_ruSlv$ode.initials,
         times=seq(0,example1_ruSlv$solver.time.limit,0.1),
         func = "derivs",
         parms=example1_ruSlv$ode.parameters.external,
         dllname = "model",
         initfunc = "initmod",
         nout=length("D"),
         outnames = "D"
  )
dyn.unload(paste0("model", .Platform$dynlib.ext))  
plot(res)

## End(Not run)

### plot simulations from SLV model 
## Not run: 
  filePath<-system.file(package = "dbs", "extdata/example1.slv")
  raw<-read.slv(filePath) # read from example
  compatible.slv(raw) # TRUE
  example1_ruSlv<-import.slv(raw)
  C.from.slv(example1_ruSlv, output="D")
  system("R CMD SHLIB model.c") # compilation for .DLL
  library(deSolve)
  dyn.load(paste0("model", .Platform$dynlib.ext))
  res<-ode(y=example1_ruSlv$ode.initials,
           times=seq(0,example1_ruSlv$solver.time.limit,0.1),
           func = "derivs",
           parms=example1_ruSlv$ode.parameters.external,
           dllname = "model",
           initfunc = "initmod",
           nout=length("D"),
           outnames = "D"
  )
  dyn.unload(paste0("model", .Platform$dynlib.ext))  
  plot(res)

## End(Not run)

insysbio/dbs-package documentation built on Aug. 4, 2022, 2:11 p.m.