5.9.1. Specifying External Pre- or Post-Solve Operations

The External Operation before Solving and External Operation after Solving fields can be used to instigate a user-defined operation immediately before or after the hydrodynamic solver runs. The default for each of these fields is None, so that no external operation is performed.

Setting External Operation before Solving to Run a Python Script adds a Pre-Solve Python Script object under the Analysis Settings. You can use this object to import an existing Python script by selecting a file in the Pre-Solve Python Script field. You can define or edit your Python script directly in the script editor that is provided.


Note:  Modifying the Pre-Solve Python Script will cause an up-to-date Solution to go out of date. If the Pre-Solve Python Script fails to execute, the Solve operation will be terminated before it progresses to the hydrodynamic calculation.


You can also set the External Operation after Solving field to Run a Python Script, which will add a Post-Solve Python Script object under the Analysis Settings. You can import an existing Python script by selecting a file in the Post-Solve Python Script field. Modifying the Post-Solve Python Script will not cause the Solution to go out of date, and the Solution will still be marked as up-to-date at the end of a Solve even if the Post-Solve Python Script fails to execute. However, a pop-up dialog box will appear to warn you of such a failure.

When you import a Python script into your hydrodynamic system, the only retained reference to the original file is the path shown in the Pre- or Post-Solve Python Script field. If you make any subsequent changes in the Aqwa editor's Python script editor, they will not be saved in the original file. If you modify the original file outside of the Aqwa editor, you will need to re-import it for those changes to be captured.

Alternatively, the External Operation before or after Solving fields can be set to Run a Custom Command. These allow you to specify paths to external programs, in the External Pre-Solve Command and External Post-Solve Command fields, that should be run immediately before or after the hydrodynamic solver. The paths can be absolute or relative. If the location of the executable is in your %PATH% environment variable, you should not need to specify the full path. You can also enter any Windows command that can be executed from the command line.

When a pre- or post-solve command is specified, the following environment variables are created in the process' environment:

  • AQWA_INPUT_FILE: points to the .DAT file used by the analysis.

  • AQWA_INPUT_FILE_NOEXT: same, but without the extension (to access the result files, with extensions .PLT, .RES etc.).

  • AQWA_WORK_DIR: the directory where the analysis is run.

  • AQWA_USER_DIR: the project's user_files subdirectory.

  • AQWA_INSTALL_DIR: the root of the Ansys installation folder.

  • AQWA_PYTHON_EXE: the path to the CPython executable shipped with the Ansys installation.

For the post-solve command only, the following variable is also set:

  • AQWA_RUN_COMPLETED: set to either TRUE or FALSE depending on the outcome of the solve.