Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3467 closed defect (fixed)

Problems with type redeclaration in complex numbers

Reported by: Francesco Casella Owned by: Per Östlund
Priority: high Milestone: 1.9.4
Component: Frontend Version:
Keywords: Cc: andrea.bartolini@…

Description

Please consider the following code fragment

package TestComplex
  package Types
    operator record ComplexVoltage = 
      Complex(redeclare Modelica.SIunits.Voltage re, 
              redeclare Modelica.SIunits.Voltage im);
    operator record ComplexCurrent = 
      Complex(redeclare Modelica.SIunits.Current re,
              redeclare Modelica.SIunits.Current im);
    operator record Impedance = 
      Complex(redeclare Modelica.SIunits.Resistance re,
              redeclare Modelica.SIunits.Resistance im);
  end Types;

  package Test
    model A
      import SI = Modelica.SIunits;
      parameter SI.Resistance R = 1;
      parameter SI.Reactance X = 1;
      parameter Types.Impedance Z = Complex(R, X);
      Types.ComplexCurrent I = Complex(1, 0);
      Types.ComplexVoltage V = Z * I;
    end A;
  end Test;
  annotation(uses(Complex(version = "3.2.1"), Modelica(version = "3.2.1")));
end TestComplex;

When compiling this, the current nightly complains that:

[1] 02:36:24 Translation Error
[TestComplex: 21:7-21:45]: Variable I: Duplicate modification of element
(redeclare .Modelica.SIunits.Current re) and  = (typed)1.0 DAE.PROP(Real, C_CONST), value: 1.0 on component re.

[2] 02:36:24 Translation Error
[TestComplex: 21:7-21:45]: Variable I: Duplicate modification of element
 (redeclare .Modelica.SIunits.Current im) and  = (typed)0.0 DAE.PROP(Real, C_CONST), value: 0.0 on component im.

plus other similar errors, but then it happily proceeds and produces correct results.

  • What do these error messages mean?
  • Why is correct simulation code produced after an error (not a warning)?

Change History (5)

comment:1 by Francesco Casella, 9 years ago

Cc: andrea.bartolini@… added
Owner: changed from somebody to Adrian Pop
Status: newassigned

comment:2 by Per Östlund, 9 years ago

Owner: changed from Adrian Pop to Per Östlund

I can take a look at this, I think I know what the issue is.

comment:3 by Per Östlund, 9 years ago

Resolution: fixed
Status: assignedclosed

Fixed in 0de2ae0.

comment:4 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:5 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.