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