Live data from Hacker News

Modelica

modelica.org

11–20 of 118 posts

Re: Modelica

#11
From the website:

> Modelica is a high-level declarative language for describing mathematical behavior. It is typically applied to engineering systems...

We use Modelica quite a bit in HVAC industry. In my case (controls engineer), I can request FMUs of various components from systems engineers for optimization work. (Functional Mockup Unit (FMU)[1]: stand-alone binary representing a dynamical system that can be driven by another application). My background is in Reinforcement learning/Model predictive control/python. Having a physics-driven model written in a domain-specific language which I can embed into my python workflow [2] is convenient.

I will say, Modelica requires a different perspective from "regular" imperative programming (python/matlab). It is a declarative language: you define equations, variables, constraints for a system, regardless of order. The compiler decides how to run the simulation; which variables to solve first etc.

While OpenModelica[3] has come a long way towards making an open source implementation of the language standard, proprietary applications (Dymola) still have an edge in the industry.

[1]: https://fmi-standard.org/

[2]: https://fmpy.readthedocs.io/en/latest/

[3]: https://openmodelica.org/

Re: Modelica

#12

AFAICT the docs don't seem to be directly searchable: https://doc.modelica.org/Modelica%204.0.0/Resources/helpDymo... Are NEMA motors modeled? Could one use this to simulate/model a CNC machine? EDIT: Apparently not, given that "NEMA" doesn't show up searching: https://mbe.modelica.university/

Modelica can absolutely be used for this, but there may not be a readily-available model created already. A generic stepper motor model is available here:

https://ie.utcluj.ro/files/acta/2003/Number%202/Paper08_Mora...

Operationalizing this into a Modelica model is pretty straightforward. Did not look for a driver model, but a driver model would be a lot more important in modern times. I am guessing that not many people would simulate this fidelity of stepping dynamics as a "first cut", and anyone who does is likely to also have a detailed driver model. Demand for this model in a standard library is likely quite small.

Re: Modelica

#13

Earlier quoted context omitted.

Modelica Language -> Modelica By Example -> https://mbe.modelica.university/ Took me under 5 seconds to find.

[flagged]

I wonder if some of those words might be terms-of-art, written with a specialist rather than a generalist audience in mind.

Re: Modelica

#14
post #3

As someone who has no idea what this is about bar the landing page explanation, and isn't in this space -- it would be great if the front page had examples, or links to examples. 30 seconds of clicking around and I've failed to find sth compelling.

The first link for “Modelica Language” includes tutorials and examples. Five seconds of clicking around got me to:

> Let us consider an extremely simple differential equation:

x = (1-X)

Looking at this equation, we see there is only one variable, x

This equation can be represented in Modelica as follows:

  model FirstOrder
    Real x;
  equation
    der(x) = 1-x;
  end FirstOrder;
This code starts with the keyword model which is used to indicate the start of the model definition.

The model keyword is followed by the model name, FirstOrder. This, in turn, is followed by a declaration of all the variables we are interested in.

[et cetera]

Re: Modelica

#15
post #3

As someone who has no idea what this is about bar the landing page explanation, and isn't in this space -- it would be great if the front page had examples, or links to examples. 30 seconds of clicking around and I've failed to find sth compelling.

As someone who is a curious outsider to Modelica, it piqued my interest a few years ago when I found out that this language lets you write equations more directly than most other programming languages. Take the ideal gas law, for example, PV = nRT, which has 5 identifiers. In most programming languages, you'd have to keep only one variable to the left, that is assigned to, e.g. T=PV/nR, and a similar set of equations if you want to determine any of the other variables, given the rest. In Modelica, the same equation, expressed as you would in natural math, works for determining the unknown, based on the knowns.

https://mbe.modelica.university/behavior/equations/electrica...

I don't know much beyond this.

Re: Modelica

#16

Earlier quoted context omitted.

Modelica Language -> Modelica By Example -> https://mbe.modelica.university/ Took me under 5 seconds to find.

[flagged]

Accessible to whom? I work in a field that uses things like Modelica and it reads just fine to me.

Re: Modelica

#17
post #5

Obligatory mention to Openmodelica[1] which is an open source implementation based on the Modelica language. While I haven't used it yet, I was planning on exploring some of the features this holiday. [1] https://openmodelica.org/

If you intend to explore OpenModelica you may also like ModelingToolkit.jl:

https://docs.sciml.ai/ModelingToolkit/dev/

There is also a project by Hilding Elmqvist, who worked for Dassault on Dymola (the leading commercial implementation of Modelica). His project is Modia.jl:

https://github.com/ModiaSim/Modia.jl

I can personally feel the Julia community settling on MTK, but Modia was ahead in the early stages of dynamic system simulation in Julia, and I believe MTK has drawn a lot of inspiration from each Modia and Modelica. Modia is a bit more ergonomic while also being the first to integrating things like 3D viewers and a complete multibody package by years, with Julia Computing only now catching up [1]. MTK has a better support for back-end solvers and holds a lot of promise to leapfrog Modia, especially since the release cadence for Modia seems to have slowed.

[1] https://github.com/JuliaComputing/Multibody.jl

Re: Modelica

#18
post #5

Obligatory mention to Openmodelica[1] which is an open source implementation based on the Modelica language. While I haven't used it yet, I was planning on exploring some of the features this holiday. [1] https://openmodelica.org/

Having used it in the work. My 2 cts about the not free version: KEEP AWAY. RUN! Cannot do much more than any free SPICE, complex licensing, buggy. Is just like the LabVIEW of simulations.

I haven't used the free Version though.

Re: Modelica

#19

From the website: > Modelica is a high-level declarative language for describing mathematical behavior. It is typically applied to engineering systems... We use Modelica quite a bit in HVAC industry. In my case (controls engineer), I can request FMUs of various components from systems engineers for optimization work. (Functional Mockup Unit (FMU)[1]: stand-alone binary representing a dynamical system that can be driv…

Another up-and-coming solution is Julia's simulation ecosystem [1]. It is powered by the commercial organization behind the Julia programming language, which has received DARPA funding [2] to build out these tools. This ecosystem unifies researchers in numerical methods [3], scalable compute, and domain experts in modeling engineering systems (electrical, mechanical, etc.) I believe this is where simulation is headed.

[1] https://juliahub.com/products/juliasim

[2] https://news.ycombinator.com/item?id=26425659

[3] https://docs.sciml.ai/DiffEqDocs/stable/

Re: Modelica

#20
I am now using Modelica with OpenModelica at work to describe electromagnetic systems and it is an excellent language and, with OpenModelica, a excellent graphical user environment. Sometimes I think of it like SPICE but for multi-physics systems.

The Modelica library is quite mature and complete and the numerical solvers included with OpenModelica robust and performing.

It looks me a while to learn it but now it is paying out.

In addition the fact that Modelica is a standard implemented by several suppliers with an open source application is also great to avoid vendor lock in so that is a technology on which is safe to invest as an engineer and as a company.

Post reply on HN