The reason for this is that the equations are extremely powerful (you can express pretty much anything computable inside an equation) and their numerical solution is often driven by heuristics (e.g., finding initial values). This makes it extremely difficult to come up with a common standard for the solution of Midelica's hybrid DAEs. Hence you will find little written information about what exactly happens during a simulation that applies to more than one implementation.
One particular issue with the circuit model example in the article, for example, is that when you add switching elements you often end up with disconnected sub-diagrams and then the solver chokes trying to determine what the potential of the floating circuit is, even though it has no effect on anything you care about. So then you have to start adding stray capacitances and stray resistances to make the solver happy, etc.
[1] https://reference.wolfram.com/system-modeler/UserGuide/Simul...
[2] https://liu.diva-portal.org/smash/get/diva2:801004/FULLTEXT0...
For instance, even finding a set of consistent initial condition requires the solution of a typically nonconvex nonlinear system of equations, which in turn requires a good initial guess (where domain knowledge is needed -- arbitrary guesses may work but often don't). This is a "solved" problem in a sense that algorithms exist that do this, but anyone who's done numerical work know how hard it is to reliably find the solution of an arbitrary nonlinear system of equations -- there's a significant element of luck involved, even with heuristics.
Formulating good models is an art. Good modelers know to avoid issues with numerical scaling (by changing units of measure, doing log or linear scaling, or simply avoiding computation of certain intermediate quantities) and avoidance of singularities (e.g. instead of x/y = z, a better and equivalent formulation is x = y * z because if y is ever 0 during iteration, one avoids div-by-0 errors). It gets even tougher with hybrid models that have discontinuities (switching behavior), because the integrator needs to do a reinitialization every time a switch is encountered. Most solvers do this well (the integrated system up to that point is usually a good initial guess for the NLE system), but not 100% of the time.
When I was doing this stuff full-time, I've often thought of writing a linter that detected poor formulations and suggested improved ones -- sort of like a spell-checker for mathematical models. I never pursued it.
These days I guess this can be done using a language server that can parse equations and generate ASTs. I'm no longer interested in these problems, but I do wonder if anyone has tried to do something like this.
[1] DAEs take the following (implicit) form:
f(ẋ, x, z, θ) = 0, x(0) = x₀
g(x, z, θ) = 0
where x = differential vars, z = algebraic vars, θ = constants. The form is very general and can be used to model any number of continuous dynamic systems. Hybrid systems can be modeled by introducing discrete variables into the mix.
The "object-oriented" part of Modelica is intended to make creating large scale models manageable. You make it sound like the object-oriented features are some kind of facade behind which all kinds of peril lies. But the peril is always there. And my experience of building such models both using a modeling language vs. creating them by hand is that you can't escape the limitations of contemporary numerical/symbolic methods or singular systems. You are, of course, free to hand code models or manually transform them into state space equations if you think there is some benefit to that in the same way. Perhaps it will make it easier to diagnose singular systems. But speaking entirely for me, I find being able to create acausal models using a modeling language gives me a productivity boost that I'd be unwilling to give up.
[1] https://github.com/ModiaSim/Modia.jl [2] https://youtu.be/hVg1eL1Qkws
I haven't really heard many updates on this in some time. I don't think it is necessarily a bad idea. But any effort along these lines takes a lot of dedicated people quite a while to make progress (as was the case with Modelica).
Thanks for pointing this out, I hadn't realized! I knew they were somehow involved in the Modelica community but not that they initiated it.
But development seems to have completely stopped earlier this year. Anybody knows what's going on there?
I think the solvers are fantastic and produce better results, in terms of speed and scale, than any other method I had used previously, I was solving the DEs using either wolfram or Julia's Differential equations.
OpenModelica is a wonderful piece of software, I just wish it had a better UI, UX and error messages. Wolfram's system modeler offers an excellent experience but it is very expensive.
Recently I have been using Mathworks take on model-based languages, Simscape[1], which is great for my use case, as it integrates the whole MATLAB and simulink ecosystem. It is not modelica compatible, but it is possible to import FMUs created with modelica.
As a final note, I truly wished that Modelica was taught more in engineering and physics degrees.
There is also a notebook UI that lets you do a lot of Ipython/Jupyter style dev with feedback plots and visualizations, in addition to code tools and visual authoring.
As others have noted Modelica is both more abstract and more performant than a lot of other ways of describing multiphysics systems; it got its start in out-of-the-way places, which may explain it's relative obscurity, but there's an opportunity for it to become pervasive in engineering, both in the academy and industry.
At first I was mainly interested in it's ability to symbolically manipulate equations for me. With complex physical systems and interconnections it can become a tremendous chore rearranging systems to provide certain inputs and certain outputs. Modelica and the above compilers allowed me to specify the equations, and in fact automatically generate and interconnect larger and larger systems as one model. Specifying what were inputs and what were outputs became a simple few lines of code. For example, forward and inverse kinematics are the same equations in Modelica, you just specify different input/outputs, and the compiler determines what's the best way to do this. This can have significant challenges sometimes, when things don't easily work, but on the whole the process has been more often than not straightforward.
Interconnection of the models to other simulations has also become more and more a delight. Initially we had to depend on specific interfaces being built, either on the modelica interpreter side, or on the external application side (for example, Mathworks or Dymola), but fortunately the growth in such use prompted the modelica community to partner with industry to foster an open specification (like modelica is) for model exchange, called FMI. Integrating my models with external software is now a relatively straightforward task, still with challenges, but not expensive ones.
I'd highly recommend modelica and the various compilers as a means of creating very effective models; easily readable and therefore maintainable, re-usable, and now more and more deployable.
I, myself, have used them in the truck industry, CNC machine controls, flight systems, and in underwater vehicles and power systems. I routinely interact with people who use modelica in a much wider domain than this, and more and more in on-board systems, such as controllers. For example, I believe northern Germany uses modelica for its power controls for a significant portion of their country's energy supply.
Here is a list: https://www.modelica.org/tools
Not fully up to date, but a starting point: https://modelica.org/jobs
https://www.physiolibrary.org/doc/Physiolibrary.html#Physiol...
https://openmodelica.org/images/M_images/Moses206/moses2016-...
https://openmodelica.org/images/M_images/Moses206/moses2016-...
(and then there's Cybersyn. It's difficult to evaluate how effective or ineffective it may have been, as the copper drop in value relative to gold by 5x in the early 1970's must've been a serious exogenous shock to the Chilean economy)