Skip to content

Commit

Permalink
Merge pull request #126 from JuDFTteam/develop
Browse files Browse the repository at this point in the history
Merge develop into master for new release v.1.2.0

- release compatible with AiiDA-core 1.3.0+
possibly ready for aiida-core 2.0.0
- supports Fleur MaXR4 and MaXR5 versions with new inpgen 
MaXR4 requires providing versions in the code nodes
- Some features relying on the id in the inpgen files, 
may be broken by the new inpgen interface change when using MaXR5.1
- Added support for GW calculations with Spex, and the Strain workchain
- Major code refactoring, moving all xml tools to masci-tools (therefore requires masci-tools >=0.4.8)
- Also all file parsers are overworked and moved to masci-tools
- Work over of the BanddosWorkChain.
- FleurinpData now consistently supports more included xml files (kpts.xml, sym.xml, ...)
- Added new modification functions to the FleurinpModifier for kpoint manipulation for Max5
  • Loading branch information
broeder-j authored Jun 7, 2021
2 parents 8ef56cb + 37bae04 commit 652570a
Show file tree
Hide file tree
Showing 145 changed files with 8,453 additions and 15,645 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.8

- name: Cache python dependencies
id: cache-pip
Expand All @@ -26,13 +26,14 @@ jobs:
pip-docs-
- name: Install python dependencies
run:
run: |
pip install -e .[docs]
reentry scan
- name: Build documentation
env:
READTHEDOCS: 'True'
run:
run: |
SPHINXOPTS='-nW' make -C docs html
pre-commit:
Expand Down Expand Up @@ -63,7 +64,7 @@ jobs:
pip freeze
- name: Run pre-commit
run:
run: |
pre-commit run --all-files || (git status --short; git diff ; exit 1)
tests:
Expand Down
20 changes: 20 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
builder: html
configuration: docs/source/conf.py

# Optionally build your docs in additional formats such as PDF
formats:
- pdf

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.8
install:
- requirements: docs/requirements_for_rtd.txt
- method: pip
path: .
system_packages: true
2 changes: 1 addition & 1 deletion AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Vasily Tseplyaev ([email protected]) 2018-today
Anoop Chandran ([email protected]) 2019-today
Henning Janssen ([email protected]) 2020-today

We would also like to thank the following people for their contibution:
We would also like to thank the following people for their contribution:

...

Expand Down
19 changes: 17 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
## v.1.2.0
### release compatible with AiiDA-core 1.3.0+
possibly ready for aiida-core 2.0.0
- supports Fleur MaXR4 and MaXR5 versions with new inpgen
MaXR4 requires providing versions in the code nodes
- Some features relying on the id in the inpgen files,
may be broken by the new inpgen interface change when using MaXR5.1
- Added support for GW calculations with Spex, and the Strain workchain
- Major code refactoring, moving all xml tools to masci-tools (therefore requires masci-tools >=0.4.8)
- Also all file parsers are overworked and moved to masci-tools
- Work over of the BanddosWorkChain.
- FleurinpData now consistently supports more included xml files (kpts.xml, sym.xml, ...)
- Added new modification functions to the FleurinpModifier for kpoint manipulation for Max5


## v.1.1.4
### release compatible with AiiDA-core 1.3.0
### still support of Fleur MaXR4 version with inpgen
### Does not support yet Fleur MaXR5 and new inpgen
- still support of Fleur MaXR4 version with inpgen
- Does not support yet Fleur MaXR5 and new inpgen
- Fixed numpy dependency issue with aiida-common-workflows and quantum mobile

## v1.1.3
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

