0% found this document useful (0 votes)
26 views24 pages

APDL Coding

The document discusses meshing and finite element analysis concepts. Meshing is the process of discretizing a geometry into small elements that can be used for analysis. Higher quality meshes with more elements better represent shapes but require more computational resources. Mesh convergence studies are used to determine the optimal mesh density.

Uploaded by

Husnain Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views24 pages

APDL Coding

The document discusses meshing and finite element analysis concepts. Meshing is the process of discretizing a geometry into small elements that can be used for analysis. Higher quality meshes with more elements better represent shapes but require more computational resources. Mesh convergence studies are used to determine the optimal mesh density.

Uploaded by

Husnain Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

APDL Scripting

FEM Lab
Engr. Saad Akram, DME, IST
Mesh
• A mesh is made up of elements which contain nodes (coordinate locations in space that can vary by element type) that represent the
shape of the geometry.

• An FEA solver cannot easily work with irregular shapes, but it is much happier with common shapes like cubes or triangles.
Meshing is the process of turning irregular shapes into more recognizable volumes called “elements.”

• These Triangles or cubes are the smallest units, that all join to represent geometry.

• Think of it as you are given squares to make a one big circle, Can you make one circle from 4 squares?

• But if you are given small number of millions of squares, you would make a nearly perfect circle.

Engr. Saad Akram, DME, IST


• Elements are the smallest part of a body.

• These elements together represent the geometry.

Element • Smaller the element, the more perfectly it would


represent a body.

• More the nodes of elements, higher would be the


computational cost.

Engr. Saad Akram, DME, IST


Above, you see two circles in two plates, One plate has small mesh,
and you can see the circle is nearly perfect, other with rough mesh
has rough circle, But what if we had no circle in plate?
Mesh Element There wont be a need to make small elements.
It would just have wasted computational cost. (It’s a square mesh
element, complex shapes should have triangular)

Engr. Saad Akram, DME, IST


Elements
Some common mesh
elements, each have a
unique name referred to it

Engr. Saad Akram, DME, IST


Mesh Convergence Study
If we keep increasing mesh quality, results would keep on
changing.

There would come a time when increasing mesh quality


further would bring no refinement in results.

We say that mesh convergence has occurred, and the


process is called mesh convergence study.

All problems should have mesh convergence study as


well to get accurate results

Engr. Saad Akram, DME, IST


1. Mesh Quality: The quality of a mesh refers to how well it represents the
geometry and how accurately it captures the features of interest in the physical
domain. A high-quality mesh typically has elements that are uniformly sized,
well-shaped, and properly aligned with the features of the geometry.

2. Mesh Density: Mesh density refers to the number of elements used to discretize
a given volume or surface. Increasing mesh density generally improves the

Other
accuracy of the solution but also increases computational cost.

3. Types of Meshes: Meshes can be categorized into structured or unstructured,

Related depending on the arrangement of elements. Structured meshes have a regular


arrangement of elements, while unstructured meshes have irregular
arrangements.

Terms 1. Structured Mesh: Regular grid-like pattern, easy to generate for simple
geometries, but inefficient for complex shapes.

2. Unstructured Mesh: Irregular arrangement, suited for complex


geometries, but more challenging to generate and may require more
computational resources.

Was the mesh shown in previous slides structured on not?

Engr. Saad Akram, DME, IST


General APDL GUI Procedure
1.Select Preferences.
2.Select Element type.
1. If ET= Plane/link Real constants Define thickness/area
2. If ET= Beam Section Define Beam Cross section area
3. If ET= Solid brick Directly make area to extrude it or make volume
3. Define Material Properties.
4. Go to mesh mesh attributes
5. mesh mesh Area/Line/Volumemapped all
6. Solve

Engr. Saad Akram, DME, IST


APDL Coding
Scripting

Engr. Saad Akram, DME, IST


10KN

20m

Script for a beam


1. KEYW,PR_SET,1 12. L, 1, 2
(Make line by joining point 1 and 2)
2. KEYW,PR_STRUC,1
(1,2 sets preferences as structural) 13. LATT,1, ,1, , , ,1
(command for mesh attribution, assigns MP 1, Cross section 1 to line)
3. /PREP7
(set the preprocessor) 14. LMESH, 1
(Mesh Line, (AMESH if it was area))
4. ET,1,BEAM188
(sets Element type named “1” as Beam188) 15. DK,1, ,0, ,0,ALL, , , , , ,
(DK= boundary condition on keypoint, syntax: DK, keypoint number,0,,0,,0,ALL,ux,uy,uz)
5. MPDATA,EX,1,,200e9
16. F,2,FY,10000
6. MPDATA,PRXY,1,,0.3
(Force on keypoint number 2 in FY direction of magnitude 10000, syntax: F, KP, Direction, magnitude)
(sets E=200e9 , v=0.3 for Material named “1”)
17. FINISH
7. SECTYPE, 1, BEAM, RECT, square, 0
(Finish the process)
(sets cross-section “1” named “Square” as “RECT” (rectangle)
18. SOLVE
8. SECOFFSET, CENT
(Solve the problem
9. SECDATA,2,2,0,0,0,0,0,0,0,0,0,0
(sets sec data for the command line 7, syntax: SECDATA, height, width) /VIEW,1,1,2,3 (If want to view result in 3d)
10. K,1,0,0,,
11. K,2,20,0,,
(Set 2 keypoints) Engr. Saad Akram, DME, IST
Script for Plane

A simple code is shown in next slide that


uses Plane 4 node element type with mesh
refinement on a square with hole in it.

Force

Pressure
on line

Engr. Saad Akram, DME, IST


1. KEYW,PR_SET,1 12.K,1,0,0,,
2. KEYW,PR_STRUC,1 13.K,2,20,0,,
(Line 1 and 2 defines preferences as structural)
14.K,3,20,20,,
3. /PREP7
15.K,4,0,20,,
(Line 3 set processor)
(makes 4 keypoints named 1,2,3,4)
4. ET,1,PLANE182
16.L, 1, 2
(Line 4 defines element type, it sets ET 1 as plane 182)
17.L, 2, 3
5. KEYOPT,1,1,0
18.L, 3, 4
6. KEYOPT,1,3,3
19.L, 4, 1
7. KEYOPT,1,6,0
(Make four lines, syntax: L, point 1, point 2)
(5,6,7 are fixed lines to turn thickness option on for plane)
20.Al, 1,2,3,4
8. R,1,10,
(Make area by joining the four lines)
(sets thickness as 10 for ET1 what was plane 182)
21.CYL4,10,10,5
9. MPDATA,EX,1,,100e9
(Make a circle, syntax: CYL4, x,y, radius)
(Defines a material prop. With E=100e9 to 1 st mat)

10.MPDATA,PRXY,1,,0.3
(Define poison ratio of 0.3 to 1st mat)

11.MPDATA,DENS,1,,7800
(Defines density of 7800 to 1st mat)

Engr. Saad Akram, DME, IST


Other Useful Common Commands
BLC4,0,0,10,10 Creates a 2d block for PLANE182 Syntax: BLC4,start coordinate x, start coordinate y, h,w
CYL4,0,0,10 Creates a 2d block for PLANE182 Syntax: CYL4, start coordinate x, start coordinate y, r
VOFFST,1,10, , Creates a 3d object by extruding Syntax: VOFFST, area number, length of extrusion,,
any selected area,
AATT, , , 1, 0,
CM,_Y,AREA Fixed five lines to mesh an area
ASEL, , , , 1
CM,_Y1,AREA,
AMESH,_Y1
AREFINE,_Y1, , ,4,0,1,1 For refining mesh, 4 represents refinement level
BF, 1, GRAV, 0, 0, -9.81 To apply self weight/ gravity

Engr. Saad Akram, DME, IST


Script to Make a Plane182
block and mesh it
1. ET,1,PLANE182
2. BLC4,0,0,20,20
3. AATT, , , 1, 0,
4. CM,_Y,AREA
5. ASEL, , , , 1
6. CM,_Y1,AREA
7. CHKMSH,'AREA'
8. CMSEL,S,_Y
9. AMESH,_Y1

(The mesh is auto and very rough)

Engr. Saad Akram, DME, IST


Refinement
1. ET,1,PLANE182
2. BLC4,0,0,20,20
3. AATT, , , 1, 0,
4. CM,_Y,AREA
5. ASEL, , , , 1
6. CM,_Y1,AREA
7. CHKMSH,'AREA'
8. CMSEL,S,_Y
9. AMESH,_Y1
10. AREFINE,_Y1, , ,4,0,1,1
11. AREFINE,_Y1, , ,4,0,1,1
(The refinement if now 16 times)

Engr. Saad Akram, DME, IST


Create Complex Areas
1. ! Define keypoints for the two 11. L, 1, 2
areas 12. L, 2, 3 22. ! Subtract area 2 from area 1
2. K, 1, 0, 0, 0 13. L, 3, 4 23. ASEL, S, AREA, , , 1 ! Select
3. K, 2, 1, 0, 0 14. L, 4, 1 area 1
4. K, 3, 1, 1, 0 24. ASEL, R, AREA, , , 2 ! Select
5. K, 4, 0, 1, 0 area 2
15. L, 5, 6 ! Lines for the second
area 25. ASBA, 1, 2 ! Subtract area 2
from area 1
6. K, 5, 0.5, 0.5, 0 ! Keypoints for 16. L, 6, 7
the second area The ASEL command is used to select
17. L, 7, 8 the areas
7. K, 6, 1.5, 0.5, 0 26. ! List the resulting areas
18. L, 8, 5 (optional)
8. K, 7, 1.5, 1.5, 0 The ASBA command is used to
27. FLST, AREA
subtract the 1 area from the another.
9. K, 8, 0.5, 1.5, 0 19. ! Create areas from the lines
20. AL, 1, 2, 3, 4 28. FINISH
10. ! Create lines to form the 21. AL, 2, 5, 6, 7, 8
boundaries of the areas
Creates 2 rectangles and then subtract one from the other to make a complex shape.
Engr. Saad Akram, DME, IST
Subtract circle from a square
1. ! Define keypoints for the 11. L, 2, 3 square
square 12. L, 3, 4 20. ASEL, S, AREA, , , 1 ! Select
2. K, 1, 0, 0, 0 13. L, 4, 1 square
3. K, 2, 1, 0, 0 21. ASEL, R, AREA, , , 2 ! Select
4. K, 3, 1, 1, 0 circle
14. ! Create the circle
5. K, 4, 0, 1, 0 22. ASBA, 1, 2 ! Subtract circle
15. CIRCLE, 5, 0.1 from square

6. ! Define keypoints for the circle 16. ! Create areas from the lines 23. ! List the resulting areas
7. K, 5, 0.5, 0.5, 0 and circle (optional)
8. K, 6, 0.6, 0.5, 0 17. AL, 1, 2, 3, 4 ! Square 24. FLST, AREA
18. AL, 2, 5, 6 ! Circle
9. ! Create lines to form the square 25. FINISH
10. L, 1, 2 19. ! Subtract the circle from the

Engr. Saad Akram, DME, IST


A sample Code of 3d block with mesh and
loading conditions
1. /PREP7 ! Enter preprocessor 14. ! Mesh the square 22. ! Fix the selected nodes (e.g., in all
15. AMESH, ALL directions)
2. ! Define keypoints for the square 23. DK, ALL, UX, 0
3. K, 1, 0, 0, 0 16. ! Select nodes belonging to one side of 24. DK, ALL, UY, 0
4. K, 2, 1, 0, 0 the square 25. DK, ALL, UZ, 0
5. K, 3, 1, 1, 0 17. ASEL,S,NODE, , ,1, ! Select nodes
belonging to one side (e.g., side 1) 26. /SOL ! Enter solution processor
6. K, 4, 0, 1, 0
27. ANTYPE,0 ! Static analysis
18. ! Apply pressure load to the selected 28. SOLVE ! Solve the system of
7. ! Create lines to form the square nodes (e.g., in the Y direction) equations
8. L, 1, 2 19. F, ALL, FY, -100 ! Apply pressure of -
9. L, 2, 3 100 units (negative for inward pressure)
29. /FILNAME,Square_output ! Specify
10. L, 3, 4 filename for output data
11. L, 4, 1 20. ! Select nodes belonging to the other 30. /POST1 ! Enter
side of the square postprocessor
12. ! Create areas from the lines (for the 21. ASEL,S,NODE, , ,2, ! Select nodes 31. PRESOL, S ! Reconstruct
square) belonging to the opposite side (e.g., the solution
side 2)
13. AL, 1, 2, 3, 4

Engr. Saad Akram, DME, IST


A different way to model a beam as area
1. ! Define parameters 13. L, 1, 2 beam
2. L = 10 ! Length of the beam 14. L, 3, 4 23. FK, 2, FY, -100 ! Apply a force of -
3. H=1 ! Height of the beam 100 units (negative for downward
direction)
4. B=1 ! Width of the beam 15. ! Define areas for the beam (for
5. Midpoint = L / 2 ! Midpoint of the meshing)
beam 16. AL, 1, 2 24. /SOL ! Enter solution processor
25. ANTYPE,0 ! Static analysis
6. /PREP7 ! Enter preprocessor 17. ! Mesh the beam using beam 26. SOLVE ! Solve the system of
elements equations

7. ! Define keypoints for the beam 18. AMESH, ALL, BEAM


27. /FILNAME,Beam_output ! Specify
8. K, 1, 0, 0, 0 filename for output data
9. K, 2, L, 0, 0 19. ! Fix the left end of the beam (simply
supported) 28. /POST1 ! Enter
10. K, 3, 0, H, 0 postprocessor
20. DK, 1, ALL, 1
11. K, 4, L, H, 0 29. PRESOL, S ! Reconstruct
21. DK, 3, ALL, 1 the solution
12. ! Define lines for the beam
22. ! Apply a load at the midpoint of the

Engr. Saad Akram, DME, IST


Assignments 1
Write a code to make a beam with cross section area of 10mm^2 and
length 2m with one end fixed and other pulled with a force equals to
your roll number.

The code should be very effective in terms of computational cost

Engr. Saad Akram, DME, IST


Assignment 2
Write APDL script to study bending of a simply supported beam of 1m
with load at its center. Cross section area of 2 x 2 square beam with self
weight

Apply mesh convergence study as well

Engr. Saad Akram, DME, IST


Assignment 3
Write apdl code to make a Rectangular block of 2 x 2m with a hole of
radius 0.5m at center (Plane element 2D), With auto meshing and
refining it 9times, with one right side refined 12 times.

Comment on quality of meshing.

Apply load of 10KN on right side of body to study deformation and


stress

Engr. Saad Akram, DME, IST


Quiz 1 (In 3rd Week)
• From the Above Slides and help Videos

Engr. Saad Akram, DME, IST


Deadline: 6 March 2024
Submit assignment in txt file as a code on given drive link named as: “A1_Roll
number (Full).txt”
“A2_Roll number (Full).txt”
“A3_Roll number (Full).txt”

Drive Link:
https://drive.google.com/drive/folders/1uAqErjFQKKtxCJjUDGukbTxOOl62Ou3f?usp=sharing

Help Videos:
https://youtu.be/Fh0aeKKs8qA
https://youtu.be/UvcgdFp1yW0
https://youtu.be/TIeSLN8VPWI
https://www.youtube.com/watch?v=3dK9c3pfoh8 (steps for modal non included rest all)
https://www.youtube.com/watch?v=gKOEI5Hs-c4 (If need to learn extra)
Engr. Saad Akram, DME, IST

You might also like