! Author: Chana Sinsabvarodom
! Edited by: Jon Arnt Kårstad
!========================
! Initial programming setup
FINISH
/CLEAR
/PREP7
/UNITS, SI
!========================
! Defining the variables
!========================
L=0.6 ! Length [m]
H=0.2 ! Height [m]
t=0.005 ! Thickness [m]
Diameter = H*0.3 ! Diameter of hole [m]
Length2hole = L*0.5 ! Length to hole [m]
P=-50e6*t ! Load, we will use as a pressure load [Pa] (positive - compression, negative - tension)
mesh_size=0.01 ! Mesh size
! Making the plate
K,,0,-H/2,0 ! Lower left node
K,,L,-H/2,0 ! Lower right node
K,,L,H/2,0 ! Upper right node
K,,0,H/2,0 ! Upper left node
A,1,2,3,4 ! Making an area from our nodes (notice the order)
CYL4,Length2hole,0,Diameter/2, ! Make cylinder
ASBA,1,2 ! Remove area 2 (cylinder) from area 1 (plate)
!========================
! Defining the material data (here aluminium)
!========================
MPTEMP,1,0
MPDATA,EX,1,,0.69e11 ! Young's modulus [Pa]
MPDATA,PRXY,1,,0.3 ! Poisson's ratio [-]
MPDATA,DENS,1,,2700 ! Density [kg/m^3]
!========================
! Define local element type
!========================
ET,1,SHELL181 ! Shell element, both bending and membrane stresses
!========================
! Connecting area to component
!========================
ASEL,S,LOC,Z,0 ! Select area at z = 0
CM,PLATE,AREA ! Group geometry into component
ALLSEL,ALL ! Select all
!========================
! Assigning a thickness to the membrane
!========================
SECTYPE,1,SHELL,,PLATE ! Associates section type information with a section ID number.
SECDATA,T,1,0,3 ! Given section data
SECOFFSET,MID ! Define section offset for cross section
!========================
! Defining the mesh
!========================
ESIZE,MESH_SIZE ! Element size
TYPE,1 ! Set element type pointer
SECNUM,1 ! Set element section attribute pointer
CMSEL,S,PLATE,AREA ! Select component named plate (of type area)
AMESH,PLATE ! Mesh plate
/ESHAPE,1
!========================
! Body weight
!========================
ACEL,0,0,9.81 ! Include gravity
!========================
! Load
!========================
LSEL,S,LOC,X,L ! Line select at x = L
SFL,ALL,PRES,P ! Apply pressure load to line selected
!========================
! Boundary conditions (Select All X)
!========================
NSEL,S,LOC,X,0 ! Select all nodes at x = 0
D,ALL,,0,,,,UX,UZ,UY,ROTX,ROTY,ROTZ
ALLSEL,ALL
!========================
! Solution
!========================
! Notice that from now on we write only lower case letters
! APDL does does not differentiate between letter cases (lower or upper, 'A' or 'a')
! It therefore does not matter here, but care, it may cause trouble when working with variables
/solu ! Enter solution processor
solve ! Start a solution
/post1 ! Enters database results postprocessor
/gline,,-1 ! Don't show element lines (0 - solid lines, 1 - dashed lines)
plnsol,s,eqv ! Display results as continous element contours
!========================
! Write results to text file
!========================
! When writing a file, it is often clever to specify where you want to store the file first
/cwd,'C:\....WRITE YOUR OWN PATH HERE' ! Changing working directory
*cfopen,answers.txt,,,append ! Open file, append (means add to end of file)
!========================
! Example task 1
!========================
*vwrite,'Meshsize','XX','YY','XY','Von Mises' ! Write text
(A13,A13,A13,A13,A13,A13) ! A = string
! Above we need to specify how much space we want to give the text. The text is then right-aligned
! x = L/2 and y = H/2 -> mid top node
s1=node(L/2, H/2, 0) ! Select node
*GET,normal_stress_x,node,s1,s,x ! Results Stress X (sigma_x)
*GET,normal_stress_y,node,s1,s,y ! Results Stress Y (sigma_y)
*GET,shear_stress,node,s1,s,xy ! Results Stress XY (tau_xy)
*GET,stress_von_mises,node,s1,s,eqv ! Results Stress Von Mises
*vwrite,mesh_size,normal_stress_x,normal_stress_y,shear_stress,stress_von_mises
(E13.3,E13.3,E13.3,E13.3,E13.3) ! E = number (sci)
*cfclos ! Close file