create a MapleSim model from either a Modelica file or Modelica source - 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

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({{}\begin{array}{cc}{{}\begin{array}{cc}{\mathrm{EG1_f_c}}{}\left({t}\right)& {\mathrm{EG1_f_d2}}{}\left({t}\right){<}{\mathrm{EG1_f_c}}{}\left({t}\right)\\ {{}\begin{array}{cc}{-}{\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}& {\mathrm{otherwise}}\end{array}& {\mathrm{EG1_contact}}{}\left({t}\right){=}{\mathrm{true}}\\ {0}& {\mathrm{otherwise}}\end{array}\right){=}{0}{,}{\mathrm{EG1_f_c}}{}\left({t}\right){=}{\mathrm{_msim_noEvent}}{}\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){,}\frac{{ⅆ}}{{ⅆ}{t}}{}{\mathrm{EG1_s_rel}}{}\left({t}\right){=}{\mathrm{EG1_v_rel}}{}\left({t}\right){,}\frac{{ⅆ}}{{ⅆ}{t}}{}{\mathrm{EG1_v_rel}}{}\left({t}\right){=}{-}\frac{{981}}{{100}}{+}\frac{{\mathrm{SM1_flange_a_f}}{}\left({t}\right)}{{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){=}{{}\begin{array}{cc}{50}{}{\mathrm{EG1_v_rel}}{}\left({t}\right)& {\mathrm{EG1_contact}}{}\left({t}\right){=}{\mathrm{true}}\\ {0}& {\mathrm{otherwise}}\end{array}\right\}$ (2)
 > $\mathrm{mo}:="model Main Real a=1; end 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)