Ansys Learning Forum › Forums › Discuss Simulation › General Mechanical › Extract Bolt Pretension Working Load with ANSYS APDL › Reply To: Extract Bolt Pretension Working Load with ANSYS APDL
total_nodes=0
ESEL,S,ENAME,,179 Â Â Â Â Â Â Â Â Â Â Â !select all pretension elements PRETS179
CM,bp_comp,ELEM Â Â Â Â Â Â Â Â Â Â Â Â !creates a component for the bolt pretension elements
NSLE,S,POS,3 Â Â Â Â Â Â Â Â Â Â Â Â Â Â !show/select head nodes for the pretension elements
CM,bphn_comp,NODE Â Â Â Â Â Â Â Â Â Â Â !creates a component for the bolt pretension head nodes
*GET,nr_nodes,NODE,0,COUNT Â Â Â Â Â Â Â !getting the number of head nodes
total_nodes=nr_nodes
*GET,NR_STEPS,ACTIVE,0,SET,NSET Â Â Â Â Â Â Â Â !get total number of time steps
*DIM,nids,ARRAY,nr_nodes,7 Â Â Â Â Â Â Â Â Â Â Â !array to store the forces
*DIM,bolt_force,ARRAY,NR_STEPS,nr_nodes+1 Â Â Â !array to store bolt forces
*IF,total_nodes,GE,1,THEN Â Â Â Â Â Â Â Â !if at least one bolt pretension exist in the model
  *DO,i,1,NR_STEPS
    SET,,,,,,,i
    *GET,time,ACTIVE,0,SET,TIME
    bolt_force(i,1)=time
    Â
    *DO,q,1,nr_nodes
      column = q+1
      *GET,nodes,NODE,0,NUM,MIN        !get minimum node number
      *GET,nx,NODE,nodes,LOC,X         !gets x coordinate of the node
      *GET,ny,NODE,nodes,LOC,Y         !gets y coordinate of the node
      *GET,nz,NODE,nodes,LOC,Z         !gets z coordinate of the node
      Â
      NSEL,S,NODE,,nodes            !select the identified head node
      Â
      my_force = 0
      *GET,my_force,NODE,nodes,RF,FX      !gets the bolt force
      bolt_force(i,column)=my_force
      CM,pproc_node,NODE            !creates component for the post processed head nodes
      ESLN                   !selects the pretnesion elements which are connected to the head node
      CM,pproc_sec,ELEM            !creates component for the post processed pretension elements
      my_elem=ELNEXT(0)            !select the first element from the list
      *GET,bpe_type,ELEM,my_elem,ATTR,TYPE   !get element type of the selected pretention elementÂ
      NSLE
      ESLN
      my_elem=ELNEXT(0)            !select the first element from the list
      !*GET,be_type,ELEM,my_elem,ATTR,TYPE   !get element type of the selected bolt element (issue with this approac when the bolt have two type of elements tetras and hex as they have different element id)Â
      *GET,mat_id,ELEM,my_elem,ATTR,MAT    !get material id of the selected solid bolt element
    Â
      nids(q,1)=q
      nids(q,2)=nodes
      nids(q,3)=mat_id
      nids(q,4)=bpe_type
      nids(q,5)=nx
      nids(q,6)=ny
      nids(q,7)=nz
    Â
      !unselect processed elements and nodes
      CMSEL,S,bp_comp
      CMSEL,U,pproc_sec
      CM,bp_comp,ELEM
      CMSEL,S,bphn_comp
      CMSEL,U,pproc_node
      CM,bphn_comp,NODE
      *GET,rem_nr_nodes,NODE,0,COUNT
      !/com, **rem_nr_nodes: %rem_nr_nodes%
      CMSEL,S,bphn_comp
      *ENDDO
    ALLSEL
    ESEL,S,ENAME,,179            !select all pretension elements PRETS179
    CM,bp_comp,ELEM             !creates a component for the bolt pretension elements
    NSLE,S,POS,3               !show/select head nodes for the pretension elements
    CM,bphn_comp,NODE Â
  *ENDDO
*ENDIF