Create and Instantiate a Submodel
You can create a submodel (a new class containing selected components, instantiated as a new component in the diagram).
-
Select the components/component that you want to include in the submodel, the following way:
- For multiple components, drag a frame around them or use Ctrl and select them.
- For a single component, click it.
The wanted components are selected. As an example, below the multiple selection of clutch1 and inertia J2.
-
Do the following:
-
For multiple components, right-click any of the selected components and select
Split Model
.
-
For a single component, right click the selected component and select
Split Model
.
A Split Model dialog box appears, the default option is for creation of a submodel ( Create and instantiate a submodel).
Note:
The dimmed options are not relevant for this task.
-
From the Name box, enter a valid Modelica name for this new class.
- To make the submodel public (visible outside the model for reuse):
- Select Public class.
- Optional:
To create the new submodel in another class than the active one, change the selection of class in the Insert in: box.
To create a class as top-level class, remove the class name. For more information about classes selection, see Using the Class Selector Field.
- Optional: Change the Component Name.
-
To remove components that should not be included in the list:
- Select the components to be removed.
- Click Remove.
-
If you do not want to automatically include connections between selected components, clear Include connections.
- If you do not want to merge external connections, clear Merge external connections.
Merging external connections means that if you create a submodel from the following selection, the submodel has one connection to the left and one to the right. If you do not merge external connections, the submodel has two connection to the left, and two to the right.
- Select OK to acknowledge the creation of the submodel and close the dialog box.
- A submodel is created. It is actually a new class of type model.
- The selected components, and all parameters required by the selected components, are moved from the initial class to the submodel. Concerning the connections, see previous step.
- The submodel is instantiated in the initial class, in the place of the selected components.
- Connections between the components in the instantiated submodel and the outside are restored. (Connectors are automatically added in the submodel.)
- If Public class has been selected, the submodel is visible and reusable outside the original class, otherwise the submodel is a protected class in the original class.
Create and Extend from a Base Class
You can create a base class containing the selected components, and extend from that class to the active model. This enables to reuse a part of the active class.
-
Select the components/component that you want to include in the base class, the following way:
- For multiple components, drag a frame around them or use Ctrl and select them.
- For a single component, click it.
The wanted components are selected. As an example, below the multiple selection of clutch1 and inertia J2.
-
Do the following:
-
For multiple components, right-click any of the selected components and select
Split Model
.
-
For a single component, right click the selected component and select
Split Model
.
A Split Model dialog box appears.
- Select Create and extend from a base class.
The dialog box now displays other possible options. Note:
The dimmed options are not relevant for this task.
-
From the Name box, enter a valid Modelica name for this new class.
- If the base class should be partial (used as a template), select Partial.
-
To create the new base class in another class than the active one, change the selection of class in the Insert in: box.
To create a class as top-level class, remove the class name. For more information about classes selection, see Using the Class Selector Field
-
To remove components that should not be included in the list:
- Select the components to be removed.
- Click Remove.
-
If you do not want to automatically include connections between selected components, clear Include connections.
- Select OK to acknowledge the creation of the base class and close the dialog box.
- A base class is created, in the package specified. The type of the class depends on the type of the selected objects.
- The selected components, and all parameters required by the selected components, are moved from the initial class to the base class. Concerning connections, see above.
- The base class is extended into the original class, by an extends clause. Looking at the original class, it looks like a previous existing base class has been extended into the active class.
- Connections between the components in the extended base class and the components of the original class are restored, if needed.
- If Partial has been selected, the extended base class is a replaceable component in the original class.
- No simplification in the diagram; the diagram is not modified.
Copy to New Model
You can copy selected objects to a new model. This enables using the selected components as a starting point for creating a new model.
-
Select the components/component that you want to include in the submodel, the following way:
- For multiple components, drag a frame around them or use Ctrl and select them.
- For a single component, click it.
The wanted components are selected. As an example, below the multiple selection of clutch1 and inertia J2.
-
Do the following:
-
For multiple components, right-click any of the selected components and select
the command Split Model
.
-
For a single component, right click the selected component and select
Split Model
.
A Split Model dialog box appears.
- Select Copy to model.
The dialog box now displays other possible options. Note:
The dimmed options are not relevant for this task.
-
From the Name box, enter a valid Modelica name for this new model.
- If the base new model should be partial (used as a template), select Partial.
-
To create the new model in another class than the active one, change the selection of class in the Insert in: box.
To create a class as top-level class, remove the class name. For more information about classes selection, see Using the Class Selector Field
- To select dynamic typing (how to treat inner/outer components), use any of the following options:
The selection is remembered between calls, and is also available as a flag Advanced.SplitModelDynamicVariant . - To keep the inner and outer components unchanged, select No Change.
This is the default selection. - To include all inner components visible from the selected subcomponents, select All Inner.
Use this option to create a model that can be run directly. - To replace any used inner components with corresponding outer ones, select Make Outer.
Use this option to create a reusable subsystem.
-
To remove components that should not be included in the list:
- Select the components to be removed.
- Click Remove.
-
If you do not want to automatically include connections between selected components, clear Include connections.
- Select OK to acknowledge the creation of the base class and close the dialog box.
- A new model is created, in the package specified.
- The selected components, and all parameters required by the selected components, are copied from the initial class to the new model. Concerning connections, see above.
|