Opened 7 years ago
Closed 6 years ago
#5009 closed defect (fixed)
Issue with parameter bindings involving Complex equations in the NF
Reported by: | Francesco Casella | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description (last modified by )
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?
Change History (3)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 6 years ago
comment:3 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
It seems that the recent updates to the NF were beneficial, since this model now works correctly with v1.13.0-dev-1096-g6770e6300
.
Reporting @perost's e-mail comment on 12 July 2018