Skip to content

Commit

Permalink
Merge pull request #210 from JuDFTteam/release-0.13.0
Browse files Browse the repository at this point in the history
🚀 Release `0.13.0`
  • Loading branch information
janssenhenning authored Nov 21, 2022
2 parents cc8301f + 40fe363 commit 613f243
Show file tree
Hide file tree
Showing 99 changed files with 81,216 additions and 204 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ jobs:
- python-version: '3.7'
experimental: false
pytest-cmdline: '-o addopts="--cov=masci_tools --cov=tests --cov-report xml"'
# - python-version: '3.11-dev'
# experimental: true
#- python-version: '3.11.0-rc.2'
# experimental: true
# pytest-cmdline: ""
fail-fast: false

name: tests-python-${{ matrix.python-version }}
Expand All @@ -140,7 +141,7 @@ jobs:
if: ${{ matrix.experimental }}
run: |
sudo apt-get update
sudo apt-get install -y libxml2-dev libxslt-dev libhdf5-serial-dev
sudo apt-get install -y libxml2-dev libxslt-dev libhdf5-serial-dev libopenblas-dev
pip install --upgrade pip setuptools wheel
pip install --upgrade cython
pip list
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Changelog

## latest
[full changelog](https://github.com/JuDFTteam/masci-tools/compare/v0.12.0...develop)
[full changelog](https://github.com/JuDFTteam/masci-tools/compare/v0.13.0...develop)

Nothing here yet

## v.0.13.0
[full changelog](https://github.com/JuDFTteam/masci-tools/compare/v0.12.0...v0.13.0)

### Improvements
- `set_kpointmesh` now also writes out the `nx/ny/nz` attributes fro the dimensions of the kpoint mesh
- `get_structure_data`, `get_parameter_data` and `get_kpoints_data` are renamed to `get_structuredata`, `get_parameterdata` and `get_kpointsdata` to match the names of the corresponding functions in aiida-fleur. Old names are available with deprecations [[#208]](https://github.com/JuDFTteam/masci-tools/pull/208)
- `FleurXMLModifier` now supports changes to input files with not yet available Fleur schemas, if the changes are compatible with the last available file schema [[#209]](https://github.com/JuDFTteam/masci-tools/pull/209)
### Bugfixes
- Bugfix in XML setters `set_inpchanges` and `set_attrib_value`, setting the `xcFunctional` key was previously not case-insensitive in constrast with all other keys
- Fixed crash in `get_parameter_data`. This function would previously crash if a kpoint mesh without `nx/ny/nz` attributes was used and the first point in the list was the gamma point

## v.0.12.0
[full changelog](https://github.com/JuDFTteam/masci-tools/compare/v0.11.3...v0.12.0)

Expand Down
6 changes: 6 additions & 0 deletions docs/source/devel_guide/fleur_parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
.. currentmodule:: masci_tools.io.parsers.fleur_schema
```

:::{note}
A more detailed walkthrough of the important design decisions concerning the implementation
Fleur XML parsers and IO capabilities can be found in this
[document](https://python-fleur-xml-design.readthedocs.io/en/latest/)
:::

Each input and output file for Fleur has a correspong XML-Schema, where the structure
of these files are defined.

Expand Down
6 changes: 3 additions & 3 deletions docs/source/user_guide/fleur_parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ in the {py:mod}`~masci_tools.util.xml.xml_getters` module. The following are ava
- {py:func}`get_nkpts()`: Get the (for older versions approximate if not `kPointList` is
used) number of kpoints to be used in the calculation
- {py:func}`get_cell()`: Get the Bravais matrix of the system
- {py:func}`get_parameter_data()`: Get the information about the calculation parameters
- {py:func}`get_parameterdata()`: Get the information about the calculation parameters
needed to reproduce a calculation starting from the inpgen
- {py:func}`get_structure_data()`: Get the structure from the xml file
- {py:func}`get_structuredata()`: Get the structure from the xml file
(atom positions + unit cell)
- {py:func}`get_kpoints_data()`: Get the defined kpoint sets (single/multiple)
- {py:func}`get_kpointsdata()`: Get the defined kpoint sets (single/multiple)
from the xml file (kpoints + weights + unit cell)
- {py:func}`get_relaxation_information()`: Get the relaxation history and current displacements
- {py:func}`get_symmetry_information()`: Get the symmetry operations used in the calculation
Expand Down
2 changes: 1 addition & 1 deletion masci_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
__copyright__ = ('Copyright (c), Forschungszentrum Jülich GmbH, IAS-1/PGI-1, Germany. '
'All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file.'
__version__ = '0.12.0'
__version__ = '0.13.0'
__authors__ = 'The JuDFT team. Also see AUTHORS.txt file.'

logging.getLogger(__name__).addHandler(logging.NullHandler())
Expand Down
12 changes: 6 additions & 6 deletions masci_tools/cmdline/commands/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ def parse_structure_data(xml_file):
"""
Parse the structure information in the given Fleur xml file
"""
from masci_tools.util.xml.xml_getters import get_structure_data
from masci_tools.util.xml.xml_getters import get_structuredata

xmltree, schema_dict = _load_xml_file(xml_file)

atoms, cell, pbc = get_structure_data(xmltree, schema_dict)
atoms, cell, pbc = get_structuredata(xmltree, schema_dict)

echo.echo_info('Atoms found:')
echo.echo_formatted_list(atoms, ['symbol', 'kind', 'position'])
Expand Down Expand Up @@ -139,11 +139,11 @@ def parse_parameter_data(xml_file):
"""
Parse the calculation parameters of the given xml file
"""
from masci_tools.util.xml.xml_getters import get_parameter_data
from masci_tools.util.xml.xml_getters import get_parameterdata

xmltree, schema_dict = _load_xml_file(xml_file)

params = get_parameter_data(xmltree, schema_dict)
params = get_parameterdata(xmltree, schema_dict)

echo.echo_info('LAPW parameters:')
echo.echo_dictionary(params)
Expand All @@ -169,10 +169,10 @@ def parse_kpoints_data(xml_file):
"""
Parse the used kpoints from the given xml-file
"""
from masci_tools.util.xml.xml_getters import get_kpoints_data
from masci_tools.util.xml.xml_getters import get_kpointsdata

xmltree, schema_dict = _load_xml_file(xml_file)
kpoints, weights, cell, pbc = get_kpoints_data(xmltree, schema_dict, only_used=True)
kpoints, weights, cell, pbc = get_kpointsdata(xmltree, schema_dict, only_used=True)

echo.echo_info('Bravais matrix:')
echo.echo(str(cell))
Expand Down
33 changes: 25 additions & 8 deletions masci_tools/io/fleurxmlmodifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
from typing_extensions import Literal #type: ignore

from masci_tools.util.xml.collect_xml_setters import XPATH_SETTERS, SCHEMA_DICT_SETTERS, NMMPMAT_SETTERS
from masci_tools.util.xml.common_functions import clear_xml
from masci_tools.util.xml.xml_setters_names import set_attrib_value
from masci_tools.util.xml.common_functions import clear_xml, eval_xpath_one
from masci_tools.util.schema_dict_util import ensure_relaxation_xinclude
from masci_tools.io.fleur_xml import load_inpxml
from masci_tools.util.typing import XMLFileLike, FileLike
Expand Down Expand Up @@ -217,7 +218,8 @@ def apply_modifications(cls,
xmltree: etree._ElementTree,
nmmp_lines: list[str] | None,
modification_tasks: list[ModifierTask],
validate_changes: bool = True) -> tuple[etree._ElementTree, list[str] | None]:
validate_changes: bool = True,
adjust_version_for_dev_version: bool = True) -> tuple[etree._ElementTree, list[str] | None]:
"""
Applies given modifications to the fleurinp lxml tree.
It also checks if a new lxml tree is validated against schema.
Expand All @@ -228,6 +230,10 @@ def apply_modifications(cls,
:param modification_tasks: a list of modification tuples
:param validate_changes: bool optional (default True), if True after all tasks are performed
both the xmltree and nmmp_lines are checked for consistency
:param adjust_version_for_dev_version: bool optional (default True), if True and the schema_dict
and file version differ, e.g. a development version is used
the version is temporarily modified to swallow the validation
error that would occur
:returns: a modified lxml tree and a modified n_mmp_mat file
"""
Expand All @@ -236,6 +242,9 @@ def apply_modifications(cls,
xmltree, schema_dict = load_inpxml(xmltree)
xmltree, _ = clear_xml(xmltree)

file_version = eval_xpath_one(xmltree, '//@fleurInputVersion', str)
is_dev_version = schema_dict['inp_version'] != file_version

for task in modification_tasks:
if task.name in cls.xpath_functions:
action = cls.xpath_functions[task.name]
Expand All @@ -253,7 +262,12 @@ def apply_modifications(cls,
raise ValueError(f'Unknown task {task.name}')

if validate_changes:
schema_dict.validate(xmltree, header='Changes were not valid')
if is_dev_version and adjust_version_for_dev_version:
set_attrib_value(xmltree, schema_dict, 'fleurinputversion', schema_dict['inp_version'])
schema_dict.validate(xmltree, header='Changes were not valid')
set_attrib_value(xmltree, schema_dict, 'fleurinputversion', file_version)
else:
schema_dict.validate(xmltree, header='Changes were not valid')
try:
validate_nmmpmat(xmltree, nmmp_lines, schema_dict)
except ValueError as exc:
Expand Down Expand Up @@ -349,7 +363,8 @@ def changes(self) -> list[ModifierTask]:
def modify_xmlfile(self,
original_inpxmlfile: XMLFileLike,
original_nmmp_file: FileLike | list[str] | None = None,
validate_changes: bool = True) -> tuple[etree._ElementTree, dict[str, str]]:
validate_changes: bool = True,
adjust_version_for_dev_version: bool = True) -> tuple[etree._ElementTree, dict[str, str]]:
"""
Applies the registered modifications to a given inputfile
Expand All @@ -375,10 +390,12 @@ def modify_xmlfile(self,
else:
original_nmmp_lines = None

new_xmltree, new_nmmp_lines = self.apply_modifications(original_xmltree,
original_nmmp_lines,
self._tasks,
validate_changes=validate_changes)
new_xmltree, new_nmmp_lines = self.apply_modifications(
original_xmltree,
original_nmmp_lines,
self._tasks,
validate_changes=validate_changes,
adjust_version_for_dev_version=adjust_version_for_dev_version)

ensure_relaxation_xinclude(new_xmltree, schema_dict)
etree.indent(new_xmltree)
Expand Down
36 changes: 25 additions & 11 deletions masci_tools/io/kkr_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
__copyright__ = ('Copyright (c), 2017, Forschungszentrum Jülich GmbH,'
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'
__version__ = '1.8.7'
__version__ = '1.8.8'
__contributors__ = 'Philipp Rüßmann'

# This defines the default parameters for KKR used in the aiida plugin:
Expand Down Expand Up @@ -448,6 +448,8 @@ def __init__(self, **kwargs):
None, '%f', False,
'Superconductivity: Scaling factor for lambda_BdG (e.g. used to deactivate BdG coupling in some layers by setting the value to 0)'
]),
('<PHASE_BDG>',
[None, '%f', False, 'Superconductivity: Atom dependent phase factor for superconducting coupling.']),
('<MIXFAC_BDG>', [
None, '%f', False,
'Superconductivity: Mixing factor used in the mixing of the BdG Delta (defaults to 0.1)'
Expand Down Expand Up @@ -489,6 +491,7 @@ def __init__(self, **kwargs):
None, '%f', False,
'Renormalization factor for energy integration weights (can be used to shift the Fermi level around).'
]),
('NQDOSMAXPOINTS', [None, '%i', False, 'Max number of q-points per batch.']),
# array dimensions
('NSHELD', [None, '%i', False, 'Array dimension: number of shells (default: 300)']),
('IEMXD', [None, '%i', False, 'Array dimension: number of energy points (default: 101)']),
Expand Down Expand Up @@ -556,6 +559,8 @@ def __init__(self, **kwargs):
None, '%l', False,
"Run option: do not add some energy terms (coulomb, XC, eff. pot.) to total energy (former: 'NoMadel')"
]),
('<NONCOBFIELD>', [None, '%l', False,
'Run option: use non-collinear exteranl fields read from bfield.dat']),
('<PRINT_GIJ>',
[None, '%l', False, "Run option: print cluster G_ij matrices to outfile (former: 'Gmatij')"]),
('<PRINT_GMAT>', [None, '%l', False, "Run option: print Gmat to outfile (former: 'Gmat')"]),
Expand Down Expand Up @@ -1256,16 +1261,23 @@ def _check_input_consistency(self, set_lists_only=False, verbose=False):

#yapf: disable
listargs = dict([
['<RBASIS>', naez], ['<RBLEFT>', nlbasis], ['<RBRIGHT>', nrbasis], ['<SHAPE>', natyp],
['<ZATOM>', natyp], ['<SOCSCL>', natyp], ['<SITE>', natyp], ['<CPA-CONC>', natyp],
['<KAOEZL>', nlbasis], ['<KAOEZR>', nrbasis], ['XINIPOL', natyp], ['<RMTREF>', natyp],
['<RMTREFL>', nlbasis], ['<RMTREFR>', nrbasis], ['<FPRADIUS>', natyp], ['BZDIVIDE', 3],
['<RBLEFT>', nlbasis], ['ZPERIODL', 3], ['<RBRIGHT>', nrbasis], ['ZPERIODR', 3],
['LDAU_PARA', 5], ['CPAINFO', 2], ['<DELTAE>', 2], ['FILES', 2], ['DECIFILES', 2],
['<RMTCORE>', naez], ['<MTWAU>', naez], ['<RTMTWAU>',nrbasis ], ['<LFMTWAU>', nlbasis],
['<MTWAL>', naez], ['<RTMTWAL>',nrbasis ], ['<LFMTWAL>', nlbasis],
['<AT_SCALE_BDG>', natyp], ['<LM_SCALE_BDG>', (lmax + 1)**2],
['BZDIVIDE', 3], ['ZPERIODL', 3], ['ZPERIODR', 3], ['LDAU_PARA', 5],
['CPAINFO', 2], ['<DELTAE>', 2], ['FILES', 2], ['DECIFILES', 2],
])
if naez is not None:
for key in ['<RBASIS>', '<RMTCORE>', '<MTWAU>', '<MTWAL>']:
listargs[key] = naez
if natyp is not None:
for key in ['<SHAPE>', '<ZATOM>', '<SOCSCL>', '<SITE>', '<CPA-CONC>', 'XINIPOL', '<RMTREF>', '<FPRADIUS>', '<AT_SCALE_BDG>', '<PHASE_BDG>']:
listargs[key] = natyp
if nlbasis is not None:
for key in ['<RBLEFT>', '<KAOEZL>', '<RMTREFL>', '<RBLEFT>', '<LFMTWAU>', '<LFMTWAL>']:
listargs[key] = nlbasis
if nrbasis is not None:
for key in ['<RBRIGHT>', '<KAOEZR>', '<RMTREFR>', '<RBRIGHT>', '<RTMTWAU>', '<RTMTWAL>']:
listargs[key] = nrbasis
if lmax is not None:
listargs['<LM_SCALE_BDG>'] = (lmax + 1)**2
#yapf: enable

# deal with special stuff for voronoi:
Expand Down Expand Up @@ -1799,7 +1811,9 @@ def read_keywords_from_inputcard(self, inputcard='inputcard', verbose=False):
rbr = self.get_value('<RBRIGHT>')
zper_l = self.get_value('ZPERIODL')
zper_r = self.get_value('ZPERIODR')
alat2ang = self.get_value('ALATBASIS') * get_aBohr2Ang()
alat2ang = self.get_value('ALATBASIS')
if alat2ang is not None:
alat2ang *= get_aBohr2Ang()
if rbl is not None:
self.set_value('<RBLEFT>', array(rbl) * alat2ang)
if rbr is not None:
Expand Down
2 changes: 1 addition & 1 deletion masci_tools/io/parsers/fleur/default_parse_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
'_conversions': [Conversion(name='convert_relax_info')],
'parsed_relax_info': {
'parse_type': 'xmlGetter',
'name': 'get_structure_data',
'name': 'get_structuredata',
'kwargs': {
'convert_to_angstroem': False,
'include_relaxations': False
Expand Down
Loading

0 comments on commit 613f243

Please sign in to comment.