How to run scripts in APDL
Before we begin the actual scripting, let's do a quick tutorial on some of the methods of running scripts in APDL.
Introduction to APDL commands
Although many APDL commands are similar to what we are familiar with from other programming languages, very few have the exact same syntax. This means that to fully understand your code, and to further improve it, you will have to read the APDL commands documentation.
The easiest way to locate the correct documentation is to open Mechanical APDL and click Help → Help Topics. Since we will focus on the scripting part of APDL, the Command reference documentation is the most relevant to us.
As a first example, we would like to obtain the stresses in the node located in the point (L/2, H/2) and write them into our file answers.txt, given the plate below.
The following script includes some simple comments for most commands, but to truly understand the code, we highly recommend you to search them up in the Command Reference as well.
The following result file will then be created.
Loops and statements in APDL
When doing FEM-analyses, we are often looking to locate e.g. how large our load is before buckling or how small the mesh size has to be before the results converges. If we were to do these tasks manually, it would take forever, and it is for that reason APDL has included loops and statements.
As an example, let's do the analysis presented in the previous section, but for mesh size = 0.10 to mesh size = 0.01 with a step size of 0.01.
The following result file will then be created.
File output format
If you're new to APDL, the output formatting may feel a bit weird at first. However, the format descriptors may be written in either FORTRAN or C format, where as we will cover both. Before we begin, I want to remind you that there are a lot of other good documentation on these format descriptors online if you should not find what you are looking for here. Such pages may be this FORTRAN guide by the Michigan Tecnological University or this C guide by cplusplus.com. In addition, ANSYS has included some additional information in their command reference on *vwrite.
Let's first start with the FORTRAN format, which is also what has been used in the previous example scripts.
The other possibility is to use the C format.
Visualization and plotting
When creating a visualization to be watched and interpreted by others, an essential parameter is the quality. You will rarely notice that an image is particularly great, but you immidately notice if an image is bad. In this section, we will aim to provide you with some tips and tricks to make your visualizations better and more personalized.
Background color
Reversing the background colors is a quick and easy way to make your images better fit a white paper sheet.
To implement this, add the following code when you're e.g. in the postprocessor.