Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5283 closed defect (duplicate)

Issue with function with multiple outputs and arrays in the NF

Reported by: Francesco Casella Owned by: Per Östlund
Priority: high Milestone: 2.0.0
Component: New Instantiation Version:
Keywords: Cc:

Description

Please check Modelica.Electrical.Machines.Examples.AsynchronousInductionMachines.AIMC_withLosses. The C-code compilation fails with

Modelica_trunk_Modelica.Electrical.Machines.Examples.AsynchronousInductionMachines.AIMC_withLosses.c:282:49: error: cannot take the address of an rvalue of type 'modelica_real' (aka 'double')
  real_array_create(&tmp14, ((modelica_real*)&((&-(data->localData[0]->realVars[167] /* sineVoltage.i[1] variable */))[calc_base_index_dims_subs(1, 3, ((modelica_integer) 1))])), 1, 3);
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Some analysis reveals that the following line of code:

  i_ = Machines.SpacePhasors.Functions.ToSpacePhasor(plug_p.pin.i);

whereas ToSpacePhasor is defined as

function Modelica.Electrical.Machines.SpacePhasors.Functions.ToSpacePhasor "Inline before index reduction" "Conversion from multi phase input to space phasor and zero sequence component"
  input Real[:] x "Multi phase (voltage or current) input";
  output Real[2] y "Space phasor";
  output Real y0 "Zero sequence component (of voltage or current)";
...

is flattened by the OF as

(electricalPowerSensor.i_, _) = 
  Modelica.Electrical.Machines.SpacePhasors.Functions.ToSpacePhasor(
   {electricalPowerSensor.plug_p.pin[1].i, 
    electricalPowerSensor.plug_p.pin[2].i, 
    electricalPowerSensor.plug_p.pin[3].i});

but is instead flattened by the NF as

electricalPowerSensor.i_ = 
  Modelica.Electrical.Machines.SpacePhasors.Functions.ToSpacePhasor(
    electricalPowerSensor.plug_p.pin.i)[1];

which has the following issues:

  • the second output arguent was skipped on the left-hand side
  • the array input was not flattened (I'm unsure if the backend can handle that)
  • only the first scalar element of the function output is assigned to the left-hand side, which has type Real[2]

Change History (3)

comment:2 by Per Östlund, 6 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #5235.

comment:3 by Francesco Casella, 6 years ago

OK, sorry, I didn't pay attention to that.

Note: See TracTickets for help on using tickets.