Opened 15 years ago

Last modified 15 years ago

#1119 closed defect (fixed)

Vectorization of array equality fails in some cases

Reported by: Adrian Pop Owned by: Adrian Pop
Priority: critical Milestone:
Component: Instantiation Version: 1.5.0RC2
Keywords: Cc: Adrian Pop, Adrian Pop, Per Östlund

Description

Instantiation of this model:

package Modelica
  package Icons
    type TypeReal "Icon for a Real type" 
        extends Real;
        annotation(Icon(Rectangle(extent=[-100,100; 100,-100], style(color=0,rgbcolor={0,0,0},fillColor=8,rgbfillColor={181,181,181})), 
                        Text(extent=[-94,94; 94,-94],style(color=0,rgbcolor={0,0,0},fillColor=8,rgbfillColor={181,181,181}),string="R")));
    end TypeReal;    
  end Icons;
end Modelica;

package Types
 type AngularVelocity_degs = Modelica.Icons.TypeReal(final quantity="AngularVelocity", final unit="deg/s") "Angular velocity type in deg/s";
end Types;

model VectorizationBug
 // works if parameter is replaced with constant.
 // does not work if parameter is removed.
 parameter Types.AngularVelocity_degs w_0_start[3]={0,0,0}; 
end VectorizationBug;

gives this error:

// Error processing file: VectorizationBug.mo
// [VectorizationBug.mo:19:2-19:59:readonly] Error: Variable w_0_start: Type mismatch in equation w_0_start[1]=0 of 
//                                                  type (TypeReal type bc:Real(quantity="AngularVelocity", unit="deg/s")[3])=Integer
 

The model we reported the issue about is as following;

package Modelica
 package Icons 
  type TypeReal "Icon for a Real type"
    extends Real;
  end TypeReal;
 end Icons;
end Modelica;

package DimensionBug
  package Types
    type myType= Real(final unit="N.m/(rad.m)", final min=0) "Torsional stiffness constant";
    type myType2= Modelica.Icons.TypeReal(final unit="N.m/(rad.m)", final min=0) "Torsional stiffness constant";
  end Types;

  model testModel
    parameter DimensionBug.Types.myType b[2,2]={{1,1},{1,1}};
    parameter DimensionBug.Types.myType2 c[2,2]={{1,1},{1,1}};
  end testModel;

end DimensionBug;

model test 
 extends DimensionBug.testModel;
end test;

and the output from Openmodelica is;

Error processing file: temp.mo

[temp.mo:1328:5-1328:62:readonly] Error: Variable c: Type mismatch in equation c[1,1]=1 of type (Modelica.Icons.TypeReal type bc:Real(unit="N.m/(rad.m)", min=0.0)[2, 2])=Integer

# Error encountered! Exiting...
# Please check the error message and the flags.

Execution failed!

Reopening ticket

Change History (3)

comment:2 by Per Östlund, 15 years ago

Added testcase VectorizeExtendedType in mofiles.

comment:3 by Per Östlund, 15 years ago

I had only fixed this bug for one-dimensional vectors previously, but it should now work for any dimensions.

Note: See TracTickets for help on using tickets.