Skip to content

Commit 9e601e2

Browse files
committed
Merge branch 'master' of github.com:SSCHAcode/python-sscha
2 parents c68f214 + dcaf70a commit 9e601e2

10 files changed

Lines changed: 1044 additions & 14 deletions

File tree

.github/workflows/python-testsuite.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,39 @@ jobs:
1313
build:
1414

1515
runs-on: ubuntu-latest
16+
1617
strategy:
1718
matrix:
1819
python-version: [3.8]
20+
21+
services:
22+
rabbitmq:
23+
image: rabbitmq:latest
24+
ports:
25+
- 5672:5672
1926

2027
steps:
2128
- uses: actions/checkout@v2
29+
2230
- name: Set up Python ${{ matrix.python-version }}
2331
uses: actions/setup-python@v2
2432
with:
2533
python-version: ${{ matrix.python-version }}
34+
2635
- name: Install dependencies
2736
run: |
2837
python -m pip install --upgrade pip
29-
pip install flake8 pytest
38+
pip install flake8 pytest~=6.0 pgtest~=1.3 aiida-core~=2.3 aiida-quantumespresso~=4.3
3039
if [ ${{matrix.python-version}} -eq 2.7 ]; then pip install -r requirements2.txt;
3140
else pip install -r requirements.txt; fi
41+
3242
- name: Lint with flake8
3343
run: |
3444
# stop the build if there are Python syntax errors or undefined names
3545
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3646
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3747
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
48+
3849
- name: Install
3950
run: |
4051
sudo apt-get update
@@ -45,9 +56,11 @@ jobs:
4556
cd ..
4657
4758
python setup.py install --user
59+
4860
- name: Test with pytest
61+
env:
62+
OMP_NUM_THREADS: 1
4963
run: |
50-
export OMP_NUM_THREADS=1
5164
cd tests
5265
rm -rf __pycache__
5366
# Test excluding very long running tests

