Skip to content

Commit

Permalink
feat: bidirectional cracks
Browse files Browse the repository at this point in the history
  • Loading branch information
caefleury committed Mar 28, 2024
1 parent 08b07e3 commit 82b3d96
Show file tree
Hide file tree
Showing 12 changed files with 9,680 additions and 162 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,26 @@ Acessar a pasta e executar o arquivo com a simulação do rasgo:
```
python3 <nome_do_arquivo>.py
```

## VMD Scripting

### set – Setting the unitcell parameters

To be able to work correctly, all other procedures of the PBCTools plugin require the VMD unitcell parameters to be set. Some file formats and their readers provide the necessary information (e.g. the DCD, VTF and Amber crdbox formats). When the format does not provide the information, the parameters can either be set with help of the command pbc set, or they can be read in from a file in XST format via the procedure pbc readxst (see section 5).

Syntax:

```
pbc set cell [options…]
```
Description

Sets the VMD unit cell properties to cell in the specified frames. cell must either contain a single set of unit cell parameters that will be used in all frames of the molecule, or it must contain a parameter set for every frame.

Example

Set the unit cell side length to 10 in all frames:

```
pbc set {10.0 10.0 10.0}
```
16 changes: 16 additions & 0 deletions src/scripts/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

import n1_crack
import n2_crack
import n1_edge_crack
import replicate_cell

if __name__ == "__main__":
print()
print("============================== Gerando Estruturas ==============================\n")
n1_crack.run('x')
n1_crack.run('y')
n1_edge_crack.run()
n2_crack.run('y')
replicate_cell.run()
print()
print("\033[1;32m" + "============================== Estruturas replicadas ===========================" + "\033[0m")
52 changes: 30 additions & 22 deletions src/scripts/n1_crack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


