﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
4828	Connection equations involving Complex numbers are redundant and incorrect	Francesco Casella	Per Östlund	"Consider the attached test package. Flattening {{{TestComplexConnect.Circuit1}}} with the old FE results in the following equations, which are correct and correspond to 8 scalar equations
{{{
  V1.p.v.re = V1.v.re;
  V1.p.v.im = V1.v.im;
  Z1.p.v = /*.Modelica.SIunits.ComplexVoltage*/(Complex.'*'.multiply(/*.Complex*/(Z1.Z), /*.Complex*/(Z1.p.i)));
  V1.p.i.re + Z1.p.i.re = 0.0;
  V1.p.i.im + Z1.p.i.im = 0.0;
  V1.p.v.re = Z1.p.v.re;
  V1.p.v.im = Z1.p.v.im;
}}}
Flattening with the new FE results in the following set of equations, which correspond to 12 scalar equations (even though the compiler repoorts only 11), on the same 8 variables.
{{{
  V1.p.v = Z1.p.v;
  V1.p.i + Z1.p.i = 0.0;
  V1.p.v = V1.v;
  Z1.p.v = Complex.'*'.multiply(Z1.Z, Z1.p.i);
  V1.p.i.re = 0.0;
  V1.p.i.im = 0.0;
  Z1.p.i.re = 0.0;
  Z1.p.i.im = 0.0;
}}}

The first issue is that the old FE flattens the simple record equations to their scalar components, while the new one doesn't. I guess this is a new feature to keep the FE workload to a minimum, and I understand the back-end will then expand those equations to their scalar counterparts. Please confirm.

The second issue is that, for some reason, connection equations are generated twice: once correctly (see the first two record equations in the flattened model), then once more as if the connect statement was not there, thus setting the real and imaginary parts of both {{{V1.p.i}}} and {{{Z1.p.i}}} to zero. Flattening {{{Circuit1a}}} further confirms this conjecture.

I guess this is due to the code handling connection equations not being correctly designed to handle complex connector variables. This needs to be fixed, as there are many libraries for power system modelling (also in the MSL) that use complex numbers in the connectors ."	defect	closed	critical	2.0.0	New Instantiation		fixed		Mahder Alemseged Gebremedhin
