Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.5K Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Extracting information from a Modelica model with Mathematica.

Posted 2 years ago
POSTED BY: Fabián Peña
2 Replies

POSTED BY: Sergio Vargas
Posted 2 years ago

Dear Sergio,

Thank you very much for your answer. Your advice is very useful.

Following your suggestions, I came up with the code below, which seems suitable for my application:

First, the components of a particular type are selected as you suggested:

(* Selects the components that are springs *)
type = "Modelica.Mechanics.MultiBody.Forces.Spring" ;
selectComps =  Select[SystemModel[mdl, "Components"], #[[-1, 1]] === type &] 

Then, the component's names of interest are appended with the variable names, (e. g. from spring1 to spring1.c):

springConstantNames = selectComps[[All, 1]]  (* For all elements, get the first sub-element *) 
springConstantNames = Map[StringJoin[#, ".c"] &,  springConstantNames] (* Append ".c" to each name *)

Finally, the simulation is carried out for zero seconds, and the numeric values of such variables are extracted:

(* Executes the simulation for zero seconds to retrieve the values of  the spring constants *)
springConstantValues =  SystemModelSimulate[mdl, All, 0][springConstantNames]

Thank you very much again.

Cheers,

Fabián

POSTED BY: Fabián Peña
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard