Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

System dynamics is an approach to understanding the behaviour of complex systems over time. It deals with internal feedback loops and time delays that affect the behaviour of the entire system. What makes using system dynamics different from other approaches to studying complex systems is the use of feedback loops and stocks and flows. These elements help describe how even seemingly simple systems display baffling nonlinearity

Here is how a system diagram looks like:

enter image description here

Apperently I should be able to this with System Modeler by loading this modelica library but I am also told here that:

The downside, as I understand it, is that each different use of a System Dynamics symbol requires its own entry in the library. For example, a stock with one inflow and one outflow requires a different Modelica symbol from one with one inflow and 2 outflows. Also (again, as I understand it), every separate equation requires its own symbol to be defined and added to the library before it can be used.

¿Anyone here can confirm or deny this? ¿Is this a limitation inherent in all Modelica enviroments? ¿or it is an implementation limitation on this particular library?

and, going back to the original aim of this question: Is there a less expensive way (than System Modeler) to do this in Mathematica, without System Modeler?

share|improve this question
I am surprised that there is no tags for: "simulation" and "nonlinearity" – Luxspes Jul 8 '12 at 17:00
3  
Check wolfram.com/system-modeler/features – belisarius Jul 8 '12 at 17:02
I was kind of hoping someone here had first had experience with System Modeler – Luxspes Jul 8 '12 at 17:05
I found this: modelica.org/libraries/SystemDynamics, apparently since System Modeler uses the Modelica language it should be able to use it. – Luxspes Jul 8 '12 at 17:21
2  
I wrote a new answer on that meta thread: meta.mathematica.stackexchange.com/a/542/12 I think that if your question is about doing these simulations in SystemModeler / Modelica, that's off topic. If it's about doing it in Mathematica, it's on topic, but SystemModeler might be a better tool for the task ... – Szabolcs Jul 9 '12 at 10:26
show 5 more comments

1 Answer

up vote 4 down vote accepted

The limitation you quote is not a general limitation of Modelica. It is possible to define a Modelica component that has a variable number of inputs/outputs. Typically the number of inputs/outputs is then given by a parameter to that component.

For example, the following component has one input but 2 outputs, varied with the parameter nout:

model SIMO "Single input, multiple output"
  parameter Integer nout=2 "Number of outputs";
  RealInput u "Connector of Real input signal";
  RealOutput y[nout] "Connector of Real output signals";
equation
  {{{your equations}}}
end SIMO;

I have not used the System Dynamics modelica library, so cannot speak to how they have chosen to implement their interfaces.

It would be fully possible to create your custom models in Mathematica by defining equations from the ground up, and then simulating them using for example NDSolve. This would however require a significant amount of manual labor.

If you want to stay in the Wolfram product universe, SystemModeler would be the way to go. It allows you to simulate and interact with models from Mathematica, using a Mathematica package bundled with the product.

An overview of features of the Mathematica package, called WSMLink, can be found at http://wolfram.com/system-modeler/features/analysis-mathematica.html.

Documentation to see how the package actually is used is found at http://reference.wolfram.com/system-modeler/WSMLink/guide/WSMLink.html.

share|improve this answer
And... is there a way to achieve the same without System Modeler? – Luxspes Jul 10 '12 at 23:16
Certainly possible, but not easy. NDSolve is powerful for solving differential equations, but Mathematica currently does not have an easy way to graphically build dynamic systems. It is of course possible to create "components" (Symbol structures with equations and graphical representations) and build functionality to connect them together, and then using NDSolve to simulate the system, and the Graphics functionality to build up the system diagram. This would be a massive undertaking though. – Malte Lenz Jul 11 '12 at 9:36
And what about the part " Also (again, as I understand it), every separate equation requires its own symbol to be defined and added to the library before it can be used." Is that true? – Luxspes Aug 9 '12 at 1:50
No, that is not true. A class (model or component) in Modelica (and therefore SystemModeler) can contain any number of equations, without defining separate classes for each equation. Of course, if you want to reuse an equation or a collection of equations, for example for the behavior of stock, you can create a class with those equations, and use that class as a component in your bigger model. – Malte Lenz Aug 9 '12 at 7:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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