Opened 7 years ago
Last modified 6 years ago
#5009 closed defect
Issue with parameter bindings involving Complex equations in the NF — at Initial Version
Reported by: | Francesco Casella | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description
Please consider the follwing 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, this one 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?
Note:
See TracTickets
for help on using tickets.