LinkModel - MapleSim Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : MapleSim : MapleSim Application Programming Interface : API Commands : MapleSim/LinkModel

LinkModel

link to a MapleSim model

 Calling Sequence MapleSim:-LinkModel(options) LinkModel(options)

Parameters

 options - (optional) equation(s) of the form name = value

Returns

 • module : evaluated ModelObject with the following exports:
 ApplySubstitutions substitute simpler names for parameters and variables
 DeleteAttachment  delete an attachment (such as a template or a file) from the model
 GetAttachment return an attachment of the model
 GetCompiledProc compile the active subsystem into executable code
 GetEquations return the equations of the system or subsystem
 GetICs return the initial conditions
 GetModel return the name of the linked model
 GetModelica return the Modelica description for the active subsystem
 GetMultibody return the multibody portion of the active subsystem
 GetParameters return the parameters of the active subsystem
 GetPorts return ports and/or probes of a system or subsystem
 GetProbes return probes of a system or subsystem
 GetSettings return simulation settings (such as the simulation time, solver, and tolerances)
 GetSubstitutions return substitution equations (used to create simpler parameter/variable names)
 GetSubsystemName return the name of the active subsystem
 GetVariables return the variables of the active subsystem
 Linearize linearize the equations of the active subsystem
 ListAttachments list the attachments (such as the templates, files, and data) of the model
 ListSubsystems list the subsystems of the system
 SetAttachment attach data to the model
 SetComponent create a component from Modelica source
 SetModel link to a particular model
 SetParameters assign values of parameters
 SetSubstitutions assign substitutions (to create simpler parameter/variable names)
 SetSubsystemName assign the active subsystem
 ShowResultsManager open the Results Manager window
 Simulate simulate the system

Options

 • filename : string
 Specifies the filename containing the MapleSim model (.msim). Default is "".
 • component : string
 Specifies the name of the MapleSim Model embedded component to link to. Default is "Simulation0".
 • modelica : [string, string or use_last_model] or string
 Specifies the Modelica model to link to. If a list is given, the first string specifies the filename where the Modelica model is defined, the second string specifies the name of the model inside the file to link to. The model name is needed because one Modelica file can define several models. Alternatively, you can pass the use_last_model keyword, to link to the last model defined in the file. If only one model is defined in the file, you can pass just the string specifying the filename. Default is ["", ""].

Description

 • The LinkModel command returns a "connection module" that allows programmatic access to a MapleSim model.
 Important: You must first link to a MapleSim model as described on this page before accessing the MapleSim API commands for your model.
 • There are two ways to link to a MapleSim model: by filename or by using a MapleSim Model embedded component.  See the Examples section on this page for more information.
 • Alternatively, you can link to a Modelica model using the modelica option.
 • The LinkModel command is part of the MapleSim package.  You can access this command using the long form of the command name, MapleSim:-LinkModel, or by first executing with(MapleSim) and then using the short form of the command name, LinkModel.

Notes

 • Executing LinkModel( ) without options is equivalent to executing LinkModel(component="Simulation0");
 • When linking to a model using a Modelica file, the following export commands can not be used:
 – GetAttachment
 – ListAttachments
 – SetAttachment
 – SetSubstitutions with savewithmodel = true

Examples

Example 1: Linking to a MapleSim model by specifying a filename. (The model is located in an .msim file.):

 > $A≔\mathrm{MapleSim}:-\mathrm{LinkModel}\left('\mathrm{filename}'=\mathrm{cat}\left(\mathrm{kernelopts}\left('\mathrm{toolboxdir}'=\mathrm{MapleSim}\right),"/data/examples/RLCcircuit.msim"\right)\right):$

Example 2: Linking to a MapleSim model by using a MapleSim Model embedded component.

 1 Open a new Maple worksheet.
 2 From the Components palette, click the MapleSim Model component icon (  ) to insert a MapleSim Model embedded component.
 3 Right-click (Control-click for Macintosh) the MapleSim Model component and then select Component Properties. The Simulation Properties window appears.
 4 Beside File, click Select... and browse to a MapleSim model.
 5 Select a model to open. Click Open.  The Simulation Properties window appears.
 6 Click OK. The model appears in the MapleSim Model component.  If desired, you can browse your model by using the navigation tools at the top of the MapleSim Model to navigate to a subsystem.

 7 Execute the following command to complete the link to the model (and subsystem, if selected) shown in the MapleSim Model component: $A≔\mathrm{MapleSim:-LinkModel}\left(\right)$

Example 3: Linking to a Modelica model.

Using the name of the model:

 > $A≔\mathrm{MapleSim}:-\mathrm{LinkModel}\left('\mathrm{modelica}'=\left[\mathrm{cat}\left(\mathrm{kernelopts}\left('\mathrm{toolboxdir}'=\mathrm{MapleSim}\right),"/data/examples/BouncingBall.mo"\right),"Main"\right]\right):$

Using the last model defined in the file:

 > $A≔\mathrm{MapleSim}:-\mathrm{LinkModel}\left('\mathrm{modelica}'=\left[\mathrm{cat}\left(\mathrm{kernelopts}\left('\mathrm{toolboxdir}'=\mathrm{MapleSim}\right),"/data/examples/BouncingBall.mo"\right),'\mathrm{use_last_model}'\right]\right):$

 See Also