defaultScriptWithParameter: Create a default script for loading and simulating a model...

Description Usage Arguments Value See Also Examples

View source: R/defaultScriptWithParameter.R

Description

Create a default script for loading and simulating a model with a varying parameter.

Usage

1
defaultScriptWithParameter(modelName, parameter=stop("parameter name required"), startTime=0, ...) 

Arguments

modelName

a string for the name of the model to be simulated. [required]

parameter

a string for the parameter to be varied [required]

startTime

OpenModelica simulate argument.

...

additional arguments to be passed to the OpenModelica simulate call.

Value

A list with two components. The first component "prefix" is a string for the model loading etc. The second component "each" is for each simulation, including a template string for the parameter value to be simulated.

See Also

See Also callOpenModelica and defaultScript.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
model <- "
model CalledbyR
  Real x(start=1.0),y(start=2.0);
  parameter Real b = 2.0;
equation
  der(x) = -b*y;
  der(y) = x;
end CalledbyR;"

out <- callOpenModelica("CalledbyR", model)
plot(y~time, data=out, type="l")

out <- callOpenModelica("CalledbyR", model, script=defaultScript("CalledbyR",stopTime=10))
plot(y~time, data=out, type="l")

out <-  callOpenModelica("CalledbyR",
                     model,
                     script=defaultScriptWithParameter("CalledbyR", "b", stopTime=10),
                     values=c(0.5,1,2))
if (require(ggplot2))
    qplot(x=time, y=y, data=transform(out, value=factor(value)), color=value, geom="line")

## End(Not run)

mclements/ROpenModelica documentation built on May 22, 2019, 3:06 p.m.