ANSYSWorkbench

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, each of its input ports receives a batch of parameter values (a RealVector or StringVector). The block then executes simulation in ANSYS Workbench with these values as input parameters, processing the batch sequentially or in parallel depending on the ANSYS Workbench project settings. Calculated output parameter values are collected to form output batches, which are finally sent to block’s 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.

Changed in version 6.13: added parallel calculations support; all ports corresponding to project parameters now have vector types; output ports also allow scalar types, so you can assign scalar values to outputs (see Error handling behavior for usage).

Since version 6.13 ANSYSWorkbench supports parallel calculations — for example, when parallel component execution mode is enabled in ANSYS Workbench project settings. This parallelization is not controlled by block’s settings: if parallel calculations are not enabled in the ANSYS Workbench project, input batches are processed in sequential mode automatically.

Compatibility

To run, the ANSYSWorkbench block requires ANSYS Workbench installed. The block was tested with ANSYS Workbench 17.2 x64, ANSYS Workbench 18.0 x64, ANSYS Workbench 19.0 x64, and ANSYS Workbench 2019 R1 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

When you select a node in the project tree, it is mapped to a port of the corresponding type. Usually this type is RealVector — a batch of numeric parameter values. If the selected parameter is a string, related port has the StringVector 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 string (search automatically)

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 string (no project selected)

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 project to become available in case when this project 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 with the same project 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 with the same project. 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.

This option does not affect blocks that use different projects: such blocks can run simultaneously provided that your ANSYS Workbench license allows running several application instances.

Clear generated data

Clear generated data for all systems after opening the project.

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

New in version 6.11.

When enabled (True), the block calls the Clear Generated Data command for all systems in the project before performing other actions. Default (False) does not clear any data.

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 (interrupt immediately)

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 and does not interrupt the workflow. In this case, the done port outputs False (the failure signal), and values assigned to other output ports are used to generate certain data (the defaults), which is output by the block in order to allow the workflow to continue.

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

Changed in version 6.13: scalar values assigned to output ports have special meaning in error handling.

Since the block is intended to process parameter batches (inputs have the RealVector or StringVector type), the actual values it outputs also have vector types. However, its output ports allow both vector and scalar types — for example, ports corresponding to numeric parameters allow RealVector and RealScalar. The scalar type is added in order to support using scalar values with the output defaults and signal behavior. You can assign either a vector or a scalar value to an output port, and they work as follows:

  • If you assign a vector value, it is always output as is (this value simply works as the default). It means that if there was error for any point (a combination of parameters) in the input batch, the whole output batch will be discarded and the vector value assigned to a port will be output instead.
  • If you assign a scalar value, this value is used to fill in the missing data in output vectors (batches). For example, when the block fails to obtain output parameter values for some of the points in the input batch, these points in output batches are replaced with the assigned scalar. This is done for failed calculations only, so the results of successful calculations are not lost.

Note that the block automatically assigns certain values to the output ports which are created when you add output variables on the Variables pane or by selecting output parameters on the Project tree pane. These values are always scalars, namely:

  • NaN for the ports corresponding to numeric parameters, and
  • an empty string for the ports corresponding to string parameters.

The automatically assigned scalars work as described above (replace the missing data), and you can change these values on the Ports tab in block configuration.

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. Setting this option to True allows the block to ignore project locks: it will force unlock the project by removing the lock file, and then open the project.

Note that the lock can also indicate that the project is currently open in an ANSYS 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 ANSYS Workbench journal or the Python script file to execute after opening the ANSYS Workbench project.

Value:path string
Default:empty string (do not run any script before simulation)

New in version 6.11.

The block can run additional project scripts before and after the simulation run in ANSYS Workbench. This option specifies the script that runs after opening the project but before parameters are updated with new values from input ports.

To prepare the script, you can use the File ‣ Scripting ‣ Record Journal… command in ANSYS Workbench, or write the code manually.

Journal to run after simulation

Path to the ANSYS Workbench journal or the Python script file to execute after simulation finishes.

Value:path string
Default:empty string (do not run any script after simulation)

New in version 6.11.

The block can run additional project scripts before and after the simulation run in ANSYS Workbench. This option specifies the script that runs after simulation finishes but before reading the values of output parameters.

To prepare the script, you can use the File ‣ Scripting ‣ Record Journal… command in ANSYS Workbench, or write the code manually.

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 (True), 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:True or False
Default:True (show the window)

When True, the ANSYS Workbench application started by the blocks runs in a visible window. When False, ANSYS Workbench runs 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.

License Management

Parallel processing of input batches by the ANSYSWorkbench block or running several ANSYSWorkbench blocks simultaneously may result in the fact that all licenses are in use and not immediately available. License availability is not controlled by the block’s settings, but the ANSYSWorkbench application can keep checking the license status periodically. This is achieved via the License Queuing option activated by setting the environment variable ANSWAIT to 1. Setting the option will help avoid a license checkout error in the ANSYSWorkbench block.

Known Issues

If multiple versions of ANSYS Workbench are installed on the same host, the ANSYSWorkbench block may work incorrectly when it fails to find the correct versions of ANSYS DLLs. Specifying the ANSYS Workbench executable path option does not fix this issue. To avoid it, add paths to ANSYS Workbench libraries to your PATH:

  • C:\Program Files\ANSYS Inc\vXXX\Framework\bin\win64
  • C:\Program Files\ANSYS Inc\vXXX\EKM\programs\jre1.7.0_07\bin\server
  • C:\Program Files\ANSYS Inc\vXXX\EKM\EKM-Connector\bin\Win64

where vXXX is the ANSYSWorkbench version that you want to use. Note that PATH should contain paths to this version only: if there are paths to other versions, you will have to remove them.