WOLFRAM SYSTEMMODELER LINK PACKAGE TUTORIAL
Getting Started with Wolfram SystemModeler Link
Wolfram SystemModeler consists of three parts: Model Center, Simulation Center, and SystemModeler Link. Modelica models are constructed in the Model Center and can be simulated both in Simulation Center and in the Wolfram Language using SystemModeler Link. The simulation results and model properties, such as system equations, can be analyzed in the Wolfram Language using SystemModeler Link.
This tutorial gives an introduction to the functionality of SystemModeler Link. To learn more about Model Center and Simulation Center, see the menu in those programs.
To use the SystemModeler Link package, we need to load it with Needs:
Create a Model
System models can be created in the Model Center with an intuitive drag-and-drop interface with components and connections. Documentation and help on the modeling aspect can be found in the Model Center menu. In this tutorial, you will use models from the MathematicaExamples library, which is included in SystemModeler. The following screen shot shows the Model Center with a model from the library opened.
WSMSimulate runs a simulation of a model created in the Model Center and returns a WSMSimulationData object. WSMPlot is used to visualize results from that simulation.
SystemModeler simulation functions.
Once a model has been created in the Model Center of SystemModeler (screen shot above), it can be simulated from the Wolfram Language. To simulate a model, use the command WSMSimulate with the model name and the simulation time as arguments.
The output from WSMSimulate is a WSMSimulationData object. This object can be used in WSMPlot to plot variables from the simulation.
The simulation result object also has a number of properties.
Take a look at the variable names in the simulation.
Retrieve the value of the variables and at time .
Simulate again, changing two parameters using the option WSMParameterValues and compare a result variable between the simulations.
Multiple simulations for a number of values of a parameter are automatically done in parallel. Simulate a bouncing ball with different amounts of bounciness, .
Plot the height of the balls over time.
By retrieving the simulation results as data, results can be visualized and analyzed in many ways. For example, plotting the results from a Chua circuit on a ParametricPlot.
Pick out the variables and .
A Lorenz attractor makes for a beautiful simulation result with ParamatricPlot3D.
In addition to driving simulations of models from the Wolfram Language, it is also possible to work with the model more directly. WSMModelData is used to retrieve information about models, and WSMFindEquilibrium and WSMLinearize are used to obtain equilibrium points and linear state-space representations.
SystemModeler model functions.
Equations from Model
Retrieve information about a model with WSMModelData. First, get an overview of the model information.
Get the system equations depending on the time variable t.
Find a point where all derivatives are zero, also called an equilibrium point.
There are a large number of properties of WSMModelData that can be used to get information about the model.
The default format for all Modelica variables contains symbols like and . Use to convert variables to strings.
Equilibrium Points and Linear Representation
Use WSMFindEquilibrium to find an equilibrium point for a model of a mixing tank.
The function WSMLinearize gives a linear state-space representation of a model at an equilibrium point. The result is a Wolfram Language StateSpaceModel.
The control functionality in the Wolfram Language can be used to further work with this representation. Design a controller using pole placement and show the output response to a unit step.