ANSYSWorkbench

Tag: Integration

This integration type block allows to apply optimization and other data mining techniques to an ANSYS Workbench project.

Introduction

ANSYSWorkbench integrates an ANSYS Workbench project into a workflow and maps its parameters to block’s input and output ports. When this block runs, it receives values to input ports and runs simulation in ANSYS Workbench with these values as input parameters. After simulation finishes, parameter values are collected and sent to output ports.

When ANSYSWorkbench executes, it actually launches ANSYS Workbench, so the block can run only on a host where ANSYS Workbench is installed. The ANSYS Workbench application starts in the following cases:

  • when you get parameter information from the selected ANSYS Workbench project,
  • when you open the selected project from the block, and
  • when actually running the ANSYS Workbench project, at the workflow run-time.

Note that ANSYSWorkbench always launches a new instance of ANSYS Workbench, so if the application is already running, the block will not re-use the running instance. As a consequence, it is not possible to work with the same project in pSeven and ANSYS Workbench simultaneously because ANSYS Workbench does not allow to open the same project twice. If your project is open in ANSYS Workbench, you will have to close it before configuring ANSYSWorkbench or running the workflow, otherwise pSeven raises an error.

Compatibility

To run, the ANSYSWorkbench block requires ANSYS Workbench installed. The block was tested with ANSYS Workbench 15.0 x64, Ansys Workbench 17.1 x64, Ansys Workbench 18.0 x64 on Windows; other versions are also compatible, but were not actively tested.

Project File

To select an ANSYS Workbench project file (.wbpj), click b_browse on the top pane in the block’s configuration dialog.

../_images/page_blocks_ANSYSWorkbench_project_file.png

The path to the selected project file is also stored in the ANSYS Workbench project option and thus can be set on the Options tab.

Project Tree

After a project file is selected, you can click b_build_tree on the Project tree pane to get project parameters.

../_images/page_blocks_ANSYSWorkbench_project_tree.png

Here you can select nodes to be mapped to input and output ports. When you select a node, a new corresponding variable appears on the Variables pane. The Ports column there shows which ports (input, output or both) are created for the corresponding tree node.

Structure

Currently ANSYSWorkbench supports mapping project input and output parameters to ports. The project tree has a simple structure with two lists of parameters:

  • input parameters
    • parameter id
    • ... more parameters
  • output parameters
    • parameter id
    • ... more parameters

Node Properties

Hovering a tree node shows a tooltip with node’s properties: type, value, description and read-only state.

Type

Parameters can have either RealScalar or StringScalar type. When you select a node in the project tree, it is mapped to a port of this type.

Value

Shows the parameter value saved in the selected project file. Note that shown values, as well as the values that ANSYSWorkbench reads from and writes to ports, are always in SI units regardless of their unit properties set in the project file.

Description

Parameter description is equivalent to the parameter name in ANSYS Workbench.

Read-only

If you select a read-only node in the project tree, it is always mapped to an output port. Writeable nodes are mapped to input ports by default.

Options

ANSYS Workbench executable path

Full path to the ANSYS Workbench executable (RunWB2.exe).

Value:path string
Default:empty

Sets the path to the ANSYS Workbench executable. This option is not required: when empty (default), the block will try to determine the path automatically. Automatic lookup checks values of ANSYS environment variables to get the path (ANSYSxxx_DIR where xxx is any version number).

ANSYS Workbench project

Full path to the ANSYS Workbench project file.

Value:path string
Default:empty

Stores the path to the selected project file. Can also be used to set this path instead of selecting a project file on the Configuration tab.

ANSYS Workbench wait timeout

The time in seconds to wait for the ANSYS Workbench application to become available in case it is currently used by another ANSYSWorkbench block.

Value:positive integer
Default:300

Several ANSYSWorkbench blocks in a workflow can start simultaneously — this is typically the case when there is a parallelized Composite block containing ANSYSWorkbench. In this case, only one of the ANSYSWorkbench blocks can run the ANSYS Workbench application at a time, because ANSYS Workbench does not allow to open the same project twice. Other blocks have to wait until the project is unlocked, and will do so until the timeout is exceeded.

Exceeding the timeout raises an error which always stops the workflow. That is, the timeout error is never suppressed regardless of the Error handling behavior setting. The workflow is not terminated immediately: all blocks that are currently running continue their execution, and the workflow stops after they finish (soft stop). Note that setting the timeout to 0 will always trigger workflow stop if an ANSYSWorkbench block with zero timeout starts while there is another ANSYSWorkbench block running. The running block will be allowed to finish execution in this case, and the workflow will be stopped by the timeout error from the second block.

Clear generated data

If enabled, call ‘Clear generated data’ for all systems after the Workbench project is opened.

Value:True or False
Default:False (don’t clear generated data)

New in version 6.11.

Error handling behavior

The action to perform if the block encounters an error.

Value:stop workflow, output defaults and signal, output signal only
Default:stop workflow

When set to stop workflow, the block simply reports an error and the workflow interrupts.

If set to output defaults and signal, the block suppresses the error. In this case output ports send values assigned to them (the defaults), and the done port outputs False (the failure signal). Note that the block automatically assigns values to output ports that are created when you select the parameters to map. These values are:

The output signal only behavior means to output only the False value to done; nothing is output to other ports.

Force project unlock

Ignore project locks and remove the lock file if it exists.

Value:True or False
Default:False (do not unlock)

New in version 6.10.

The project used by the block can be locked for various reasons, and sometimes the lock file just remains in the project because it was not closed properly. If you are sure this is the case, you can force unlocking the project: the block then removes the lock file and always opens the project. Note that the lock can also indicate that the project is currently open in a Workbench session, and in this case forcing the unlock can lead to unexpected behavior. Keeping this option enabled is not recommended. To fix an incorrectly closed project, you can also open it in ANSYS Workbench or remove the lock file manually.

Journal to run after open

Path to the Workbench journal or the Python script file which is executed during the block run after the Workbench project is opened.

Value:path string
Default:empty

New in version 6.11.

This script will be run after the project is opened and before parameters are updated with new values from input ports. You can write this script manually or use File ‣ Scripting ‣ Record Journal... in Workbench.

Journal to run after simulation

Path to the Workbench journal or the Python script file which is executed during the block run after simulation finishes.

Value:path string
Default:empty

New in version 6.11.

This script will be run after the simulation and before the values of output parameters are read. You can write this script manually or use File ‣ Scripting ‣ Record Journal... in Workbench.

Save project

Save the project after each simulation run.

Value:True or False
Default:False (do not save changes)

New in version 6.10.

If enabled, the block saves all changes done to the project after running the simulation.

Simulation timeout

Maximum allowed simulation run time in seconds.

Value:positive integer
Default:0 (unlimited)

Maximum time that can be spent for a single simulation run. Default (0) means no limit. If another value is set, the block raises an error when the timeout is exceeded. This error is handled according to the Error handling behavior setting.

Visible

Show the ANSYS Workbench application window during run-time calculations.

Value:Boolean
Default:True (show the window)

If False, ANSYS Workbench will be run in the background without showing a window. This option affects only the run-time. When you configure the block (get parameter information from a project), ANSYS Workbench is always launched in the background without showing a window.

Notes

This section answers some specific questions on using the ANSYSWorkbench block.

Updating Geometry

If the Workbench project depends on a geometry file in some neutral format, you can change this file at the workflow run-time taking advantage of CAD integration blocks (SolidWorks, Creo, Kompas3D and others). In this case you should set the path to the export file in the CAD integration block, so it replaces the file on which the project depends. At the workflow run-time, the block calls Update From CAD command in Workbench and the file is read again.

However, if geometry is taken from DesignModeler, Update From CAD is not available, so to read the geometry file again, you may need to reimport it in DesignModeler. To do it automatically before each simulation run you should use Journal to run after open option. The script below finds a geometry component in the first system of the project and sends a command to it which refreshes Import1 feature to make it read the source file again.

dm_script = """
var feature;
for (var i = 0; i < ag.agApplet.FeatureMgr.FeatureCount; i++) {
    feature = ag.agApplet.FeatureMgr.feature(i);
    if (feature.Name == "Import1") {
        feature.Refresh = 1;
        break;
    }
}
"""
geometry = GetAllSystems()[0].GetContainer(ComponentName="Geometry")
geometry.SendCommand(Command = dm_script)

Save this script to the file (edit the system index and the feature name if necessary) and set its path to the Journal to run after open option to read the geometry file each time the project is opened.