Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.4K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Programmatically set rotationType from Mathematica?

Posted 4 years ago

Dear Colleagues,

I am trying to figure out how to programmatically set, with Mathematica, the rotationType parameter in a Modelica.Mechanics.MultiBody.Parts.FixedRotation.

This is a snippet of my code where topMdlName is the name of the model, tNames4Modelica is a list of names of FixedRotation transforms in the model, and tCnt is the number of transforms.

Map[
  SetSystemModel[topMdlName, <|"ParameterValues" -> {StringJoin[tNames4Modelica[[#]], 
         ".rotationType"] ->"Modelica.Mechanics.MultiBody.Types.RotationTypes.PlanarRotationSequence"}|>] &,Range[tCnt]];

The function, obviously, writes strings to the model and the Simulation Center stops on an error that asserts that the value of the parameter is a string and not the expected enumeration.

I know that the value of the rotationType parameter is a Modelica enumeration as explained in the documentation

type RotationTypes = enumeration(RotationAxis "Rotating frame\_a around an angle with a fixed axis", TwoAxesVectors "Resolve two vectors of frame\_b in frame\_a", PlanarRotationSequence "Planar rotation sequence") "Enumeration defining in which way the fixed orientation of frame\_b with respect to frame_a is specified" annotation(Documentation(Evaluate = true, info = "<html>

but I cannot find a way to set it in Mathematica.

I have read the SetSystemModel help pages and searched the interwebs to no avail. So I am writing to ask for help either for a pointer to documentation or a workaround.

Thank you.

Bogdan

POSTED BY: Bogdan Udrea
4 Replies

I see, this is something that certainly works in the more recent versions, now that we have given more attention to other types of value setting like in enumerations. There are a couple of options. We could first try something like this that may have worked in 12.1,

<|"ParameterValues" -> {"transf.rotationType" -> WSMLink`Reference`ToDotName["Modelica.Mechanics.MultiBody.Types.RotationTypes.PlanarRotationSequence"]}|>

Try this association in either SetSystemModel or possibly in the ConnectSystemModelComponents call, which may have already been supported at the the time.

POSTED BY: Sergio Vargas
Posted 4 years ago

Thank you Sergio. The new method gives the same error

SystemModel::irl: The list of rules is not on the form {"variable" -> numericValue, ...}.

I'll email you about the bugs.

B

POSTED BY: Bogdan Udrea

A wrapper that allows the value setting functions to see a string as a component identifier is QuantityVariable. QuantityVariable, when representing a variable, has two arguments. For the first, we use the identifier string. Conventionally, the second argument is a physical quantity, but in this case you can use a generic IndependentPhysicalQuantity[""]. So your parameter can be added as

QuantityVariable["Modelica.Mechanics.MultiBody.Types.RotationTypes.PlanarRotationSequence", IndependentPhysicalQuantity[""]]

Sergio

POSTED BY: Sergio Vargas
Posted 4 years ago
POSTED BY: Bogdan Udrea
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard