Opened 11 years ago

Closed 11 years ago

#2617 closed enhancement (duplicate)

Parentheses in equations.

Reported by: joakim.sandin@… Owned by: Joakim Sandin
Priority: high Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: parentheses, brackets, equations Cc: Per Östlund

Description

I am running OpenModelica 1.9.0 (r17628) and I have some problems with parentheses/brackets in some of my equations. Below is a simple exampel and I hope the comments in the code will explain the problem.

model Testar

constant Real A = 2;
constant Real B = 3;
constant Real C = 5;
I wish to whrite equation F as: F = 10 / ((A+B)/2) * C; which is equal to 20

Real G;
Real H;
Real I;

equation

When I save the model, OpenModelica choose to read equation F as in equation G below, without parentheses outside (A+B)/2. But it works fine as long as the model is unsaved.
G = 10 / (A + B) / 2 * C;
G = 5

If i split up equation G, in equation I and H as follows below, I will get the correct answer, which is 20.
I = (A + B) / 2; I = 2.5
H = 10 / I * C;
H = 20

end Testar;

It is the same issue when calculations are made in parameters and constants.

Change History (2)

comment:1 by Per Östlund, 11 years ago

Hi Joakim,

I believe I've already fixed this issue in r19422. Please try the recently released 1.9.1 Beta2.

comment:2 by Per Östlund, 11 years ago

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.