Dymola warnings: Redeclaration requires a subtype

When a model is translated, warnings may be present in the translation log. One of the frequently occurring warnings is the Redeclaration requires a subtype warning, this post looks at how to fix this issue.

Why does this warning occur?

The Redeclaration requires a subtype warning occurs when a component is redeclared to a class that does not contain everything that is in the base class.

A simple example

A base class called SISOBaseClass is created, as in Figure 1.

Figure 1. Single Input Single Output base class
Figure 1. Single Input Single Output base class

The SISOBaseClass base class has an input u, an output y and a parameter scale. A testing template is created to test components extended from the SISOBaseClass components, see Figure 2.

Figure 2.  Template for testing components extended from SISOBaseClass
Figure 2. Template for testing components extended from SISOBaseClass

In Figure 2 sISOBlock is extended from SISOBaseClass.

A class is created that connects the input to the output, as in Figure 3.

Figure 3.  Single input and single output model where the output is equal to the input
Figure 3. Single input and single output model where the output is equal to the input

Note that this PassThrough class does not have the scale parameter that is present in the SISOBaseClass base class.

A model to test PassThrough is created by extending the template in Figure 2. and redeclaring the sISOBlock component to be the PassThrough class. The Modelica code for this testing block is in Figure 4.

Figure 4.  Modelica code for testing PassThrough class
Figure 4. Modelica code for testing PassThrough class

When the TestPathThrough model is checked by pressing F8 the following warning is generated:

Figure 5.  Check of TestPassThrough generates Redeclaration requires a subtype warning
Figure 5. Check of TestPassThrough generates Redeclaration requires a subtype warning

Why is the warning generated in this example?

In the TestPathThrough example in Figure 5. the scale parameter is not present in the redeclaration PassThrough class; however, scale is present in the SISOBaseClass base class.

What modifications are required to remove this warning?

To correct the issue all the things that are in the base class must be in redeclaration class. The best way to ensure this warning does not occur is to extend the redeclaration class from the base class. In the example above, this means that the PassThrough class, in Figure 3., should be extended from SISOBaseClass.

Written by: Garron Fish – Chief Engineer

Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion

CONTACT US

Got a question? Just fill in this form and send it to us and we'll get back to you shortly.

Sending

© Copyright 2010-2020 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?