Data Files for “Fragmentation Analysis” Example

fragment.p3dat

; fname: fragment.p3dat
;
; Illustrate how the Fragment, DFN and Model Result logic can be used
; to study the fragmentation of a Bonded Particle Model.
;
;=============================================================================
model new
model precision 15
model title 'Fragmentation of a Bonded Particle Model'

;-----------------------------------------------------------------------------
; -------------- INITIAL PHASE: CREATION OF A BONDED SPECIMEN ----------------
;-----------------------------------------------------------------------------

model domain extent -5 5 -5 5 -7.5 7.5 condition destroy
contact cmat proximity 0.1
contact cmat default model linear property kn 1e7
contact cmat default type ball-ball model linearpbond ...
                                    property kn 5e6

wall generate box -2.5 2.5 -2.5 2.5 -5 5
model random 10001
ball distribute porosity 0.3 radius 0.25 0.3 box -2.5 2.5 -2.5 2.5 -5 5
ball attribute density 1.0e3 damp 0.7
model cycle 2000 calm 10
model solve calm 1000 ratio-average 5e-3

contact method bond gap 0.1
contact property pb_kn 1e7 pb_ks 1e7 pb_ten 4e5 pb_coh 4e5 pb_fa 20.0

wall delete
contact cmat default type ball-facet model linear ...
                                     property kn 1e7 ks 1e7 fric 0.5

wall generate id 1 name 'top' polygon -4.0 -4.0 5.0 ...
                                      -4.0  4.0 5.0 ...
                                       4.0  4.0 5.0 ...
                                       4.0 -4.0 5.0


wall generate id 2 name 'bottom' polygon -4.0 -4.0 -5.0 ...
                                         -4.0  4.0 -5.0 ...
                                          4.0  4.0 -5.0 ...
                                          4.0 -4.0 -5.0

wall attribute rotation-center 0.0 0.0  5.0 range position-z  5.0
wall attribute rotation-center 0.0 0.0 -5.0 range position-z -5.0
model clean
model cycle 10
model solve elastic ratio-average 5e-3
wall attribute velocity-z 0.0 gradient 0.0 0.0 -0.001
model history name 1 mechanical time-total
wall history name 2 force-contact id 1
wall history name 3 force-contact id 2
model save 'initial'

;-----------------------------------------------------------------------------
; ----------- CASE 0: NO TRACKING OF FRAGMENTS - NO BALL RESULTS -------------
;-----------------------------------------------------------------------------
model solve time 50.0
model save 'final-case0'

;-----------------------------------------------------------------------------
; ----------- CASE 1: CONTINUOUS UPDATE OF FRAGMENTS WITH BALL RESULTS -------
;-----------------------------------------------------------------------------
model restore 'initial'

fragment register ball-ball
fragment activate time 0.1
model mechanical time-total 0.0
model result interval mechanical 0.1 
model result warn off interval active true 
ball result add-attribute fragment active true
wall result add-attribute velocity active true
model solve time 50.0
model save 'final-case1'

;program call 'post_treat.p3fis'
;@make_movie_case1

;-----------------------------------------------------------------------------
; ----------- CASE 2: CUSTOM UPDATE OF FRAGMENTS AND BALL RESULTS ------------
;-----------------------------------------------------------------------------
model restore 'initial'

program call 'fracture.p3fis'
@track_init
model solve time 50.0
@track_end
model save 'final-case2'

;program call 'post_treat.p3fis'
;@make_movie_case2

return 
;=============================================================================
; eof: fragment.p3dat

fracture.p3fis

; fname: fracture.p3fis
;
; Simple environment to track fragmentation in a BPM.
; Monitor LinearPBond model "bond_break" events and turn them into fractures.
; Use the Fragment and Ball Result logic to record fragment IDs 
;
;=============================================================================

