Skip to content

Commit

Permalink
WIP: Cauchy-born sublattices are now set on unit cell before cluster
Browse files Browse the repository at this point in the history
built
  • Loading branch information
Fraser-Birks committed Sep 23, 2023
1 parent f19006e commit 4e068b3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions matscipy/fracture_mechanics/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,26 @@ def set_regions(cryst, r_I, cutoff, r_III, extended_far_field=False,extended_reg
return cryst

def cluster(el, a0, n, crack_surface=[1,1,0], crack_front=[0,0,1],
lattice=None, shift=None):
cb=None, lattice=None, shift=None,switch_sublattices=False):
nx, ny, nz = n
third_dir = np.cross(crack_surface, crack_front)
directions = [ third_dir, crack_surface, crack_front ]
if np.linalg.det(directions) < 0:
third_dir = -third_dir
directions = [ third_dir, crack_surface, crack_front ]
A = np.zeros([3,3])
for i, direc in enumerate(directions):
A[:,i] = direc/np.linalg.norm(direc)
#print('FINAL DIRECTIONS', directions)
unitcell = lattice(el, latticeconstant=a0, size=[1, 1, 1],
directions=directions )
directions=directions)
print('cell',unitcell.get_cell())
if shift is not None:
unitcell.translate(np.dot(shift, unitcell.cell))

if cb is not None:
cb.set_sublattices(unitcell,A)
if switch_sublattices:
cb.switch_sublattices(unitcell)
# Center cluster in unit cell
x, y, z = (unitcell.get_scaled_positions()%1.0).T
x += (1.0-x.max()+x.min())/2 - x.min()
Expand Down

0 comments on commit 4e068b3

Please sign in to comment.