- Index
- » Programming
- » Modelica Language
- » Parentheses in equations!
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.
- sjoelund.se
- 1700 Posts
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
Beta2 was actually uploaded 4 days ago 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.
- perost
- 114 Posts
- Index
- » Programming
- » Modelica Language
- » Parentheses in equations!