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

OMedit can not find modelica standard library

OMedit can not find modelica standard library

Sorry for my noob problem.
I can not simulate any model, because of error "Class modelica.xxx.yyy.zzz not found in scope mysample"
How I can install/enable the standard library?

This is one of codes that does not work:
model boz

parameter Modelica.SIunits.Mass m = 2;
parameter Real f(unit="N",min=0) = 2;
Real s(unit="m");
Real v(unit="m/s");

equation
  v = der(s);
  f = der(v) * m;
end boz;

Which produce error:
[1] 17:13:33 Translation Error
[boz: 3:1-3:38]: Class Modelica.SIunits.mass not found in scope boz.

Re: OMedit can not find modelica standard library

You have a typo in the name, its

Code:

Modelica.SIunits.Mass

Usually the names of models are starting with a capital letter.

See chapter 3.10.3 Naming Conventions of Modelica: Equation-Based, Object-Oriented Modelling of Physical Systems by Peter Fritzson about naming conventions.


• Type and class names (but usually not functions) always start with an uppercase letter, e.g., Voltage.
• Variable names start with a lowercase letter, e.g., body, with the exception of some one-letter names such
as T for temperature.
• Names consisting of several words have each word capitalised, with the initial word subject to the above
rules, e.g., ElectricCurrent and bodyPart.
• The underscore character is only used at the end of a name, or at the end of a word within a name, often to
characterise lower or upper indices, e.g., body_low_up.
• Preferred names for connector instances in (partial) models are p and n for positive and negative connectors
in electrical components, and name variants containing a and b, e.g., flange_a and flange_b, for other kinds
of otherwise-identical connectors often occurring in two-sided components.

Edited by: AnHeuermann - Dec-04-20 15:30:16

Re: OMedit can not find modelica standard library

Otherwise make sure you have the Modelica library loaded. It should be visible in the left side in OMEdit in the Libraries Browser.
When you start OMEdit you should see something like

Code:


[1] 16:33:59 Scripting Notification
Automatically loaded package Complex 3.2.3 due to uses annotation.

[2] 16:33:59 Scripting Notification
Automatically loaded package ModelicaServices 3.2.3 due to uses annotation.

in the message browser in the bottom part of OMEdit.

Oh and for MSL 4.0.0 SIunits got renamed:

Code:


Modelica.Units.SI.Mass

Edited by: AnHeuermann - Dec-04-20 15:39:10

Re: OMedit can not find modelica standard library

Thank you for your quick response.

No it is not loaded. I see this at the start:
[1] 17:10:45 Scripting Notification
You can install the requested package using one of the commands:
  installPackage(Modelica, "3.2.3+maint.om", exactMatch=true)
  installPackage(Modelica).

[2] 17:10:45 Scripting Error
Failed to load package Modelica (default) using MODELICAPATH /usr/bin/../lib/omlibrary:/home/hamid/.openmodelica/libraries/.

[3] 17:10:45 Scripting Notification
You can install the requested package using one of the commands:
  installPackage(ModelicaReference, "3.2.3+maint.om", exactMatch=true)
  installPackage(ModelicaReference).

Where I should run the commands? Openmodelica Compiler CLI print a "false" immediately after I send the command "installPackage(ModelicaReference)".

Re: OMedit can not find modelica standard library

What OM version do you have? What operating system are you running on?

Re: OMedit can not find modelica standard library

Ah, you have Linux from the form of MODELICAPATH.
I guess you need to do this: https://openmodelica.org/download/download-linux

Code:


for PKG in `apt-cache search "omlib-.*" | cut -d" " -f1`; do sudo apt-get install -y "$PKG"; done

to install the Modelica libraries.

Re: OMedit can not find modelica standard library

It should work also with installPackage, try:

Code:


installPackage(ModelicaReference);
getErrorString();

to also display what the error was.

There are 0 guests and 0 other users also viewing this topic
You are here: