Skip to content

Commit

Permalink
Merge pull request #109 from JuDFTteam/develop
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
PhilippRue authored Aug 22, 2022
2 parents 1514c3d + 7ffe2b8 commit 914bdc4
Show file tree
Hide file tree
Showing 73 changed files with 1,792 additions and 301 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.11.post1
current_version = 1.1.12
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,17 @@ jobs:
chmod +x kkr.x voronoi.exe kkrflex.exe
- name: Run pytest
if: ${{ ! matrix.allowed-to-fail }}
run: |
cd tests/
GITHUB_SUITE=True ./run_all.sh
- name: Run pytest allow failure
if: ${{ matrix.allowed-to-fail }}
run: |
cd tests/
GITHUB_SUITE=True ./run_all.sh || exit 0
- name: Archive test output artifacts
uses: actions/upload-artifact@v3
if: failure()
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -18,15 +18,16 @@ repos:
- id: forbid-new-submodules

- repo: https://github.com/pre-commit/mirrors-yapf
rev: v0.31.0
rev: v0.32.0
hooks:
- id: yapf
name: yapf
types: [python]
args: ["-i"]
additional_dependencies: [toml]

- repo: https://github.com/ikamensh/flynt/
rev: '0.55'
rev: '0.76'
hooks:
- id: flynt
args: [
Expand Down
2 changes: 1 addition & 1 deletion aiida_kkr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
AiiDA KKR
"""

__version__ = '1.1.11.post1'
__version__ = '1.1.12'
26 changes: 14 additions & 12 deletions aiida_kkr/calculations/kkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
)
from masci_tools.io.common_functions import get_alat_from_bravais, get_Ang2aBohr
from aiida_kkr.tools.tools_kkrimp import make_scoef, write_scoef_full_imp_cls
from aiida_kkr.tools.find_parent import find_parent_structure
from masci_tools.io.kkr_params import __kkr_default_params__, kkrparams
import six
from six.moves import range

__copyright__ = (u'Copyright (c), 2017, Forschungszentrum Jülich GmbH, ' 'IAS-1/PGI-1, Germany. All rights reserved.')
__copyright__ = (u'Copyright (c), 2017, Forschungszentrum Jülich GmbH, '
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'
__version__ = '0.12.1'
__version__ = '0.12.2'
__contributors__ = ('Jens Bröder', 'Philipp Rüßmann')

verbose = False
Expand Down Expand Up @@ -442,7 +444,7 @@ def _get_structure_inputs(self, parent_calc, parameters):
structure = None
self.logger.info('KkrCalculation: Get structure node from voronoi parent')
try:
structure, voro_parent = VoronoiCalculation.find_parent_structure(parent_calc)
structure, voro_parent = find_parent_structure(parent_calc)
except:
self.logger.error(f'KkrCalculation: Could not get structure from Voronoi parent ({parent_calc}).')
raise ValidationError(f'Cound not find structure node from parent {parent_calc}')
Expand Down Expand Up @@ -625,7 +627,7 @@ def _get_local_copy_list(self, parent_calc, voro_parent, tempfolder, parameters)
# add shapefun file from voronoi parent if needed
if self._SHAPEFUN not in copylist:
try:
struc, voro_parent = VoronoiCalculation.find_parent_structure(parent_calc)
struc, voro_parent = find_parent_structure(parent_calc)
except ValueError:
return self.exit_codes.ERROR_NO_SHAPEFUN_FOUND # pylint: disable=no-member
# copy shapefun from retrieved of voro calc
Expand Down Expand Up @@ -738,13 +740,13 @@ def _get_qdos_filelist(self, parameters, natom, nspin, addition=''):
add_files = [self._QVEC]
for iatom in range(natom):
for ispin in range(nspin):
add_files.append((self._QDOS_ATOM % (iatom + 1, ispin + 1)).replace(' ', '0'))
add_files.append((self._QDOS_ATOM % (iatom + 1, ispin + 1)).replace(' ', '0') + addition)
# try to retrieve both old and new version of the files
add_files.append((self._QDOS_ATOM_OLD % (iatom + 1, ispin + 1)).replace(' ', '0'))
add_files.append((self._QDOS_ATOM_OLD % (iatom + 1, ispin + 1)).replace(' ', '0') + addition)
# retrieve also qdos_sx,y,z files if written out
add_files.append((self._QDOS_SX % (iatom + 1)).replace(' ', '0'))
add_files.append((self._QDOS_SY % (iatom + 1)).replace(' ', '0'))
add_files.append((self._QDOS_SZ % (iatom + 1)).replace(' ', '0'))
add_files.append((self._QDOS_SX % (iatom + 1)).replace(' ', '0') + addition)
add_files.append((self._QDOS_SY % (iatom + 1)).replace(' ', '0') + addition)
add_files.append((self._QDOS_SZ % (iatom + 1)).replace(' ', '0') + addition)

return add_files

Expand Down Expand Up @@ -807,7 +809,7 @@ def _get_BdG_filelist(self, parameters, natom, nspin):

#also retrieve BdG DOS files for anomalous density and hole part
for BdGadd in ['_eh', '_he', '_hole']:
add_files += self._get_dos_filelist(natom, nspin, parameters, BdGadd)
add_files += self._get_dos_filelist(parameters, natom, nspin, BdGadd)
add_files += self._get_qdos_filelist(parameters, natom, nspin, BdGadd)

return add_files
Expand Down Expand Up @@ -869,7 +871,7 @@ def _set_ef_value_potential(self, ef_set, local_copy_list, tempfolder):
self.report(f'set ef {ef_set} in potential starting in line {ipotstart}')
tmpline = txt[ipotstart + 3]
tmpline = tmpline.split()
newline = '%10.5f%20.14f%20.14f\n' % (float(tmpline[0]), ef_set, float(tmpline[-1]))
newline = f'{float(tmpline[0]):10.5f}{ef_set:20.14f}{float(tmpline[-1]):20.14f}\n'

txt[ipotstart + 3] = newline

Expand Down Expand Up @@ -952,7 +954,7 @@ def _prepare_qdos_calc(self, parameters, kpath, structure, tempfolder, use_alat_
alat_input = alat
kpath_array = kpath_array * (alat_input / alat) / get_Ang2aBohr() / (2 * np.pi / alat)
# now write file
qvec = ['%i\n' % len(kpath_array)]
qvec = [f'{len(kpath_array)}\n']
qvec += [f'{kpt[0]:e} {kpt[1]:e} {kpt[2]:e}\n' for kpt in kpath_array]
with tempfolder.open(self._QVEC, 'w') as qvecfile:
qvecfile.writelines(qvec)
Expand Down
3 changes: 2 additions & 1 deletion aiida_kkr/calculations/kkrimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import six
from six.moves import range

__copyright__ = (u'Copyright (c), 2018, Forschungszentrum Jülich GmbH, ' 'IAS-1/PGI-1, Germany. All rights reserved.')
__copyright__ = (u'Copyright (c), 2018, Forschungszentrum Jülich GmbH, '
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'
__version__ = '0.7.0'
__contributors__ = (u'Philipp Rüßmann', u'Fabian Bertoldo')
Expand Down
3 changes: 2 additions & 1 deletion aiida_kkr/calculations/kkrimporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#from aiida_kkr.tools.common_workfunctions import structure_from_params
#from six.moves import range

__copyright__ = (u'Copyright (c), 2017, Forschungszentrum Jülich GmbH, ' 'IAS-1/PGI-1, Germany. All rights reserved.')
__copyright__ = (u'Copyright (c), 2017, Forschungszentrum Jülich GmbH, '
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'
__version__ = '0.2'
__contributors__ = ('Philipp Rüßmann')
Expand Down
24 changes: 12 additions & 12 deletions aiida_kkr/calculations/kkrnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"""
Input plug-in for a KKRnano calculation.
"""
from aiida.engine import CalcJob
from aiida.orm import CalcJobNode, Dict, Bool, Float, RemoteData, StructureData
from aiida_kkr.data.strucwithpot import StrucWithPotData
from aiida.common.datastructures import (CalcInfo, CodeInfo)

import numpy as np
from masci_tools.io.common_functions import get_Ang2aBohr
from aiida.orm import CalcJobNode, Dict, Bool, Float, RemoteData, StructureData
from aiida.engine import CalcJob
from aiida.common import NotExistent
from aiida.common.datastructures import (CalcInfo, CodeInfo)
from aiida.common.exceptions import InputValidationError, UniquenessError
from aiida_kkr.tools.find_parent import get_remote, get_parent
from aiida_kkr.data.strucwithpot import StrucWithPotData

from aiida_kkr.calculations.voro import VoronoiCalculation

import numpy as np

__copyright__ = (u'Copyright (c), 2021, Forschungszentrum Jülich GmbH, ' 'IAS-1/PGI-1, Germany. All rights reserved.')
__copyright__ = (u'Copyright (c), 2021, Forschungszentrum Jülich GmbH, '
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'
__version__ = '0.0.1'
__version__ = '0.0.2'
__contributors__ = ('Markus Struckmann', 'Philipp Rüßmann')


Expand Down Expand Up @@ -703,9 +703,9 @@ def find_parent_struc_from_voro_or_stwpd(self, parent_folder):
"""
iiter = 0
Nmaxiter = 1000
parent_folder_tmp = VoronoiCalculation.get_remote(parent_folder)
parent_folder_tmp = get_remote(parent_folder)
while not self._has_struc(parent_folder_tmp) and iiter < Nmaxiter:
parent_folder_tmp = VoronoiCalculation.get_remote(VoronoiCalculation.get_parent(parent_folder_tmp))
parent_folder_tmp = get_remote(get_parent(parent_folder_tmp))
iiter += 1
if iiter % 200 == 0:
print(
Expand Down
89 changes: 8 additions & 81 deletions aiida_kkr/calculations/voro.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from aiida.common.exceptions import (InputValidationError, ValidationError)
from aiida.common.datastructures import (CalcInfo, CodeInfo)
from aiida_kkr.tools.common_workfunctions import generate_inputcard_from_structure, check_2Dinput_consistency, vca_check
from aiida.common.exceptions import UniquenessError, NotExistent
from aiida.common.exceptions import UniquenessError
import os
import six

__copyright__ = (u'Copyright (c), 2017, Forschungszentrum Jülich GmbH, ' 'IAS-1/PGI-1, Germany. All rights reserved.')
__copyright__ = (u'Copyright (c), 2017, Forschungszentrum Jülich GmbH, '
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'
__version__ = '0.5.3'
__contributors__ = ('Jens Broeder', 'Philipp Rüßmann')
Expand Down Expand Up @@ -147,7 +148,8 @@ def prepare_for_submission(self, tempfolder):
else:
overwrite_potential = False
if not found_structure:
raise InputValidationError('Neither structure nor parent_KKR specified for this ' 'calculation')
raise InputValidationError('Neither structure nor parent_KKR specified for this '
'calculation')

# check if overwrite potential is given explicitly
if 'potential_overwrite' in self.inputs:
Expand Down Expand Up @@ -273,86 +275,11 @@ def _is_KkrCalc(self, calc):

return is_KKR

@classmethod
def _get_struc(self, parent_calc):
"""
Get structure from a parent_folder (result of a calculation, typically a remote folder)
"""
return parent_calc.inputs.structure

@classmethod
def _has_struc(self, parent_folder):
"""
Check if parent_folder has structure information in its input
"""
success = True
if 'structure' not in parent_folder.get_incoming().all_link_labels():
success = False
return success

@classmethod
def get_remote(self, parent_folder):
"""
get remote_folder from input if parent_folder is not already a remote folder
"""
parent_folder_tmp0 = parent_folder
try:
parent_folder_tmp = parent_folder_tmp0.get_incoming().get_node_by_label('remote_folder')
except NotExistent:
parent_folder_tmp = parent_folder_tmp0
return parent_folder_tmp

@classmethod
def get_parent(self, input_folder):
"""
get the parent folder of the calculation. If not parent was found return input folder
"""
input_folder_tmp0 = input_folder

# first option: parent_calc_folder (KkrimpCalculation)
try:
parent_folder_tmp = input_folder_tmp0.get_incoming().get_node_by_label('parent_calc_folder')
return_input = False
except NotExistent:
return_input = True

# second option: parent_folder (KkrCalculation)
try:
parent_folder_tmp = input_folder_tmp0.get_incoming().get_node_by_label('parent_folder')
return_input = False
except NotExistent:
return_input = return_input & True

# third option: parent_KKR option (special mode of VoronoiCalculation)
try:
parent_folder_tmp = input_folder_tmp0.get_incoming().get_node_by_label('parent_KKR')
return_input = False
except NotExistent:
return_input = return_input & True

if return_input:
parent_folder_tmp = input_folder_tmp0

return parent_folder_tmp

@classmethod
def find_parent_structure(self, parent_folder):
"""
Find the Structure node recuresively in chain of parent calculations (structure node is input to voronoi calculation)
This is a copy of the find_parent_structure that moved to tools.find_parent to keep backwards compatibility.
"""
iiter = 0
Nmaxiter = 1000
parent_folder_tmp = self.get_remote(parent_folder)
while not self._has_struc(parent_folder_tmp) and iiter < Nmaxiter:
parent_folder_tmp = self.get_remote(self.get_parent(parent_folder_tmp))
iiter += 1
if iiter % 200 == 0:
print(
'Warning: find_parent_structure takes quite long (already searched {} ancestors). Stop after {}'.
format(iiter, Nmaxiter)
)
if self._has_struc(parent_folder_tmp):
struc = self._get_struc(parent_folder_tmp)
return struc, parent_folder_tmp
else:
raise ValueError('structure not found')
from aiida_kkr.tools.find_parent import find_parent_structure
return find_parent_structure(parent_folder)
Loading

0 comments on commit 914bdc4

Please sign in to comment.