.gitignore

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
28+
# Dev
29+
.vscode
30+
.history/
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
35+
*.manifest
36+
*.spec
37+
38+
# Installer logs
39+
pip-log.txt
40+
pip-delete-this-directory.txt
41+
42+
# Unit test / coverage reports
43+
htmlcov/
44+
.tox/
45+
.coverage
46+
.coverage.*
47+
.cache
48+
nosetests.xml
49+
coverage.xml
50+
*.cover
51+
.hypothesis/
52+
.pytest_cache
53+
input_tmp.in
54+
tmp_dyn*
55+
dyn_end_*
56+
dyn_start_*
57+
final_dyn*
58+
grad_*.dat
59+
u_population*.dat
60+
energies*.dat
61+
forces_*.dat
62+
prova
63+
scf_population*.dat
64+
frequencies*.*
65+
timer.json
66+
minim.dat
67+
68+
# Translations
69+
*.mo
70+
*.pot
71+
72+
# Django stuff:
73+
*.log
74+
local_settings.py
75+
76+
# Flask stuff:
77+
instance/
78+
.webassets-cache
79+
80+
# Scrapy stuff:
81+
.scrapy
82+
83+
# Sphinx documentation
84+
docs/_build/
85+
86+
# PyBuilder
87+
target/
88+
89+
# Jupyter Notebook
90+
.ipynb_checkpoints
91+
92+
# pyenv
93+
.python-version
94+
95+
# celery beat schedule file
96+
celerybeat-schedule
97+
98+
# SageMath parsed files
99+
*.sage.py
100+
101+
# dotenv
102+
.env
103+
104+
# virtualenv
105+
.venv
106+
venv/
107+
ENV/
108+
109+
# Spyder project settings
110+
.spyderproject
111+
.spyproject
112+
113+
# Rope project settings
114+
.ropeproject
115+
116+
# mkdocs documentation
117+
/site
118+
119+
# mypy
120+
.mypy_cache/
121+
122+
*~
123+
.DS_Store
124+
.idea
125+
submit_test/
126+
# Autogenerated API docs
127+
docs/*
128+
tox.ini

Modules/Cluster.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,10 +1511,11 @@ def compute_single_jobarray(jobs_id, calc):
15111511
if error_struct > 1e-2:
15121512
print("ERROR IDENTIFYING STRUCTURE!")
15131513
MSG = """
1514-
Error in thread {}.
1515-
Displacement between the expected structure {} and the one readed from the calculator
1516-
is of {} A.
1517-
""".format(threading.get_native_id(), jobs_id[i], error_struct)
1514+
Error in thread {}.
1515+
Displacement between the expected structure {}
1516+
and the one readed from the calculator
1517+
is of {} A.
1518+
""".format(threading.get_native_id(), jobs_id[i], error_struct)
15181519
print(MSG)
15191520
ensemble.structures[jobs_id[i]].save_scf('t_{}_error_struct_generated_{}.scf'.format(threading.get_native_id(), jobs_id[i]))
15201521
structures[i].save_scf('t_{}_error_struct_cmp_local_{}.scf'.format(threading.get_native_id(), jobs_id[i]))

Modules/Relax.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import print_function
2+
from __future__ import print_function, annotations
33

44
"""
55
This module performs the relax over more
@@ -15,6 +15,7 @@
1515
import sscha.Utilities as Utilities
1616
import cellconstructor as CC
1717
import cellconstructor.symmetries
18+
from sscha.aiida_ensemble import AiiDAEnsemble
1819

1920
import sys, os
2021

@@ -49,8 +50,17 @@
4950

5051
class SSCHA(object):
5152

52-
def __init__(self, minimizer = None, ase_calculator=None, N_configs=1, max_pop = 20,
53-
save_ensemble = False, cluster = None, **kwargs):
53+
def __init__(
54+
self,
55+
minimizer = None,
56+
ase_calculator=None,
57+
aiida_inputs: dict | None = None,
58+
N_configs=1,
59+
max_pop = 20,
60+
save_ensemble = False,
61+
cluster = None,
62+
**kwargs
63+
):
5464
"""
5565
This module initialize the relaxer. It may perform
5666
constant volume or pressure relaxation using fully anharmonic potentials.
@@ -63,6 +73,16 @@ def __init__(self, minimizer = None, ase_calculator=None, N_configs=1, max_pop =
6373
ase_calculator : ase.calculators...
6474
An initialized ASE calculator. This will be used to compute energies and forces
6575
for the relaxation of the SSCHA.
76+
aiida_input: dict
77+
Dictionary containing the input data for the
78+
:class:`~sscha.aiida_ensemble.AiiDAEnsemble.compute_ensmble`
79+
method; namely:
80+
* pw_code: str,
81+
* protocol: str = 'moderate',
82+
* options: dict = None,
83+
* overrides: dict = None,
84+
* group_label: str = None,
85+
* kwargs
6686
N_configs : int
6787
The number of configuration to be used for each population
6888
max_pop: int, optional
@@ -84,6 +104,7 @@ def __init__(self, minimizer = None, ase_calculator=None, N_configs=1, max_pop =
84104
self.N_configs = N_configs
85105
self.max_pop = max_pop
86106
self.cluster = cluster
107+
self.aiida_inputs = aiida_inputs
87108
self.start_pop = 1
88109

89110
# If the ensemble must be saved at each iteration.
@@ -350,8 +371,11 @@ def relax(self, restart_from_ens = False, get_stress = False,
350371
self.minim.ensemble.generate(self.N_configs, sobol = sobol, sobol_scramble = sobol_scramble, sobol_scatter = sobol_scatter)
351372

352373
# Compute energies and forces
353-
self.minim.ensemble.compute_ensemble(self.calc, get_stress,
354-
cluster = self.cluster)
374+
if isinstance(self.minim.ensemble, AiiDAEnsemble):
375+
self.minim.ensemble.compute_ensemble(**self.aiida_inputs)
376+
else:
377+
self.minim.ensemble.compute_ensemble(
378+
self.calc, get_stress, cluster = self.cluster)
355379
#self.minim.ensemble.get_energy_forces(self.calc, get_stress)
356380

357381
if ensemble_loc is not None and self.save_ensemble:
@@ -572,8 +596,11 @@ def vc_relax(self, target_press = 0, static_bulk_modulus = 100,
572596
# self.minim.ensemble.save_bin(ensemble_loc, pop)
573597

574598
# Compute energies and forces
575-
self.minim.ensemble.compute_ensemble(self.calc, True, stress_numerical,
576-
cluster = self.cluster)
599+
if isinstance(self.minim.ensemble, AiiDAEnsemble):
600+
self.minim.ensemble.compute_ensemble(**self.aiida_inputs)
601+
else:
602+
self.minim.ensemble.compute_ensemble(
603+
self.calc, True, stress_numerical, cluster = self.cluster)
577604
#self.minim.ensemble.get_energy_forces(self.calc, True, stress_numerical = stress_numerical)
578605

579606
print("RELAX force length:", len(self.minim.ensemble.force_computed))

0 commit comments

Comments
 (0)