CreateModel - MapleSim Help

CreateModel

create a MapleSim model from either a Modelica file or Modelica source

 Calling Sequence MapleSim:-CreateModel(modelica, options) CreateModel(modelica, options)

Parameters

 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

Returns

 • string ; the name of the created MapleSim file

Options

 • 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.

Description

 • 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.

Examples

 > $\mathrm{with}\left(\mathrm{MapleSim}\right):$
 > $\mathrm{msimfile}≔\mathrm{CreateModel}\left(\mathrm{cat}\left(\mathrm{kernelopts}\left('\mathrm{toolboxdir}'=\mathrm{MapleSim}\right),"/data/examples/BouncingBall.mo"\right),'\mathrm{output}'=\mathrm{cat}\left(\mathrm{FileTools}:-\mathrm{TemporaryDirectory}\left(\right),"/example1.msim"\right)\right):$
 > $\mathrm{FileTools}:-\mathrm{Exists}\left(\mathrm{msimfile}\right)$
 ${\mathrm{true}}$ (1)
 > $A≔\mathrm{LinkModel}\left('\mathrm{filename}'=\mathrm{msimfile}\right):$
 > $A:-\mathrm{GetEquations}\left(\right)$
 $\left\{{-}{\mathrm{EG1_f_c}}{}\left({t}\right){-}{\mathrm{SM1_flange_a_f}}{}\left({t}\right){-}{\mathrm{_msim_noEvent}}{}\left(\left\{\begin{array}{cc}\left\{\begin{array}{cc}{\mathrm{EG1_f_c}}{}\left({t}\right)& {\mathrm{EG1_f_d2}}{}\left({t}\right){<}{\mathrm{EG1_f_c}}{}\left({t}\right)\\ {-}{\mathrm{EG1_f_c}}{}\left({t}\right)& {-}{\mathrm{EG1_f_c}}{}\left({t}\right){<}{\mathrm{EG1_f_d2}}{}\left({t}\right)\\ {\mathrm{EG1_f_d2}}{}\left({t}\right)& {\mathrm{otherwise}}\end{array}\right\& {\mathrm{EG1_contact}}{}\left({t}\right){=}{\mathrm{true}}\\ {0}& {\mathrm{otherwise}}\end{array}\right\\right){=}{0}{,}{\mathrm{EG1_f_c}}{}\left({t}\right){=}{\mathrm{_msim_noEvent}}{}\left(\left\{\begin{array}{cc}{-}{1000000}{}\left|{\mathrm{EG1_s_rel}}{}\left({t}\right){-}\frac{{3}}{{20}}\right|& {\mathrm{EG1_contact}}{}\left({t}\right){=}{\mathrm{true}}\\ {0}& {\mathrm{otherwise}}\end{array}\right\\right){,}\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{t}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{EG1_s_rel}}{}\left({t}\right){=}{-}\frac{{-}{\mathrm{SM1_flange_a_f}}{}\left({t}\right){+}\frac{{981}{}{m}}{{100}}}{{m}}{,}{\mathrm{EG1_contact}}{}\left({t}\right){=}\left({\mathrm{EG1_s_rel}}{}\left({t}\right){<}\frac{{3}}{{20}}\right){,}{\mathrm{EG1_f_d2}}{}\left({t}\right){=}\left\{\begin{array}{cc}{50}{}\frac{{ⅆ}}{{ⅆ}{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{EG1_s_rel}}{}\left({t}\right)& {\mathrm{EG1_contact}}{}\left({t}\right){=}{\mathrm{true}}\\ {0}& {\mathrm{otherwise}}\end{array}\right\\right\}$ (2)
 > $\mathrm{mo}≔"model Main\nReal a=1;\nend Main;"$
 ${\mathrm{mo}}{≔}{"model Main Real a=1; end Main;"}$ (3)
 > $\mathrm{msimfile2}≔\mathrm{CreateModel}\left(\mathrm{mo},\mathrm{file}=\mathrm{false},\mathrm{output}=\mathrm{cat}\left(\mathrm{FileTools}:-\mathrm{TemporaryDirectory}\left(\right),"/example2.msim"\right)\right):$
 > $\mathrm{FileTools}:-\mathrm{Exists}\left(\mathrm{msimfile2}\right)$
 ${\mathrm{true}}$ (4)