Project Elements
You should understand the following terms and concepts when working with Ansys Workbench scripting. The following image depicts the relationship between the objects in a project.
- Project
The project is the full collection of systems, components, data, and their connections that you create to achieve an overall CAE goal.
- System
A system is a collection of components that together provide workflow to achieve an engineering simulation goal, such as completing a static structural analysis or a steady state fluid flow simulation. Systems may also contain a single component to complete an analysis sub-task, for example, meshing a geometric assembly.
- Component
A component includes a collection of data and a data editor that work together to achieve a CAE-related task. A system may include several components which together to define a simulation workflow. A data editor can be an Ansys Workbench-enabled application like Ansys Fluent or Mechanical, or a native Ansys Workbench workspace like Engineering Data or Design Exploration. In the Ansys Workbench user interface, a component is depicted as a cell in the Project Schematic.
In an abstract sense, a component receives data from external or upstream sources, enables you to edit data local to the container, and then performs operations to produce output data. For example, a meshing component may receive geometry data from an upstream source, enable you define meshing attributes, and then generate a mesh for a downstream analysis.
In addition to managing the data and data editor required for a CAE task, a component also provides common services to control the input and output data from the component. For example, the component allows its output data to be transferred to other components.
- Data Container
A data container includes data unique to an individual component as well as the services to manage and manipulate it. Although most components have a single data container, they may have more than one.
Services which create, retrieve, or modify a component’s local data are provided by the data container, while services to control the transfer of data into and out of the component are provide by the component.
- Data Entity
A data entity is a data structure defined within the data container. A data container often employs several data entities. A data entity is similar to a class in an object-oriented programming language. It defines member data (or properties) and methods that can be called to perform operations on the data.
- Data Reference
A data reference is a handle to an instantiated data entity. From a data entity definition, an object can be created, and the data reference provides access to that object. In an Ansys Workbench journal, data references are assigned to variables. The variables are then used to access the properties and methods of the data entity. Consider the following example:
system = GetSystem(Name="My Analysis") system.Update()
The first line queries for a previously instantiated system data entity named
My Analysis
. TheGetSystem
method returns a data reference to the specified system object and assigns it to the variablesystem
. Using this variable, the second line calls a method supported by the system data entity namedUpdate
. This method updates the state of the system referenced by the variable, which is namedMy Analysis
.- Data Container Reference
Similar to data references, a data container reference is a handle to an instantiated data container object.
Scripting Interface Concepts
- Object
An object encapsulates a combination of data and services that act on the data. In the Ansys Workbench scripting interface, data entities, data containers, or components are all examples of objects. Access to these objects is provided by data references and data container references.
- Property
A object’s data is referred to as its properties. In the Ansys Workbench scripting interface, only objects derived from data entities have properties. A property is defined by its name, type, and value. Property types include:
Boolean
String
Numerical types (Integer, Real)
Physical quantities
Data references and data container references
Collections of the above types (Lists, Dictionaries)
An object’s properties are accessed by applying the dot operator on the corresponding reference to that object. In the following example,
parameter1
is a data reference to a parameter object. TheExpression
property of this object is set to 10.parameter1.Expression = "10"
- Method
A method is a command that is bound to a data entity or data container object. Methods can change property values, create or delete properties, or invoke complex calculations and operations. Methods may require arguments to further specify the action to be taken, and they may return an object as a result of that action. Like properties, an object's methods are accessed by applying the dot operator on a corresponding data reference. In the following example,
parameter1
is a data reference to a parameter object. The methodSetQuantityUnits
is called to set the object's units to meters.parameter1.SetQuantityUnits("m")
To see a list of all methods and queries in a component, execute
dir(
from the Workbench script console.component
)- Argument
An argument is a variable that can be passed to a method when invoked. An argument has a type and share most of the same types as properties.
Ansys Workbench methods use named arguments, where each argument is given a name that is used to distinguish it from other arguments in the method. Because the arguments are named, their order is inconsequential.
Arguments can be required or optional. All required arguments must be specified or the method will fail. Optional arguments may be omitted and typically take a default value.
In the following example, the density property of a material is set to 8500 kg/m3. The named arguments are
Variables
andValues
, which are set to"Density"
and"8500 [kg m^-3]"
respectively.property1.SetData(Variables="Density", Values="8500 [kg m^-3]")
Because Ansys Workbench uses named arguments, the following form of the command is also acceptable.
property1.SetData(Values="8500 [kg m^-3]", Variables="Density")
- Query
A query is a method which typically returns a data or container reference which can then be used to further interrogate or modify the project. Queries by themselves do not change the state of the project. Like methods, queries may require specifying arguments.
- Namespaced Commands
Namespaced commands are commands that are not bound to a particular object but have been grouped in a namespace with other commands having similar context. Like methods, commands perform some action, often require arguments, and may return an object as a result of the action. In the following example, the Update command is called in the
Project
namespace to update all components in a project by refreshing the input data and performing local calculations:Project.Update()
Apps and Templates
Ansys Workbench uses template apps to create the project, system, and component elements described earlier.
Apps that create templates are analogous to document templates provided for Microsoft Word. For example, you can pick a Word report template that contains the formatting and sections for a type of report that you want to create. You then create a document from that template and fill out your specific content within that document to produce the report. Comparably, you may pick a system template in Ansys Workbench that describes the components, data, and relationships needed to execute a particular type of CAE analysis. You then create a system from that template, enter data, and perform operations within that system to complete the analysis.
Templates facilitate and automate creation of project elements for a specific purpose. However, these templates do not preclude you from manually (and flexibly) building up a project from the constituent elements to achieve the same goal.
- Project Template
A project template defines a set of system templates and the connections between them that can be used to perform a multi-disciplinary CAE analysis task (such as Thermal-Stress or One-Way FSI).
The project template can be used to create specific instances of systems and components within the project (such as the custom templates in the Ansys Workbench Toolbox).
- System Template
A system template contains the information to create an Ansys Workbench System designed for a particular simulation objective. Ansys Workbench provides system templates for many types of standard analyses, including static structural, fluid flow, explicit dynamics, steady-state thermal, and others. The analysis systems listed in the Ansys Workbench Toolbox are all examples of system templates. All analyses performed in Ansys Workbench begin by referencing a system template.
- Component Template
The component template includes the allowed input/output data types, internal data, and key commands associated with a specific component (such as Geometry).