Message Boards Message Boards

1
|
4641 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Connection between two MultiBody SystemModels

Posted 3 years ago

Dear Colleagues,

I am trying to connect a set of SystemModels that I generated programmatically in Mathematica. I am interested in MultiBody models and I haven't tried other types of models. I am failing gloriously and I have spent a good part of the day reading the online help pages and performing a lot of trial and error. Here's a simplified example

First model called "model1"

comp1 = {"c11" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
         "c12" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape"}
conn1 = {"c11.frame_b" \[DirectedEdge] "c12.frame_a"}
ConnectSystemModelComponents["model1", comp1, conn1, GraphLayout -> None]

Second model called "model2"

comp2 = {"c21" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
"c22" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape"}
conn2 = {"c21.frame_b" \[DirectedEdge] "c22.frame_a"}
ConnectSystemModelComponents["model2", comp2, conn2, GraphLayout -> None]

Model'o'models - failure

(*"Model" found by trial error. Is it needed, is it correct? At least Mathematica don't complain about it*)
compM = {"model1" \[Element] "Model", "model2" \[Element] "Model"}
connM = {"model1.c11.frame_a" \[DirectedEdge] "model2.c21.frame_a"}
ConnectSystemModelComponents["mdlOfMdls", compM, connM]

The error message is

ConnectSystemModelComponents::cnf: Connectors {model1.c11.framea,model2.c21.framea} are not one of the expected ones: {}.

I have also tried

connM = {"c11.frame_a" \[DirectedEdge] "c21.frame_a"}
ConnectSystemModelComponents["mdlOfMdls", compM, connM]

that gives a similar error message:

ConnectSystemModelComponents::cnf: Connectors {c11.framea,c21.framea} are not one of the expected ones: {}.

According to the Mathematica help page for ConnectSystemModelComponents at https://reference.wolfram.com/language/ref/ConnectSystemModelComponents.html

The compi can be a SystemModel object, a full model name string or a shortened model name accepted by SystemModel.

The error seems to come from the connectors of each model so the question is What type of connectors should I use?

Last but not least, I have also tried something a bit more sophisticated by introducing a MultoBody Interface component

comp1 = {"c11" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
         "c12" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
         "if1" \[Element] "Modelica.Mechanics.MultiBody.Interfaces.Frame_a"}
conn1 = {"c11.frame_a" \[DirectedEdge] "if1", 
  "c11.frame_b" \[DirectedEdge] "c12.frame_a"}
ConnectSystemModelComponents["model1", comp1, conn1]

comp2 = {"c21" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
  "c22" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
  "if2" \[Element] "Modelica.Mechanics.MultiBody.Interfaces.Frame_a"}
conn2 = {"c21.frame_a" \[DirectedEdge] "if2", 
  "c21.frame_b" \[DirectedEdge] "c22.frame_a"}
ConnectSystemModelComponents["model2", comp2, conn2]

compM = {"model1" \[Element] "Model", "model2" \[Element] "Model"}
connM = {"model1.if1" \[DirectedEdge] "model2.if2"}
ConnectSystemModelComponents["mdlOfMdls", compM, connM]

That gives the same type of error.

I have posted this question on StackExchange as well.

Thank you.

B

POSTED BY: Bogdan Udrea
2 Replies
Posted 3 years ago

Neil, Thank you. Yes, it helps. I totally missed the fact that I have to instantiate the models that I created. The World component is at the top and not shown in this example. Best regards, B

POSTED BY: Bogdan Udrea

Bogdan,

You need to have a connector on each of your mode1 and model2 models if you want to connect them together. For example

comp1 = {"c11" \[Element] 
   "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
  "c12" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
  "frame1" \[Element] 
   "Modelica.Mechanics.MultiBody.Interfaces.Frame_a"}
conn1 = {"c11.frame_b" \[DirectedEdge] "c12.frame_a", 
  "c11.frame_a" \[DirectedEdge] "frame1"}
ConnectSystemModelComponents["model1", comp1, conn1, 
 GraphLayout -> None]

comp2 = {"c21" \[Element] 
   "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
  "c22" \[Element] "Modelica.Mechanics.MultiBody.Parts.BodyShape", 
  "frame2" \[Element] 
   "Modelica.Mechanics.MultiBody.Interfaces.Frame_a"}
conn2 = {"c21.frame_b" \[DirectedEdge] "c22.frame_a", 
  "c21.frame_a" \[DirectedEdge] "frame2"}
ConnectSystemModelComponents["model2", comp2, conn2, 
 GraphLayout -> None]

You can connect them as you tried except your syntax of

"model1" \[Element] "Model"

makes no sense. You need to name an instance of the models you created:

compM = {"aa" \[Element] "model1", "bb" \[Element] "model2"}
connM = {"aa.frame1" \[DirectedEdge] "bb.frame2"}
ConnectSystemModelComponents["mdlOfMdls", compM, connM]

One other note, If you intend to use the multibody elements, you MUST have a World element in the top level model.

I hope this helps.

Regards,

Neil

POSTED BY: Neil Singer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract