42
$\begingroup$

Mathematica 11.3 includes some functionality from SystemModeler, but not the full SystemModeler environment.

I assume that most people here are familiar with Mathematica, but not SystemModeler, or Modelica, therefore they will find this question relevant.

My question is:

  • What practical use do these new functions have for those who don't have the full SystemModeler?

  • What does SystemModeler provide beyond that?


After some cursory exploration, I found that SystemModeler is based on Modelica, an open modelling language that has multiple implementation and is used in several other systems such as OpenModelica or MapleSim. "Models" seem to describe systems of differential equations.

It appears that we can use plain Modelica code in Mathematica. Here's the Modelica sample program from Wikipedia:

mo = ImportString["
   model FirstOrder
     parameter Real c=1 \"Time constant\";
     Real x \"An unknown\";
   equation
     der(x) = -c*x \"A first order differential equation\";
   end FirstOrder;
   ", "MO"];

result = SystemModelSimulate[mo, {0, 5}, <|"InitialValues" -> {"x" -> 10}|>]

SystemModelPlot[result, "x"]

enter image description here

We can also go the other way, and read the Modelica code of built-in models:

mo = First@SystemModels["IndustryExamples.IndustrialManufacturing.ChemicalTankReactor"];

mo["ModelicaDisplay"]

enter code here

So it seems to me that despite not including the full SystemModeler, a new world has really been opened up to Mathematica users. What is not clear to me is how far the included functionality goes compared to the full SystemModeler, when one would want to use it and write Modelica code from scratch, or what this provides beyond NDSolve. I am looking for answers targeted at Mathematica users who have never been exposed to Modelica before.

$\endgroup$
  • $\begingroup$ I don't have systemModeler. On my machine SystemModelSimulate[] calls Visual Studio to compile some C and creates a Executable. This is totally new compared to NDSolve[] $\endgroup$ – andre314 Mar 12 '18 at 21:26
43
$\begingroup$

I'm one of the developers behind this functionality, so I might be biased, but in my opinion this does provide a huge new feature set to Mathematica users.

What practical use do these new functions have for those who don't have the full SystemModeler?

The new functions provide a sophisticated analysis environment for system modeling. They do that stand-alone, without requiring SystemModeler. The only new function that requires SystemModeler to work, is the symbol SystemModeler, since it exists purely for workflow interaction with that application.

System modeling in this context is indeed based on the Modelica language, which is used to describe systems of differential equations.

The new functions add tools for:

  • Simulating these models (SystemModelSimulate, SystemModelParametricSimulate, SystemModelSimulateSensitivity)
  • Building new models programatically (CreateSystemModel, ConnectSystemModelComponents, CreateDataSystemModel)
  • Doing analysis on models and their simulation results. This can use all of the existing symbolic and numeric tools provided by Wolfram Language. There are also some functions for linearizing models into the control systems objects in Wolfram Language.

What this provides beyond NDSolve

Many models written in Modelica can be expressed in equation form usable in NDSolve. In fact, SystemModelSimulate takes a Method option to use NDSolve as the solver. However, the Modelica modeling language and the SystemModeler kernel and solvers also have features that NDSolve does not have (at least, yet).

But primarily, building up the equations for NDSolve by hand quickly becomes a daunting proposition. You also need to figure out every single equation by yourself.

With Modelica and SystemModel, you get the "building block" approach. You are provided with a wide range of pre-built components you can just use and combine. To take a simple example, it comes with a lot of electrical components like resistors, capacitors, ... The library that comes with the product(s) includes a lot more domains.

There are also more libraries available (free and commercial) that are tested by Wolfram. Of course, there is also a wider selection of Modelica libraries out there.

From these components, you typically build up your hierarchical model of more advanced components. This leads to a far superior workflow over pure NDSolve equations, as soon as you get above a handful of equations (which any real world system is likely to have). System modeling enables you to model vastly more complex systems.

What does SystemModeler provide beyond that?

The product SystemModeler still exists apart from Wolfram Language/Mathematica, as you noted.

It provides a graphical interface for creating and modifying models (Model Center). This is almost a requirement when developing deeply hierarchical models of advanced systems.

Model Center in SystemModeler has wider support for more advanced modeling features. It is technically possible to create models using all these features using pure Modelica and using ImportString as in the question, but that quickly becomes untenable in practice for larger models.

It can also be easier to understand and explore hierarchical models in a graphical user interface.

SystemModeler also provides a simulation interface (Simulation Center), which provides things like interactive plots and 3D animations of mechanical systems.

when one would want to use it and write Modelica code from scratch

To start with, most users would probably use the provided model creation functions. Those create the Modelica code for you (and give you the result back in the form of a SystemModel). Writing Modelica code from scratch is getting into pretty advanced territory, and my personal feeling is that when you arrive at that point, you would probably benefit from the graphical SystemModeler environment.

The intended primary customer for the SystemModeler product is users who build their own models. The new functions in Wolfram Language are also for those users, but widens the audience to "consumers" of models, for example people running an analysis on a model someone else built.

| improve this answer | |
$\endgroup$
  • 5
    $\begingroup$ Great answer! Thanks! $\endgroup$ – ktm Mar 9 '18 at 19:32
  • 2
    $\begingroup$ "The SystemModeler kernel and solvers also have features that NDSolve does not have (at least, yet)" -- could you elaborate on this point? $\endgroup$ – Chris K Mar 9 '18 at 21:08
  • 6
    $\begingroup$ @ChrisK I don't have a complete list, but examples are a more advanced event handling system, hierarchical models, units/quantities, FMI support, different symbolic processing that probably handles larger systems better, export of standalone simulation executable... This isn't my area of expertise, I'm sure there are good points I'm forgetting/missing. Of course there are cases where NDSolve has better support as well, for example PDE/FEM support. $\endgroup$ – Malte Lenz Mar 9 '18 at 21:23
  • 13
    $\begingroup$ "I'm one of the developers behind this functionality, so I might be biased" -- You're also probably one of the most qualified people to talk about this, then. Thanks for the answer! $\endgroup$ – Fund Monica's Lawsuit Mar 10 '18 at 3:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.