fish define add_crack(entries)
  local contact    = entries(1)
  local mode       = entries(2)
  local strength   = entries(3)
  local frac_pos   = contact.pos(contact)
  local norm       = contact.normal(contact)
  local dfn_label  = 'crack'
  local frac_dip
  local frac_dipdir
  local frac_size = contact.prop(contact,'pb_radius')
  
  local len2 = math.sqrt(comp.x(norm)*comp.x(norm)+comp.y(norm)*comp.y(norm))
  if len2 = 0
    len2 = 1
  endif
  frac_dipdir = math.atan2(comp.x(norm)/len2,comp.y(norm)/len2) / math.degrad
  local len3 = math.sqrt(len2*len2+comp.z(norm)*comp.z(norm))
  if len3 = 0
    len3 = 1
  endif
  frac_dip = math.atan2(len2/len3,comp.z(norm)/len3) / math.degrad
  if frac_dip<0.0
    frac_dip = -frac_dip
    frac_dipdir = frac_dipdir + 180.0
  endif
  if frac_dip>90.0
    frac_dip = 180.0-frac_dip
    frac_dipdir = frac_dipdir + 180.0
  endif
  if frac_dipdir<0.0
    frac_dipdir = frac_dipdir + 360.0
  endif
  if frac_dipdir > 360.0
    frac_dipdir = frac_dipdir - 360.0
  endif
  if mode = 1 then 
    ; failed in tension
    dfn_label = dfn_label + '_tension'
  else if mode = 2 then
    ; failed in shear
    dfn_label = dfn_label + '_shear'
  endif
  local arg = array.create(5)
  arg(1) = 'disk'
  arg(2) = frac_pos
  arg(3) = frac_size
  arg(4) = frac_dip
  arg(5) = frac_dipdir 

  global dfn = dfn.find(dfn_label)
  if dfn = null then
    dfn = dfn.create(dfn_label)
  endif
  local fnew = fracture.create(dfn,arg)
  fracture.prop(fnew,'failure_strength') = strength
  fracture.prop(fnew,'age')  = mech.time.total
  crack_added = true
end

fish define monitor
  if crack_added = true then
    local numfrag = fragment.num()
    command 
      fragment compute
    endcommand
    if fragment.num() # numfrag then
      command
        model result export @track_fname
      endcommand
      map.add(track_map,mech.time.total,numfrag)
    endif
  endif
  crack_added = false
end

fish define track_fname
  track_fcount += 1
  track_fname = string.build('frag%1.p3result',track_fcount)
end

fish define track_init
  command
    fracture delete
    model result clear-map
    fragment clear
    fragment register ball-ball
    ball result add-attribute fragment active true
    wall result add-attribute velocity active true
  endcommand
  ; activate fishcalls
  command
    fish callback remove @add_crack event bond_break
    fish callback add @add_crack event bond_break
    fish callback remove @monitor 100.0
    fish callback add @monitor 100.0
  endcommand
  ; reset global variables
  global crack_added = false
  global track_fcount = 0
  command
    fragment compute
    model result export @track_fname
  endcommand
  global track_map = map(mech.time.total,fragment.num(1))
end

fish define track_end
  local numfrag = fragment.num()
  command 
    fragment compute
  endcommand
  if fragment.num() # numfrag then
    command
      model result export @track_fname
    endcommand
    map.add(track_map,mech.time.total,numfrag)
  endif
  make_table
end

fish define make_table
  local frag1 = fragment.find(1)
  local tab = table.create('volfrag1')
  loop foreach local value map.keys(track_map)
    table(tab,value) = ...
       fragment.vol(frag1,fragment.catalog.num(value)) / fragment.vol(frag1,1)
  endloop
end

;=============================================================================
; eof: fracture.p3fis

post_treat.p3fis

fish define make_movie_case1
  command
    program echo off
    model result map @track_map
  endcommand
  local count = 1
  loop foreach local value track_map
    global fname = string.build('fragments_case1_%1.png',count)
    command
      model domain extent -10 10
      model result import @count skip-fish
      plot 'system' export bitmap filename @fname 
    endcommand
    count += 1
  endloop
  command
    program echo on
  endcommand
end

fish define make_movie_case2
  local keys = map.keys(track_map)
  local count = 1
  command
    program echo off
  endcommand
  loop foreach value keys
    local fname = string.build('fragments_case2_%1.png',count)
    command
      model domain extent -10 10
      model result import [string.build('frag%1.p3result',count)] skip-fish
      plot 'system' export bitmap filename @fname 
    endcommand
    count += 1
  endloop
  command
    program echo on
  endcommand
end