Author Topic: Vector Simulation with openmodelica  (Read 2011 times)

DerDybel

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Vector Simulation with openmodelica
« on: September 05, 2023, 10:36:52 pm »
Hello,

I am relatively new to Enterprise Architect and SysML and have started doing parametric analyses using the interface of EA to openmodelica. This works quite well with 1D variables (eg.: x=1) but I seem to be unable to get the simulation to work with 3D vectors (e.g.: x=(1,2,3)).

Here is how my model and simulation are set up:

BDD:


Parametric Diagram of "Block Needing Vetcor" Block:



IBD of "Vector Simulation Context" Block




When I run the simulation with values "1" and "0" for X and Y respectively, everything works fine. When I use (1,1,1) and (0,0,0) instead, I get the following error:

 Error: Tuple expressions may only occur on the left side of an assignment or equation with a single function call on the right side. Got the following expression: (1, 1, 1). (Expression: "      BlockNeedingVector Property1(pY=(0,0,0),pX=(1,1,1),Type="X1") annotation(Documentation(info = ""), Placement(visible = true, transformation( origin = {-70, -221}, extent = {{0, 0}, { 335, 402}})));  ")

What am I doing wrong? The type "Real" should cover vectors as well and even renaming parameters to indicate "extra dimensions" doesn't work (i.e.: pX --> pX[3]).

Thank you in advance.


« Last Edit: September 11, 2023, 08:36:37 pm by DerDybel »

DerDybel

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Vector Simulation with openmodelica
« Reply #1 on: September 11, 2023, 06:10:14 pm »
Update: I recognised my mistake in declaring arrays with "()" instead of the correct form "{}". However, in doing so I only managed to shift the error somewhere else.

If the input is declared like this pX={1,1,1} then the following error is displayed: 

Error: Type mismatch in binding ‘pX = {1, 1, 1}‘, expected array dimensions [], got [3]. (Expression: "      parameter Real pX annotation(Documentation(info = ""), Placement(visible = true, transformation( origin = {-81, -180}, extent = {{0, 0}, { 85, 32}})));  ")

Fair enough, in modelica arrays need to be declared like this: pX[3]={1,1,1}. However, when this is implemented the constraint formula no longer recognises the parameters as inputs ("Not Required Parameters"), no matter how the parameters are used in the formula





Consequently, the error message says that the variable could not be found in the scope of the block "Block Needing Vector".




DerDybel

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Vector Simulation with openmodelica
« Reply #2 on: September 13, 2023, 05:00:53 pm »
Another Update (but still no solution):

I changed the parameters to SysPhs Constants and Variables and was able to use multiplicity and the SysPhs "Multidimensional Element" Stereotype to specify them as vectors:





However, even though it now seemingly looks right in the Sim, modelica still doesn't get it:





Anyone have any suggestions?