Opened 9 years ago

Closed 3 years ago

#3388 closed defect (fixed)

Instantation uses parameter value instead of parameter reference

Reported by: carlj@… Owned by: somebody
Priority: high Milestone: 1.16.0
Component: New Instantiation Version: trunk
Keywords: Cc:

Description

This was found using 1.9.3~dev-542.

Create a new model with a Modelica.Mechanics.MultiBody.World and a Modelica.Mechanics.MultiBody.Parts.Body.
After the model has been flattened, the equation

g_0 = world.gravityAcceleration(frame_a.r_0 + Frames.resolve1(frame_a.R, r_CM));

in the body component has been transformed to:

body1.g_0 = Modelica.Mechanics.MultiBody.World.gravityAcceleration({body1.frame_a.r_0[1], body1.frame_a.r_0[2], body1.frame_a.r_0[3]} + Modelica.Mechanics.MultiBody.Frames.resolve1(body1.frame_a.R, {body1.r_CM[1], body1.r_CM[2], body1.r_CM[3]}), Modelica.Mechanics.MultiBody.Types.GravityTypes.UniformGravity, {0.0, -9.81, 0.0}, 398600000000000.0);

where the numeric value for world.g has been used instead of component reference to world.g.

GravityAcceleration in the world component is defined as

replaceable function gravityAcceleration = Modelica.Mechanics.MultiBody.Forces.Internal.standardGravityAcceleration(gravityType = gravityType, g = g * Modelica.Math.Vectors.normalizeWithAssert(n), mue = mue) constrainedby Modelica.Mechanics.MultiBody.Interfaces.partialGravityAcceleration

and world.g is a parameter

  parameter SI.Acceleration g = 9.81.

So here, the reference to the parameter g in the definition of gravityAcceleration has unnecessarily been replaced with its value, 9.81, which removes the possibility to change the gravity after building the model.

Change History (2)

comment:1 Changed 9 years ago by adrpo

This is a known bug, we evaluate (change the parameters to values) in more cases than we should (structural parameters, i.e. array sizes, etc). We're working on fixing this.

comment:2 Changed 3 years ago by perost

  • Component changed from Frontend to New Instantiation
  • Milestone changed from Future to 1.16.0
  • Resolution set to fixed
  • Status changed from new to closed

The new frontend only generates parameters if they are structural, so in this case it generates the equation:

  body.g_0 = M.world.gravityAcceleration(body.frame_a.r_0 + Modelica.Mechanics.MultiBody.Frames.resolve1(body.frame_a.R, body.r_CM), Modelica.Mechanics.MultiBody.Types.GravityTypes.UniformGravity, {0.0, world.g * (-1.0), 0.0}, world.mu);
Note: See TracTickets for help on using tickets.