Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Difference between Class and Model in OpenModellica

Difference between Class and Model in OpenModellica

Hi,
I am new to OpenModelica and want to know if there is any difference between 'Class" and "Model" in OpenModelica ( Open New Modelica class and set the Specialization as Class or Model)
I find whatever can be done by Class can also  be done as Model and vice versa

Thanks

Re: Difference between Class and Model in OpenModellica

OpenModelica doesn't really differentiate between class and model, since historically they've been pretty much the same thing. This has been changed in the specification recently though, by restricting class to only be allowed to contain class-definitions, annotations, and extends-clauses. class also has the property that anything can extend a class, while model is really only allowed to extend other models.

I don't think there are many situations where you would actually need to use class now, and the recommendation is to always use the most specialized type of class that you can. In other words, prefer to use model when something is an actual model.

Re: Difference between Class and Model in OpenModellica

I frequently define icons in classes rather than models. That way I can use the same icon in both models and packages. In Dymola, for example, I get a warning if I extend a package from an icon model. For example:

Code:


class valveIcon
  annotation(graphics(...)) // valve icons drawn here;
end valveIcon

model valveModel
  extends valveIcon;
  // equations here
end valveModel

package valvePackage
  extends valveIcon;
  // various valve models inside package
end valvePackage;

Edited by: justnielsen - Apr-20-21 12:23:52
There are 0 guests and 0 other users also viewing this topic
You are here: