!========================
! Initial programming setup before entering the loop
!========================
FINISH
/CLEAR
!========================
! 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.10 ! Initial mesh size
! We only want to write this section on the very top of our file
/cwd,'C:\....WRITE YOUR OWN PATH HERE' ! Changing working directory
*cfopen,answers.txt,,,append ! Open file, append (means add to end of file)
*vwrite,'Meshsize','XX','YY','XY','Von Mises' ! Write text
(A13,A13,A13,A13,A13,A13) ! A = string
!========================
! Start of loop
!========================
condition = 1 ! We want an infinite loop
*DOWHILE, condition ! Regular while loop with condition
*IF,mesh_size,EQ,0.01,EXIT ! If mesh_size == 0.01, exit loop
!========================
! Initial programming setup
!========================
! To clear area, mesh etc, but not all variables, we first write all variables to a separate file
! The reason for this is mainly because we want to keep the mesh_size and our condition
PARSAV,,param
FINISH
/CLEAR
! After clear, we read in the variables we had previously.
PARRES,,param
/PREP7
/UNITS, SI
!========================
! Making 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 plate
!========================
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
!========================
! 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
!========================
/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 2
!========================
! 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
mesh_size = mesh_size - 0.01 ! Decrease mesh size
*ENDDO ! End of while loop