Skip to content

Commit

Permalink
feat: pytest config
Browse files Browse the repository at this point in the history
  • Loading branch information
caefleury committed Mar 14, 2024
1 parent d7c354e commit 4fe46d0
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__pycache__
__pycache__
.vscode
.pytest_cache
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# PIBITI - SIMULACOES

Repositório para armazenar as simulações do projeto de PIBITI focado em simulações termodinâmicas em estruturas nanomoleculares.
Repositório com as simulações do projeto de PIBITI focado em simulações termodinâmicas em estruturas nanomoleculares.

### Título do projeto : Propriedades Físicas de Sistemas Nanoestruturados na Presença de Defeitos

- ### Início: Setembro 2023
- ### Fim: Setembro 2024

## Objetivos:

- Criar a célula unitário do R10-Graphene em arquivo .xyz
- Gerar a estrutura padrão de uma folha de R10-Grapehene com um script genético
- Gerar estruturas com rasgos
- Gerar estruturas com rasgos (nanocracks)

## Configurações iniciais

Expand All @@ -28,35 +33,35 @@ Subistituir `$PWD` pelo caminho até o repositorio. Exemplo: `/home/my_user/.../

## Como rodar o arquivo genético:

Em src/scripts/replicate.py altere número de replicações em cada direção mudando o valor das variáveis `n_replications_x` e `n_replications_y`.
Em src/scripts/replicate.py altere número de replicações em cada direção mudando o valor das variáveis `n_replications_x` e `n_replications_y`:

```
n_replications_x = 17 # alterar replicações na direção x
n_replications_y = 19 # alterar replicações na direção y
```

Acessar a pasta e executar o arquivo replicate.py
Acessar a pasta e executar o arquivo replicate.py:

```
python3 replicate.py
```

## Como rodar os arquivos com rasgos:

Em src/scripts acesse os arquivos n1_nanocrack e n2_nanocrack e altere número de replicações em cada direção mudando o valor das variáveis `n_replications_x` e `n_replications_y`.
Em src/scripts acesse os arquivos n1_nanocrack e n2_nanocrack e altere número de replicações em cada direção mudando o valor das variáveis `n_replications_x` e `n_replications_y`:

```
n_replications_x = 17 # alterar replicações na direção x
n_replications_y = 19 # alterar replicações na direção y
```

Para mudar o tamanho do rasgo central altere o valor da varíavel `crack_size`
Para mudar o tamanho do rasgo central altere o valor da varíavel `crack_size`:

```
crack_size = 9 # alterar o tamanho do rasgo
```

Acessar a pasta e executar o arquivo com a simulação do rasgo
Acessar a pasta e executar o arquivo com a simulação do rasgo:

```
python3 <nome_do_arquivo>.py
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
pythonpath = . src
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
flake8
autopep8
autopep8
pytest
5 changes: 2 additions & 3 deletions src/scripts/n1_nanocrack.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

import sys
sys.path.append('./src/utils')
from utils import *

from my_utils import read_xyz,write_xyz
from n1_crack import center_crack


Expand Down
6 changes: 2 additions & 4 deletions src/scripts/n2_nanocrack.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@


import sys
sys.path.append('./src/utils')
from utils import read_xyz,write_xyz
from n2_crack import *
from my_utils import read_xyz,write_xyz
from n2_crack import left_crack,center_crack,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):
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/replicate_cell.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

from utils import read_xyz, write_xyz

import sys
sys.path.append('./src/utils')
from utils import read_xyz, write_xyz

# Replicar a célula unitária

Expand Down
1 change: 0 additions & 1 deletion src/tests/cracks/n2_crack.py

This file was deleted.

8 changes: 3 additions & 5 deletions src/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
__all__ = [
'n1_crack',
'n2_crack',
'utils'
]
__all___ = [
'my_utils'
]
File renamed without changes.
1 change: 1 addition & 0 deletions src/utils/n1_crack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


def center_crack(y_index, atom, n_replications_y, crack_size, atom_index, new_position):
floor = int(n_replications_y//2 - ((crack_size - 1)/2))
ceiling = int(n_replications_y//2 + ((crack_size - 1)/2))
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions tests/replicate_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@


import pytest

from utils.my_utils import read_xyz

class TestReplicate():
def test_read():
test_file = 'tests/test_read.xyz'
number_of_atoms, comment, atom_list = read_xyz(test_file)
assert number_of_atoms == 10
assert comment == 'a = 6.3028 Å and b = 4.9302 Å\n'
assert atom_list == [
('C', [1.7314000000000003, 0.7510083707151027, 0.0]),
('C', [3.1514, 0.7510083707151027, 0.0]),
('C', [4.571400000000001, 0.7510083707151027, 0.0]),
('C', [5.5754916292848975, 1.7551, 0.0]),
('C', [5.5754916292848975, 3.1751, 0.0]),
('C', [4.571400000000001, 4.179191629284897, 0.0]),
('C', [3.1514, 4.179191629284897, 0.0]),
('C', [1.7314000000000003, 4.179191629284897, 0.0]),
('C', [0.7273083707151029, 3.1751, 0.0]),
('C', [0.7273083707151029, 1.7551, 0.0])]

12 changes: 12 additions & 0 deletions tests/test_read.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
10
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
C 5.5754916292848975 1.7551000000000001 0.0000000000000000
C 5.5754916292848975 3.1751000000000000 0.0000000000000000
C 4.5714000000000006 4.1791916292848974 0.0000000000000000
C 3.1514000000000002 4.1791916292848974 0.0000000000000000
C 1.7314000000000003 4.1791916292848974 0.0000000000000000
C 0.7273083707151029 3.1751000000000000 0.0000000000000000
C 0.7273083707151029 1.7551000000000001 0.0000000000000000

0 comments on commit 4fe46d0

Please sign in to comment.