Skip to content

Commit

Permalink
feat: n1_crack x direction
Browse files Browse the repository at this point in the history
  • Loading branch information
caefleury committed Mar 20, 2024
1 parent 57a5df2 commit d8e4d43
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 133 deletions.
29 changes: 20 additions & 9 deletions src/scripts/n1_crack.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@


from my_utils import read_xyz, write_xyz
from n1_crack_utils import center_crack
from n1_crack_utils import y_center_crack,x_center_crack


# Replicar a célula unitária com os nanocracks lineares (n2)
def replicate_cell(atoms, lattice_constants, n_replications_x, n_replications_y, crack_size):
def replicate_cell(atoms, lattice_constants, n_replications_x, n_replications_y, crack_size,crack_direction):
replicated_atoms = []
for x in range(n_replications_x):
for y in range(n_replications_y):
for index, (atom, position) in enumerate(atoms):
# POSICOES PERMANECEM CONSTANTES
new_position = [
position[0] + (lattice_constants[0]) * x, position[1] + (lattice_constants[1]) * y, 0.0]
if crack_direction == 'y':
if x == (n_replications_x // 2):
if y_center_crack(y, atom, n_replications_y, crack_size, index, new_position):
atom, new_position = y_center_crack(
y, atom, n_replications_y, crack_size, index, new_position)
replicated_atoms.append((atom, new_position))
else:
replicated_atoms.append((atom, new_position))

if x == (n_replications_x // 2):
if center_crack(y, atom, n_replications_y, crack_size, index, new_position):
atom, new_position = center_crack(
y, atom, n_replications_y, crack_size, index, new_position)
elif crack_direction == 'x':
if y == (n_replications_y // 2):
if x_center_crack(x, atom, n_replications_x, crack_size, index, new_position):
atom, new_position = x_center_crack(
x, atom, n_replications_x, crack_size, index, new_position)
replicated_atoms.append((atom, new_position))
else:
replicated_atoms.append((atom, new_position))

else:
replicated_atoms.append((atom, new_position))


return [len(replicated_atoms), replicated_atoms]

Expand All @@ -32,6 +42,7 @@ def replicate_cell(atoms, lattice_constants, n_replications_x, n_replications_y,
n_replications_x = 17
n_replications_y = 19
crack_size = 9
crack_direction = 'x'

# Ler a célula unitária
n_atoms, comment, atoms = read_xyz(INPUT_UNIT_CELL_FILE)
Expand All @@ -43,7 +54,7 @@ def replicate_cell(atoms, lattice_constants, n_replications_x, n_replications_y,

# Replicar a célula unitária
replicated_atoms = replicate_cell(
atoms, lattice_constants, n_replications_x, n_replications_y, crack_size)
atoms, lattice_constants, n_replications_x, n_replications_y, crack_size,crack_direction)

n_atoms_modified = replicated_atoms[0]
atoms_modified = replicated_atoms[1]
Expand Down
Loading

0 comments on commit d8e4d43

Please sign in to comment.