About Modelica Components

A component is an instantiated class. Its parameters can be overloaded.

Related Topics
About Dynamic Behavior Modeling
Working with the Component Browser

About Replaceable Components

In a replaceable component, you can redeclare:

  • an inherited class
  • a class of its sub-components

Refer to Working with Replaceable Components

Modelica Text

In Modelica, a replaceable component is declared in the following way:

class C1
replaceable MyClass M1;
end C1;

The component can be replaced either in another class that extends C1:

class C2
extends C1(redeclareMyOtherClass M1);
end C2;

or by creating a component from C1:

class C2
C1 c1comp(redeclare MyOtherClass M1);
end C2;

When replaced, M1 attributes are modified in both C1 and C2. Note that you can edit only components that have a graphical representation.

It is also possible to set constraints on which the class of the replaceable component can be replaced with:

class C3
replaceable MyClass M1 constrainedby MySpecialClass;
 
end C3;

For more information about the capabilities and attributes of replaceable and replaced components, refer to the Modelica specification.