# 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,crack_direction):
def replicate_n1_crack(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):
Expand Down Expand Up @@ -35,31 +35,39 @@ def replicate_cell(atoms, lattice_constants, n_replications_x, n_replications_y,

return [len(replicated_atoms), replicated_atoms]

def run(crack_direction):
# Parâmetros
INPUT_UNIT_CELL_FILE = 'src/simulations/unit_cell.xyz'

# Parâmetros
INPUT_UNIT_CELL_FILE = 'src/simulations/unit_cell.xyz'
OUTPUT_STRUCTURE_FILE = 'src/simulations/n1_crack_structure.xyz'
n_replications_x = 17
n_replications_y = 19
crack_size = 9
crack_direction = 'y'
n_replications_x = 17
n_replications_y = 21
crack_size = 7

# Ler a célula unitária
n_atoms, comment, atoms = read_xyz(INPUT_UNIT_CELL_FILE)
# Ler a célula unitária
n_atoms, comment, atoms = read_xyz(INPUT_UNIT_CELL_FILE)

# Vetores de rede (lattice constants)
a = float(comment.split()[2])
b = float(comment.split()[-2])
lattice_constants = [a, b]
# Vetores de rede (lattice constants)
a = float(comment.split()[2])
b = float(comment.split()[-2])
lattice_constants = [a, b]

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

n_atoms_modified = replicated_atoms[0]
atoms_modified = replicated_atoms[1]
replicated_atoms = replicate_n1_crack(
atoms, lattice_constants, n_replications_x, n_replications_y, crack_size,crack_direction)

# Escrever o arquivo .xyz com a estrutura replicada
write_xyz(OUTPUT_STRUCTURE_FILE, n_atoms_modified, comment, atoms_modified)
n_atoms_modified = replicated_atoms[0]
atoms_modified = replicated_atoms[1]

print('Estrutura n1 replicada, arquivo salvo em {}'.format(OUTPUT_STRUCTURE_FILE))
# Escrever o arquivo .xyz com a estrutura replicada
if crack_size == 1:
OUTPUT_STRUCTURE_FILE = 'src/simulations/center_crack_structure.xyz'
elif crack_direction == 'x':
OUTPUT_STRUCTURE_FILE = 'src/simulations/n1_x_crack_structure.xyz'
else:
OUTPUT_STRUCTURE_FILE = 'src/simulations/n1_y_crack_structure.xyz'

write_xyz(OUTPUT_STRUCTURE_FILE, n_atoms_modified, comment, atoms_modified)


print('Estrutura com rasgo n1 replicada no eixo {}, arquivo salvo em {}'.format(crack_direction,OUTPUT_STRUCTURE_FILE))
44 changes: 22 additions & 22 deletions src/scripts/n1_edge_crack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


# 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_edge_crack(atoms, lattice_constants, n_replications_x, n_replications_y, crack_size):
replicated_atoms = []
for x in range(n_replications_x):
for y in range(n_replications_y):
Expand All @@ -25,30 +25,30 @@ def replicate_cell(atoms, lattice_constants, n_replications_x, n_replications_y,

return [len(replicated_atoms), replicated_atoms]

def run():
# Parâmetros
INPUT_UNIT_CELL_FILE = 'src/simulations/unit_cell.xyz'
OUTPUT_STRUCTURE_FILE = 'src/simulations/n1_edge_crack_structure.xyz'
n_replications_x = 17
n_replications_y = 21
crack_size = 9

# Parâmetros
INPUT_UNIT_CELL_FILE = 'src/simulations/unit_cell.xyz'
OUTPUT_STRUCTURE_FILE = 'src/simulations/n1_edge_crack_structure.xyz'
n_replications_x = 17
n_replications_y = 19
crack_size = 9
# Ler a célula unitária
n_atoms, comment, atoms = read_xyz(INPUT_UNIT_CELL_FILE)

# Ler a célula unitária
n_atoms, comment, atoms = read_xyz(INPUT_UNIT_CELL_FILE)
# Vetores de rede (lattice constants)
a = float(comment.split()[2])
b = float(comment.split()[-2])
lattice_constants = [a, b]

# Vetores de rede (lattice constants)
a = float(comment.split()[2])
b = float(comment.split()[-2])
lattice_constants = [a, b]
# Replicar a célula unitária
replicated_atoms = replicate_edge_crack(
atoms, lattice_constants, n_replications_x, n_replications_y, crack_size)

# Replicar a célula unitária
replicated_atoms = replicate_cell(
atoms, lattice_constants, n_replications_x, n_replications_y, crack_size)
n_atoms_modified = replicated_atoms[0]
atoms_modified = replicated_atoms[1]

n_atoms_modified = replicated_atoms[0]
atoms_modified = replicated_atoms[1]
# Escrever o arquivo .xyz com a estrutura replicada
write_xyz(OUTPUT_STRUCTURE_FILE, n_atoms_modified, comment, atoms_modified)

# Escrever o arquivo .xyz com a estrutura replicada
write_xyz(OUTPUT_STRUCTURE_FILE, n_atoms_modified, comment, atoms_modified)

print('Estrutura n1 replicada, arquivo salvo em {}'.format(OUTPUT_STRUCTURE_FILE))
print('Estrutura com rasgo em borda n1 replicada, arquivo salvo em {}'.format(OUTPUT_STRUCTURE_FILE))
45 changes: 22 additions & 23 deletions src/scripts/n2_crack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from n2_crack_utils import y_left_crack, y_center_crack, y_right_crack,x_left_crack, x_center_crack, x_right_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_n2_crack(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):
Expand Down Expand Up @@ -56,31 +56,30 @@ def replicate_cell(atoms, lattice_constants, n_replications_x, n_replications_y,

return [len(replicated_atoms), replicated_atoms]

def run(crack_direction):
# Parâmetros
INPUT_UNIT_CELL_FILE = 'src/simulations/unit_cell.xyz'
OUTPUT_STRUCTURE_FILE = 'src/simulations/n2_crack_structure.xyz'
n_replications_x = 17
n_replications_y = 21
crack_size = 9

# Parâmetros
INPUT_UNIT_CELL_FILE = 'src/simulations/unit_cell.xyz'
OUTPUT_STRUCTURE_FILE = 'src/simulations/n2_crack_structure.xyz'
n_replications_x = 17
n_replications_y = 19
crack_size = 9
crack_direction = 'y'
# Ler a célula unitária
n_atoms, comment, atoms = read_xyz(INPUT_UNIT_CELL_FILE)

# Ler a célula unitária
n_atoms, comment, atoms = read_xyz(INPUT_UNIT_CELL_FILE)
# Vetores de rede (lattice constants)
a = float(comment.split()[2])
b = float(comment.split()[-2])
lattice_constants = [a, b]

# Vetores de rede (lattice constants)
a = float(comment.split()[2])
b = float(comment.split()[-2])
lattice_constants = [a, b]
# Replicar a célula unitária
replicated_atoms = replicate_n2_crack(
atoms, lattice_constants, n_replications_x, n_replications_y, crack_size,crack_direction)

# Replicar a célula unitária
replicated_atoms = replicate_cell(
atoms, lattice_constants, n_replications_x, n_replications_y, crack_size)
n_atoms_modified = replicated_atoms[0]
atoms_modified = replicated_atoms[1]

n_atoms_modified = replicated_atoms[0]
atoms_modified = replicated_atoms[1]
# Escrever o arquivo .xyz com a estrutura replicada
write_xyz(OUTPUT_STRUCTURE_FILE, n_atoms_modified, comment, atoms_modified)

# Escrever o arquivo .xyz com a estrutura replicada
write_xyz(OUTPUT_STRUCTURE_FILE, n_atoms_modified, comment, atoms_modified)

print('Estrutura n2 replicada, arquivo salvo em {}'.format(OUTPUT_STRUCTURE_FILE))
print('Estrutura com rasgo n2 replicada, arquivo salvo em {}'.format(OUTPUT_STRUCTURE_FILE))
40 changes: 20 additions & 20 deletions src/scripts/replicate_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ def replicate_cell(atoms, lattice_constants, n_replications_x, n_replications_y)
replicated_atoms.append((atom, new_position))
return replicated_atoms

def run():
# Parâmetros
unit_cell_file = 'src/simulations/unit_cell.xyz'
n_replications_x = 17
n_replications_y = 21

# Parâmetros
unit_cell_file = 'src/simulations/unit_cell.xyz'
n_replications_x = 15
n_replications_y = 15
# Ler a célula unitária
n_atoms, comment, atoms = read_xyz(unit_cell_file)

# Ler a célula unitária
n_atoms, comment, atoms = read_xyz(unit_cell_file)
# Vetores de rede (lattice constants)
a = float(comment.split()[2])
b = float(comment.split()[-2])
lattice_constants = [a, b]

# Vetores de rede (lattice constants)
a = float(comment.split()[2])
b = float(comment.split()[-2])
lattice_constants = [a, b]
# Replicar a célula unitária
replicated_atoms = 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)

# Escreva o arquivo .xyz com a estrutura replicada
OUTPUT_STRUCTURE_FILE = 'src/simulations/structure.xyz'
# Escreva o arquivo .xyz com a estrutura replicada
OUTPUT_STRUCTURE_FILE = 'src/simulations/pristine_structure.xyz'

write_xyz(OUTPUT_STRUCTURE_FILE, n_replications_x *
n_replications_y * n_atoms, comment, replicated_atoms)
write_xyz(OUTPUT_STRUCTURE_FILE, n_replications_x *
n_replications_y * n_atoms, comment, replicated_atoms)

print('Estrutura replicada com sucesso! arquivo salvo em {}'.format(
OUTPUT_STRUCTURE_FILE))
print('Estrutura "pristine" replicada com sucesso! arquivo salvo em {}'.format(
OUTPUT_STRUCTURE_FILE))
Loading

0 comments on commit 82b3d96

Please sign in to comment.