diff --git a/src/scripts/n1_nanocrack.py b/src/scripts/n1_nanocrack.py index b00cbc6..6278c0e 100644 --- a/src/scripts/n1_nanocrack.py +++ b/src/scripts/n1_nanocrack.py @@ -1,17 +1,4 @@ - -# Vetores de rede (lattice constants) -a = 6.3028 -b = 4.9302 -lattice_constants = [a, b] - -# Parâmetros -unit_cell_file = 'src/simulations/unit_cell.xyz' -n_replications_x = 15 -n_replications_y = 15 - # Ler o arquivo XYZ - - def read_xyz(file): with open(file, 'r') as f: n_atoms = int(f.readline()) @@ -23,22 +10,26 @@ def read_xyz(file): return n_atoms, comment, atoms # Replicar a célula unitária com os nanocracks lineares (n1) - - def replicate_cell(atoms, lattice_constants, n_replications_x, n_replications_y): replicated_atoms = [] for i in range(n_replications_x): for j in range(n_replications_y): - for atom, position in atoms: - new_position = [ - position[0] + (lattice_constants[0]) * i, position[1] + (lattice_constants[1])*j, 0.0] + for index,(atom, position) in enumerate(atoms): + if i == 7: + atom = 'H' + if j < 7: + if j == 0: + new_position = [position[0] + (lattice_constants[0]) * i, position[1] + (lattice_constants[1])*j, 0.0] + else: + new_position = [ + position[0] + (lattice_constants[0]) * i, position[1] + (lattice_constants[1])*j, 0.0] replicated_atoms.append((atom, new_position)) + + return replicated_atoms # Escrever o arquivo .xyz - - -def escrever_xyz(file, n_atoms, comment, atoms): +def write_xyz(file, n_atoms, comment, atoms): with open(file, 'w') as f: f.write(str(n_atoms) + '\n') f.write(comment + '\n') @@ -49,6 +40,17 @@ def escrever_xyz(file, n_atoms, comment, atoms): f.write('{} {} {} {}\n'.format(atom, x, y, z)) +# Vetores de rede (lattice constants) +a = 6.3028 +b = 4.9302 +lattice_constants = [a, b] + +# 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) @@ -59,7 +61,7 @@ def escrever_xyz(file, n_atoms, comment, atoms): # Escrever o arquivo .xyz com a estrutura replicada OUTPUT_STRUCTURE_FILE = 'src/simulations/n1_nanocrack_structure.xyz' -escrever_xyz(OUTPUT_STRUCTURE_FILE, n_replications_x * +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( diff --git a/src/simulations/n1_nanocrack_structure.xyz b/src/simulations/n1_nanocrack_structure.xyz index c067b87..c818a2d 100644 --- a/src/simulations/n1_nanocrack_structure.xyz +++ b/src/simulations/n1_nanocrack_structure.xyz @@ -1,6 +1,5 @@ 2250 a = 6.3028 Å and b = 4.9302 Å - C 1.7314000000000003 0.7510083707151027 0.0000000000000000 C 3.1514000000000002 0.7510083707151027 0.0000000000000000 C 4.5714000000000006 0.7510083707151027 0.0000000000000000 @@ -1281,16 +1280,16 @@ C 53.5738000000000056 38.6905916292848957 0.0000000000000000 C 52.1538000000000039 38.6905916292848957 0.0000000000000000 C 51.1497083707151035 37.6865000000000023 0.0000000000000000 C 51.1497083707151035 36.2665000000000006 0.0000000000000000 -C 52.1538000000000039 40.1926083707151065 0.0000000000000000 -C 53.5738000000000056 40.1926083707151065 0.0000000000000000 -C 54.9938000000000073 40.1926083707151065 0.0000000000000000 -C 55.9978916292849007 41.1966999999999999 0.0000000000000000 -C 55.9978916292849007 42.6167000000000016 0.0000000000000000 -C 54.9938000000000073 43.6207916292848950 0.0000000000000000 -C 53.5738000000000056 43.6207916292848950 0.0000000000000000 -C 52.1538000000000039 43.6207916292848950 0.0000000000000000 -C 51.1497083707151035 42.6167000000000016 0.0000000000000000 -C 51.1497083707151035 41.1966999999999999 0.0000000000000000 +H 52.1538000000000039 40.1926083707151065 0.0000000000000000 +H 53.5738000000000056 40.1926083707151065 0.0000000000000000 +H 54.9938000000000073 40.1926083707151065 0.0000000000000000 +H 55.9978916292849007 41.1966999999999999 0.0000000000000000 +H 55.9978916292849007 42.6167000000000016 0.0000000000000000 +H 54.9938000000000073 43.6207916292848950 0.0000000000000000 +H 53.5738000000000056 43.6207916292848950 0.0000000000000000 +H 52.1538000000000039 43.6207916292848950 0.0000000000000000 +H 51.1497083707151035 42.6167000000000016 0.0000000000000000 +H 51.1497083707151035 41.1966999999999999 0.0000000000000000 C 52.1538000000000039 45.1228083707151058 0.0000000000000000 C 53.5738000000000056 45.1228083707151058 0.0000000000000000 C 54.9938000000000073 45.1228083707151058 0.0000000000000000