Skip to content

Commit

Permalink
WIP: Made it so assigned groups always works regardless of size
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser-Birks committed Jan 25, 2024
1 parent a229c65 commit 7231f8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions matscipy/fracture_mechanics/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,18 @@ def generate_3D_cubic_111(cryst_2D, nzlayer, el, a0, lattice, crack_surface,
def set_groups(a, n, skin_x, skin_y, central_x=-1. / 2, central_y=-1. / 2,
invert_central=False):
nx, ny, nz = n
sx, sy, sz = a.cell.diagonal()
#sx, sy, sz = a.cell.diagonal()
#get sx and sy instead from looking directly at atoms
sx = np.max(a.positions[:, 0]) - np.min(a.positions[:, 0])
sy = np.max(a.positions[:, 1]) - np.min(a.positions[:, 1])
print('skin_x = {0}*a0, skin_y = {1}*a0'.format(skin_x, skin_y))
skin_x = skin_x * sx / nx
skin_y = skin_y * sy / ny
print('skin_x = {0}, skin_y = {1}'.format(skin_x, skin_y))
r = a.positions
r = a.get_positions()
#shift r such that the min x and y values are 0
r[:, 0] -= np.min(r[:, 0])
r[:, 1] -= np.min(r[:, 1])

g = np.ones(len(a), dtype=int)
mask = np.logical_or(
Expand Down
2 changes: 1 addition & 1 deletion matscipy/fracture_mechanics/thin_strip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def build_thin_strip(self,width,height,thickness,vacuum):
self.trackable_atoms_mask = crack_slab.arrays['trackable']
#ase.io.write('1_slab.xyz',crack_slab)
#set groups (useful later for crack tip determination)
set_groups(crack_slab,[nx,ny,nz],20,10)
set_groups(crack_slab,[nx,ny,nz],int(nx/5),int(ny/5))
self.group_array = crack_slab.arrays['groups']
crack_slab.set_pbc((False,False,True))
return crack_slab
Expand Down

0 comments on commit 7231f8f

Please sign in to comment.