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

Trying (and failing) to produce unit errors

Trying (and failing) to produce unit errors

Hello, I am new to both Modelica and OpenModelica. I am attempting to produce an error by using a unphysical equation, however when I run it it simulates fine and produces a result. The code I am using is shown below, adapted from Modelica by Example:

model RLC
  parameter Modelica.SIunits.Voltage Vb = 24 "Battery voltage";
  parameter Modelica.SIunits.Inductance L = 1;
  parameter Modelica.SIunits.Resistance R = 100;
  parameter Modelica.SIunits.Capacitance C = 0.001;
  Modelica.SIunits.Voltage V;
  Modelica.SIunits.Current i_L;
  Modelica.SIunits.Current i_R;
  Modelica.SIunits.Current i_C;
equation
  i_R = V * R;
  i_C = C * der(V);
  i_L = i_R + i_C;
  L * der(i_L) = Vb - V;
end RLC;

I have intentionally entered i_R = V * R rather than i_R = V / R, and no errors are produced. I am running OpenModelica 1.9.1+dev (r17983) (Bootstrapping version).
Thanks in advance.


Re: Trying (and failing) to produce unit errors

Yes, OpenModelica does not perform unit checking by default (and does not have a reliable unit checker anyway).

Code:

omc RLC.mo Modelica -s --preOptModules+=unitChecking

...
Warning: The following equation is INCONSISTENT due to specified unit information: i_R = V * R
The units of following sub-expressions need to be equal:
- sub-expression "V * R" has unit "Mm4.s-6.A-3.g2"
- sub-expression "i_R" has unit "A"

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