WSMLink`
WSMLink`

WSMModelData

WSMModelData is being phased out in favor of SystemModel, which was introduced experimentally in Version 11.3.

WSMModelData["mmodel"]

gives a diagram representation of the model "mmodel", usable as input to other functions.

WSMModelData["mmodel","property"]

gives the specified "property" for the model "mmodel".

Details

  • WSMModelData["mmodel","Properties"] gives a list of possible properties.
  • Properties related to the whole model: »
  • "Description"top-level description of model
    "Diagram"diagram view of model
    "Icon"icon view of model
    "ModelicaText"show Modelica model code
    "ModelName"fully qualified path of model
    "LocalPlotNames"names of plots saved locally in model
    "PlotNames"names of plots, including inherited
    "SourceFile"file where the model is saved
    "Summary"model summary data
  • "ModelicaText" creates a cell with style "Program" containing the textual form of "mmodel".
  • With a text-based interface, "ModelicaText" returns the textual form of "mmodel" as a string.
  • WSMModelData[{"mmodel","c1","c2",}, "Diagram"] shows the diagram for component "c1.c2...ci" in "mmodel".
  • WSMModelData["mmodel",{property,options}] accepts the following options for property "Diagram" and "Icon":
  • FrameTrueshow frame
    FrameTicksFalseshow frame ticks
    GridLinesNonewhat grid lines to show
    PlotRangeAutomaticplot range in mm
    PlotRangePaddingAutomaticpadding in mm
  • GridLines->Inherited inherits the grid defined in the model diagram. »
  • PlotRange->Automatic specifies a plot range that encloses the primitives drawn in the diagram.
  • PlotRange->Inherited inherits the page size specified in the model diagram. »
  • Properties related to equations and variables: »
  • "SystemEquations"differential and algebraic equations
    "InitialEquations"initial value equations
    "StateVariables"differentiated variables
    "AlgebraicVariables"non-differentiated variables
    "SystemVariables"state and algebraic variables
    "InputVariables"variables specified as inputs
    "OutputVariables"variables specified as outputs
    "ParameterNames"parameters
    "DiscreteVariables"variables changing only at events
  • "SystemEquations" gives equations depending on t.
  • WSMModelData["mmodel","SystemEquations",t] gives equations depending on t.
  • WSMModelData[] contains Missing[type,content] for any parts of equations that cannot be represented.
  • "InputVariables" are distinct from "SystemVariables", and "OutputVariables" are a subset of "SystemVariables".
  • "DiscreteVariables" are a subset of "SystemVariables", and are given in a form suitable as a setting for the DiscreteVariables option to NDSolve.
  • Properties related to values: »
  • "ParameterValues"parameter rules {p1->val1,}
    "InitialValues"initial value rules {v1->val1,}
    "GroupedInitialValues"initial values grouped by state, input, and output
  • For variable and parameter lists, WSMModelData["mmodel",{prop,patt}] returns the elements of prop whose Modelica form match the string pattern patt.
  • Properties related to the structure of the model:
  • "BaseClasses"classes the model extends
    "Components"model components
    "Connections"model connections
    "Connectors"model connector components
    "LocalComponents"components defined locally in model
  • Properties related to relations with other models:
  • "ExtendingClasses"classes that build upon this model
    "InstantiatingClasses"classes that use this model as a component
  • The shortest unique model name mmodel can be used where WSMNames["*.mmodel"] gives a unique match.
  • The following options can be given:
  • MethodAutomaticmethods for equation processing
  • Possible settings for "opti" in Method->{"opt1"->val1} include:
  • "Elimination"Alleliminate simple equations
    "ReduceIndex"Truereduced index of DAEs in balanced models
    "StartTime"0simulation start time

Examples

open allclose all

Basic Examples  (4)

Load Wolfram SystemModeler Link:

Show a model represented by a diagram:

Use the diagram representation as input:

Show a summary of a model:

Get the differential equations for a model:

Scope  (30)

General Properties  (12)

Show a list of possible properties:

Get the description of a model:

Get the diagram of a model:

Show the grid:

Show frame ticks:

Get the diagram of a component in a model:

Increase the PlotRangePadding for a diagram:

Show the diagram of a model without a frame, using the page size from the model:

Show the icon of a model:

Show the text view of a model:

Get the path of the file containing a model:

Get the names of saved plots in the model:

Simulate and show a saved plot:

Plots are inherited:

There are no plots saved locally in the model:

The saved model comes from the base class:

Retrieve the model name of a diagram representation:

Variables and Equations  (9)

Get the system equations of a model:

Get the initial equations of a model:

Get all state variables of a model:

Get a list of all algebraic variables in the model:

Get a list of all system variables in the model:

Get a list of all input variables in the model:

Get a list of all output variables in the model:

Get the discrete variables of a model:

Get all parameter names of a model:

Initial and Parameter Values  (3)

Get all parameter values of a model:

Get all initial values of a model:

Get initial values grouped by state, input, and output:

Naming  (2)

By default, equations use t as the time variable:

Get the differential equations depending on a chosen variable:

Get parameter values matching a pattern:

Structural Properties  (4)

Get the classes a model builds on:

Get the components and connections in a DC motor model:

Get the components locally declared in a model:

"Components" includes inherited components:

Get the connectors in a model:

Options  (3)

Method  (3)

Use a custom start time in initial equations:

The Method option "Elimination" can be used to eliminate redundant equations:

Elimination can greatly reduce the number of equations:

Disable index reduction with the method option "ReduceIndex":

Applications  (4)

Solve equations using NDSolve:

Construct initial equations from an initial values list:

Solve the system:

Plot the found solution:

Solve equations using DSolve:

Get the equations and system variables:

Get initial values:

Combine the equations and replace all parameters with their default values:

Solve the system and plot the result:

Find an equilibrium point for a model:

Get the equations:

Set derivatives to zero and solve:

WSMFindEquilibrium gives the same result:

Use the differential equations to study the behavior of a damped pendulum:

Properties & Relations  (3)

Compare the solutions from WSMSimulate and NDSolve:

Solve using NDSolve:

Solve using WSMSimulate:

A model is represented by its diagram:

The diagram representation evaluates to WSMModelData["modelname"]:

The diagram representation can be used directly as input in other functions:

A diagram of a component may be different than a diagram of the component class:

The motor class itself does not have parameters set: