LinkModel - MapleSim Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


LinkModel

link to a MapleSim model

 

Calling Sequence

Parameters

Returns

Options

Description

Notes

Examples

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

  

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

Options

• 

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.

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

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

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.

AMapleSim:-LinkModelfilename=catkerneloptstoolboxdir=MapleSim,/data/examples/RLCcircuit.msim:

Linking to a MapleSim Component embedded component

1. 

Open a new Maple worksheet.

2. 

From the Components palette, click the MapleSim Component icon (  ) to insert a MapleSim Component embedded component.

3. 

Right-click (Control-click for Macintosh) the MapleSim Component 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 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.

7. 

Execute the following command to complete the link to the model (and subsystem, if selected) shown in the MapleSim Component component: AMapleSim:−LinkModel

Linking to a code edit region

1. 

Open a new Maple worksheet.

2. 

From the Insert menu, click Code Edit Region. A code edit region is added to the worksheet.

3. 

Right-click in the region and select Component Properties. Note the Name of the region (CodeEditRegion0).

4. 

Change the Language to Modelica.

5. 

Click OK.

6. 

Enter a valid Modelica model in the code edit region; for example, model test = Modelica.Electrical.Analog.Examples.CauerLowPassAnalog;.

7. 

Execute the following command to link to the model.

AMapleSim:-LinkModelcomponent=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:

AMapleSim:-LinkModelfilename=catkerneloptstoolboxdir=MapleSim,/data/examples/BouncingBall.mo,Main:

Using the last model defined in the file:

AMapleSim:-LinkModelfilename=catkerneloptstoolboxdir=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.

AMapleSim:-LinkModelmodelica=Modelica.Electrical.Analog.Examples.CauerLowPassAnalog:

Linking to a string of Modelica code

mocatmodel test\n, Real y;\n,equation\n, y = sin(time);\n,end test;:

AMapleSim:-LinkModelmodelica=mo:

See Also

MapleSim