CreateModel
create a MapleSim model from either a Modelica file or Modelica source
Calling Sequence
Parameters
Returns
Options
Description
Examples
MapleSim:-CreateModel(modelica, options)
CreateModel(modelica, options)
modelica
-
string ; either the name of the file containing the Modelica code model or the Modelica source from which the MapleSim model is to be created. Use the file option to specify whether modelica is a file name or code.
options
(optional) equation(s) of the form name = value
string ; the name of the created MapleSim file
file : true or false
Specifies whether modelica represents a file name or Modelica code. If file = true, then modelica represents a file name. If file = false, then modelica contains Modelica code. The default is true.
output : string
Specifies the file name for the output MapleSim model (.msim).
Note: If file = false, the output file name must be specified. If file = true, the default name of the output file is the base name of modelica with the .msim file extension. For example, if modelica is sample.mo the output file name is sample.msim.
The CreateModel command creates a MapleSim model from a Modelica file.
If modelica contains a model called Main, this model is used as the active model in MapleSim. That is, it is displayed on the modeling canvas when the model opens in MapleSim and calls to any API commands will operate on this model. All other models appear in the Components palette under the Definitions tab.
If no Main model is defined in the Modelica file, the active model is empty.
If modelica is an empty string and file = false, a MapleSim file is created consisting of an empty Main model.
The CreateModel command is part of the MapleSim package. You can access this command using the long form of the command name, MapleSim:-CreateModel, or by first executing with(MapleSim) and then using the short form of the command name, CreateModel.
with⁡MapleSim:
msimfile≔CreateModel⁡cat⁡kernelopts⁡toolboxdir=MapleSim,/data/examples/BouncingBall.mo,output=cat⁡FileTools:-TemporaryDirectory⁡,/example1.msim:
FileTools:-Exists⁡msimfile
true
A≔LinkModel⁡filename=msimfile:
A:-GetEquations⁡
−EG1_f_c⁡t−SM1_flange_a_f⁡t−_msim_noEvent⁡EG1_f_c⁡tEG1_f_d2⁡t<EG1_f_c⁡t−EG1_f_c⁡t−EG1_f_c⁡t<EG1_f_d2⁡tEG1_f_d2⁡totherwiseEG1_contact⁡t=true0otherwise=0,EG1_f_c⁡t=_msim_noEvent⁡−1000000⁢EG1_s_rel⁡t−320EG1_contact⁡t=true0otherwise,ⅆⅆtEG1_s_rel⁡t=EG1_v_rel⁡t,ⅆⅆtEG1_v_rel⁡t=−981100+SM1_flange_a_f⁡tm,EG1_contact⁡t=EG1_s_rel⁡t<320,EG1_f_d2⁡t=50⁢EG1_v_rel⁡tEG1_contact⁡t=true0otherwise
mo≔model Main\nReal a=1;\nend Main;
mo≔model Main Real a=1; end Main;
msimfile2≔CreateModel⁡mo,file=false,output=cat⁡FileTools:-TemporaryDirectory⁡,/example2.msim:
FileTools:-Exists⁡msimfile2
See Also
GetEquations
LinkModel
MapleSim
Opening Modelica Models
Download Help Document