Live data from Hacker News

All about Modelica: An equation-based language for modeling physical systems

marcobonvini.com

21–30 of 47 posts

Re: All about Modelica: An equation-based language for modeling physical systems

#21
post #16

Is Modelica used for economic modeling as well?

While most Modelica's applications are primarily engineering related, it is used for stock and flow models and there are some folks digging into use it for economic modeling (as there are others using it for environmental and biological systems modelling). If you are looking to get started using Modelica for economics modeling these might be of interest:

https://openmodelica.org/images/M_images/Moses206/moses2016-...

https://openmodelica.org/images/M_images/Moses206/moses2016-...

https://ep.liu.se/ecp/157/037/ecp19157037.pdf

Re: All about Modelica: An equation-based language for modeling physical systems

#22
post #8

One thing about Modelica is quite important and might confuse newcomers: the language specification mostly only covers the model, not the equations. That is, when you evaluate your model under, e.g., Dymola and Openmodelica you will (most of the time) end up with equal (or rather similar) systems of equations. The meaning of these equations, i.e., the actual simulation can easily differ, though (except for the most t…

Another thing that we discovered when testing out using Modelica for some stuff is that it is very easy to design yourself a model that can't be solved. The whole premise of the "object orientation" is that you can just compose models without knowing how to solve the entire system. Once the solver fails, though, all that abstraction comes crashing down and you're left with trying to look at a 500-variable Jacobian and figure out what's making the solver choke.

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.

Re: All about Modelica: An equation-based language for modeling physical systems

#23
post #22
post #8

One thing about Modelica is quite important and might confuse newcomers: the language specification mostly only covers the model, not the equations. That is, when you evaluate your model under, e.g., Dymola and Openmodelica you will (most of the time) end up with equal (or rather similar) systems of equations. The meaning of these equations, i.e., the actual simulation can easily differ, though (except for the most t…

Another thing that we discovered when testing out using Modelica for some stuff is that it is very easy to design yourself a model that can't be solved. The whole premise of the "object orientation" is that you can just compose models without knowing how to solve the entire system. Once the solver fails, though, all that abstraction comes crashing down and you're left with trying to look at a 500-variable Jacobian an…

"Error: Model is singular" is pretty frustrating to debug

Re: All about Modelica: An equation-based language for modeling physical systems

#25

Are there Modelica programmers? Or is it a tool engineers use? Like could you become a Modelica developer and do that as a living?

It's a domain specific language mainly for Modeling dynamic systems. Typically engineers focusing on simulation use it along with a commercial IDE and paid libraries with a lot of prebuilt components.

Re: All about Modelica: An equation-based language for modeling physical systems

#26
post #22
post #8

One thing about Modelica is quite important and might confuse newcomers: the language specification mostly only covers the model, not the equations. That is, when you evaluate your model under, e.g., Dymola and Openmodelica you will (most of the time) end up with equal (or rather similar) systems of equations. The meaning of these equations, i.e., the actual simulation can easily differ, though (except for the most t…

Another thing that we discovered when testing out using Modelica for some stuff is that it is very easy to design yourself a model that can't be solved. The whole premise of the "object orientation" is that you can just compose models without knowing how to solve the entire system. Once the solver fails, though, all that abstraction comes crashing down and you're left with trying to look at a 500-variable Jacobian an…

Yes this is an art form in itself. I've been planning to do a series on debugging Modelica and the different failure modes that come up, and what tools can be used. It is a known limitation in the Modelica community, but it is also really hard to address in an automatic fashion. See [1] and [2] for some ideas.

[1] https://reference.wolfram.com/system-modeler/UserGuide/Simul...

[2] https://liu.diva-portal.org/smash/get/diva2:801004/FULLTEXT0...

Re: All about Modelica: An equation-based language for modeling physical systems

#27
post #16

Is Modelica used for economic modeling as well?

I don't know enough about economic modeling, but if the models can somehow be expressed as driven by a "potential" and a "flow" variable (like electric voltage and electric currents), then it would definitely make sense to try that out in Modelica.

historical stock and flow economic modelling: https://en.wikipedia.org/wiki/MONIAC

(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)

Re: All about Modelica: An equation-based language for modeling physical systems

#28
post #22
post #8

One thing about Modelica is quite important and might confuse newcomers: the language specification mostly only covers the model, not the equations. That is, when you evaluate your model under, e.g., Dymola and Openmodelica you will (most of the time) end up with equal (or rather similar) systems of equations. The meaning of these equations, i.e., the actual simulation can easily differ, though (except for the most t…

Another thing that we discovered when testing out using Modelica for some stuff is that it is very easy to design yourself a model that can't be solved. The whole premise of the "object orientation" is that you can just compose models without knowing how to solve the entire system. Once the solver fails, though, all that abstraction comes crashing down and you're left with trying to look at a 500-variable Jacobian an…

That's absolutely true. A severe limitation of Modelica's type system is that you cannot constrain your modeling domain to something that is always solvable, or at least analyzable. You cannot, for instance, limit yourself to linear equations. In my opinion it would be the library author's responsibility to constrain the usage of their models in a way that prevents typical modeling errors (as in your example, the switch).

Re: All about Modelica: An equation-based language for modeling physical systems

#29
post #17

There's a project to create a language similar to Modelica as a DSL in Julia, Modia[1]. I'm not currently a user of either language, but saw a presentation at JuliaCon about it[2] and thought it looked interesting. [1] https://github.com/ModiaSim/Modia.jl [2] https://youtu.be/hVg1eL1Qkws

That looks really promising.

But development seems to have completely stopped earlier this year. Anybody knows what's going on there?

Post reply on HN