﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5301	The NF does not evaluate final parameters computed by functions of parameters with Evaluate = true and literal constants	Francesco Casella	Per Östlund	"Some MultiBody models still do not produce the correct results (or possibly fail) when the NF is employed to flatten the model. For example, the results of [https://libraries.openmodelica.org/branches/newInst/Modelica_trunk/files/Modelica_trunk_Modelica.Mechanics.MultiBody.Examples.Elementary.HeatLosses.diff.html Modelica.Mechanics.MultiBody.Examples.Elementary.HeatLosses] do not match with the reference, in particular the z-axis component of the angular velocity {{{w_a[3]}}} is initialized to zero instead of 2 deg/s, and thus remains constant instead of oscillating.

Some analysis reveals that the start attribute of {{{w_a[3]}}} is computed using {{{R_start.T}}}, which is incorrectly computed to {{{zeros[3,3]}}} instead of {{{diagonal(1, 1, 1)}}}.

The NF-flattened model sets the {{{fixed}}} attribute of {{{R_start.T}}} to false, and adds the initial equation
{{{
  body1.R_start = Modelica.Mechanics.MultiBody.Frames.axesRotations({1, 2, 3}, body1.angles_start, {0.0, 0.0, 0.0});
}}}

However, the {{{Body}}} model contains the following code
{{{
  final parameter Frames.Orientation R_start=
      Modelica.Mechanics.MultiBody.Frames.axesRotations(
        sequence_start,
        angles_start,
        zeros(3))
    ""Orientation object from world frame to frame_a at initial time"";
}}}
Since {{{R_start}}} is {{{final}}} and both {{{sequence_start}}} and {{{angles_start}}} have {{{Evaluate = true}}}, {{{R_start}}} should be marked as structural and evaluated by the front-end.

The issue is similar to #5084; in that case the parameter had {{{Evaluate = true}}}, while here it is {{{final}}}, but the end result should be the same.

I suspect this issue is probably the cause of other simulation failures or errors with the MultiBody library, which are due to the lack of constant evaluation of such rotation matrices, preventing the proper symbolic manipulation of the multibody system equations. I would suggest to fix this asap to improve the coverage and avoid getting wrong results from models that simulate successfully.
"	defect	closed	high	2.0.0	New Instantiation		fixed		Karim Adbdelhak
