Hi everyone, in this video, we’ll introduce Mechanical APDL
(which we’ll abbreviate as “MAPDL”), focusing mainly on its capabilities,
a brief history of the APDL syntax, the motivation for learning and using APDL scripting
and finally getting our feet wet by going through installing and running a model using an APDL script.
Let’s get started!
Mechanical APDL is a general-purpose finite element analysis program that is driven by the Ansys Parametric Design Language, also known as APDL.
It’s a fully-featured FEA program that includes pre-processing, multiple equation solvers & solution techniques, and post-processing capabilities.
It can run a wide range of simulations such as stress analysis, spectrum analysis, vibro-acoustics and even heat transfer analysis.
Using APDL scripting, one can perform geometric and mesh generation, define solution controls, and perform other pre- and post-processing tasks.
In addition to these features, APDL can also perform different vector and math operations, use process control, create, and use macros, and the list goes on.
APDL scripting involves inputting a list of commands that are executed line-by-line by the MAPDL program.
Over the fifty-plus years, several features may have come and go but the foundation of MAPDL program continues to be APDL.
While there are several pre- and post-processing tools such as Ansys Mechanical that can communicate with the MAPDL program, there are several advantages of learning APDL scripting.
The first benefit is accessing the finite element mesh and other model details written by other pre- and post-processors.
We may wish to do this to add specialized elements or to access element options not natively supported by the preprocessor, or we may want to utilize advanced solver options.
The second advantage of using APDL scripting is the ability to automate repetitive preprocessing and postprocessing tasks or even to automate entire workflows.
For example, I may have hundreds of bolted connections and wish to extract bolt shear and axial forces and write them in a specific format to a text file, which can be quite readily achieved with APDL scripting.
Another advantage of using APDL scripting is to build custom vertical applications that run a specific type of analysis.
By doing so, one can condense the workflow and even scale its usage to users who are not well-versed with the entire finite element process.
In addition to these points, one can also venture into advanced engineering analyses.
MAPDL generates a lot of data and results such as reduced matrices, eigenvectors of a system, or even specific results that may be used in other analyses performed using third-party tools.
Some applications include design optimization using advanced algorithms available in MATLAB or Python,
performing system-level reduced-order modeling,
or even interfacing with state-of-the-art technologies such as artificial intelligence and machine learning.
In a nutshell, the ability to drive MAPDL via scripting opens opportunities for running both simple and complex analyses in the most efficient and user-specific way.
Now let’s look at a sample APDL script to see how it is structured.
Here’s the APDL script for static analysis of a 3-D plate with a hole, that is subjected to pressure load on opposing sides
We’ll model an eighth of the geometry for simplicity, and we will apply symmetry conditions on all three planes.
For loading, we apply pressure on one face of the quarter symmetry model.
The script performs all the basic operations of an FE analysis such as defining the element type and material properties,
creating a geometry, meshing it, applying appropriate loads and boundary conditions, defining the solution controls, solving, and extracting the relevant results.
Irrespective of the complexity of the model, one can construct, solve and post-process all models using APDL scripting.
Before we run this script, lets briefly look at where to download and install MAPDL.
MAPDL is not available as a stand-alone installation.
Instead, it is included as part of the full structures package.
Both commercial and academic customers can download this package from the Ansys customer portal.
Alternatively, it is also included in the Ansys Student free software, although this free student version has some limitations on the size of problems that can be solved.
The setup executable file will walk the users through the installation process, and there are no additional steps needed in installing MAPDL.
Once the installation is done, one can launch Mechanical APDL in several ways, but we’ll highlight four ways of doing this.
First is to launch it via Workbench, this is recommended if the user intends to share the files from MAPDL with other WB modules.
The second method is to launch it via Windows Start menu, this method launches a stand-alone MAPDL session using the default product settings.
The third and the preferred method is to launch it via Mechanical APDL Product Launcher from the Windows Start menu so one can customize the product settings.
The fourth method is to launch it via command line, such as a Linux terminal or Windows Command prompt.
For this demo, let’s use the product launcher, go to Start menu, and locate the Ansys folder and click on Mechanical APDL product launcher.
This is the product launcher window, in here one can change different product settings such as
picking a simulation environment and license,
selecting a working directory where all the files generated by MAPDL are stored,
assigning a jobname which is used as filename for all the files created by MAPDL.
The simulation environment gives two main options
– the first runs MAPDL interactively, with a graphical user interface,
and the second option of “ANSYS Batch” runs MAPDL in batch mode
that takes an APDL input file to process and exits when complete, without any user interaction.
With this demonstration, we’ll stick with the interactive “ANSYS” simulation environment.
One can also use customization preferences and High-Performance Computing setup to define advanced product settings, but for this course, we will use the default settings.
Download the sample APDL script that is provided as a .dat file and save it to a folder on your local drive.
Now click on Browse and navigate to the folder where the input file is stored.
Select that folder and Click OK.
Now assign a job name for this run, in this case, we will name it as “sample_script”.
Now click ‘Run’ to launch MAPDL program with these product settings.
This is the GUI, or graphical user interface, of MAPDL.
Before we run the script, let’s do a short review of this interface.
It is broadly classified into different panels such as the Utility Menu, the Main Menu, the command line, the Graphics Windows, and the View Settings.
It also has an Output window that pops up as a separate window.
This is where we see the feedback from MAPDL program for each command executed.
One can either type individual commands via Command line or run the script from a text file.
In this demo, we already have the script as a text file, so let’s use that.
Go to File in the Utility Menu and go to Read Input from and select the input file that we downloaded earlier.
As you can see the MAPDL program begins to execute the script line by line and provides feedback in the output window.
When it finishes solving the model it issues a message stating the same.
In this plot, we are looking at the equivalent stresses developed in the plate due to the pressure loading.
One can use Cntrl + left mouse button to pan, Cntrl + right mouse button to rotate, and scroll to zoom-in and out.
We can also click-drag with the right mouse button to zoom in on a portion of the model,
and clicking once with the right-mouse button provides a context-sensitive menu that allows us to fit the entire model back on the screen.
One can also use different options in the View Settings panel to change the view.
When we’re ready to close the application, click on Save db to save the full database to a .db file.
Alternatively, hit Exit and the program prompts to save the file partially or fully, or to exit the program without saving anything.
This concludes the demo on how to launch MAPDL and run a simulation from an APDL script.
Thank you for watching and we’ll continue learning APDL scripting in the next video.