Opened 12 years ago
Closed 12 years ago
#1957 closed defect (fixed)
Modelica.Mechanics.MultiBody.Examples.Elementary.Surfaces
Reported by: | Christian Schubert | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | 1.9.0 |
Component: | Backend | Version: | trunk |
Keywords: | omc crash MultiBody | Cc: | Martin Sjölund |
Description
When running the MSL 3.2.1 testsuite the omc crashes at Modelica.Mechanics.MultiBody.Examples.Elementary.Surfaces with both the new and the old instantiation. Nevertheless it outputs (run with +d=execstat)
*** Enter Main -> time: 0.0000024360162920769613, memory: 0.001953125/20.0 MB (0.009765625%) true true true a->dim_size[0] != b->dim_size[0], 57 != 64 Assertion failed: base_array_shape_eq(source, dest), file util/real_array.c, line 129 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
Change History (9)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
If you call with +d=execstat you can see that it does not crash during simulation. It crashes in the FrontEnd. This couldn't be wanted?
*** Enter Main -> time: 0.000006926949845237357, memory: 0.003070831298828125/20 .0 MB (0.015354156494140625%) true true true a->dim_size[0] != b->dim_size[0], 57 != 64 Assertion failed: base_array_shape_eq(source, dest), file util/real_array.c, lin e 129 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
comment:3 by , 12 years ago
I'll look into this as it need more investigation.
Looks like maybe some redeclares or modifiers are not passed correctly.
Cheers,
Adrian Pop/
comment:4 by , 12 years ago
As far as I can see until now this is a bug on our part as we call function:
Modelica.Mechanics.MultiBody.Visualizers.Advanced.PipeWithScalarField.colorMap
with n_colors = 64 instead of the n_colors = 32 given by modifier.
I'll dig up more.
comment:5 by , 12 years ago
The following is a patch for the problem with the array-dimensions in the jet function, but it cannot be used without breaking the frontend for MSL 3.1. From what little time I spent locating that bug, it seems to be due to having something like:
paramater Real x[:] = {15}; paramater Real y[1] = if cond then {1} else x;
So we do not yet know the dimension of x and thus crap out later in type-checking. Maybe I should just force it to evaluate parameter expressions with unknown dimensions...
-
Compiler/FrontEnd/Static.mo
11796 11796 case (cache,env,e1,DAE.PROP(type_ = t1,constFlag = c1),e2,DAE.PROP(type_ = t2,constFlag = c2),e3,DAE.PROP(type_ = t3,constFlag = c3),impl,st,_, _) 11797 11797 equation 11798 11798 (e1,_) = Types.matchType(e1, t1, DAE.T_BOOL_DEFAULT, true); 11799 (t2,t3) = Types.ifExpMakeDimsUnknown(t2,t3); 11799 11800 (e2_1,t2_1) = Types.matchType(e2, t2, t3, true); 11800 11801 c = constIfexp(e1, c1, c2, c3) "then-part type converted to match else-part" ; 11801 11802 (cache,exp) = cevalIfexpIfConstant(cache,env, e1, e2_1, e3, c1, impl, st, inInfo); … … 11805 11806 case (cache,env,e1,DAE.PROP(type_ = t1,constFlag = c1),e2,DAE.PROP(type_ = t2,constFlag = c2),e3,DAE.PROP(type_ = t3,constFlag = c3),impl,st,_, _) 11806 11807 equation 11807 11808 (e1,_) = Types.matchType(e1, t1, DAE.T_BOOL_DEFAULT, true); 11809 (t2,t3) = Types.ifExpMakeDimsUnknown(t2,t3); 11808 11810 (e3_1,t3_1) = Types.matchType(e3, t3, t2, true); 11809 11811 c = constIfexp(e1, c1, c2, c3) "else-part type converted to match then-part" ; 11810 11812 (cache,exp) = cevalIfexpIfConstant(cache,env, e1, e2, e3_1, c1, impl, st, inInfo); -
Compiler/FrontEnd/Types.mo
7463 7463 end match; 7464 7464 end classTypeEqualIfRecord; 7465 7465 7466 public function ifExpMakeDimsUnknown "If one branch of an if-expression has truly unknown dimensions they both will need to return unknown dimensions for type-checking to work" 7467 input DAE.Type ty1; 7468 input DAE.Type ty2; 7469 output DAE.Type oty1; 7470 output DAE.Type oty2; 7471 algorithm 7472 (oty1,oty2) := match (ty1,ty2) 7473 local 7474 DAE.Type inner1,inner2; 7475 DAE.TypeSource ts1,ts2; 7476 DAE.Dimensions dims2; 7477 DAE.Dimension d; 7478 case (DAE.T_ARRAY(ty=inner1,dims={DAE.DIM_UNKNOWN()},source=ts1),DAE.T_ARRAY(ty=inner2,dims={_},source=ts2)) 7479 equation 7480 (oty1,oty2) = ifExpMakeDimsUnknown(inner1,inner2); 7481 then (DAE.T_ARRAY(inner1,DAE.DIM_UNKNOWN()::{},ts1),DAE.T_ARRAY(inner2,DAE.DIM_UNKNOWN()::{},ts2)); 7482 case (DAE.T_ARRAY(ty=inner1,dims={_},source=ts1),DAE.T_ARRAY(ty=inner2,dims={DAE.DIM_UNKNOWN()},source=ts2)) 7483 equation 7484 (oty1,oty2) = ifExpMakeDimsUnknown(inner1,inner2); 7485 then (DAE.T_ARRAY(inner1,DAE.DIM_UNKNOWN()::{},ts1),DAE.T_ARRAY(inner2,DAE.DIM_UNKNOWN()::{},ts2)); 7486 case (DAE.T_ARRAY(ty=inner1,dims={_},source=ts1),DAE.T_ARRAY(ty=inner2,dims={_},source=ts2)) 7487 equation 7488 (oty1,oty2) = ifExpMakeDimsUnknown(inner1,inner2); 7489 then (DAE.T_ARRAY(inner1,DAE.DIM_UNKNOWN()::{},ts1),DAE.T_ARRAY(inner2,DAE.DIM_UNKNOWN()::{},ts2)); 7490 else (ty1,ty2); 7491 end match; 7492 end ifExpMakeDimsUnknown; 7493 7466 7494 public function fixUnknownDimensions "Fixes unknown dimensions by getting hints from the final expression" 7467 7495 input DAE.Type ty1; 7468 7496 input DAE.Type ty2 "Simplified type, but might have more dimensions known";
comment:6 by , 12 years ago
r14707 now manages Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps.jet fine. So one step down.
comment:7 by , 12 years ago
The following is the library diff that makes Surfaces simulate:
-
MultiBody/Visualizers.mo
2177 2177 "Function defining the color map" 2178 2178 annotation(choicesAllMatching=true, Dialog(group="Color coding")); 2179 2179 protected 2180 parameter Real colorMapData[ n_colors,3] = colorMap(n_colors) annotation(HideResult=true);2180 parameter Real colorMapData[:,3] = colorMap(n_colors) annotation(HideResult=true); 2181 2181 Surface surface( 2182 2182 R=R, 2183 2183 r_0=r_0,
It should be possible to instead fix the typing of the function to realize that the type Real[n_colors,3] that colorMap(n_colors) returns is a parameter expression that we can force evaluation on. Note: The error-message given by omc is nowhere close to the real problem, which only showed up when I ran instantiateModel directly on Advanced.PipeWithScalarField.
comment:8 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:9 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed in r14708. Someone should update the test to use the reference file.
This is expected. The code is legal but written in such a way that a Modelica tool should crash during simulation time. Go figure.