# Introduction to Ansys APDL Programming — Easy Hand-on Bar Example of Learning APDL

The first Finite Element (FE) commercial software I learn is Ansys Workbench, and it is quite intuitive to me to get hand on it for the beautiful user interface, very powerful CAD software-SpaceClaim. Mesh setting and imposing boundary condition are also not that hard for me at the time, but when I first approach to APDL (ANSYS Parametric Design Language), it surprise me in a way that how Ansys code work in behind and makes me want to explore more about where Ansys started it.

The quick outline of the hand-on APDL, MAPDL, involves following tasks:

- Create geometry in the preprocessor (/PREP7 )
- Define material properties and element attributes (For mechanical analysis: Poisson’s ratio, density, elastic modulus. For element attribute such as element types)
- Mesh the model (Global and local mesh are allowed)
- Impose Dirichlet Boundary Conditions and Neuman Boundary Conditions (that is, boundary conditions and loads)
- Solve for displacement (/SOLVE)
- Post-processing to obtain nodal solution and result plots (/POST1)

After knowing the outline of the APDL, we can now start to devise the problem that we are going to tackle. For this tutorial, I am going to start with a bar question: with one fixed-ended boundary conditions and another has an applied load.

! Clear the previous result

FINISH

/CLEAR/PREP7

! Element type and material properties

ET, 1, 187 ! ElementType, 1, ElementTypeNumber

MP, EX, 1, 10E6 ! Material Properties: Young's Modulus

MP, NUXY, 1, .3 ! Material Properties: Poisson's ratio ! Geometry and element type

BLOCK, 0, 10, 0, 100, 0, 10! Volumne mesh

VMESH, ALL ! APPLY BOUNDARY CONDITION: Clamp one end (coordinate origin)

NSEL, S, LOC, Y, 0

D, ALL, ALL, 0 ! APPLIED LOAD: Load on another end

NSEL, S, LOC, Y, 100 ! Select Y direction 100 side

NSEL, ALL, FY, 100 ! Select all points on the plane

ALLSELFINISH ! Solution

/SOLU

/STATUS, SOLU

SOLVE

FINISH ! Post-processing

/POST1

PLNSOL, U, SUM, 0, 1 ! Solve for displacement

One command that I found very useful if we import geometry (.IGES) file from SOLIDWORK or import Mesh file (.CDB) file from WORKBENCH, the node dimension might change. Therefore, it’s important for us to know the distance between the node, by using the command `NDIST(P)`

we are able to manually select the nodes that we node and obtain the distance between them.

Some useful tutorial links:

- https://www.youtube.com/c/FemExpert
- https://www.youtube.com/watch?v=qx69C-UyxsE&list=PLtt6-ZgUFmMKFfbOBhmCwG30KIVyvhDop
- https://courses.ansys.com/index.php/courses/intro-to-ansys-mechanical-apdl-scripting/

Thank you for your reading, I hope this helps a bit to your Ansys APDL study!