Message Boards Message Boards

6
|
10899 Views
|
4 Replies
|
9 Total Likes
View groups...
Share
Share this post:

Specify sets of parameters in SystemModeler

Attachments:
POSTED BY: Patrik Ekenberg
4 Replies

Yes, replaceable components could be used for that. If you put:

replaceable ParameterSets.Records.Set1 set

Then as before you can add choices for the user in the annotation. You can either add a choice like this:

choice(redeclare ParameterSets.Records.Set1 set(m=2,c=2,f=2) "Set 2")

Where you directly in the annotation hard code the different values.

For scale up, I would suggest using this instead:

choices(choice(redeclare ParameterSets.Records.Set1 set "Set 1"),choice(redeclare ParameterSets.Records.Set2 set "Set 2"),choice(redeclare ParameterSets.Records.Set2Alt set "Set 2 alternative"))

Now the actual values can be changed in the records instead and it is easier to add new ones.

You need to create a base class with this replaceable component. In an extended class, you can choose to redeclare the record:

diagram before redeclaration

redeclare record

diagram after redeclaration

I updated the model file and attached it below!

Attachments:
POSTED BY: Patrik Ekenberg

Patrik,

I like the feature of the first approach in that you get to see the parameter of the set in the model view (In your figure the set block in the upper left corder has the values for m,c and f visible in the model view) . The second approach is more convenient to use, but the parameters do not appear anywhere on the model view. Is there a way to do the second approach and have the values used in the set appear in the model? I tried to experiment with this but could not get values to display.

Is there a way to use the replaceable components (that you show in the golf and soccer model) to redeclare the record so the visual changes to show some indication of the values in the record (for example: m=1 for one and m=2 for another, etc.)?

Thanks

POSTED BY: Neil Singer

enter image description here - you have earned "Featured Contributor" badge, congratulations !

This is a great post and it has been selected for the curated Staff Picks group. Your profile is now distinguished by a "Featured Contributor" badge and displayed on the "Featured Contributor" board.

POSTED BY: Moderation Team

Patrik,

This is awesome!

My only suggested change is to make the replaceable record its own model because in many applications the parameter sets will be used in vastly different models. Having the set as part of a larger model is cumbersome and restricts changes. For example, in your spring mass example, lets say I wanted to add another mass but still use the same parameter sets. This would not be possible. I modified your example to make it possible to use the sets in various models:

Here is the base class replaceable record (NewReplaceableSetClass):

enter image description here

Patrick's model looks the same:

enter image description here

But now it is duplicatable and editable:

enter image description here

To do this you only need one line from Patrik's example in the newReplaceableSetClass:

  replaceable ParameterSetsRedeclare.Records.Set1 set annotation(choices(choice(redeclare ParameterSetsRedeclare.Records.Set1 set "Set 1"), choice(redeclare ParameterSetsRedeclare.Records.Set2 set "Set 2"), choice(redeclare ParameterSetsRedeclare.Records.Set2Alt set "Set 2 alternative")), Placement(visible = true, transformation(origin = {-124.703, 81.48}, extent = {{-13.52, -13.52}, {13.52, 13.52}}, rotation = 0)));

and you need to add only one line to the models in which you use the replaceable set: (Note I added the icon AFTER my parameter set so the model will replace the parameter icon with the example icon -- makes things look nicer)

  extends ParameterSetsRedeclare.BaseClasses.NewReplaceableSetClass(redeclare ParameterSetsRedeclare.Records.Set2 set);
  extends Modelica.Icons.Example;

I have attached Patrik's file with these small edits.

Attachments:
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