Within Dymola you are able to propagate a model declaration to enable the model to be replaced and modified from a higher level, as it brings access to the parameter dialog box associated with the chosen model. It also allows common parameters defined in the base model to be propagated separately to ensure that any modifications to them are retained if the model is replaced.
This method uses a replaceable model declaration ‘parameter’ (in that the model declaration is similar to a parameter declaration) rather than having a replaceable definition on the component declaration. This method must be used to define the model at the base level to allow the same model declaration ‘parameter’ to be propagated up through the levels.
The example shown below is the base model of a system that requires a replaceable source of translational control, using the base class within the Modelica standard library that the sources of translational control use. Using this base class also allows an example to be shown of a common parameter within this class being propagated separately.
// REPLACEABLE MODEL 'PARAMETER' DECLARATION replaceable model flangeOutput = Modelica.Mechanics.Translational.Sources.Position constrainedby Modelica.Mechanics.Translational.Interfaces.PartialElementaryOneFlangeAndSupport2 (useSupport=useSupportExternal) "Replaceable model declaration" annotation (choices( choice=Modelica.Mechanics.Translational.Sources.Position "Position actuation dependent on input", choice=Modelica.Mechanics.Translational.Sources.Speed "Speed actuation dependent on input", choice=Modelica.Mechanics.Translational.Sources.Accelerate "Acceleration actuation dependent on input"));
// DECLARATION OF EXTERNAL COMMON PARAMETER parameter Boolean useSupportExternal=false "Boolean to control the common parameter that defines the use of the support flange" annotation (choices(checkBox=true));
// DECLARATION OF COMPONENT USED WITHIN MODEL CONSTRAINED TO MODEL 'PARAMETER' flangeOutput outputComponent "Component defined by replaceable model parameter flangeOuput" annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
The example code, which is all contained within the same model, shows that the model declaration ‘parameter’ flangeOutput defines a replaceable model that both is constrained by the base component PartialElementaryOneFlangeAndSupport2. Furthermore, this declaration constrains the common parameter useSupport, defined within PartialElementaryOneFlangeAndSupport2, to an external parameter useSupportExternal. The definitions used are the same as can be used when declaring a replaceable model, as such the example allows 3 different choices defined by the choices definition within the annotation.
The example shows that the model declaration ‘parameter’ defines what component to be used, therefore the component declaration outputComponent must use the flangeOutput ‘parameter’ as the declaration of the type of component. As flangeOutput also constrains the common parameter useSupport to useSupportExternal, there is no need to re-constrain the parameter within the component.
The image below shows the model example, which is extended from a base class. This base class contains the declarations shown above, which create the input parameters useSupportExternal and flangeOutput as shown in the parameters group of the image. The parameter flangeOutput also has the Edit control that accesses the parameter dialog box for, in this case, the position actuator that is defined by flangeOutput.
With the base class allowing the component, outputComponent, now complete the flangeOutput declaration can be propagated up through the model in the same way another parameter would; and as with a parameter the flangeOutput declaration can be used to control multiple components as long as the declaration (in this case flangeOutput) constrains the declaration on the level below.
Written by: David Briant – Project Engineer