include aiida_fleur/tools/exp_bindingenergies.json
include aiida_fleur/fleur_schema/input/*/*.xsd
include ./tests/run*
recursive-include ./tests/files/ *
include setup.json
include setup_requirements.txt
include AUTHORS.txt
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ Developed at [Forschungszentrum Jülich GmbH](http://www.fz-juelich.de/pgi/pgi-1
| `v1.0.0 < v2.0.0` | <img class="svg-badge" title="Compatible with aiida-core >=1.3.0,<2.0.0" src="https://img.shields.io/badge/AiiDA->=1.3.0,<2.0.0-007ec6.svg?logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAACMAAAAhCAYAAABTERJSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAFhgAABYYBG6Yz4AAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAUbSURBVFiFzZhrbFRVEMd%2Fc%2B5uu6UUbIFC%2FUAUVEQCLbQJBIiBDyiImJiIhmohYNCkqJAQxASLF8tDgYRHBLXRhIcKNtFEhVDgAxBJqgmVh4JEKg3EIn2QYqBlt917xg%2BFss%2ByaDHOtzsz5z%2B%2FuZl7ztmF%2F5HJvxVQN6cPYX8%2FPLnOmsvNAvqfwuib%2FbNIk9cQeQnLcKRL5xLIV%2Fic9eJeunjPYbRs4FjQSpTB3aS1IpRKeeOOewajy%2FKKEO8Q0DuVdKy8IqsbPulxGHUfCBBu%2BwUYGuFuBTK7wQnht6PEbf4tlRomVRjCbXNjQEB0AyrFQOL5ENIJm7dTLZE6DPJCnEtFZVXDLny%2B4Sjv0PmmYu1ZdUek9RiMgoDmJ8V0L7XJqsZ3UW8YsBOwEeHeeFce7jEYXBy0m9m4BbXqSj2%2Bxnkg26MCVrN6DEZcwggtd8pTFx%2Fh3B9B50YLaFOPwXQKUt0tBLegtSomfBlfY13PwijbEnhztGzgJsK5h9W9qeWwBqjvyhB2iBs1Qz0AU974DciRGO8CVN8AJhAeMAdA3KbrKEtvxhsI%2B9emWiJlGBEU680Cfk%2BSsVqXZvcFYGXjF8ABVJ%2BTNfVXehyms1zzn1gmIOxLEB6E31%2FWBe5rnCarmo7elf7dJEeaLh80GasliI5F6Q9cAz1GY1OJVNDxTzQTw7iY%2FHEZRQY7xqJ9RU2LFe%2FYqakdP911ha0XhjjiTVAkDwgatWfCGeYocx8M3glG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ABJRU5ErkJggg%3D%3D"> | [![PyPI pyversions](https://img.shields.io/pypi/pyversions/aiida-fleur.svg)](https://pypi.org/project/aiida-fleur.svg) | MaXR1 < MaXR5 (v0.29)|
| `< v0.6.3` | <img class="svg-badge" title="Compatible with aiida-core >=0.12,<1.0.0" src="https://img.shields.io/badge/AiiDA->=0.12,<1.0.0-007ec6.svg?logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAACMAAAAhCAYAAABTERJSAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAFhgAABYYBG6Yz4AAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAUbSURBVFiFzZhrbFRVEMd%2Fc%2B5uu6UUbIFC%2FUAUVEQCLbQJBIiBDyiImJiIhmohYNCkqJAQxASLF8tDgYRHBLXRhIcKNtFEhVDgAxBJqgmVh4JEKg3EIn2QYqBlt917xg%2BFss%2ByaDHOtzsz5z%2B%2FuZl7ztmF%2F5HJvxVQN6cPYX8%2FPLnOmsvNAvqfwuib%2FbNIk9cQeQnLcKRL5xLIV%2Fic9eJeunjPYbRs4FjQSpTB3aS1IpRKeeOOewajy%2FKKEO8Q0DuVdKy8IqsbPulxGHUfCBBu%2BwUYGuFuBTK7wQnht6PEbf4tlRomVRjCbXNjQEB0AyrFQOL5ENIJm7dTLZE6DPJCnEtFZVXDLny%2B4Sjv0PmmYu1ZdUek9RiMgoDmJ8V0L7XJqsZ3UW8YsBOwEeHeeFce7jEYXBy0m9m4BbXqSj2%2Bxnkg26MCVrN6DEZcwggtd8pTFx%2Fh3B9B50YLaFOPwXQKUt0tBLegtSomfBlfY13PwijbEnhztGzgJsK5h9W9qeWwBqjvyhB2iBs1Qz0AU974DciRGO8CVN8AJhAeMAdA3KbrKEtvxhsI%2B9emWiJlGBEU680Cfk%2BSsVqXZvcFYGXjF8ABVJ%2BTNfVXehyms1zzn1gmIOxLEB6E31%2FWBe5rnCarmo7elf7dJEeaL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fORzQZb6P2kymS9oTxzBiM9rUqLWr1WE5G6ODhycQd%2FUnNVeMbcH68hYkGycNoUNWc8fxaxfwhDbHpfwM5oeTY7rUX8QAAAABJRU5ErkJggg%3D%3D"> | [![PyPI pyversions](https://img.shields.io/pypi/pyversions/aiida-fleur/0.6.svg)](https://pypi.python.org/pypi/aiida-fleur/0.6.3/) | MaXR1 < MaXR3 (v0.28)|

### Documentation
### Documentation and User Support

Hosted at http://aiida-fleur.readthedocs.io/en/develop/index.html.
For other information see the AiiDA-core docs or http://www.flapw.de.

Users can post any questions in the Fleur user [forum](http://fleur.xobor.de/)

For bugs, feature requests and further issues please use the issue tracker on github of the aiida-fleur repository.

### License:

MIT license.
Expand Down Expand Up @@ -94,7 +98,6 @@ filename | Description
---------|------------
Structure_util.py | Constains some methods to handle AiiDA structures (some of them might now be methods of the AiiDA structureData, if so use them from there!)
merge_parameter.py | Methods to handle parameterData nodes, i.e merge them. Which is very useful for all-electron codes, because instead of pseudo potentialsfamilies you can create now families of parameter nodes for the periodic table.
xml_util.py | All xml functions that are used, by parsers and other tools are in here. Some are 'general' some a very specific to Fleur.
read_cif.py | This can be used as stand-alone to create StructureData nodes from .cif files from an directory tree.

Utility and tools, which are independend of AiiDA are moved to the [masci-tools](https://github.com/JuDFTteam/masci-tools) (material science tools) repository,
Expand Down Expand Up @@ -214,11 +217,10 @@ Usage examples are shown in 'examples'.

## Acknowledgements

Besides the Forschungszentrum Juelich, this work is supported by the [MaX
European Centre of Excellence](<http://www.max-centre.eu/>) funded by the Horizon 2020 EINFRA-5 program,
Grant No. 676598.
Besides the Forschungszentrum Juelich, this work is supported by the European MaX Centre of Excellence 'Materials design at the Exascale' [MaX](<http://www.max-centre.eu/>) funded by the Horizon 2020 EINFRA-5 program, Grant No. 676598 and under grant agreement No. 824143. This work is further supported by the Joint Lab Virtual Materials Design (JLVMD) of the Forschungszentrum Jülich.

For this work essential is AiiDA, which itself is supported by the [MARVEL National Centre for Competency in Research](<http://nccr-marvel.ch>) funded by the [Swiss National Science Foundation](<http://www.snf.ch/en>).


![MaX](docs/source/images/MaX.png)
<img src="docs/source/images/MAX-orizz.png" alt="MaX" width="200"/>
<img src="docs/source/images/Logo-JLVMD.png" alt="JLVMD" width="200"/>
2 changes: 1 addition & 1 deletion aiida_fleur/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
'''
AiiDA-FLEUR
'''
__version__ = '1.1.4'
__version__ = '1.2.0'
26 changes: 21 additions & 5 deletions aiida_fleur/calculation/fleur.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class FleurCalculation(CalcJob):
_DOSINP_FILE_NAME = 'dosinp'
_BAND_GNU_FILE_NAME = 'band.gnu'
_BAND_FILE_NAME = 'bands.*'
_BANDDOS_FILE_NAME = 'banddos.hdf'

# helper files
_FLEUR_WARN_ONLY_INFO_FILE_NAME = 'FLEUR_WARN_ONLY'
Expand All @@ -99,6 +100,9 @@ class FleurCalculation(CalcJob):
_NMMPMAT_FILE_NAME = 'n_mmp_mat'
_NMMPMAT_HDF5_FILE_NAME = 'n_mmp_mat_out'

#files for greensfunctions
_GREENSF_HDF5_FILE_NAME = 'greensf.hdf'

# files for hybrid functionals
_COULOMB1_FILE_NAME = 'coulomb1'
_MIXBAS_FILE_NAME = 'mixbas'
Expand Down Expand Up @@ -188,8 +192,6 @@ class FleurCalculation(CalcJob):
'additional_retrieve_list', 'remove_from_retrieve_list', 'additional_remotecopy_list',
'remove_from_remotecopy_list', 'cmdline'
]
# possible modes?
_fleur_modes = ['band', 'dos', 'forces', 'chargeDen', 'latticeCo', 'scf', 'force_theorem', 'gw', 'ldau']

@classmethod
def define(cls, spec):
Expand Down Expand Up @@ -396,16 +398,23 @@ def prepare_for_submission(self, folder):
if modes['band']:
mode_retrieved_filelist.append(self._BAND_FILE_NAME)
mode_retrieved_filelist.append(self._BAND_GNU_FILE_NAME)
if with_hdf5:
mode_retrieved_filelist.append(self._BANDDOS_FILE_NAME)
if modes['dos']:
mode_retrieved_filelist.append(self._DOS_FILE_NAME)
if modes['forces']:
if with_hdf5:
mode_retrieved_filelist.append(self._BANDDOS_FILE_NAME)
if modes['relax']:
# if l_f="T" retrieve relax.xml
mode_retrieved_filelist.append(self._RELAX_FILE_NAME)
if modes['ldau']:
if with_hdf5:
mode_retrieved_filelist.append(self._NMMPMAT_HDF5_FILE_NAME)
else:
mode_retrieved_filelist.append(self._NMMPMAT_FILE_NAME)
if modes['greensf']:
if with_hdf5:
mode_retrieved_filelist.append(self._GREENSF_HDF5_FILE_NAME)
if modes['force_theorem']:
if 'remove_from_retrieve_list' not in settings_dict:
settings_dict['remove_from_retrieve_list'] = []
Expand Down Expand Up @@ -514,7 +523,13 @@ def prepare_for_submission(self, folder):
# Retrieve by default the output file and the xml file
retrieve_list = []
retrieve_list.append(self._OUTXML_FILE_NAME)
retrieve_list.append(self._INPXML_FILE_NAME)
if has_fleurinp:
allfiles = fleurinp.files
for file1 in allfiles:
if file1.endswith('.xml'):
retrieve_list.append(file1)
else:
retrieve_list.append(self._INPXML_FILE_NAME)
retrieve_list.append(self._SHELLOUTPUT_FILE_NAME)
retrieve_list.append(self._ERROR_FILE_NAME)
retrieve_list.append(self._USAGE_FILE_NAME)
Expand All @@ -526,7 +541,8 @@ def prepare_for_submission(self, folder):
retrieve_list.append(self._CDN1_FILE_NAME)

for mode_file in mode_retrieved_filelist:
retrieve_list.append(mode_file)
if mode_file not in retrieve_list:
retrieve_list.append(mode_file)
self.logger.info('retrieve_list: %s', str(retrieve_list))

# user specific retrieve
Expand Down
45 changes: 40 additions & 5 deletions aiida_fleur/calculation/fleurinputgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@

from aiida_fleur.data.fleurinp import FleurinpData
from aiida_fleur.tools.StructureData_util import abs_to_rel_f, abs_to_rel
from aiida_fleur.tools.xml_util import convert_to_fortran_bool, convert_to_fortran_string
from aiida_fleur.common.constants import BOHR_A

from masci_tools.util.xml.converters import convert_to_fortran_bool
from masci_tools.io.common_functions import convert_to_fortran_string


class FleurinputgenCalculation(CalcJob):
"""
Expand Down Expand Up @@ -137,8 +139,7 @@ def define(cls, spec):
spec.exit_code(307, 'ERROR_MISSING_RETRIEVED_FILES', message='Some required files were not retrieved.')
spec.exit_code(308,
'ERROR_FLEURINPDATA_INPUT_NOT_VALID',
message=('During parsing: FleurinpData could not be initialized, see log. '
'Maybe no Schemafile was found or the Fleurinput is not valid.'))
message=('During parsing: FleurinpData could not be initialized, see log. '))
spec.exit_code(309, 'ERROR_FLEURINPDATA_NOT_VALID', message='During parsing: FleurinpData failed validation.')

def prepare_for_submission(self, folder):
Expand Down Expand Up @@ -346,6 +347,9 @@ def prepare_for_submission(self, folder):
site_symbol = kind.symbols[0]
atomic_number = _atomic_numbers[site_symbol]
atomic_number_name = atomic_number
if atomic_number == 0: # 'X' element for vacancies
natoms = natoms - 1
continue

# per default we use relative coordinates in Fleur
# we have to scale back to atomic units from angstrom
Expand Down Expand Up @@ -484,8 +488,15 @@ def prepare_for_submission(self, folder):

codeinfo = CodeInfo()
# , "-electronConfig"] # TODO? let the user decide -electronconfig?
#cmdline_params = ['-explicit', '-inc', '+all', '-f', '{}'.format(self._INPUT_FILE_NAME)]
cmdline_params = ['-explicit']

# We support different inpgen and fleur version via reading the version from the code node extras
code_extras = code.extras
code_version = code_extras.get('version', 32)
if int(code_version) < 32:
# run old inpgen
cmdline_params = ['-explicit']
else:
cmdline_params = ['-explicit', '-inc', '+all', '-f', '{}'.format(self._INPUT_FILE_NAME)]

# user specific commandline_options
for command in settings_dict.get('cmdline', []):
Expand Down Expand Up @@ -618,3 +629,27 @@ def _lowercase_dict(dic, dict_name):
return new_dict
else:
raise TypeError('_lowercase_dict accepts only dictionaries as argument')


def write_inpgen_file_aiida_struct(structure, path, input_params=None, settings=None):
"""Wraps around masci_tools write inpgen_file, unpacks aiida structure"""
from masci_tools.io.io_fleur_inpgen import write_inpgen_file # pylint: disable=import-error,no-name-in-module

atoms_dict_list = []
kind_list = []

for kind in structure.kinds:
kind_list.append(kind.get_raw())

for site in structure.sites:
atoms_dict_list.append(site.get_raw())

report = write_inpgen_file(structure.cell,
atoms_dict_list,
kind_list,
path=path,
pbc=structure.pbc,
input_params=input_params,
settings=settings)

return report
45 changes: 44 additions & 1 deletion aiida_fleur/cmdline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
'''
import click
import click_completion
import difflib

from aiida_fleur import __version__
from aiida.cmdline.params import options, types
from .launch import cmd_launch
from .data import cmd_data
from .workflows import cmd_workflow
from .visualization import cmd_plot
from .util import options as options_af

# Activate the completion of parameter types provided by the click_completion package
# for bash: eval "$(_AIIDA_FLEUR_COMPLETE=source aiida-fleur)"
Expand All @@ -30,14 +33,54 @@
# less material science specific


class MostSimilarCommandGroup(click.Group):
"""
Overloads the get_command to display a list of possible command
candidates if the command could not be found with an exact match.
"""

def get_command(self, ctx, cmd_name):
"""
Override the default click.Group get_command with one giving the user
a selection of possible commands if the exact command name could not be found.
"""
cmd = click.Group.get_command(self, ctx, cmd_name)

# return the exact match
if cmd is not None:
return cmd

matches = difflib.get_close_matches(cmd_name, self.list_commands(ctx), cutoff=0.5)

if not matches:
# single letters are sometimes not matched, try with a simple startswith
matches = [c for c in sorted(self.list_commands(ctx)) if c.startswith(cmd_name)][:3]

if matches:
ctx.fail("'{cmd}' is not a aiida-fleur command.\n\n"
'The most similar commands are: \n'
'{matches}'.format(cmd=cmd_name, matches='\n'.join('\t{}'.format(m) for m in sorted(matches))))
else:
ctx.fail(f"'{cmd_name}' is not a aiida-fleur command.\n\nNo similar commands found.")

return None


# Uncomment this for now, has problems with sphinx-click
#@click.command('aiida-fleur', cls=MostSimilarCommandGroup, context_settings={'help_option_names': ['-h', '--help']})
@click.group('aiida-fleur', context_settings={'help_option_names': ['-h', '--help']})
@options.PROFILE(type=types.ProfileParamType(load_profile=True))
# Note, __version__ should always be passed explicitly here,
# because click does not retrieve a dynamic version when installed in editable mode
@click.version_option(__version__, '-v', '--version', message='AiiDA-FLEUR version %(version)s')
def cmd_root(profile): # pylint: disable=unused-argument
"""CLI for the `aiida-fleur` plugin."""


# To avoid circular imports all commands are not yet connected to the root
# but they have to be here because of bash completion
# but they have to be here because of bash completion on the other hand, this
# makes them not work with the difflib...
# see how aiida-core does it.

cmd_root.add_command(cmd_launch)
cmd_root.add_command(cmd_data)
Expand Down
Loading

0 comments on commit 652570a

Please sign in to comment.