Opened 7 years ago

Closed 7 years ago

#4606 closed defect (fixed)

Wrong equation count with complex numbers

Reported by: massimo ceraolo Owned by: Per Östlund
Priority: high Milestone: 1.13.0
Component: Frontend Version:
Keywords: Cc:

Description

After a check it seems to me that this is not a duplicate, but I'm not totally sure.
Consider the following code:

model NumOfEq
  function F
    input Complex Z1, Z2;
    output Complex Z3;
  algorithm
    Z3 := Z1 + Z2;
  end F;
  model M4x2
    parameter Complex Z1 = Complex(1, 1);
    parameter Complex Z2 = Z1;
    Complex Z3 = F(Z1, Z2);
  end M4x2;
  model M4x4
    parameter Complex Z1 = Complex(1, 1);
    Complex Z2 = Z1;
    Complex Z3 = F(Z1, Z2);
  end M4x4;
end NumOfEq;

I expect to have 4 equations and variables in model M4x4 and 2 equations and variables in model M2x2.
However OM reports in the second case 4 equations and 2 variables.

Change History (4)

comment:1 by Martin Sjölund, 7 years ago

Component: *unknown*Frontend

The flattened code looks like this:

  Real Z3.re = 2.0 "Real part of complex number";
  Real Z3.im = 2.0 "Imaginary part of complex number";
equation
  Z3 = NumOfEq.F(Z1, Z2);

So it seems we both evaluate the binding and move it to the equation section, resulting in duplicates :(

comment:2 by Francesco Casella, 7 years ago

Owner: changed from somebody to Per Östlund
Status: newassigned

@perost, can this be fixed easily in the old front-end? Otherwise, we can schedule this for 2.0.0

comment:3 by Per Östlund, 7 years ago

Fixed in c93ff57.

comment:4 by Per Östlund, 7 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.