Modelica Tutorial
Modelica Tutorial
ANSYS, Ansys Workbench, AUTODYN, CFX, FLUENT and any and all ANSYS, Inc. brand,
product, service and feature names, logos and slogans are registered trademarks or trademarks
of ANSYS, Inc. or its subsidiaries located in the United States or other countries. ICEM CFD is a
trademark used by ANSYS, Inc. under license. All other brand, product, service and feature
names or trademarks are the property of their respective owners. FLEXlm and FLEXnet are
trademarks of Flexera Software LLC.
Disclaimer Notice
ANSYS, Inc. and ANSYS Europe, Ltd. are UL registered ISO 9001: 2015 companies.
For U.S. Government users, except as specifically granted by the ANSYS, Inc. software license
agreement, the use, duplication, or disclosure by the United States Government is subject to
restrictions stated in the ANSYS, Inc. software license agreement and FAR 12.212 (for non-
DOD licenses).
Third-Party Software
See the legal information in the product help files for the complete Legal Notice for Ansys
proprietary software and third-party software. If you are unable to access the Legal Notice,
please contact ANSYS, Inc.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Table of Contents
Table of Contents Contents-1
Workflow for Creating, Compiling, and Simulating a Modelica Model in Twin Builder 2-19
Adding an Initial Equation and Variable Declaration to the PID Controller 2-23
Defining Outputs and Creating Reports for the PID Controller 2-33
Contents-1
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Setting Up and Running a Transient Analysis for the PID Controller 2-34
Defining Outputs and Creating Reports for the Heat Losses Design 3-15
Setting Up and Running a Transient Analysis for the Heat Losses Design 3-16
Declaring a Fluid Medium Variable for the Controlled Tanks Model 3-25
Defining Outputs and Creating Reports for the Controlled Tanks Design 3-35
Setting Up and Running a Transient Analysis for the Controlled Tanks Design 3-36
Placing Modelica Components for the Parallel Pump Drop Out Model 3-39
Setting Up Model Properties for the Parallel Pump Drop Out Example 3-42
Compiling and Updating the Parallel Pump Drop Out Project 3-45
Contents-2
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Adding the Parallel Pump Drop Out Component to a Twin Builder Schematic 3-48
Defining Outputs and Creating Reports for the Parallel Pump Drop Out Design 3-50
Setting Up and Running a Transient Analysis for the Parallel Pump Drop Out Design 3-51
Placing Modelica Components for the SMPM Inverter MultiPhase Model 3-56
Setting Up Model Properties for the SMPM Inverter MultiPhase Example 3-64
Adding the SMPM Inverter MultiPhase Component to a Twin Builder Schematic 3-73
Defining Outputs and Creating Reports for the SMPM Inverter MultiPhase Design 3-75
Setting Up and Running a Transient Analysis for the SMPM Inverter MultiPhase
Design 3-77
Adding an Initial Equation and Variable Declaration to the AIMC Design 3-84
Defining Outputs and Creating Reports for the AIMC Design 3-100
Setting Up and Running a Transient Analysis for the AIMC Design 3-102
Contents-3
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Placing Modelica Components for the Simple Power Train Model 3-106
Setting Up Model Properties for the Modelica Power Train Example 3-109
Adding the Simple Power Train Component to a Twin Builder Schematic 3-116
Placing and Connecting Twin Builder Components for the Simple Power Train
Design 3-117
Setting Up Properties for the Simple Power Train Twin Builder Components 3-119
Defining Outputs and Creating Reports for the Simple Power Train Design 3-121
Setting Up and Running a Transient Analysis for the Simple Power Train Design 3-124
4 - Index 127
Contents-4
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder’s simple graphical interface makes even complex models easy to design. Fast and
stable simulation algorithms reduce simulation time and provide reliable results.
The various tools used for modeling, simulating, and analyzing are integrated within the Twin
Builder application which manages the project files, sets options for both simulation and program
environment, runs analyses, and generates reports.
As a modeling language, Modelica has the following advantages for modeling engineering
systems:
l It is a very capable modeling language, which is well designed considering all physical
and signal domains. It allows user to focus on high-level mathematical descriptions of
engineering component. While deep knowledge of complex solution enabling topics, such
as differential-algebraic equations, symbolic manipulation, numeric solvers, etc., is not
required. These solver-related aspects of simulation models are handled by Modelica
compiler through complex algorithms behind the scenes.
l The language syntax supports both behavioral and structural definition of a model. For
behavioral definition, it is an equation-based language, which enables easy high-level
modeling of various engineering components (e.g. springs, resistors, clutches, etc.). And
the structural definition supports convenient connection between components, so they
can be easily combined into systems and architectures.
l It supports a wide range of modeling formalisms. It allows both causal (often used for
control system design) and acausal (often used in creating schematic oriented physical
designs) approaches within the same model. And it also supports continuous and discrete
behaviors. As a result, both physical design and control design can be done using
Modelica.
l It is designed to support effective library development and model exchange. It is built on
object-oriented constructs, with JAVA like Syntax, to facilitate reuse of models. Being an
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
open language also makes it possible to import and export Modelica models between
different tools that support the standard.
Provides an overview of the Twin Builder software package for use in designing and analyzing
complex technical systems using components, including components created using the
Modelica modeling language.
Provides an overview of the Twin Builder environment, the use of the Modelica environment
within Twin Builder to create and use Modelica components in Twin Builder designs, analyzing
designs and obtaining results, and includes an example workflow for creating, compiling, and
simulating a Modelica model in Twin Builder.
Case Studies
Uses six case study examples to provide an in-depth understanding of how to use Modelica
models in Twin Builder designs.
Table 2: Help
Help Click Help > Twin Builder Help to access the Help with index and
search capabilities available for the Twin Builder programs and
installed models.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Click Help > Twin Builder PDFs > Twin Builder Help to access the
PDF of the Twin Builder Help.
Examples Examples are available for installed Twin Builder models. Open the
example by right-clicking on the model in the Project Manager and
selecting Load Example.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
l Provide an overview of the Twin Builder user interface, Twin Builder projects and the
Project Manager window, and Twin Builder components.
l Explain basic user operations: creating a Modelica component in Twin Builder, using a
Modelica component in a Twin Builder design, analyzing designs, and plotting results.
l Provide an example workflow for creating, compiling, and simulating a Modelica model in
Twin Builder.
Project The Project Manager window shows all the components, models, and other
Manager elements of each design in the project. Each project has its own expandable
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
window and Project Tree. Many operations on the design elements can be performed directly
Project Tree from the Project Manager window.
Component Displays, on the Components tab, the component categories, including
Libraries Favorites, Most Recently Used, Simplorer Elements, and Project Components.
window The Project Components section lists the elements that are active in your
projects. It also provides a search feature on the Search tab.
Note that the Modelica libraries are not displayed in this window, because
Modelica models cannot be directly used in Twin Builder Design. Only after a
Modelica model is compiled in a project and a component is generated, will it be
displayed in this window under Project Component.
The Modelica libraries are displayed only in the Twin Builder Modelica
Environment.
Message Displays error, informational, and warning messages for the active project.
Manager
window
Progress Displays solution progress information.
window
Properties Displays the attributes of a selected object in the active model, such as the
window object’s name, electrical or other associated physical quantities, orientation, and
color.
Also displays information about a selected command that has been carried out.
For example, if a circle was drawn, its command information would include the
command’s name, the circle’s center position coordinates, and the size of its
radius.
Design area Displays one or more editor windows such as the Schematic Editor, model
window editors, and symbol editor. It also displays various report windows.
Menu bar Provides various menus that enable you to perform Twin Builder tasks, such as
managing project files, designs, and libraries; customizing desktop components;
drawing objects; and setting and modifying project parameters and options.
Ribbons Provides tabs containing icons that act as shortcuts for executing various
commands.
Status bar Shows current actions and provides instructions.
Note The screen layout may be different from what is shown in the picture above, depending
on the View menu settings.
For additional information, please refer to the help and the Twin Builder Getting Started
Guide.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Ribbons Provides a Modelica tab containing icons that act as shortcuts for Modelica
special commands.
Component Displays only the Modelica libraries, which can be used in the Modelica
Libraries Environment. Library file supported here is the Modelica package file, which is
window formatted differently than the main Twin Builder libraries.
Properties Displays Modelica model properties of a selected instance in the diagram editor.
window User can also edit property values here.
Also displays information about a selected command that has been carried out.
For example, if a circle was drawn, its command information would include the
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
command’s name, the circle’s center position coordinates, and the size of its
radius.
Design area Provide two views for a Modelica model: text, and diagram. You can switch
window between the two views using the tabs at the bottom of this window.
You will be asked whether to overwrite from diagram when switching to the text
view, or when compiling. This is because a model created or edited using the
Diagram Editor can be saved and used in the project only after the model text
has been updated.
1. Click Start, and select Programs > Ansys EM Suite version > Ansys Twin
Builder version.
By default, opening Twin Builder creates a new project named Projectn and inserts a new
design named TwinBuildern, where n is the order in which each was added to the current
session. A project is a collection of one or more designs saved in a single *.aedt file.
The new project, which appears in the Project Manager window, contains a file structure
that organizes design elements such as Ports, Analysis, Optimetrics, and Results. Project
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Definitions such as Components, Symbols, Models, Packages, Materials, and Scripts are
also listed.
The Project Manager window shows the projects loaded into Twin Builder. Each project
may consist of one or more designs. The Project Manager window contains details about
all open Twin Builder projects in a form known as the project tree, as shown below:
The top node listed in the project tree is the project name. Expand the project icon to view
all the Twin Builder design information and definitions for the project. If there are multiple
designs in a project, each design’s ports, analysis setup, and results are displayed as
entries in a separate sub-tree.
The label of the selected Project Tree element that is active (that is, has focus) may be
rendered in bold text; or a small “window” icon may display next to the selected Project
Tree element. The icon will be gray if the editor or plot window associated with the
selected element is closed, or not in focus. Clicking the gray icon will open the window and
bring it into focus.
Right-clicking a folder or item opens a shortcut menu that allows you to perform various
operations. For example, right-clicking the analysis icon for a design displays a menu
similar to this:
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Virtually all project editing and management can be done from the Project Manager
window using the right mouse button shortcut menus. Many of these menus are also
available from the main menu bar in the Twin Builder menu.
Once you insert a Twin Builder design into a project, it is listed as the second node in the
project tree. It is named TwinBuildern by default, where n is the order in which the design
was added to the project. Expand the design icon in the project tree to view all of the
specific data about the model, including its solution and post-processing information.
Ports Displays the interface and global ports added to a Twin Builder
design.
Analysis Displays the solution setups and solution options for a Twin
Builder design. A solution setup specifies how Twin Builder will
compute the solution. The solution options provide settings such
as the integration formula, iterations, and maximum and
minimum errors.
Optimetrics Displays any Optimetrics setups added to an Twin Builder
design.
Results Displays any post-processing reports generated.
Refer to The Project Manager Window in the main Twin Builder help for more information.
2. To rename the design, right-click Twin Buildern in the project tree, and choose Rename
on the shortcut menu.
3. Type a name of your choosing, and then press Enter to complete the change.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Note To use the example files provided for this Tutorial, choose File > Open Examples from
the main menu and navigate to the example *.aedt files in the Tutorial Examples folder
in "C:\Program Files\ANSYS Inc\v252\AnsysEM\Examples\Twin Builder\Modelica
Tutorial".
In Twin Builder projects, library component definitions are accessed once per component –
when you place the first instance of a component onto a schematic. Once a component is
placed, all the definitions for that component are transferred (copied) from the library to the
project file.
Editing component definitions and updating instances on a schematic are then controlled from
the project definitions, which are listed in the Definitions folder in the Project Manager window.
In other words, you edit the various definitions associated with a component in the project, not in
the library.
For a component's model definition, Twin Builder supports multiple modeling languages, as
shown below in the Add Model dialog box. Modelica is one of the supported languages. Adding
or editing a Modelica model is done using the Twin Builder Modelica Environment.
After a Modelica model is compiled, Twin Builder creates a component of the same name in the
project definitions. The component, and its associated symbol and model, are local to the
project. You can locate the component either in the project tree Definitions > Components in
the Project Manager, or in the Component Libraries window, under Project Components as
shown in the figure below. Within the project, you can drag-and-drop the Modelica component
onto the schematic of a design, where it can be connected with other Twin Builder components,
and simulated with the design.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Related Topics
To create a Modelica component in Twin Builder by importing a Modelica model .mo file:
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. In a Twin Builder project, select: Tools > Project Tools > Import Twin Builder Models.
2. Navigate to the Modelica model you want to import, and click Open.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. In the Select Model dialog box, select the check boxes to make sure the desired model’s
information is transferred into Twin Builder, then click OK.
4. Select interface and other properties for the imported Modelica model.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
5. After the Modelica model, function, or package has been successfully transferred into
Twin Builder, the following dialog box appears.
To create a Modelica component in Twin Builder using the Modelica Model diagram editor:
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
The Add Model dialog box appears. Ensure that the Modelica type is selected.
2. Enter a name for the model and click OK. The model file opens in Twin Builder's Modelica
model diagram editor in a separate Diagram tab.
Note If an editable model has been imported, you must add a new Diagram Editor by
clicking the Add Diagram Editor icon in the Modelica ribbon, or by clicking
Modelica Model Editor > Add Diagram Editor.
3. From the right side of the Diagram Editor, drag and drop the component you want on the
Diagram Editor. Press Esc to complete the action.
l To move a component after placing it, select and drag it.
l To rotate a component before placing it, press R before releasing the mouse click.
l To rotate a component after placing it, select it and press Ctrl +R, which rotates it
by 90°, or right-click the component and select the Rotate option.
Note When you rotate a block or component, the diagram editor removes wires
connected to unselected components. You must reconnect the blocks and
components.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
l To delete a component, select it and press Delete, or right-click and select Delete.
Note When you delete a block or component, the Diagram Editor removes all
connected wires.
For more information, refer to Component Libraries in the Twin Builder help.
4. After arranging the components, use wires and connectors to connect the components.
Click on the input/output pins of the component and connect them to the desired pins.
5. For Modelica models, if the component has an array interface port and you make a
connection, you can select the connection and change the default value of 1 for
ArrayIndexOfConnectionX in the Properties window.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
6. After you complete the diagram, edit the properties and parameters of the components in
the Properties window.
8. You can also declare variables or add equations by clicking the Variables and Equations
icons in Modelica ribbon.
9. To update the model file text, click Modelica Model Editor > Update Text from Diagram
or click the Update Text from Diagram icon on the Modelica ribbon. For more
information, refer to Updating Text from Diagram in the Twin Builder help.
10. Now the Modelica model is complete, it is ready to be compiled and added to the Twin
Builder project as a component. Click Compile & Update Project on the Modelica ribbon
tab.
11. A model created or edited using the Diagram Editor can be saved and used in the project
only after the model text has been updated. Thus, after clicking Compile & Update
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Project, an overwrite model text dialog will be displayed. The same dialog is also
displayed whenever you switch tabs to SimModel to view Modelica model text. You can
choose either to overwrite from the diagram, or to use the current model text and not
overwrite from the diagram. The latter choice won’t apply any change to the diagram since
the last save or compile.
12. Following the compile operation, you can select interfaces for the component, which will
be accessible in the higher-level Twin Builder design. Click Apply Changes to continue.
13. The resulting Update Components dialog box allows you to confirm whether to create
orupdate an existing Twin Builder component.
Click OK and the Modelica component is ready to use in a Twin Builder design.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
You can find the newly created Modelica component in the Project Manager's
Definitions > Components folder.
If a complete system is built inside the Modelica component, it is ready to simulate and plot
results as described in Analyzing a Design and Plotting Results.
You also have the option to implement a subsystem inside a Modelica component, then connect
the Modelica component with other Twin Builder components in a design schematic. For an
example of this workflow, refer to the case study: Simple Motor Power Train.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. To define outputs for plotting, click on Output Dialog on the Schematic tab of the ribbon.
2. Select the outputs that are needed for your plots. (Refer to Setting the Outputs for
Simulation in the Twin Builder help for more information.)
3. In the Project Manager Results context menu, you can then select from a list of report
types under Create Standard Report for the design to be simulated. The defined outputs
will be available for plotting. For details of viewing simulation results, see Generating
Reports and Postprocessing in the Twin Builder Help.
4. By default, a transient analysis TR is created for each design. You can find it in the Project
Manager under Analysis for the design. A transient analysis simulates the time-domain
response of the system. Double-click TR to set up the end time and desired time step for
the simulation. For more details of transient analysis, see Transient Analysis Setup in the
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
6. When simulation is complete, you can review reports under Results in Project Manager.
This example illustrates the workflow for creating, compiling, and simulating a Modelica model of
a simple drive train controlled by a PID controller. The Modelica system diagram is shown below.
The model consists of a causal connection (including Torque, Inertias, Spring, load Torque) and
an acausal control loop (including KinemPTP, Integrator, PI, and SpeedSensor). The two blocks
kinematic_PTP and integrator are used to generate the reference speed. To check whether
the system starts in steady state, the reference speed is zero until time = 0.5 s, and then follows
the sketched trajectory. The PI block is a PI controller in which several practical important
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
properties, such as anti-windup-compensation, have been added. The output of the controller is
a torque that drives a motor inertia, inertia1. The load inertia, inertia2 is attached using a
compliant spring/damper component. A constant external torque of 10 Nm is acting on the load
inertia.
This example is based on the following example project located in the Modelica Tutorial
Examples folder:
<Installation location>\Examples\Twin Builder\Modelica Tutorial\Tutorial Examples\Blocks_PID_
[Link]
In this example, we will create a Modelica PID P2P model, and analyze its performance in the
Twin Builder environment. The following steps outline the process for accomplishing these
goals.
l Add a new project and Modelica Model in Twin Builder.
l Place the Modelica components for the new model into the Diagram Editor.
l Connect the Modelica components.
l Provide an initial equation and variable declarations.
l Assign the various component properties.
l Compile and update the Twin Builder project.
l Add the Modelica component to the Twin Builder Schematic.
l Define outputs and Create Reports for the simulation results.
l Set up and run a Transient analysis.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. Select Modelica as the Type and enter a Name for the new model.
The Modelica environment is displayed, with the Modelica libraries appearing in the
Component Libraries window on the right.
Next, you will place the Modelica components that are needed for the new model into the
Diagram Editor.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. Drag and drop the components into Diagram Editor in the Modelica Environment,
arranging them as shown in the figure below. (Connections will be added later.)
3. You can change the instance names for the components by clicking on the component to
display its Properties window. You can enter the desired instanceName in the associated
Value field on the Properties tab
4. Press Esc to complete each action.
1. Click on an input or output pin of one of the components and connect it to the desired pin
of another component.
2. Repeat for each connection.
Note More graphic options are available in a context menu by right-clicking on a component,
as shown below. For more information on these options refer to the Diagram Editor
section in the Twin Builder help.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Next, you will add an initial equation and declare a variable for the PID Controller model.
Initial Equation
1. For the initial equation, on the Twin Builder Modelica tab, click the Equations icon to open
the Edit Model dialog box.
2. Select Initial Equation, then click the button in the upper right of the dialog to open
der(Spring.w_rel) = 0;
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. Click OK to close the dialog box, adding the equation to the Edit Model dialog box.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
4. Click OK to close the Edit Model dialog box. The Overwrite Model Text dialog
boxdisplays.
5. Click Yes, overwrite from diagram to generate the equation and add it to the model text.
Variable Declaration
1. To create a new variable for the real parameter driveAngle, on the Twin Builder Modelica
tab, click the Variables icon to open the Edit Model dialog box.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. Click the button in the upper right of the dialog to open the Edit Variable dialog box,
3. Click OK to close the dialog box, adding the variable to the Edit Model dialog box.
4. Click OK to close the Edit Model dialog box. The Overwrite Model Text dialog box
displays.
5. Click Yes, overwrite from diagram to add the variable declaration to the model text.
Next, you will set up properties for the PID Controller model.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
qdd_max = {1}
startTime = 0.5
Integrator Use the default values.
controllerType = [Link]
Ti = 0.1
yMax = 12
wp = 1
PI
k = 100
limitsAtInit = false
Ni = 0.1
initType = [Link]
Torque Modelica/Mechanics/Rotational/Sources/Torque
J=1
a(fixed = true,start = 0)
Inertia2 J=2
c = 1e4
Spring
d = 100
loadTorque tau_constant = 10
SpeedSensor Use the default values.
For example, to set properties for the KinemPTP component in the Diagram Editor:
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. On the General tab, per the information in the above table, enter {driveAngle} for the
deltaq property; {1} for the qd_max and qdd_max properties; and 0.5 for startTime.
nout remains at its default value of 1. No changes are needed on the Subcircuit tab. The
Properties tab allows you to set the name of the component instance.
1. Click Compile & Update Project on the ribbon Modelica tab as shown below.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Note This same dialog box appears when you switch to the SimModel tab to view the
Modelica model text. You can choose either to overwrite from the diagram, or to
use the current model text. The latter choice won’t apply any changes made in the
diagram since the most recent save or compile.
2. For the PID Controller example, all the editing has been completed in the diagram, so
select Yes, overwrite from diagram. The model is compiled. (This may take several
seconds.)
3. Following the compile operation, you can select interfaces for the PID or just accept the
default set of preselected interfaces.
4. When finished selecting interfaces, click Apply Changes to close the dialog box and
apply the changes to the PID Controller model. The Update Components dialog box
appears with both the PID model and component selected for import into Twin Builder.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
5. Click OK to complete the update and import the PID Controller model and component into
Twin Builder.
The Modelica PID Controller component is now ready to use in a Twin Builder design. You can
find the Modelica component in the Project Manager > Definitions > Components folder, as
shown below.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. To open the schematic editor for a design, in the Project Manager window, find the project
in which the Modelica component definition is located, then double-click the icon for an
existing design to open the schematic editor.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Note If you need to look inside or modify the Modelica model, do one of the following to
open the model again in the Modelica environment:
l In the schematic editor, right-click the Modelica component and select Edit
Model.
l In the Project Manager, find the model in Definitions > Models folder, then
right-click the model icon and select Edit Model.
Any change made in the Modelica environment will need to be compiled and
updated to the project again.
Because the entire PID controller system is built inside the Modelica component, the Twin
Builder design is now complete and ready to analyze.
Next, you will define outputs and create reports for simulation results.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. To create reports or graphical representations of simulation results, you must first define
outputs in the Output dialog to make them available for plotting. This can be done by
clicking on Output Dialog in the Schematic tab of the desktop ribbon. For this example,
the following outputs are selected as shown below:
l Case1PID1.Inertia1_a
l Case1PID1.Inertia1_b
l Case1PID1.loadTorque_phi
l Case1PID1.loadTorque_tau
l Case1PID1.PI_y
l Case1PID1.SpeedSensor_w
l Case1PID1.Spring_lossPower
l Case1PID1.KinemPTP_y_1_
Refer to Setting the Outputs for Simulation in the Twin Builder help for more information.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. In the Project Manager, you can then right-click on Results and choose Create Standard
Report to add various types of reports for the design being simulated.
The outputs you set in the Output dialog box will be available in the Report dialog boxes
for plotting. For details on the various ways for viewing simulation results, see Generating
Reports and Postprocessing in the Twin Builder help.
Next, you will set up and run a transient analysis to generate PID Controller simulation results.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Double-click on TR to set up end time and the desired time step for the simulation.
2. For this example, set End Time to 4s, Min Time Step to 100us, and keep Max Step Time
as the default 1 ms. For more details about transient analysis, see Transient Analysis
Setup in the Twin Builder help.
3. To start the simulation, run the transient analysis by doing one of the following:
l On the desktop ribbon, Schematic tab, click the Analyze icon.
l In the Project Manager, right click on TR of the design, then select Analyze.
Below are sample reports of the simulation results for the design.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3 - Case Studies
The following examples describe the use of multiple Modelica model architectures for different
levels of complexity, different modeling styles, and different behavior.
l Mechanics Example: Heat Losses
l Fluids Example: Controlled Tanks
l Thermal Example: Parallel Pump Drop Out
l Magnetic Example: SMPM Inverter MultiPhase
l Electrical Example: AIMC with Losses
l Simple Motor Power Train
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
This example is based on the following example project located in the Modelica Tutorial
Examples folder:
3. Select Modelica as the Type and enter a Name for the new model.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
The Modelica environment is displayed, with the Modelica libraries appearing in the
Component Libraries window on the right.
Next, you will place the Modelica components that are needed for the new model into the
Diagram Editor.
2. Drag and drop the components into the Diagram Editor in the Modelica Environment,
arranging them as shown in the figure below. Press Esc after placing each component to
stop the placement action. (Connections will be added later.)
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. You can change the instance names for a components by clicking on the component to
display its Properties window. You can enter the desired instanceName in the associated
Value field on the Properties tab
4. Press Esc to complete each action.
Next, you will add connections between the various Heat Losses components.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click on an input or output pin of one of the components and connect it to the desired pin
of another component.
2. Repeat for each connection.
Note More graphic options are available in a context menu by right-clicking on a component,
as shown below. For more information on these options refer to the Diagram Editor
section in the Twin Builder help.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Next, you will set up model properties for the Heat Losses example.
freqHz = 0.2
sine2 phase = 0
offset = 0
startTime = 0
const k = 20
torque
convection
fixed
TAmbient T = 25
inertia 1 J=2
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
w(start = 0)
J=2
w(fixed = true,start = 0)
inertia 5 6 J=2
d = 10
useHeatPort = true
c = 1e4
d = 20
phi_rel0 = 0
phi_nominal = 1e-4
springDamper
useHeatPort = true
phi_rel(start = 0)
w_rel(start = 0)
a_rel(start = 0)
c = 1e5
d = 100
b = 0.001
elastoBacklash phi_rel0 = 0
useHeatPort = true
phi_nominal = 1e-4
w_rel(start = 0)
tau_pos = [0, 1]
peak = 1
bearingFriction
useHeatPort = true
w_small = 1e10
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
useHeatPort = true
Unknown = 3
lossyGear
Free = 2
Forward = 1
Stuck = 0
Backward = -1
mue_pos = [0, 0.5]
peak = 1
cgeo =1
fn_max = 10
useHeatPort = true
w_small = 1e10
phi_rel(fixed = true)
w_rel(fixed = true)
mue_pos = [0, 0.5]
peak = 1
cgeo = 1
fn_max = 1
phi_nominal = 1e-4
w_small = 1e10
phi_rel(fixed = true)
w_rel(fixed = true,start = 0)
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
peak = 1
cgeo = 1
brake
fn_max = 2
w_small = 1e10
useHeatPort = true
For example, to set properties for the Spring3 component in the Diagram Editor:
2. On the General tab, per the information in the above table, enter 1e4 for the cproperty;
and 0 for phi_rel0. No changes are needed on the other tabs. The Properties tab allows
you to set the name of the component instance.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click Compile & Update Project on the ribbon Modelica tab as shown below.
Note This same dialog is also displayed whenever you switch to the SimModel tab to
view the Modelica model text. You can choose either to overwrite from the
diagram, or to use the current model text. The latter choice won’t apply any
changes made in the diagram since the most recent save or compile.
2. For Heat Losses example, all the editing has been completed in the diagram, so select
Yes, overwrite from diagram. The model is compiled. (This may take several seconds.)
3. Following the compile operation, you can select interfaces for the Heat Losses model, or
just accept the default set of preselected interfaces.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
4. When finished selecting interfaces, click Apply Changes to close the dialog and apply the
changes to the Heat Losses model. The Update Components dialog is displayed with
both the Heat Losses model and component selected for import into Twin Builder.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
5. Click OK to complete the update and import the Heat Losses model and component into
Twin Builder.
The Modelica Heat Losses component is now ready to use in a Twin Builder design. You can
find the Modelica component in the Project Manager > Definitions > Components folder, as
shown below.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. To open the schematic editor for a design, in the Project Manager window, find the project
in which the Modelica component definition is located, then double-click the icon for an
existing design to open the schematic editor.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Note If you need to look inside or modify the Modelica model, do one of the following to
open the model again in the Modelica environment:
l In the schematic editor, right-click the Modelica component and select Edit
Model.
l In the Project Manager, find the model in Definitions > Models folder, then
right-click on the model icon and select Edit Model.
Any change made in the Modelica environment will need to be compiled and
updated to the project again.
Because the entire PID controller system is built inside the Modelica component, the Twin
Builder design is now complete and ready to analyze.
Next, you will define outputs and create reports for simulation results.
Defining Outputs and Creating Reports for the Heat Losses Design
When Modelica PID Controller component is ready to use in a Twin Builder design, you can find
the component in the Project Manager > Definitions > Components folder, as shown below.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. To create reports or graphical representations of simulation results, you must first define
outputs in the Output dialog to make them available for plotting. This can be done by
clicking on Output Dialog in the Schematic tab of the desktop ribbon. Refer to Setting
the Outputs for Simulation in the Twin Builder help for more information.
2. In the Project Manager, you can then right-click on Results and choose Create Standard
Report to add various types of reports for the design being simulated.
The outputs you set in the Output dialog box will be available in the Report dialog boxes
for plotting. For details on the various ways for viewing simulation results, see Generating
Reports and Postprocessing in the Twin Builder help.
Next, you will set up and run a transient analysis to generate PID Controller simulation results.
Setting Up and Running a Transient Analysis for the Heat Losses Design
In this example, we would like to simulate the time-domain response of the Heat Losses system.
This requires that a transient analysis needs to be performed on the design. By default, a
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
transient analysis, TR, is created for the design. You can find it in the Project Manager under
Analysis of the design.
1. Double-click on TR to set up end time and the desired time step for the simulation.
2. For this example, set End Time to 1s, Min Time Step to 10us, and keep Max Step Time
as the default 1 ms. For more details about transient analysis, please refer to Transient
Analysis Setup in the Twin Builder help.
3. To start the simulation, run the transient analysis by doing one of the following:
l On the desktop ribbon, Schematic tab, click the Analyze icon.
l In the Project Manager, right click on TR of the design, then select Analyze.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
In this case, the two tanks are filled and emptied by following scheme:
3. After a waiting time, valve 2 is opened and the fluid flows from tank 1 into tank 2.
5. After a waiting time, valve 3 is opened and the fluid flows out of tank 2.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
l Button “stop” stops the above process by closing all valves. Then, the controller waits for
further input (either "start" or "shut" operation).
l 3)Button “shut” is used to shut down the process, by emptying at once both tanks by
opening valve 2 and valve 3. When this is achieved, the process goes back to its start
configuration where all 3 valves are closed. Clicking on "start", restarts the process.
This example is based on the following example project located in the Modelica Tutorial
Examples folder:
<Installation location>\Examples\Twin Builder\Modelica Tutorial\Tutorial Examples\[Link]
In this example, we will create a Modelica controlled tanks model and analyze its performance in
Twin Builder environment. The following steps outline the process for accomplishing these
goals.
l Add a new project and Modelica Model in Twin Builder.
l Place the Modelica components for the Controlled Tanks model into the Diagram Editor.
l Connect the Modelica Controlled Tanks components.
l Declare a fluid medium for the Controlled Tanks model.
l Assign the various component properties.
l Compile and update the Twin Builder project.
l Add the Modelica component to the Twin Builder Schematic.
l Define outputs and Create Reports for the Controlled Tanks simulation results.
l Set up and run a Transient analysis for the Controlled Tanks design.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. Select Modelica as the Type and enter a Name for the new model.
The Modelica environment is displayed, with the Modelica libraries appearing in the
Component Libraries window on the right.
Next, you will place the Modelica components that are needed for the new model into the
Diagram Editor.
Component
Location in Library
Instance
source Modelica/Fluid/Sources/Boundary_pT
tank1, tank2 Modelica/Fluid/Vessels/OpenTank
valve1, valve2,
Modelica/Fluid/Valve/ValveDiscrete
valve3
tankController Modelica/Fluid/Examples/ControlledTankSystem/Utilities/TankController
ambient1 Modelica/Fluid/Sources/Boundary_pT
system Modelica/Fluid/System
start Modelica/Fluid/Examples/ControlledTankSystem/Utilities/RadioButton
stop Modelica/Fluid/Examples/ControlledTankSystem/Utilities/RadioButton
shut Modelica/Fluid/Examples/ControlledTankSystem/Utilities/RadioButton
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Component
Location in Library
Instance
level1, level2 Modelica/Blocks/Sources/RealExpression
2. Drag and drop the components into the Diagram Editor in the Modelica Environment,
arranging them as shown in the figure below. Press Esc after placing each component to
stop the placement action. Connections will be added later.
3. You can change the instance names for a components by clicking on the component to
display its Properties window. You can enter the desired instanceName in the associated
Value field on the Properties tab.
4. Press Esc to complete each action.
Next, you will add connections between the various Controlled Tanks components.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click on an input or output pin of one of the components and connect it to the desired pin
of another component.
2. Repeat for each connection.
3. An additional step is required to set the vector port indexes for tank1 and tank2.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
The above valve-to-tank settings generate the following lines in the Modelica model
text code:
connect(valve1.port_b, [Link][1]);
connect(valve2.port_a, [Link][2]);
connect(valve2.port_b, [Link][1]);
connect(valve3.port_a, [Link][2]);
Note More graphic options are available in a context menu by right-clicking on a component,
as shown below. For more information on these options refer to the Diagram Editor
section in the Twin Builder help.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Next, you will add a declaration of a fluid medium variable for the model.
For the Controlled Tanks example, the medium is water. Seven models in the example have a
Medium property.
1. To declare the Medium to be water, select any one of the Controlled Tanks models that
have the Medium property, for example, valve1.
2. In the Properties dialog box General tab, select Create Variable from the dropdown list
in the Value column.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. Click the [...] button for the Value field and select ConstantPropertyLiquidWater in the
Modelica > Media > Water library. Select package in the Type drop-down menu.
4. Click OK. The declaration of package Medium is created in Modelica model text:
//Declaration(s)
package Medium =
[Link]( );
Now that Medium is defined, it is available for selection in the remaining six models in the
Controlled Tanks model that have the Medium property by choosing Select Variable,
then choosing Medium in the Select Variable dialog box.
5. To change the fluid medium in the system, click Modelica > Variables on the ribbon. The
Edit Model dialog box appears.
6. Click Model > Variable in the directory tree. Select the declared Medium value and edit
as desired.
Next, you will set up properties for the Controlled Tanks model.
source nPorts = 1
crossArea = 6
level_start = 0.05
Medium = Medium
nPorts = 2
tank 1 Re_turbulent = 100.000000
portsData = {[Link]
(diameter=0.2, height=4, zeta_out=0, zeta_
in=1),[Link]
(diameter=0.2, height=0, zeta_out=0, zeta_in=1)}
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
crossArea = 6
level_start = 0.05
Medium = Medium
nPorts = 2
tank 2 Re_turbulent = 100.000000
portsData = {[Link]
(diameter=0.2, height=5, zeta_out=0, zeta_
in=1),[Link]
(diameter=0.2, height=0, zeta_out=0,zeta_in=1)}
valve 1 m_flow_nominal = 40
Medium = Medium
dp_noninal = 1
Medium = Medium
dp_noninal = 1
valve 3 m_flow_nominal = 10
Medium = Medium
maxLevel = 0.9*4
waitTime = 50
nPorts = 1
ambient1
Medium = Medium
system energyDynamics = [Link]
button Time Table = {20, 280}
start
reset = {[Link], [Link]}
stop button Time Table = {220, 650}
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
To display the editable parameters and properties of a component, click the model to open its
Properties dialog box.
For example, to set properties for the valve1 component in the Diagram Editor:
2. Click the General tab. Using the information in the above table, enter 1e5 for the dp_
nominalproperty and 40 for m_flow_nominal. To edit the Medium property, choose
Select Variable from the drop-down list. The Select Variable dialog opens. Select
Medium for the Medium property. No changes are needed on the other tabs. Note that
you can set the name of the component instance in the Properties tab allows.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click Compile & Update Project on the ribbon Modelica tab as shown below.
Note This same dialog box appears when you switch to the SimModel tab to view the
Modelica model text. You can choose either to overwrite from the diagram, or to
use the current model text. The latter choice won’t apply any changes made in the
diagram since the most recent save or compile.
2. For the Controlled Tanks example, all the editing has been completed in the diagram, so
select Yes, overwrite from diagram. The model is compiled. This may take several
seconds.
3. Following the compile operation, you can select interfaces for the Controlled Tanks model.
Make sure to select outputs that need to be plotted and parameters that need external
input. In this example, you should at least select start->on, tank1->level, and tank2-
>level, in order to generate simulation reports as demonstrated later in this tutorial..
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
4. When finished selecting interfaces, click Apply Changes to close the dialog and apply the
changes to the Controlled Tanks model. The Update Components dialog is displayed
with both the Controlled Tanks model and component selected for import into Twin
Builder.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
5. Click OK to complete the update and import the Controlled Tanks model and component
into Twin Builder.
The Modelica Heat Losses component is now ready to use in a Twin Builder design. You can
find the Modelica component in the Project Manager > Definitions > Components folder, as
shown below.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. To open the schematic editor for a design, in the Project Manager window, find the project
in which the Modelica component definition is located, then double-click the icon for an
existing design to open the schematic editor.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Note If you need to look inside or modify the Modelica model, do one of the following to
open the model again in the Modelica environment:
l In the schematic editor, right-click the Modelica component and select Edit
Model.
l In the Project Manager, find the model in Definitions > Models folder, then
right-click on the model icon and select Edit Model.
Any change made in the Modelica environment will need to be compiled and
updated to the project again.
Because the entire Controlled Tanks system is built inside the Modelica component, the
Twin Builder design is now complete and ready to analyze.
Next, you will define outputs and create reports for simulation results.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Defining Outputs and Creating Reports for the Controlled Tanks Design
When the Modelica Controlled Tanks component is ready to use in a Twin Builder design, you
can find the component in the Project Manager > Definitions > Components folder.
1. To create reports or graphical representations of simulation results, you must first define
outputs in the Output dialog to make them available for plotting. This can be done by
clicking on Output Dialog in the Schematic tab of the desktop ribbon. For this example,
three outputs are selected, ControlledTanks1.start_on, ControlledTanks1.tank1_
level, and ControlledTanks1.tank2_level as shown below. Refer to Setting the Outputs
for Simulation in the Twin Builder help for more information.
If a quantity of interest inside the Modelica model is not available to select as output, go
back to Compiling and Updating the Controlled Tanks Project and check if the
quantity is selected as an interface when the Modelica model is compiled.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. In the Project Manager, you can then right-click on Results and choose Create Standard
Report to add various types of reports for the design being simulated.
The outputs you set in the Output dialog will be available in the Report dialogs for plotting.
For details on the various ways for viewing simulation results, see Generating Reports
and Postprocessing in the Twin Builder help.
Next, you will set up and run a transient analysis to generate Controlled Tanks simulation
results.
1. Double-click on TR to set up end time and the desired time step for the simulation.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. For this example, set End Time to 900s, Min Time Step to 100us, and Max Time Step to
10 ms. For more details about transient analysis, see Transient Analysis Setup in the Twin
Builder help.
3. To start the simulation, run the transient analysis by doing one of the following:
l On the desktop ribbon, Schematic tab, click the Analyze icon.
l In the Project Manager, right click on TR of the design, then select Analyze.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
The coolant flow is taken from an ambient source, and is driven by a pump with prescribed
constant flow rate. The coolant flow is then split into two flows connected to the two heat
sources, and afterwords merged. The pump is set up to run for 0.2s; then is shut down (using a
ramp of 0.2s) for 0.2s; then started again (using a ramp of 0.2s).
This example is based on the following example project located in the Modelica Tutorial
Examples folder:
<Installation location>\Examples\Twin Builder\Modelica Tutorial\Tutorial
Examples\[Link]
In this example, we will create a Modelica parallel pump drop out model and analyze its
performance in the Twin Builder environment. The following steps outline the process for
accomplishing these goals.
l Add a new project and Modelica Model in Twin Builder.
l Place the Modelica components for the Parallel Pump Drop Out model into the Diagram
Editor.
l Connect the Modelica Controlled Tanks components.
l Assign the various component properties.
l Compile and update the Twin Builder project.
l Add the Modelica component to the Twin Builder Schematic.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
l Define outputs and Create Reports for the Controlled Tanks simulation results.
l Set up and run a Transient analysis for the Controlled Tanks design.
3. Select Modelica as the Type and enter a Name for the new model.
The Modelica environment is displayed, with the Modelica libraries appearing in the
Component Libraries window on the right.
Next, you will place the Modelica components that are needed for the new model into the
Diagram Editor.
Placing Modelica Components for the Parallel Pump Drop Out Model
All of the required components for the Controlled Tanks example can be found in the Modelica
library in the locations shown in the following table.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. Drag and drop the components into the Diagram Editor in the Modelica Environment,
arranging them as shown in the figure below. Press Esc after placing each component to
stop the placement action. Connections will be added later.
3. You can change the instance names for a components by clicking on the component to
display its Properties window. You can enter the desired instanceName in the associated
Value field on the Properties tab
4. Press Esc to complete each action.
Next, you will add connections between the various Parallel Pump Drop Out components.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click on an input or output pin of one of the components and connect it to the desired pin
of another component.
2. Repeat for each connection.
Note More graphic options are available in a context menu by right-clicking on a component,
as shown below. For more information on these options refer to the Diagram Editor
section in the Twin Builder help.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Next, you will set up model properties for the Parallel Pump Drop Out example.
Setting Up Model Properties for the Parallel Pump Drop Out Example
The model properties for the components used in this example are summarized in the following
table.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
constantVolumeFlow = 1
m=0
pump
T0 = 293.15
T0fixed = false
tapT = 1
h_g = 0
m = 0.1
T0 = 293.15
T0fixed = true
pipe1
V_flowLaminar = 0.1
dpLaminar = 0.1
V_flowNominal = 1
dpNominal = 1
h_g = 0
m = 0.1
T0 = 293.15
T0fixed = true
pipe2
V_flowLaminar = 0.1
dpLaminar = 0.1
V_flowNominal = 1
dpNominal = 1
pipe3 h_g = 0
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
T0 = 293.15
T0fixed = true
V_flowLaminar = 0.1
dpLaminar = 0.1
V_flowNominal = 1
dpNominal = 1
For example, to set properties for the Spring3 component in the Diagram Editor:
2. On the General tab, per the information in the above table, select true for the
useVolumeFlowInput property; 1 for constantVolumeFlow, 0 for m, 293.15 for T0,
false for T0fixed, and 1 for tapT. No changes are needed on the other tabs. The
Properties tab allows you to set the name of the component instance.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click Compile & Update Project on the ribbon Modelica tab as shown below.
Note This same dialog box appears when you switch to the SimModel tab to view the
Modelica model text. You can choose either to overwrite from the diagram, or to
use the current model text. The latter choice won’t apply any changes made in the
diagram since the most recent save or compile.
2. For Parallel Pump Drop Out example, all the editing has been completed in the diagram,
so select Yes, overwrite from diagram. The model is compiled. This may take several
seconds.
3. Following the compile operation, you can select interfaces for the Parallel Pump Drop Out
model, or just accept the default set of preselected interfaces.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
4. When finished selecting interfaces, click Apply Changes to close the dialog and apply the
changes to the Parallel Pump Drop Out model. The Update Components dialog box
appears with both the Parallel Pump Drop Out model and component selected for import
into Twin Builder.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
5. Click OK to complete the update and import the Parallel Pump Drop Out model and
component into Twin Builder.
The Modelica Parallel Pump Drop Out component is now ready to use in a Twin Builder design.
You can find the Modelica component in the Project Manager > Definitions > Components
folder, as shown below.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. To open the schematic editor for a design, in the Project Manager window, find the project
in which the Modelica component definition is located, then double-click the icon for an
existing design to open the schematic editor.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Note If you need to look inside or modify the Modelica model, do one of the following to
open the model again in the Modelica environment:
l In the schematic editor, right-click the Modelica component and select Edit
Model.
l In the Project Manager, find the model in Definitions > Models folder, then
right-click on the model icon and select Edit Model.
Any change made in the Modelica environment will need to be compiled and
updated to the project again.
Because the entire PID controller system is built inside the Modelica component, the Twin
Builder design is now complete and ready to analyze.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Next, you will define outputs and create reports for simulation results.
Defining Outputs and Creating Reports for the Parallel Pump Drop Out
Design
When Modelica Parallel Pump drop Out component is ready to use in a Twin Builder design, you
can find the component in the Project Manager > Definitions > Components folder, as shown
below.
1. To create reports or graphical representations of simulation results, you must first define
outputs in the Output dialog to make them available for plotting. This can be done by
clicking on Output Dialog in the Schematic tab of the desktop ribbon. For this example,
three outputs are selected, ParallelPumpDropOut1.pipe1_T,
ParallelPumpDropOut1.pipe1_T, and ParallelPumpDropOut1.pipe3_T, as shown
below. Refer to Setting the Outputs for Simulation in the Twin Builder help for more
information.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. In the Project Manager, you can then right-click on Results and choose Create Standard
Report to add various types of reports for the design being simulated.
The outputs you set in the Output dialog box will be available in the Report dialog boxes
for plotting. For details on the various ways for viewing simulation results, see Generating
Reports and Postprocessing in the Twin Builder help.
Next, you will set up and run a transient analysis to generate parallel pump drop out simulation
results.
Setting Up and Running a Transient Analysis for the Parallel Pump Drop
Out Design
In this example, we would like to simulate the time-domain response of the Parallel Pump Drop
Out system. This requires that a transient analysis needs to be performed on the design. By
default, a transient analysis, TR, is created for the design. You can find it in the Project
Manager under Analysis of the design.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Double-click on TR to set up end time and the desired time step for the simulation.
2. For this example, set End Time to 2s, Min Time Step to 10us, and keep Max Time Step
as the default 1 ms. For more details about transient analysis, please refer to Transient
Analysis Setup in the Twin Builder help.
3. To start the simulation, run the transient analysis by doing one of the following:
l On the desktop ribbon, Schematic tab, click the Analyze icon.
l In the Project Manager, right click on TR of the design, then select Analyze.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
For this example, two equivalent permanent magnet synchronous induction motors with different
numbers of phases are modeled and compared, and their equal behavior is demonstrated. An
ideal frequency inverter is modeled using VfController and SignalVoltage. Frequency is then
raised by a ramp function, causing the permanent magnet synchronous induction motors to
start, and accelerate their respective load inertias. A load torque is applied to each motor at time
tStep.
This example is based on the following example project located in the Modelica Tutorial
Examples folder:
<Installation location>\Examples\Twin Builder\Modelica Tutorial\Tutorial Examples\SMPM_Inverter_
[Link]
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
In this example, we will create a Modelica SMPM Inverter MultiPhase model and analyze its
performance in the Twin Builder environment. The following steps outline the process for
accomplishing these goals.
l Add a new project and Modelica Model in Twin Builder.
l Place the Modelica components for the SMPM Inverter MultiPhase model into the
Diagram Editor.
l Connect the Modelica SMPM Inverter MultiPhase components.
l Provide an initial equation and variable declarations.
l Assign the various component properties.
l Compile and update the Twin Builder project.
l Add the Modelica component to the Twin Builder Schematic.
l Define outputs and Create Reports for the SMPM Inverter MultiPhase simulation results.
l Set up and run a Transient analysis for the SMPM Inverter MultiPhase design.
3. Select Modelica as the Type and enter a Name for the new model.
The Modelica environment is displayed, with the Modelica libraries appearing in the
Component Libraries window on the right.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Next, you will place the Modelica components that are needed for the new model into the
Diagram Editor.
Component
Location in Library
Instance
smpmM and
Modelica/Magnetic/FundamentalWave/BasicMachines/SynchronousInducti
smpm3
onMachines/SM_PermanentMagnet
terminalBoxM
and Modelica/Electrical/Machines/Utilities/TerminalBox
terminalBox3
loadInertiaM
Modelica/Mechanics/Rotational/Components/Inertia
and loadInertia3
torqueStepM
and Modelica/Mechanics/Rotational/Sources/TorqueStep
torqueStep3
rotorAngle3 Modelica/Electrical/Machines/Sensors/RotorDisplacementAngle
Modelica/Electrical/Machines/Utilities/ParameterRecords/SM_
smpmData
PermanentMagnetData
currentRMSens
orM and
Modelica/Electrical/Machines/Sensors/CurrentQuasiRMSSensor
currentRMSens
or3
feedback Modelica/Blocks/Math/Feedback
gain Modelica/Blocks/Math/Gain
vfController and
Modelica/Electrical/Machines/Utilities/VfController
vfController3
signalVoltageM
and Modelica/Electrical/MultiPhase/Sources/SignalVoltage
signalVoltage3
ramp Modelica/Blocks/Sources/Ramp
starM and star3 Modelica/Electrical/MultiPhase/Basic/Star
groundM and
Modelica/Electrical/Analog/Basic/Ground
ground3
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. Drag and drop the components into the Diagram Editor in the Modelica Environment,
arranging them as shown in the figure below. Press Esc after placing each component to
stop the placement action. (Connections will be added later.)
3. You can change the instance names for a components by clicking on the component to
display its Properties window. You can enter the desired instanceName in the associated
Value field on the Properties tab
4. Press Esc to complete each action.
Next, you will add connections between the various SMPM Inverter MultiPhase components.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click on an input or output pin of one of the components and connect it to the desired pin
of another component.
2. Repeat for each connection.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
b. Similarly, \fFor the connection between vfController and signalVoltageM, click the
connecting wire between the components, then in the Properties window, delete the
default numbers for ArrayIndexOfConnection1 and ArrayIndexOfConnection2
and leave them empty.
The above valve-to-tank settings generate the following lines in the Modelica model
text code:
connect(vfController3.y, signalVoltage3.v);
connect(vfController.y, signalVoltageM.v);
Note More graphic options are available in a context menu by right-clicking on a component,
as shown below. For more information on these options refer to the Diagram Editor
section in the Twin Builder help.
Next, you will add an initial equation and declare a variable for the SMPM Inverter MultiPhase
model.
Initial Equation
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. For the initial equation, on the Twin Builder Modelica tab, click the Equations icon to open
the Edit Model dialog box.
2. Select Initial Equation, then click the button in the upper right of the dialog to open
[Link][1:2] = zeros(2);
[Link][1:2] = zeros(2);
3. Click OK to close the dialog box, adding the equation to the Edit Model dialog box.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
4. Click OK to close the Edit Model dialog box. The Overwrite Model Text dialog box
appears.
5. Click Yes, overwrite from diagram to generate the equation and add it to the model text.
Variable Declarations
1. To create the needed variables for this design, on the Twin Builder Modelica tab, click the
Variables icon to open the Edit Model dialog box.
2. Click the button in the upper right of the dialog box to open the Edit Variable dialog
box, and enter the settings such as for the integer parameter m3=3 shown below. (The
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. Click OK to close the dialog box, adding the variable to the Edit Model dialog box.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
5. Click OK to close the Edit Model dialog box. The Overwrite Model Text dialog box
appears.
6. Click Yes, overwrite from diagram to add the variable declarations to the model text.
Next, you will set up properties for the SMPM Inverter MultiPhase model.
Component
Properties
Instance
m=m
Jr = [Link]
p = smpmData.p
fsNominal = [Link]
VsOpenCircuit = [Link]
TsOperational = 20
smpmM TrOperational = 20
Rs = [Link]*m/3
TsRef = [Link]
alpha20s = smpmData.alpha20s
Lssigma = [Link]*m/3
Lszero = [Link]*m/3
Lmd = [Link]*m/3
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Component
Properties
Instance
Lmq = [Link]*m/3
useDamperCage = [Link]
Lrsigmad = [Link]
Lrsigmaq = [Link]
Rrd = [Link]
Rrq = [Link]
TrRef = [Link]
alpha20r = smpmData.alpha20r
frictionParameters = [Link]
statorCoreParameters = [Link]
strayLoadParameters = [Link]
permanentMagnetLossParameters =
[Link]
Jr = [Link]
p = smpmData.p
fsNominal = [Link]
VsOpenCircuit = [Link]
TsOperational = 20
Smpm3
TrOperational = 20
Rs = [Link]
TsRef = [Link]
alpha20s = smpmData.alpha20s
Lssigma = [Link]
Lszero = [Link]
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Component
Properties
Instance
Lmd = [Link]
Lmq = [Link]
useDamperCage = [Link]
Lrsigmad = [Link]
Lrsigmaq = [Link]
Rrd = [Link]
Rrq = [Link]
TrRef = [Link]
alpha20r = smpmData.alpha20r
frictionParameters = [Link]
statorCoreParameters = [Link]
strayLoadParameters = [Link]
permanentMagnetLossParameters =
[Link]
torqueStepM offsetTorque = 0
startTime = tStep
stepTorque = -T_Load
torqueStepM offsetTorque = 0
startTime = tStep
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Component
Properties
Instance
rotorAngle3 p = smpm3.p
smpmData Use defaults
currentRMSensorM m = m
currentRMSensor3 m = m3
feedback Use defaults
gain k = (m/m3)
m=m
orientation = -
vfController [Link](m)
VNominal = VsNominal
orientation = -
vfController3 [Link](m3)
VNominal = VsNominal
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
b. On the General tab, per the information in the above table, enter m for the m
property; VsNominal for VNominal, fsNominal for fNominal,
[Link](m) for
orientation, and +[Link]/2 for BasePhase. No other changes are
needed. The Properties tab allows you to set the name of the component instance.
This example requires modification of variables ir, phiMechanical and wMechanical for the
machines smpmM and smpm3. This cannot be done directly in the Properties window, but
instead requires that modifiers be added.
1. To add modifiers to smpmM, select the smpmM instance in diagram editor and on the
ribbon Modelica tab click Add Modifier (or right click on the smpmM instance and select
Add Modifier from the context menu). In the Add Modifier dialog box, add the following 3
lines:
ir(fixed=true)
wMechanical(fixed = true)
phiMechanical(fixed = true)
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click Compile & Update Project on the ribbon Modelica tab as shown below.
Note This same dialog box appears when you switch to the SimModel tab to view the
Modelica model text. You can choose either to overwrite from the diagram, or to
use the current model text. The latter choice won’t apply any changes made in the
diagram since the most recent save or compile.
2. For SMPM Inverter MultiPhase example, all the editing has been completed in the
diagram, so select Yes, overwrite from diagram. The model is compiled. This may take
several seconds.
3. Following the compile operation, you can select interfaces for the SMPM Inverter
MultiPhase model, or just accept the default set of preselected interfaces.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
4. When finished selecting interfaces, click Apply Changes to close the dialog box and
apply the changes to the SMPM Inverter MultiPhase model. The Update Components
dialog box is displayed with both the SMPM Inverter MultiPhase model and component
selected for import into Twin Builder.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
5. Click OK to complete the update and import the SMPM Inverter MultiPhase model and
component into Twin Builder.
The Modelica SMPM Inverter MultiPhase component is now ready to use in a Twin Builder
design. You can find the Modelica component in the Project
Manager > Definitions > Components folder, as shown below.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. To open the schematic editor for a design, in the Project Manager window, find the project
in which the Modelica component definition is located, then double-click the icon for an
existing design to open the schematic editor.
Note If you need to look inside or modify the Modelica model, do one of the following to
open the model again in the Modelica environment:
l In the schematic editor, right-click the Modelica component and select Edit
Model.
l In the Project Manager, find the model in Definitions > Models folder, then
right-click on the model icon and select Edit Model.
Any change made in the Modelica environment will need to be compiled and
updated to the project again.
Because the entireSMPM Inverter MultiPhase system is built inside the Modelica
component, the Twin Builder design is now complete and ready to analyze.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Next, you will define outputs and create reports for simulation results.
Defining Outputs and Creating Reports for the SMPM Inverter MultiPhase
Design
When Modelica SMPM Inverter MultiPhase component is ready to use in a Twin Builder design,
you can find the component in the Project Manager > Definitions > Components folder, as
shown below.
1. To create reports or graphical representations of simulation results, you must first define
outputs in the Output dialog box to make them available for plotting. This can be done by
clicking on Output Dialog in the Schematic tab of the desktop ribbon. For this example,
the following outputs are selected as shown below:
l SMPM_Inverter_MultiPhase1.currentRMSensor3_CurrentSensor1_
currentSensor_1_i
l SMPM_Inverter_MultiPhase1.currentRMSensor3_CurrentSensor1_
currentSensor_2_i
l SMPM_Inverter_MultiPhase1.currentRMSensor3_CurrentSensor1_
currentSensor_3_i
l SMPM_Inverter_MultiPhase1.currentRMSensorM_CurrentSensor1_
currentSensor_1_i
l SMPM_Inverter_MultiPhase1.currentRMSensorM_CurrentSensor1_
currentSensor_2_i
l SMPM_Inverter_MultiPhase1.currentRMSensorM_CurrentSensor1_
currentSensor_3_i
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
l SMPM_Inverter_MultiPhase1.currentRMSensorM_CurrentSensor1_
currentSensor_4_i
l SMPM_Inverter_MultiPhase1.currentRMSensorM_CurrentSensor1_
currentSensor_5_i
See Setting the Outputs for Simulation in the Twin Builder help for more information.
2. In the Project Manager, you can then right-click on Results and choose Create Standard
Report to add various types of reports for the design being simulated.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
The outputs you set in the Output dialog box will be available in the Report dialog boxes
for plotting. For details on the various ways for viewing simulation results, see Generating
Reports and Postprocessing in the Twin Builder help.
Next, you will set up and run a transient analysis to generate SMPM Inverter MultiPhase
simulation results.
1. Double-click on TR to set up end time and the desired time step for the simulation.
2. For this example, set End Time to 1.5 s, Min Time Step to 10 us, and keep Max Time
Step as the default 1 ms. For more details about transient analysis, see Transient
Analysis Setup in the Twin Builder help.
3. To start the simulation, run the transient analysis by doing one of the following:
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Below are sample reports of the simulation results for both 3-phase and 5-phase currents.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Machine parameters are those for a standard 18.5 kW, 400 V, 50 Hz motor. For the first 5
seconds of simulation time, the machine is started at a nominal speed and flux is built up in the
machine. Then, for the next 5 seconds, a load ramp is applied.
This example is based on the following example project located in the Modelica Tutorial
Examples folder:
<Installation location>\Examples\Twin Builder\Modelica Tutorial\Tutorial Examples\[Link]
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
In this example, we will create a Modelica AIMC (asynchronous squirrel cage induction machine
with losses) model and analyze its performance in the Twin Builder environment. The following
steps outline the process for accomplishing these goals.
l Add a new project and Modelica Model in Twin Builder.
l Place the Modelica components for the AIMC model into the Diagram Editor.
l Connect the Modelica AIMC components.
l Provide initial equations and variable declarations.
l Assign the various component properties.
l Compile and update the Twin Builder project.
l Add the Modelica component to the Twin Builder Schematic.
l Define outputs and Create Reports for the AIMC simulation results.
l Set up and run a Transient analysis for the AIMC design.
3. Select Modelica as the Type and enter a Name for the new model.
The Modelica environment is displayed, with the Modelica libraries appearing in the
Component Libraries window on the right.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Next, you will place the Modelica components that are needed for the new model into the
Diagram Editor.
Component
Location in Library
Instance
terminalBox Modelica/Electrical/Machines/Utilities/TerminalBox
aimc Modelica/Electrical/Machines/BasicMachines/AsynchronousInduction
Machines/AIM_SquirrelCage
powerSensor Modelica/Mechanics/Rotational/Sensors/PowerSensor
loadInertia Modelica/Mechanics/Rotational/Components/Inertia
torque Modelica/Mechanics/Rotational/Sources/Torque
Modelica/Electrical/Machines/Utilities/ParameterRecords/AIM_
aimcData
SquirrelCageData
combiTable1Ds Modelica/Blocks/Tables/CombiTable1Ds
ramp Modelica/Blocks/Sources/Ramp
feedback Modelica/Blocks/Math/Feedback
PI Modelica/Blocks/Continuous/PI
gain Modelica/Blocks/Math/Gain
star [Link]/MultiPhase/Basic/Star
ground Modelica/Electrical/Analog/Basic/Ground
sineVoltage Modelica/Electrical/MultiPhase/Sources/SineVoltage
currentQuasiRMSSe
Modelica/Electrical/Machines/Sensors/CurrentQuasiRMSSensor
nsor
electricalPowerSens
Modelica/Electrical/Machines/Sensors/ElectricalPowerSensor
or
2. Drag and drop the components into the Diagram Editor in the Modelica Environment,
arranging them as shown in the figure below. Press Esc after placing each component to
stop the placement action. Connections will be added later.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. You can change the instance names for a components by clicking on the component to
display its Properties window. You can enter the desired instanceName in the associated
Value field on the Properties tab
4. Press Esc to complete each action.
Next, you will add connections between the various AIMC components.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click on an input or output pin of one of the components and connect it to the desired pin
of another component.
2. Repeat for each connection.
Note More graphic options are available in a context menu by right-clicking on a component,
as shown below. For more information on these options refer to the Diagram Editor
section in the Twin Builder help.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Next, you will add an initial equation and declare a variable for the AIMC design.
Initial Equation
1. For the initial equations, on the Twin Builder Modelica tab, click the Equations icon to
open the Edit Model dialog box.
2. Select Initial Equation, then click the button in the upper right of the dialog box to
aimc.i_0_s = 0;
der(aimc.idq_sr) = zeros(2);
der(aimc.idq_rr) = zeros(2);
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. Click OK to close the dialog box, adding the equation to the Edit Model dialog box.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
5. Click OK to close the Edit Model dialog box. The Overwrite Model Text dialog box
appears.
6. Click Yes, overwrite from diagram to generate the equation and add it to the model text.
Variable Declarations
1. To create the needed variables for this design, on the Twin Builder Modelica tab, click the
Variables icon to open the Edit Model dialog box.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. Click the button in the upper right of the dialog to open the Edit Variable dialog box,
and enter the settings such as for the integer parameter m3=3 shown below. The Prefix,
Connector, and Causality settings remain the defaults as shown.
3. Click OK to close the dialog box, adding the variable to the Edit Model dialog box.
Array
Variable Variabili Typ
Value dimensi
Name ty e
on
paramet
m 3 real
er
paramet
PNominal 18500 real
er
paramet
VNominal 400 real
er
paramet
INominal 32.85 real
er
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Array
Variable Variabili Typ
Value dimensi
Name ty e
on
paramet
pfNominal 0.898 real
er
paramet
fNominal 50 real
er
[Link].from_rpm paramet
wNominal real
(1462.5) er
paramet
TNominal PNominal/wNominal real
er
TempNomi paramet
[Link].from_degC(90) real
nal er
{1E-
paramet
Ptable 6,1845,3549,5325,7521,9372,11010,12930, real :
er
14950,16360,18500,18560,20180,22170}
{11.0,11.20,12.27,13.87,16.41,18.78,21.07,23. paramet
Itable real :
92, 27.05,29.40,32.85,32.95,35.92,39.35} er
{1500,1496,1493,1490,1486,1482,1479,1475, paramet
ntable real :
1471, 1467,1462,1462,1458,1453} er
{0.085,0.327,0.506,0.636,0.741,0.797,0.831,0. paramet
ctable real :
857, 0.875,0.887,0.896,0.896,0.902,0.906} er
{0,0.7250,0.8268,0.8698,0.8929,0.9028,0.906
paramet
etable 4,0.9088, real :
er
0.9089,0.9070,0.9044,0.9043,0.9008,0.8972}
Note that for array parameters such as Ptable, you must specify : in the Array dimension
field so that the size can adapt to user input.
5. Outputs can also be declared as a special type of variable by setting Causality to output.
For this example, declare the following special variables:
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
6. Click OK to close the Edit Model dialog box. The Overwrite Model Text dialog box
appears.
7. Click Yes, overwrite from diagram to add the variable declarations to the model text.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Lrsigma = [Link]
Rr = [Link]
TrRef = [Link]
TrOperational = TempNominal
p = aimcData.p
fsNominal = [Link]
TsOperational = TempNominal
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
TsRef = [Link]
alpha20s = aimcData.alpha20s
Lszero = [Link]
Lssigma = [Link]
Jr = [Link]
useSupport = false
Js = [Link]
useThermalPort = false
statorCoreParameters = [Link]
strayLoadParameters = [Link]
frictionParameters = [Link]
phiMechanical(fixed = true)
Lm = 66.4/(2*[Link]*fNominal)
Lrsigma = 2.31/(2*[Link]*fNominal)
aimcData Rr = 0.42
Rs = 0.56
alpha20r =
[Link].alpha20Aluminiu
m
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Lssigma = 1.52/(2*[Link]*fNominal)
frictionParameters = frictionParameters(PRef=180,
wRef=wNominal)
statorCoreParameters = statorCoreParameters(PRef=410,
VRef=387.9)
strayLoadParameters = strayLoadParameters(PRef=0.005*sqrt
(3)*VNominal*INominal*pfNominal, IRef=INominal/sqrt(3),
wRef=wNominal)
verboseRead = false
columns = 2:size([Link], 2)
smoothness =
[Link]
height = 1.2*PNominal
startTime = 4.5
feedback Use defaults
k = 0.01
PI T = 0.01
initType = [Link]
gain k = -1
star Use defaults
ground Use defaults
V = fill(sqrt(2/3)*VNominal, 3)
m =3
currentQuasiRMSSensor Use defaults
electricalPowerSensor m =3
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
b. On the General tab, per the information in the above table, enter 3 for the m
property; fill(fNominal, 3) for freqHz, and fill(sqrt(2/3)*VNominal, 3) for V. No
other changes are needed. The Properties tab allows you to set the name of the
component instance.
This example requires modification of variables phiMechanical and wMechanical for the aimc
machine. This cannot be done directly in the Properties window, but instead requires that
modifiers be added.
1. To add modifiers to aimc, select the aimc instance in diagram editor and on the ribbon
Modelica tab click Add Modifier (or right click on the aimc instance and select Add
Modifier from the context menu). In the Add Modifier dialog box, add the following three
lines:
wMechanical(fixed=true,
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
start=2*[Link]*[Link]/aimcDat
a.p)
phiMechanical(fixed = true)
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click Compile & Update Project on the ribbon Modelica tab as shown below.
Note This same dialog is also displayed whenever you switch to the SimModel tab to
view the Modelica model text. You can choose either to overwrite from the
diagram, or to use the current model text. The latter choice won’t apply any
changes made in the diagram since the most recent save or compile.
2. For the AIMC example, all the editing has been completed in the diagram, so select Yes,
overwrite from diagram. The model is compiled. This may take several seconds.
3. Following the compile operation, you can select interfaces for the AIMC model, or just
accept the default set of preselected interfaces.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
4. When finished selecting interfaces, click Apply Changes to close the dialog box and
apply the changes to the AIMC model. The Update Components dialog box appears with
both the AIMC model and component selected for import into Twin Builder.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
5. Click OK to complete the update and import the AIMC model and component into Twin
Builder.
The Modelica AIMC component is now ready to use in a Twin Builder design. You can find the
Modelica component in the Project Manager > Definitions > Components folder, as shown
below.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. To open the schematic editor for a design, in the Project Manager window, find the project
in which the Modelica component definition is located, then double-click the icon for an
existing design to open the schematic editor.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Note If you need to look inside or modify the Modelica model, do one of the following to
open the model again in the Modelica environment:
l In the schematic editor, right-click the Modelica component and select Edit
Model.
l In the Project Manager, find the model in Definitions > Models folder, then
right-click on the model icon and select Edit Model.
Any change made in the Modelica environment will need to be compiled and
updated to the project again.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Because the entire AIMC system is built inside the Modelica component, the Twin Builder
design is now complete and ready to analyze.
Next, you will define outputs and create reports for simulation results.
1. To create reports or graphical representations of simulation results, you must first define
outputs in the Output dialog box to make them available for plotting. This can be done by
clicking on Output Dialog in the Schematic tab of the desktop ribbon. For this example,
the following outputs are selected as shown below:
l aimcnew1.combiTable1Ds_y_4_
l aimcnew1.eff_sim
l aimcnew1.electricalPowerSensor_P
l aimcnew1.powerSensor_power
l [Link]
Refer to Setting the Outputs for Simulation in the Twin Builder help for more information.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. In the Project Manager, you can then right-click Results and choose Create Standard
Report to add various types of reports for the design being simulated.
The outputs you set in the Output dialog box will be available in the Report dialog boxes
for plotting. For details on the various ways for viewing simulation results, see Generating
Reports and Postprocessing in the Twin Builder help.
Next, you will set up and run a transient analysis to generate AIMC simulation results.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Double-click on TR to set up end time and the desired time step for the simulation.
2. For this example, set End Time to 20 s, Min Time Step to 10 us, and keep Max Time
Step as the default 1 ms. For more details about transient analysis, see Transient
Analysis Setup in the Twin Builder help.
3. To start the simulation, run the transient analysis by doing one of the following:
l On the desktop ribbon, Schematic tab, click the Analyze icon.
l In the Project Manager, right-click on TR of the design, then select Analyze.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
In Twin Builder schematic shown above, the current sources, PMSM component, and all
components (except the circled Modelica gear shift component) are from Twin Builder
component libraries. The Modelica gear shift load is modeled in the Modelica environment.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
The figure below shows the internal diagram of the gear shift Modelica model. It is based on the
[Link] in the Modelica Standard
Library. It shows how an automatic gear shift is built up from a planetary gear, a brake, a clutch,
and related Modelica components. The basic operation of the model is as follows:
l In the beginning, the clutch is free (disengaged) and the brake prevents the ring of the
planetary gear from moving. Thus the gearRatio = 1/(1 + [Link]).
l At time = 2 s, the brake releases the ring of the planetary gear, while the clutch blocks the
ring and the sun gear. Thus we obtain a gearRatio = 1.
This example is based on the following example project located in the Modelica Tutorial
Examples folder:
<Installation location>\Examples\Twin Builder\Modelica Tutorial\Tutorial
Examples\[Link]
In this example, we will create a Modelica gear shift model, then add it as one component in a
larger Twin Builder Power Train design that includes a permanent magnet synchronous motor
and supporting components taken from Twin Builder's component libraries. We will then analyze
its performance in the Twin Builder environment. The following steps outline the process for
accomplishing these goals.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. Select Modelica as the Type and enter a Name for the new model.
The Modelica environment is displayed, with the Modelica libraries appearing in the
Component Libraries window on the right.
Next, you will place the Modelica components that are needed for the simple power train model
into the Diagram Editor.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. Drag and drop the components into the Diagram Editor in the Modelica Environment,
arranging them as shown in the figure below. Press Esc after placing each component to
stop the placement action. (Connections will be added later.)
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
3. You can change the instance names for a components by clicking on the component to
display its Properties window. You can enter the desired instanceName in the associated
Value field on the Properties tab
4. Press Esc to complete each action.
Next, you will add connections between the various power train components.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click on an input or output pin of one of the components and connect it to the desired pin
of another component.
2. Repeat for each connection.
Note More graphic options are available in a context menu by right-clicking on a component,
as shown below. For more information on these options refer to the Diagram Editor
section in the Twin Builder help.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Next, you will set up properties for the power train model.
fn_max = 100
phi_rel(fixed = true)*
clutch
w_rel(fixed = true)*
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
phi(start = 0)*
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
b. On the General tab, per the information in the above table, enter 2 for the cgeo
property; and 100 for fn_max. No other changes are needed. (The Properties tab
allows you to set the name of the component instance.)
This example requires modification of variables phi and wfor the load component; and variables
phi_reland w_relfor the clutch component. This cannot be done directly in the Properties
window, but instead requires that modifiers be added.
1. To add modifiers to load, select the load instance in diagram editor and on the ribbon
Modelica tab click Add Modifier (or right click on the load instance and select Add
Modifier from the context menu). In the Add Modifier dialog box, add the following three
lines:
phi(start = 0)
w(start = 0)
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. To add modifiers to clutch, select the clutch instance in diagram editor and on the ribbon
Modelica tab click Add Modifier (or right click on the load instance and select Add
Modifier). In the Add Modifier dialog box, add the following three lines:
phi_rel(fixed = true)
w_rel(fixed = true)
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Click Compile & Update Project on the ribbon Modelica tab as shown below.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Note This same dialog box appears when you switch to the SimModel tab to view the
Modelica model text. You can choose either to overwrite from the diagram, or to
use the current model text. The latter choice won’t apply any changes made in the
diagram since the most recent save or compile.
2. For the Simple Power Train example, all the Modelica model editing has been completed
in the diagram, so select Yes, overwrite from diagram. The model is compiled. This may
take several seconds.
3. Following the compile operation, you can select interfaces for the simple power train
model, or just accept the default set of preselected interfaces.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
4. When finished selecting interfaces, click Apply Changes to close the dialog and apply the
changes to the simple power train model. The Update Components dialog box appears
with both the simplePowerTrain model and component selected for import into Twin
Builder.
5. Click OK to complete the update and import the simplePowerTrain model and component
into Twin Builder.
The Modelica simplePowerTrain component is now ready to use in a Twin Builder design. You
can find the Modelica component in the Project Manager > Definitions > Components folder,
as shown below.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. To open the schematic editor for a design, in the Project Manager window, find the project
in which the Modelica component definition is located, then double-click the icon for an
existing design to open the schematic editor.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Note If you need to look inside or modify the Modelica model, do one of the following to
open the model again in the Modelica environment:
l In the schematic editor, right-click the Modelica component and select Edit
Model.
l In the Project Manager, find the model in Definitions > Models folder, then
right-click on the model icon and select Edit Model.
Any change made in the Modelica environment will need to be compiled and
updated to the project again.
Next, you will add and connect Twin Builder components to the design.
Placing and Connecting Twin Builder Components for the Simple Power
Train Design
All of the required Twin Builder components for the simple power train design can be found in the
Twin Builder libraries locations shown in the following table.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
2. Drag and drop the components into the Schematic Editor in the Twin Builder Environment,
arranging them as shown in the figure below. (The circled Modelica component was
already placed on the schematic.)
3. Press Esc after placing each component to stop the placement action. Connections will
be added below.
4. To change a component instance name, click on one to display its properties. Enter the
desired instanceName in the associated Value field on the Properties tab.
5. To connect the components, click on an input or output pin of one of the components and
connect it to the desired pin on the other component. Note that:
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
l You can right-click a component and choose Pin Visibility to toggle pin display.
l In the figure above, input pin i_q for the dq02abc component is fed by a sinusoidal
signal. The other two inputs (i_d and i_0) can be hidden.
l In the figure above, for the PMSM component, input signal pin free is not used, and
output pin phi_eo must be turned on and connected to input phi_e of the dq02abc
component.
6. Repeat this procedure for each connection.
The Modelica model is based on a Functional Mock-up Interface (FMI) which only supports
causal input/output pins. However, physical connections in Twin Builder is usually acausal, as a
result, acausal-causal and causal-acausal connectors are necessary for this example to connect
Twin Builder PMSM element and created Modelica power train model, as shown below.
Next, you will assign properties for the Twin Builder components.
Setting Up Properties for the Simple Power Train Twin Builder Components
The properties for the Twin Builder components used in this example are summarized in the
following table.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
b. On the Quantities tab, per the information in the above table, enter 84.6 for the
ampl property; and 1Hz for freq. No other changes are needed.
Next, you will define outputs and create reports for the simple power train design.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Defining Outputs and Creating Reports for the Simple Power Train Design
When all of the simple power train components are ready to use in the Twin Builder design, you
can define outputs and set up reports.
1. To create reports or graphical representations of simulation results, you must first define
outputs in the Output dialog to make them available for plotting. This can be done by
clicking on Output Dialog in the Schematic tab of the desktop ribbon. For this example,
the following outputs are selected:
l simPowerTrain1.u
l simPowerTrain1.y
l simPowerTrain1.engine_w
l simPowerTrain1.load_w
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Refer to Setting the Outputs for Simulation in the Twin Builder help for more information.
2. In the Project Manager, you can then right-click on Results and choose Create Standard
Report to add various types of reports for the design being simulated.
The outputs you set in the Output dialog box will be available in the Report dialog boxes
for plotting. Below are example reports dialogs for plotting the outputs mentioned above.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
For details on the various ways for viewing simulation results, see Generating Reports
and Postprocessing in the Twin Builder help.
Next, you will set up and run a transient analysis to generate simulation results.
Setting Up and Running a Transient Analysis for the Simple Power Train
Design
In this example, we would like to simulate the time-domain response of the simple power train
design. This requires that a transient analysis be performed on the design. By default, a
transient analysis, TR, is created for the design. You can find it in the Project Manager under
Analysis of the design.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
1. Double-click on TR to set up end time and the desired time step for the simulation.
2. For this example, set End Time to 5 s, Min Time Step to 10 us, and keep Max Time Step
as the default 1 ms. For more details about transient analysis, see Transient Analysis
Setup in the Twin Builder help.
3. To start the simulation, run the transient analysis by doing one of the following:
l On the desktop ribbon, Schematic tab, click the Analyze icon.
l In the Project Manager, right click on TR of the design, then select Analyze.
Below are sample reports of the simulation results for the design.
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential
4 - Index
Examples 1-2
Help 1-2
Introduction 1-1
Manuals 1-2
SIMPLORER
Documentation 1-2
Simplorer
Help 1-2
Simulation
Examples 1-2
Index 127
Twin Builder 2025 R2 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential