I'm having trouble applying a Constant source with a 3D vector to a WorldForce model. When I try to set the constant k to a 3D vector, I get the following error:
[2] 17:19:55 Translation Error [Modelica.Blocks.Sources: 165:5-166:102]: Type mismatch in binding 'k = {-100, 100, 0}', expected array dimensions [], got [3]
This occurs despite copying exactly the same working models from the example (Example - ForceAndTorque in Elementary). As soon as I put a 3D vector into constant k, it gives this error.
Here's what I've tried:
The error suggests that the Constant block is expecting a scalar value (array dimensions []) but is receiving a vector ([3]). However, I thought WorldForce required a 3D vector input. Can anyone explain why this is happening and how I can correctly apply a 3D constant force to a WorldForce (any Multibody.Forces) model?
Thank you for your help!
It would be good to have to code to debug. This way it is guessing, but a bit too much text for a comment, so: My guess would be that the Modelica.Blocks.Sources.Constant
you are using is not vectorized.
The OpenModelica GUI unfortunately does not show if components/blocks are vectorized. The Modelica-Code should show something like: Modelica.Blocks.Sources.Constant force1[3](k = {0, 1000, 0})
with the [3]
being important. It means that actually three instances of the block are created, each getting one value from the vector {0,1000,0}
.
Here is how the code looks as a screenshot:
At least copying Modelica.Mechanics.MultiBody.Examples.Elementary.ForceAndTorque
and removing the [3]
from the code gives the same error message: