modelicadymolaredeclaration

Modelica/Dymola Redeclare Component through integer


I'm currently working on a model, where I want to use an Array of Integers in order to redeclare the shown components: Image of the blocks and redeclaration-window My goal is to have i.e. the blank at the top left corner redeclared to a pump if the integervalue in my reference array is 1. My question would be, if it is even possible to accomplish my goal this way, or if I have to go with the dropdown-menus/manual implementation?

I already tried to use an if-clause or an Array filled with strings, but Modelica/Dymola is only allowing records to be used in the fields for redeclaration. I also tried using "redeclare model extends", to vary the extends which didn't work because of errors in the syntax.

[Possible(?) workaround] If this is truly impossible, could it be done by piling all the components/parameters up into one model and activate/deactivate the needed parts with a parameter as shown below? small scale of the described "workaround" Unfortunately I'm lacking a lot of knowledge when it comes to scripting. I hope my problem is understandable.


Solution

  • You cannot base a redeclare on the value of an Integer parameter.

    Having all of the components in one model and disabling the unneeded parts simply doesn't work for parameters (it may possibly work in some cases for components, but it will be complicated, and I wouldn't recommend it) because you aren't allowed to use the conditional parameter.

    I think you should present the original goal so that we can find a better solution.

    Added: In case was just to redeclare all of the blocks in the same way you could use a "class parameter", i.e. replaceable model M=... and use that for all of the components.

    But it seems the intent is to have them different which makes it trickier.