LinkModel
link to a MapleSim model
Calling Sequence
Parameters
Returns
Options
Description
Notes
Examples
MapleSim:-LinkModel(options)
LinkModel(options)
options
-
(optional) equation(s) of the form name = value
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
GetFilename return the name of the linked file
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
MakeMovie create a movie of a model with visualization components
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
component : string or [string, string]
Specifies the name of either a MapleSim Component or a Code Edit Region. A list can be used with a code edit region to specify a particular model if more than one model is assigned in the region; the first string is the name of the code edit region, the second is the name of the selected model. The default is "Simulation0".
filename : string or [string,string]
Specifies the filename containing the MapleSim model (.msim) or Modelica code (.mo). A list specifies a particular class in a Modelica file with multiple classes: the first string is the filename, the second string is the class name. The symbol use_last_model can be used for the class name to select the last class assigned in the file. An attachment in a Maple workbook can be specified using the URI syntax maple://path-to-workbook/filename.
modelica : string or [string, string]
Specifies either a Modelica identifier that corresponds to a model in one of the installed libraries, or is a string of literal Modelica code that assigns the model. A list specifies a particular model when the literal code assigns more than one class: the first string is the modelica, the second string is the selected class name. The symbol use_last_model can be used for the class name to select the last class assigned in the file.
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 Component embedded component. See the Examples section on this page for more information.
Alternatively, you can link to a Modelica model by using the filename option to specify a file of Modelica code, or the modelica option to specify either literal Modelica code or a Modelica class in an installed library.
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.
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
Linking to an msim file
Link to the MapleSim file RLCcircuit.msim that is located in the data/examples subdirectory of the MapleSim toolbox installation.
A≔MapleSim:-LinkModel⁡filename=cat⁡kernelopts⁡toolboxdir=MapleSim,/data/examples/RLCcircuit.msim:
Linking to a MapleSim Component embedded component
Open a new Maple worksheet.
From the Components palette, click the MapleSim Component icon ( ) to insert a MapleSim Component embedded component.
Right-click (Control-click for Macintosh) the MapleSim Component component and then select Component Properties. The Simulation Properties window appears.
Beside File, click Select... and browse to a MapleSim model.
Select a model to open. Click Open. The Simulation Properties window appears.
Click OK. The model appears in the MapleSim Component component. If desired, you can browse your model by using the navigation tools at the top of the MapleSim Component to navigate to a subsystem.
Execute the following command to complete the link to the model (and subsystem, if selected) shown in the MapleSim Component component: A≔MapleSim:−LinkModel⁡
Linking to a code edit region
From the Insert menu, click Code Edit Region. A code edit region is added to the worksheet.
Right-click in the region and select Component Properties. Note the Name of the region (CodeEditRegion0).
Change the Language to Modelica.
Click OK.
Enter a valid Modelica model in the code edit region; for example, model test = Modelica.Electrical.Analog.Examples.CauerLowPassAnalog;.
Execute the following command to link to the model.
A≔MapleSim:-LinkModel⁡component=CodeEditRegion0:
Linking to a Modelica file
If the file contains more than one top-level model, a list is used to specify the file and the selected model.
Using the name of the model:
A≔MapleSim:-LinkModel⁡filename=cat⁡kernelopts⁡toolboxdir=MapleSim,/data/examples/BouncingBall.mo,Main:
Using the last model defined in the file:
A≔MapleSim:-LinkModel⁡filename=cat⁡kernelopts⁡toolboxdir=MapleSim,/data/examples/BouncingBall.mo,use_last_model:
Linking to a class in a library
Link to the model Modelica.Electrical.Analog.Examples.CauerLowPassAnalog, which is part of the standard Modelica library.
A≔MapleSim:-LinkModel⁡modelica=Modelica.Electrical.Analog.Examples.CauerLowPassAnalog:
Linking to a string of Modelica code
mo≔cat⁡model test\n, Real y;\n,equation\n, y = sin(time);\n,end test;:
A≔MapleSim:-LinkModel⁡modelica=mo:
See Also
MapleSim
Download Help Document