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

omc enable unit consistency check

omc enable unit consistency check

Hi all,
I want to enable warnings about unit mismatches (dimentionality) on modelica code. Here is the test code I mis-formulated on purpose:

Code:


class test
Real v(final unit="V");
Real i(final unit="A");
parameter Real r(start = 120, final unit="Ohm");
equation
    v = i * i * r;
    v = sin(time);
end test;

Here is the script I used for compiling:

Code:


loadModel(Modelica);
loadFile("test.mo");
simulate(test, stopTime=10);
plot(i);

I compile the code above with the following command:

Code:


omc t.mos --debug=dumpEqInUC --debug=dumpEqUCStruct --debug=dumpUnits

But there is no warning about units. How to enable unit check? Thanks.

omc version: 1.9.3+dev (r25940)

Edited by: semicolon - Mar-01-16 12:59:14

Re: omc enable unit consistency check

Add the following line to script,

Code:

setCommandLineOptions("--preOptModules+=unitChecking");

Adeel.

Re: omc enable unit consistency check

(I think the 1.9.3 pre-release did not support preOptModules+=xxx.)

Re: omc enable unit consistency check

I compiled from svn source. How can I reach the release version?

Re: omc enable unit consistency check

Did you see the readme that said the repository has moved to git?

Re: omc enable unit consistency check

I was misguided. I've read that svn is more up-to-date and git is just mirror. Now it works with v1.9.4-dev.beta2.79+g3f4477c. Thanks a lot guys. Happy modeling.

Edited by: semicolon - Mar-02-16 06:04:57

Re: omc enable unit consistency check

Is there a way to employ unit checking within OMEdit?

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