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

Parentheses in equations!

Parentheses in equations!

Hi
I have some problems with parentheses/brackets in some of my equations. This just 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 G as: G = 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 the equation as in equation G below, without parentheses outside (A+B)/2.
  G = 10 / (A + B) / 2 * C;     // G = 5
  //
  // If i split up equation G in 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;

When it is just constants I am calculating I could do parts of the calculation outside the equation.
But, is there a way to solve equation G without split it up in several equations?

Re: Parentheses in equations!

https://trac.openmodelica.org/OpenModelica/newticket - Component Frontend, set CC to "perost". It should be a quick fix for him.

Re: Parentheses in equations!

Thanks! A ticket was sent and a few minutes later the 1.9.1 Beta2 (r19422) was uploaded and the problem was solved current/big_smile

Re: Parentheses in equations!

JoakimSandin wrote:

Thanks! A ticket was sent and a few minutes later the 1.9.1 Beta2 (r19422) was uploaded and the problem was solved current/big_smile

Beta2 was actually uploaded 4 days ago current/smile I fixed the issue a week ago, and Beta2 was just conveniently released a couple of days later. But great, then I'll close the ticket.

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