August 25, 2015

Error handling in pSeven

pSeven provides a wide range of tools to build quite sophisticated workflows for solving real-world engineering problems. Such workflows, especially for multidisciplinary design optimization and data analysis, contain many integration type blocks that build geometry models using CAD systems or perform finite-element analyses with CAE systems.

However, one of the main challenges of solving an engineering problem is that for some configuration parameters a model cannot be built, or analysis cannot be carried out. For example, when the solution of a non-linear strength problem loses its numerical stability, or strong turbulent flows can lead to instability of solving the Navier-Stokes equations. In order to handle such exceptions in pSeven a user has to perform the following steps.

Step 1Set up built-in block error handling

In order to prevent the main workflow from stopping prematurely if some block fails, pSeven provides the error handling functionality.

Let us consider the SolidWorks block as an example (Figure 1). This block allows to select different types of error handling behavior. For example, to output defaults in case of failure instead of stopping the workflow (Figure 2).

Figure 1 – GUI of SolidWorks block

Figure 2 – Options tab of SolidWorks block 

ShellScript block is the most often used block when solving real application problem in pSeven. This block integrates any external executable in the workflow. It can be a commercial program such as ANSYSAbaqusNastran, or some in-house program (Figure 3).      


Figure 3 – GUI of ShellScript block


          ShellScript block can generate an error in the following cases:

  • program exit code is not in the list of success codes;
  • execution timeout occurs;
  • program outputs to the standard error stream.   

        User is able to control the above listed settings (Figure 4).


Figure 4 – Options tab of ShellScript block


Step 2Set up blocks integration

There are two alternatives for user to organize continuous interconnected running of blocks in the computational chain with the one finished with failure.

2.1. Set default values for output ports

Let us consider connection between ShellScript and Text blocks in the workflow presented in Figure 5.


Figure 5 – Workflow with ShellScript block

What can be specified as default values for output ports of ShellScript block? The output ports of ShellScript block are files with the computation results of executable. Typically, these files are then transferred to Text block to extract numerical results from them. By default, if the files with results are not generated by ShellScript block due to an error, then empty files will be transferred to the next block in a computational chain.

In this case, if Text block takes an empty file or file in which, for some reason, there is no data to be processed, then user can assign NaN default values to output ports of Text block (Figure 6).


Figure 6 – Ports of Text block

Let us consider the next example with SolidWorks block (Figure 1) in the following optimization workflow (Figure 7).


Figure 7 – Workflow with SolidWorks block

Here we set a NaN value for the output port mass (Figure 8). Thus, if SolidWorks fails to rebuild a model with the current input parameters and therefore to evaluate the mass of this model, then NaN will be output instead of the mass value.


Figure 8 – Ports of SolidWorks block 

Why NaN? By convention, data analysis and optimization algorithms implemented in pSeven treat NaN as an undefined function value and effectively use this information when solving a problem.

2.2. Condition-based error handling using Condition block

The idea is to use Condition block in the workflow as a switch. Each block in pSeven has the output port done, which can be interpreted as a finish status of the block: it outputs True in case of success, otherwise False.

In the workflow presented in Figure 9, the Condition block receives output of the ANSYS block and analyses its finish status. Depending on this status, Condition either passes the output data to the Text block or in case of failure activates the Const block which outputs NaN values.


Figure 9 – Workflow with Condition block



By Dinara Shvarts, Application engineer, DATADVANCE