﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5009	Issue with parameter bindings involving Complex equations in the NF	Francesco Casella	Per Östlund	"Please consider the following test model
{{{
model TestComplexParameter
  import CM = Modelica.ComplexMath;
  parameter Real v_abs_start = 2, v_phase_start = 0.5;
  parameter Modelica.SIunits.ComplexVoltage v_start = CM.fromPolar(v_abs_start, v_phase_start);
  Modelica.SIunits.ComplexVoltage v(re(start=v_start.re), im(start=v_start.im));
equation
  CM.'abs'(v) = 1;
  CM.arg(v) = 0.5;
end TestComplexParameter;
}}}
When building the model with the NF, the generated {{{TestComplex_06inz.c}}} C-code contains:
{{{
/*
 equation index: 1
 type: ALGORITHM
 
   v_start := Complex(v_abs_start * cos(v_phase_start), v_abs_start * sin(v_phase_start));
 */
void TestComplex_eqFunction_1(DATA *data, threadData_t *threadData)
{
  TRACE_PUSH
  const int equationIndexes[2] = {1,1};
  Complex tmp0;
  Modelica_SIunits_ComplexVoltage tmp1;
  tmp0._re = (data->simulationInfo->realParameter[0]) * (cos(data->simulationInfo->realParameter[1]));
  tmp0._im = (data->simulationInfo->realParameter[0]) * (sin(data->simulationInfo->realParameter[1]));
  tmp1 = tmp0;
  data->simulationInfo->realParameter[3] = tmp1._re;
  data->simulationInfo->realParameter[2] = tmp1._im;
  TRACE_POP
}
}}}
which breaks the compiler because {{{Modelica_SIunits_ComplexVoltage}}} is undefined.

I understand binding equations for Complex parameters are now moved to the initial equations. For some reason, the call to the {{{fromPolar}}} function is not inlined correctly, as it is instead the case for regular binding equations, such as in 
{{{
model TestComplexVariable
  import CM = Modelica.ComplexMath;
  Modelica.SIunits.ComplexVoltage v = CM.fromPolar(time, sin(time));
end TestComplexVariable;
}}}
Perhaps the {{{Inline}}} annotation of the {{{fromPolar}}} function is lost on these added initial equations?"	defect	closed	high	2.0.0	New Instantiation		fixed		
