Message Boards Message Boards

1
|
5703 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Extract ODEs from Component Based Model

I have a model made up of MEchanical MultiBody components and I would like to extract just the ODE model from the model in Mathematica for use in a document/report.

I have used:

mdl["SystemEquations", Method -> {"Elimination" -> All}]

But this does not seem to eliminate all the algebraic equations that are from all the linkages. Ive also tried to use "Reduce" and "Eliminate" but without much success.

Further, "SystemEquations" returns variables as "Quantity Variables" which I find difficult to work with. Is there a easy way to just use straight variable names?

Any advice would be appreciated!

POSTED BY: Wayne Weaver

A key aspect of MutliBody components is that they are intended to help with the innate complexity of 3D mechanics, each one ultimately standing for a large number of non-trivial equations optimized to fit most common scenarios, pushing for the use of component connections instead of directly tackling the ODE. Animation features are also part of the components themselves, and an alternative to reduce the system of equations more is to turn them off in the "world" component of your model. For instance, with the model "Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum", we can make a copy of the model in which we do this:

 model2 = SystemModel["Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum", <|"ParameterValues" -> {"world.enableAnimation" -> False}|>]; 

and then request equations with

eqs = model2["SystemEquations", Method -> {"Elimination" -> All, "ReduceIndex" -> True}];

The wrapper of QuantityVariable is convenient for dealing with names of non-top level components, which have the "." separation. In addition, models can involve strings in their equations and, without a proper wrapper, parameter names and strings would not be distinguishable. If you prefer to work with the string themselves instead of QuantityVariable, you can do a replacement of the form

exp /. {QuantityVariable[id_, _] :> id}
POSTED BY: Sergio Vargas
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