From ed97424f1a4b9e3575e95c7433870931b124f8b2 Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Wed, 22 Dec 2021 12:08:45 +0100 Subject: [PATCH 1/9] Update flake8 linting tests - Reduce test env deps to flake8 only - Set max-line-length = 100 --- qeschema/converters.py | 2 +- qeschema/options.py | 2 +- qeschema/utils.py | 7 ++++--- tox.ini | 5 +++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/qeschema/converters.py b/qeschema/converters.py index a4045af..2aea189 100644 --- a/qeschema/converters.py +++ b/qeschema/converters.py @@ -490,7 +490,7 @@ class PwInputConverter(RawInputConverter): 'fix_area': ("CELL[cell_dofree]", options.get_cell_dofree, None), 'fix_xy': ("CELL[cell_dofree]", options.get_cell_dofree, None), 'isotropic': ("CELL[cell_dofree]", options.get_cell_dofree, None), - 'cell_do_free': ("CELL[cell_dofree]",options.get_cell_dofree, None), + 'cell_do_free': ("CELL[cell_dofree]", options.get_cell_dofree, None), }, 'symmetry_flags': { 'nosym': "SYSTEM[nosym]", diff --git a/qeschema/options.py b/qeschema/options.py index ea61732..e2fe7ce 100644 --- a/qeschema/options.py +++ b/qeschema/options.py @@ -211,7 +211,7 @@ def get_cell_dofree(name, **kwargs): assert isinstance(name, str) cell_dofree_str = " cell_dofree = '%s'" cell_dofree_all = 'all' - ret = [cell_dofree_str % cell_dofree_all] + ret = [cell_dofree_str % cell_dofree_all] map_data = { 'fix_volume': 'shape', 'fix_area': '2Dshape', diff --git a/qeschema/utils.py b/qeschema/utils.py index 7a86724..e95c7f7 100644 --- a/qeschema/utils.py +++ b/qeschema/utils.py @@ -48,12 +48,13 @@ def set_logger(loglevel=1, logfile=None): lh.setLevel(effective_level) if effective_level <= logging.DEBUG: - formatter = logging.Formatter("[%(levelname)s:%(module)s:%(funcName)s: %(lineno)s] %(message)s") + fmt = "[%(levelname)s:%(module)s:%(funcName)s: %(lineno)s] %(message)s" elif effective_level <= logging.INFO: - formatter = logging.Formatter("[%(levelname)s:%(module)s] %(message)s") + fmt = "[%(levelname)s:%(module)s] %(message)s" else: - formatter = logging.Formatter("%(levelname)s: %(message)s") + fmt = "%(levelname)s: %(message)s" + formatter = logging.Formatter(fmt) lh.setFormatter(formatter) logger.addHandler(lh) else: diff --git a/tox.ini b/tox.ini index ae9347a..1ed76a7 100644 --- a/tox.ini +++ b/tox.ini @@ -16,7 +16,6 @@ deps = h5py docs: Sphinx docs: sphinx_rtd_theme - flake8: flake8 coverage: coverage commands = python -m unittest whitelist_externals = make @@ -28,9 +27,11 @@ commands = make -C docs latexpdf [flake8] -max-line-length = 119 +max-line-length = 100 [testenv:flake8] +deps = + flake8 commands = flake8 qeschema From c979e6e3272eaa52ffed2b6442aa7c57dada34cb Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Wed, 22 Dec 2021 12:24:31 +0100 Subject: [PATCH 2/9] Modify configuration of CI/CD tests - Remove Python 3.6, add 3.9 and 3.10 - Add linting test with flake8 --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f2155a..e34beb9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ['3.6', '3.7', '3.8'] + python-version: ['3.7', '3.8', '3.9', '3.10'] steps: - uses: actions/checkout@v2 - name: Set up Python @@ -28,6 +28,9 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements-dev.txt + - name: Lint with flake8 + run: | + flake8 qeschema --max-line-length=100 --statistics - name: Run tests run: | python -m unittest From 7f3ca37122f410c73a47a6807d6f23b9114a98ee Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Wed, 22 Dec 2021 17:47:33 +0100 Subject: [PATCH 3/9] Fix typos and logging in converters.py module - Full tests coverage for cards.py module --- qeschema/converters.py | 46 +++++++++++++++++++++--------------------- tests/test_cards.py | 33 ++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 25 deletions(-) diff --git a/qeschema/converters.py b/qeschema/converters.py index 2aea189..c0877e7 100644 --- a/qeschema/converters.py +++ b/qeschema/converters.py @@ -73,14 +73,12 @@ def _build_maps(dict_element, path): path_key = '/'.join((path, key)) if isinstance(item, dict): _build_maps(item, path_key) - continue - if isinstance(item, str): + elif isinstance(item, str): invariant_map[path_key] = item - logger.debug("Added one-to-one association: '{0}'='{1}'".format(path_key, item)) - continue + logger.debug("Added one-to-one association: %r=%r", path_key, item) - if isinstance(item, tuple) or isinstance(item, list): + elif isinstance(item, (tuple, list)): try: variant_map[path_key] = _check_variant(*item) logger.debug("Added single-variant mapping: %r=%r", @@ -90,10 +88,11 @@ def _build_maps(dict_element, path): for variant in item: if isinstance(variant, str): invariant_map[path_key] = variant - elif isinstance(item, tuple) or isinstance(item, list): + elif isinstance(variant, (tuple, list)): variants.append(_check_variant(*variant)) else: - raise TypeError("Expect a tuple, list or string! {0}".format(variant)) + raise TypeError(f"Expect a tuple, list or string! {variant!r}") + variant_map[path_key] = tuple(variants) logger.debug("Added multi-variant mapping: %r=%r", path_key, variant_map[path_key]) @@ -107,7 +106,7 @@ def _build_maps(dict_element, path): # Check inconsistencies between maps for items in variant_map.values(): for value in items: - logger.debug("Check value: {0}".format(value)) + logger.debug("Check value: %r", value) if isinstance(value, str) and value in invariant_map.inverse(): raise ValueError("A variant is also in invariant map! " "'%s': '%s'" % (invariant_map.getkey(value), value)) @@ -163,7 +162,7 @@ def set_path(self, path, tag, node_dict): if len(node_dict) != 1: raise ValueError("The node_dict argument must contains exactly " "one element! {0}".format(node_dict)) - logger.debug("Set input with path '{0}' and node dict '{1}'".format(path, node_dict)) + logger.debug("Set input with path %r and node dict %r", path, node_dict) _path, _, keyword = path.rpartition('/') value = node_dict[tag] if isinstance(value, dict) and keyword != tag: @@ -178,7 +177,7 @@ def set_path(self, path, tag, node_dict): ) if value is None: - logger.debug("Skip element '%s': None value!" % path) + logger.debug("Skip element %r: None value!", path) return # Set the target parameter if the path is in invariant_map dictionary @@ -200,7 +199,7 @@ def set_parameter(self, path, value): raise ValueError("Wrong value {!r} for invariant parameter {!r}".format(target, path)) self._input[namelist][name] = to_fortran(value) - logger.debug("Set {0}[{1}]={2}".format(namelist, name, self._input[namelist][name])) + logger.debug("Set %s[%s]=%s", namelist, name, self._input[namelist][name]) def add_kwarg(self, path, tag, node_dict): if isinstance(self.variant_map[path][0], str): @@ -208,8 +207,8 @@ def add_kwarg(self, path, tag, node_dict): else: target_items = self.variant_map[path] for target, _get_qe_input, _ in target_items: - logger.debug("Add argument to '{0}'".format(target)) - logger.debug("Argument's conversion function: {0}".format(_get_qe_input)) + logger.debug("Add argument to %r", target) + logger.debug("Argument's conversion function: %r", _get_qe_input) group, name = self.target_pattern.match(target).groups() if name is not None: try: @@ -251,36 +250,37 @@ def get_qe_input(self): lines.append('&%s' % namelist) for name, value in sorted(_input[namelist].items(), key=lambda x: x[0].lower()): - logger.debug("Add input for parameter %s[%r] with value %r", namelist, name, value) + logger.debug("Add input for parameter %s[%r] with value %r", + namelist, name, value) + if isinstance(value, dict): # Variant conversion: apply to_fortran_input function with saved arguments try: to_fortran_input = value['_get_qe_input'] except KeyError: - logger.debug( - 'No conversion function for parameter %s[%r], skip ... ', namelist, name - ) + logger.debug('No conversion function for parameter %s[%r], skip ... ', + namelist, name) continue if callable(to_fortran_input): lines.extend(to_fortran_input(name, **value)) else: - logger.error( - 'Parameter %s[%r] conversion function is not callable!', namelist, name - ) + logger.error('Parameter %s[%r] conversion function is not callable!', + namelist, name) else: # Simple invariant conversion lines.append(' {0}={1}'.format(name, value)) lines.append('/') + for card in self.input_cards: - logger.debug("Add card: %s" % card) + logger.debug("Add card %r", card) card_args = _input[card] - logger.debug("Card arguments: {0}".format(card_args)) + logger.debug("Card arguments: %r", card_args) if card not in OPTIONAL_CARDS and \ ('_get_qe_input' not in card_args or not callable(card_args['_get_qe_input'])): - logger.error("Missing conversion function for card '%s'" % card) + logger.error("Missing conversion function for card %r", card) _get_qe_input = card_args.get('_get_qe_input', None) diff --git a/tests/test_cards.py b/tests/test_cards.py index 0670df8..34d5f37 100755 --- a/tests/test_cards.py +++ b/tests/test_cards.py @@ -15,7 +15,7 @@ get_atomic_constraints_card, get_k_points_card, get_atomic_forces_card, \ get_cell_parameters_card, get_qpoints_card, get_climbing_images, \ get_neb_images_positions_card, get_neb_cell_parameters_card, \ - get_neb_atomic_forces_card + get_neb_atomic_forces_card, get_positions_units logger = logging.getLogger('qeschema') @@ -39,7 +39,28 @@ def test_get_atomic_species_card(self): self.assertListEqual(result, []) self.assertEqual(context.output, ["ERROR:qeschema:Missing required arguments when " - "building ATOMIC_SPECIES card! 'atomic_species'"]) + "building ATOMIC_SPECIES card! 'atomic_species'"]) + + def test_get_positions_units(self): + item = { + '@nat': 2, + '@alat': 1.0, + 'crystal_positions': {'atom': [ + {'@name': 'Fe', '@index': 1, '$': [0.0, 0.0, 0.0]}, + {'@name': 'Fe1', '@index': 2, '$': [0.5, 0.5, 0.5]} + ]}, + 'cell': {'a1': [5.406506, 0.0, 0.0], + 'a2': [0.0, 5.406506, 0.0], + 'a3': [0.0, 0.0, 5.406506]} + } + + result, unit = get_positions_units(item) + self.assertDictEqual(result, item['crystal_positions']) + self.assertEqual(unit, 'crystal') + + result, unit = get_positions_units(item={}) + self.assertDictEqual(result, {}) + self.assertIsNone(unit) def test_get_atomic_positions_cell_card(self): kwargs = { @@ -329,6 +350,14 @@ def test_get_neb_images_positions_card(self): 'END_POSITIONS ' ]) + kwargs['free_positions'] = { + '@rank': 2, '@dims': [3, 3], '$': [1, 1] # Wrong number of free positions + } + with self.assertLogs(logger, level='ERROR') as ctx: + get_neb_images_positions_card('ATOMIC_POSITIONS', **kwargs) + self.assertListEqual(ctx.output, ['ERROR:qeschema:ATOMIC_POSITIONS: ' + 'incorrect number of position constraints!']) + kwargs['free_positions'] = { '@rank': 2, '@dims': [3, 3], '$': [1, 1, 1, 1, 1, 1, 1, 1, 1] } From c4acff602f35bc8ce78c626354c08afe642072cb Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Wed, 22 Dec 2021 17:54:41 +0100 Subject: [PATCH 4/9] Update package requirements - Drop support for Python 3.6 (end-of-life date: 23/12/2021) - Requires xmlschema>=1.6.4 (grant Python 3.10 support) --- README.rst | 2 +- docs/conf.py | 2 +- qeschema/__init__.py | 2 +- requirements-dev.txt | 2 +- setup.py | 5 ++--- tox.ini | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index a063bf3..b55de73 100644 --- a/README.rst +++ b/README.rst @@ -11,7 +11,7 @@ opEn-Source Package for Research in Electronic Structure, Simulation and Optimiz Requirements ------------ -* Python_ 3.6+ +* Python_ 3.7+ * xmlschema_ (Python library for processing XML Schema based documents) .. _Python: http://www.python.org/ diff --git a/docs/conf.py b/docs/conf.py index 01418d5..d381488 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ author = 'Davide Brunato, Pietro Delugas' # The full version, including alpha/beta/rc tags -release = '1.2.1' +release = '1.3.0' # -- General configuration --------------------------------------------------- diff --git a/qeschema/__init__.py b/qeschema/__init__.py index 9b8edf4..428ea3f 100644 --- a/qeschema/__init__.py +++ b/qeschema/__init__.py @@ -14,7 +14,7 @@ from .exceptions import QESchemaError, XmlDocumentError from .utils import set_logger -__version__ = '1.2.1' +__version__ = '1.3.0' __all__ = [ 'XmlDocument', 'QeDocument', 'PwDocument', 'PhononDocument', 'NebDocument', diff --git a/requirements-dev.txt b/requirements-dev.txt index 8b6d1b9..a956eb8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,7 +3,7 @@ setuptools tox flake8 coverage -xmlschema>=1.3.0 +xmlschema>=1.6.4 pyyaml numpy h5py diff --git a/setup.py b/setup.py index bf7d76e..c1f9ae8 100644 --- a/setup.py +++ b/setup.py @@ -15,8 +15,8 @@ setup( name='qeschema', - version='1.2.1+devel', - install_requires=['xmlschema>=1.3.0', 'pyyaml', 'numpy'], + version='1.3.0', + install_requires=['xmlschema>=1.6.4', 'pyyaml', 'numpy'], packages=['qeschema'], package_data={'qeschema': ['schemas/*.xsd', 'schemas/releases/*.xsd']}, scripts = ['scripts/xml2qeinput.py', 'scripts/yaml2qeinput.py'], @@ -33,7 +33,6 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', diff --git a/tox.ini b/tox.ini index 1ed76a7..2406d3e 100644 --- a/tox.ini +++ b/tox.ini @@ -4,13 +4,13 @@ # and then run "tox" from this directory. [tox] -envlist = py{36,37,38,39,310}, docs, flake8, coverage +envlist = py{37,38,39,310}, docs, flake8, coverage skip_missing_interpreters = true toxworkdir = {homedir}/.tox/qeschema [testenv] deps = - xmlschema>=1.3.0 + xmlschema>=1.6.4 pyyaml numpy h5py From 809ac7361fe0b64103e9abdd7f80ed30310d404c Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Fri, 24 Dec 2021 12:30:56 +0100 Subject: [PATCH 5/9] Rename tests/examples/ -> tests/resources/ - Add resources for testing QE incomplete data or schema --- tests/resources/dummy/incomplete.xml | 3 +++ tests/resources/dummy/incomplete.xsd | 27 +++++++++++++++++++ .../dummy/instance.csv | 0 .../dummy/instance.json | 0 .../dummy/instance.xml | 0 .../dummy/instance.yaml | 0 .../dummy/instance_json | 0 .../dummy/instance_xml | 0 .../dummy/instance_yaml | 0 .../{examples => resources}/dummy/schema.xsd | 1 + .../neb/Al001+H_pbc.in.test | 0 .../neb/Al001+H_pbc.xml | 0 .../neb/Al001_plus_H_bc3.in.test | 0 .../neb/Al001_plus_H_bc3.xml | 0 .../{examples => resources}/neb/H2+H.in.test | 0 tests/{examples => resources}/neb/H2+H.xml | 0 .../neb/H2+H_crystal.in.test | 0 .../neb/H2+H_crystal.xml | 0 .../periodic_dft_65_WaterP1_0_neb_0.in.test | 0 .../neb/periodic_dft_65_WaterP1_0_neb_0.xml | 0 .../ph/al.elph.in.test | 0 tests/{examples => resources}/ph/al.elph.xml | 0 .../ph/alas_ph.in.test | 0 tests/{examples => resources}/ph/alas_ph.xml | 0 .../ph/alas_recover.in.test | 0 .../ph/alas_recover.xml | 0 .../{examples => resources}/ph/ch4_nm.in.test | 0 tests/{examples => resources}/ph/ch4_nm.xml | 0 .../ph/nat_todo.in.test | 0 tests/{examples => resources}/ph/nat_todo.xml | 0 .../ph/nat_todo_zero.in.test | 0 .../ph/nat_todo_zero.xml | 0 .../ph/sio2_dielectric.in.test | 0 .../ph/sio2_dielectric.xml | 0 .../ph/sio2_prova_disp.in.test | 0 .../ph/sio2_prova_disp.xml | 0 .../ph/sio2_prova_qplot.in.test | 0 .../ph/sio2_prova_qplot.xml | 0 .../pw/Al001_relax_bfgs-input.yml | 0 .../pw/Al001_relax_bfgs.in.test | 0 .../pw/Al001_relax_bfgs.json | 0 .../pw/Al001_relax_bfgs.xml | 0 .../pw/Al001_relax_bfgs.yml | 0 .../pw/Al001_rlx_damp.in.test | 0 .../pw/Al001_rlx_damp.xml | 0 .../pw/Al_bands.in.test | 0 tests/{examples => resources}/pw/Al_bands.xml | 0 .../pw/CO_bgfs_relax.in.test | 0 .../pw/CO_bgfs_relax.xml | 0 ...CO_bgfs_relax_with_external_forces.in.test | 0 .../pw/CO_bgfs_relax_with_external_forces.xml | 0 .../pw/ESM_2Dxy.in.test | 0 tests/{examples => resources}/pw/ESM_2Dxy.xml | 0 .../pw/FeO_LDAU_standard.in.test | 0 .../pw/FeO_LDAU_standard.xml | 0 .../pw/FeO_LDAU_with_no_U.in.test | 0 .../pw/FeO_LDAU_with_no_U.xml | 0 .../pw/FeO_LDAU_with_starting_ns.in.test | 0 .../pw/FeO_LDAU_with_starting_ns.xml | 0 .../pw/Fe_Im-3m_0_dftd3.in.test | 0 .../pw/Fe_Im-3m_0_dftd3.xml | 0 .../pw/Fe_crystal_crystal_positions.in.test | 0 .../pw/Fe_crystal_crystal_positions.xml | 0 .../pw/Fe_non_collinear_penalty.in.test | 0 .../pw/Fe_non_collinear_penalty.xml | 0 .../pw/Fe_noncolin.in.test | 0 .../pw/Fe_noncolin.xml | 0 tests/{examples => resources}/pw/Ni.xml | 0 .../pw/PbTiO3_BerryPhase.in.test | 0 .../pw/PbTiO3_BerryPhase.xml | 0 .../pw/PbTiO3_bc3_fcp_opt.in.test | 0 .../pw/PbTiO3_bc3_fcp_opt.xml | 0 .../pw/PbTiO3_scf.in.test | 0 .../{examples => resources}/pw/PbTiO3_scf.xml | 0 .../pw/Pt_spinorbit.in.test | 0 .../pw/Pt_spinorbit.xml | 0 tests/{examples => resources}/pw/Si.xml | 0 .../{examples => resources}/pw/Si_md.in.test | 0 tests/{examples => resources}/pw/Si_md.xml | 0 .../tddfpt/Ag.tddfpt-eels.in.test | 0 .../tddfpt/Ag.tddfpt-eels.xml | 0 .../tddfpt/Benzene.dav.in.test | 0 .../tddfpt/Benzene.dav.xml | 0 .../tddfpt/CH4.tddfpt.in.test | 0 .../tddfpt/CH4.tddfpt.xml | 0 .../tddfpt/CH4.tddfpt_pp.in.test | 0 .../tddfpt/CH4.tddfpt_pp.xml | 0 87 files changed, 31 insertions(+) create mode 100644 tests/resources/dummy/incomplete.xml create mode 100644 tests/resources/dummy/incomplete.xsd rename tests/{examples => resources}/dummy/instance.csv (100%) rename tests/{examples => resources}/dummy/instance.json (100%) rename tests/{examples => resources}/dummy/instance.xml (100%) rename tests/{examples => resources}/dummy/instance.yaml (100%) rename tests/{examples => resources}/dummy/instance_json (100%) rename tests/{examples => resources}/dummy/instance_xml (100%) rename tests/{examples => resources}/dummy/instance_yaml (100%) rename tests/{examples => resources}/dummy/schema.xsd (94%) rename tests/{examples => resources}/neb/Al001+H_pbc.in.test (100%) rename tests/{examples => resources}/neb/Al001+H_pbc.xml (100%) rename tests/{examples => resources}/neb/Al001_plus_H_bc3.in.test (100%) rename tests/{examples => resources}/neb/Al001_plus_H_bc3.xml (100%) rename tests/{examples => resources}/neb/H2+H.in.test (100%) rename tests/{examples => resources}/neb/H2+H.xml (100%) rename tests/{examples => resources}/neb/H2+H_crystal.in.test (100%) rename tests/{examples => resources}/neb/H2+H_crystal.xml (100%) rename tests/{examples => resources}/neb/periodic_dft_65_WaterP1_0_neb_0.in.test (100%) rename tests/{examples => resources}/neb/periodic_dft_65_WaterP1_0_neb_0.xml (100%) rename tests/{examples => resources}/ph/al.elph.in.test (100%) rename tests/{examples => resources}/ph/al.elph.xml (100%) rename tests/{examples => resources}/ph/alas_ph.in.test (100%) rename tests/{examples => resources}/ph/alas_ph.xml (100%) rename tests/{examples => resources}/ph/alas_recover.in.test (100%) rename tests/{examples => resources}/ph/alas_recover.xml (100%) rename tests/{examples => resources}/ph/ch4_nm.in.test (100%) rename tests/{examples => resources}/ph/ch4_nm.xml (100%) rename tests/{examples => resources}/ph/nat_todo.in.test (100%) rename tests/{examples => resources}/ph/nat_todo.xml (100%) rename tests/{examples => resources}/ph/nat_todo_zero.in.test (100%) rename tests/{examples => resources}/ph/nat_todo_zero.xml (100%) rename tests/{examples => resources}/ph/sio2_dielectric.in.test (100%) rename tests/{examples => resources}/ph/sio2_dielectric.xml (100%) rename tests/{examples => resources}/ph/sio2_prova_disp.in.test (100%) rename tests/{examples => resources}/ph/sio2_prova_disp.xml (100%) rename tests/{examples => resources}/ph/sio2_prova_qplot.in.test (100%) rename tests/{examples => resources}/ph/sio2_prova_qplot.xml (100%) rename tests/{examples => resources}/pw/Al001_relax_bfgs-input.yml (100%) rename tests/{examples => resources}/pw/Al001_relax_bfgs.in.test (100%) rename tests/{examples => resources}/pw/Al001_relax_bfgs.json (100%) rename tests/{examples => resources}/pw/Al001_relax_bfgs.xml (100%) rename tests/{examples => resources}/pw/Al001_relax_bfgs.yml (100%) rename tests/{examples => resources}/pw/Al001_rlx_damp.in.test (100%) rename tests/{examples => resources}/pw/Al001_rlx_damp.xml (100%) rename tests/{examples => resources}/pw/Al_bands.in.test (100%) rename tests/{examples => resources}/pw/Al_bands.xml (100%) rename tests/{examples => resources}/pw/CO_bgfs_relax.in.test (100%) rename tests/{examples => resources}/pw/CO_bgfs_relax.xml (100%) rename tests/{examples => resources}/pw/CO_bgfs_relax_with_external_forces.in.test (100%) rename tests/{examples => resources}/pw/CO_bgfs_relax_with_external_forces.xml (100%) rename tests/{examples => resources}/pw/ESM_2Dxy.in.test (100%) rename tests/{examples => resources}/pw/ESM_2Dxy.xml (100%) rename tests/{examples => resources}/pw/FeO_LDAU_standard.in.test (100%) rename tests/{examples => resources}/pw/FeO_LDAU_standard.xml (100%) rename tests/{examples => resources}/pw/FeO_LDAU_with_no_U.in.test (100%) rename tests/{examples => resources}/pw/FeO_LDAU_with_no_U.xml (100%) rename tests/{examples => resources}/pw/FeO_LDAU_with_starting_ns.in.test (100%) rename tests/{examples => resources}/pw/FeO_LDAU_with_starting_ns.xml (100%) rename tests/{examples => resources}/pw/Fe_Im-3m_0_dftd3.in.test (100%) rename tests/{examples => resources}/pw/Fe_Im-3m_0_dftd3.xml (100%) rename tests/{examples => resources}/pw/Fe_crystal_crystal_positions.in.test (100%) rename tests/{examples => resources}/pw/Fe_crystal_crystal_positions.xml (100%) rename tests/{examples => resources}/pw/Fe_non_collinear_penalty.in.test (100%) rename tests/{examples => resources}/pw/Fe_non_collinear_penalty.xml (100%) rename tests/{examples => resources}/pw/Fe_noncolin.in.test (100%) rename tests/{examples => resources}/pw/Fe_noncolin.xml (100%) rename tests/{examples => resources}/pw/Ni.xml (100%) rename tests/{examples => resources}/pw/PbTiO3_BerryPhase.in.test (100%) rename tests/{examples => resources}/pw/PbTiO3_BerryPhase.xml (100%) rename tests/{examples => resources}/pw/PbTiO3_bc3_fcp_opt.in.test (100%) rename tests/{examples => resources}/pw/PbTiO3_bc3_fcp_opt.xml (100%) rename tests/{examples => resources}/pw/PbTiO3_scf.in.test (100%) rename tests/{examples => resources}/pw/PbTiO3_scf.xml (100%) rename tests/{examples => resources}/pw/Pt_spinorbit.in.test (100%) rename tests/{examples => resources}/pw/Pt_spinorbit.xml (100%) rename tests/{examples => resources}/pw/Si.xml (100%) rename tests/{examples => resources}/pw/Si_md.in.test (100%) rename tests/{examples => resources}/pw/Si_md.xml (100%) rename tests/{examples => resources}/tddfpt/Ag.tddfpt-eels.in.test (100%) rename tests/{examples => resources}/tddfpt/Ag.tddfpt-eels.xml (100%) rename tests/{examples => resources}/tddfpt/Benzene.dav.in.test (100%) rename tests/{examples => resources}/tddfpt/Benzene.dav.xml (100%) rename tests/{examples => resources}/tddfpt/CH4.tddfpt.in.test (100%) rename tests/{examples => resources}/tddfpt/CH4.tddfpt.xml (100%) rename tests/{examples => resources}/tddfpt/CH4.tddfpt_pp.in.test (100%) rename tests/{examples => resources}/tddfpt/CH4.tddfpt_pp.xml (100%) diff --git a/tests/resources/dummy/incomplete.xml b/tests/resources/dummy/incomplete.xml new file mode 100644 index 0000000..3a0d204 --- /dev/null +++ b/tests/resources/dummy/incomplete.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/resources/dummy/incomplete.xsd b/tests/resources/dummy/incomplete.xsd new file mode 100644 index 0000000..612e30b --- /dev/null +++ b/tests/resources/dummy/incomplete.xsd @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/examples/dummy/instance.csv b/tests/resources/dummy/instance.csv similarity index 100% rename from tests/examples/dummy/instance.csv rename to tests/resources/dummy/instance.csv diff --git a/tests/examples/dummy/instance.json b/tests/resources/dummy/instance.json similarity index 100% rename from tests/examples/dummy/instance.json rename to tests/resources/dummy/instance.json diff --git a/tests/examples/dummy/instance.xml b/tests/resources/dummy/instance.xml similarity index 100% rename from tests/examples/dummy/instance.xml rename to tests/resources/dummy/instance.xml diff --git a/tests/examples/dummy/instance.yaml b/tests/resources/dummy/instance.yaml similarity index 100% rename from tests/examples/dummy/instance.yaml rename to tests/resources/dummy/instance.yaml diff --git a/tests/examples/dummy/instance_json b/tests/resources/dummy/instance_json similarity index 100% rename from tests/examples/dummy/instance_json rename to tests/resources/dummy/instance_json diff --git a/tests/examples/dummy/instance_xml b/tests/resources/dummy/instance_xml similarity index 100% rename from tests/examples/dummy/instance_xml rename to tests/resources/dummy/instance_xml diff --git a/tests/examples/dummy/instance_yaml b/tests/resources/dummy/instance_yaml similarity index 100% rename from tests/examples/dummy/instance_yaml rename to tests/resources/dummy/instance_yaml diff --git a/tests/examples/dummy/schema.xsd b/tests/resources/dummy/schema.xsd similarity index 94% rename from tests/examples/dummy/schema.xsd rename to tests/resources/dummy/schema.xsd index 98a3c43..103d558 100644 --- a/tests/examples/dummy/schema.xsd +++ b/tests/resources/dummy/schema.xsd @@ -1,4 +1,5 @@ + diff --git a/tests/examples/neb/Al001+H_pbc.in.test b/tests/resources/neb/Al001+H_pbc.in.test similarity index 100% rename from tests/examples/neb/Al001+H_pbc.in.test rename to tests/resources/neb/Al001+H_pbc.in.test diff --git a/tests/examples/neb/Al001+H_pbc.xml b/tests/resources/neb/Al001+H_pbc.xml similarity index 100% rename from tests/examples/neb/Al001+H_pbc.xml rename to tests/resources/neb/Al001+H_pbc.xml diff --git a/tests/examples/neb/Al001_plus_H_bc3.in.test b/tests/resources/neb/Al001_plus_H_bc3.in.test similarity index 100% rename from tests/examples/neb/Al001_plus_H_bc3.in.test rename to tests/resources/neb/Al001_plus_H_bc3.in.test diff --git a/tests/examples/neb/Al001_plus_H_bc3.xml b/tests/resources/neb/Al001_plus_H_bc3.xml similarity index 100% rename from tests/examples/neb/Al001_plus_H_bc3.xml rename to tests/resources/neb/Al001_plus_H_bc3.xml diff --git a/tests/examples/neb/H2+H.in.test b/tests/resources/neb/H2+H.in.test similarity index 100% rename from tests/examples/neb/H2+H.in.test rename to tests/resources/neb/H2+H.in.test diff --git a/tests/examples/neb/H2+H.xml b/tests/resources/neb/H2+H.xml similarity index 100% rename from tests/examples/neb/H2+H.xml rename to tests/resources/neb/H2+H.xml diff --git a/tests/examples/neb/H2+H_crystal.in.test b/tests/resources/neb/H2+H_crystal.in.test similarity index 100% rename from tests/examples/neb/H2+H_crystal.in.test rename to tests/resources/neb/H2+H_crystal.in.test diff --git a/tests/examples/neb/H2+H_crystal.xml b/tests/resources/neb/H2+H_crystal.xml similarity index 100% rename from tests/examples/neb/H2+H_crystal.xml rename to tests/resources/neb/H2+H_crystal.xml diff --git a/tests/examples/neb/periodic_dft_65_WaterP1_0_neb_0.in.test b/tests/resources/neb/periodic_dft_65_WaterP1_0_neb_0.in.test similarity index 100% rename from tests/examples/neb/periodic_dft_65_WaterP1_0_neb_0.in.test rename to tests/resources/neb/periodic_dft_65_WaterP1_0_neb_0.in.test diff --git a/tests/examples/neb/periodic_dft_65_WaterP1_0_neb_0.xml b/tests/resources/neb/periodic_dft_65_WaterP1_0_neb_0.xml similarity index 100% rename from tests/examples/neb/periodic_dft_65_WaterP1_0_neb_0.xml rename to tests/resources/neb/periodic_dft_65_WaterP1_0_neb_0.xml diff --git a/tests/examples/ph/al.elph.in.test b/tests/resources/ph/al.elph.in.test similarity index 100% rename from tests/examples/ph/al.elph.in.test rename to tests/resources/ph/al.elph.in.test diff --git a/tests/examples/ph/al.elph.xml b/tests/resources/ph/al.elph.xml similarity index 100% rename from tests/examples/ph/al.elph.xml rename to tests/resources/ph/al.elph.xml diff --git a/tests/examples/ph/alas_ph.in.test b/tests/resources/ph/alas_ph.in.test similarity index 100% rename from tests/examples/ph/alas_ph.in.test rename to tests/resources/ph/alas_ph.in.test diff --git a/tests/examples/ph/alas_ph.xml b/tests/resources/ph/alas_ph.xml similarity index 100% rename from tests/examples/ph/alas_ph.xml rename to tests/resources/ph/alas_ph.xml diff --git a/tests/examples/ph/alas_recover.in.test b/tests/resources/ph/alas_recover.in.test similarity index 100% rename from tests/examples/ph/alas_recover.in.test rename to tests/resources/ph/alas_recover.in.test diff --git a/tests/examples/ph/alas_recover.xml b/tests/resources/ph/alas_recover.xml similarity index 100% rename from tests/examples/ph/alas_recover.xml rename to tests/resources/ph/alas_recover.xml diff --git a/tests/examples/ph/ch4_nm.in.test b/tests/resources/ph/ch4_nm.in.test similarity index 100% rename from tests/examples/ph/ch4_nm.in.test rename to tests/resources/ph/ch4_nm.in.test diff --git a/tests/examples/ph/ch4_nm.xml b/tests/resources/ph/ch4_nm.xml similarity index 100% rename from tests/examples/ph/ch4_nm.xml rename to tests/resources/ph/ch4_nm.xml diff --git a/tests/examples/ph/nat_todo.in.test b/tests/resources/ph/nat_todo.in.test similarity index 100% rename from tests/examples/ph/nat_todo.in.test rename to tests/resources/ph/nat_todo.in.test diff --git a/tests/examples/ph/nat_todo.xml b/tests/resources/ph/nat_todo.xml similarity index 100% rename from tests/examples/ph/nat_todo.xml rename to tests/resources/ph/nat_todo.xml diff --git a/tests/examples/ph/nat_todo_zero.in.test b/tests/resources/ph/nat_todo_zero.in.test similarity index 100% rename from tests/examples/ph/nat_todo_zero.in.test rename to tests/resources/ph/nat_todo_zero.in.test diff --git a/tests/examples/ph/nat_todo_zero.xml b/tests/resources/ph/nat_todo_zero.xml similarity index 100% rename from tests/examples/ph/nat_todo_zero.xml rename to tests/resources/ph/nat_todo_zero.xml diff --git a/tests/examples/ph/sio2_dielectric.in.test b/tests/resources/ph/sio2_dielectric.in.test similarity index 100% rename from tests/examples/ph/sio2_dielectric.in.test rename to tests/resources/ph/sio2_dielectric.in.test diff --git a/tests/examples/ph/sio2_dielectric.xml b/tests/resources/ph/sio2_dielectric.xml similarity index 100% rename from tests/examples/ph/sio2_dielectric.xml rename to tests/resources/ph/sio2_dielectric.xml diff --git a/tests/examples/ph/sio2_prova_disp.in.test b/tests/resources/ph/sio2_prova_disp.in.test similarity index 100% rename from tests/examples/ph/sio2_prova_disp.in.test rename to tests/resources/ph/sio2_prova_disp.in.test diff --git a/tests/examples/ph/sio2_prova_disp.xml b/tests/resources/ph/sio2_prova_disp.xml similarity index 100% rename from tests/examples/ph/sio2_prova_disp.xml rename to tests/resources/ph/sio2_prova_disp.xml diff --git a/tests/examples/ph/sio2_prova_qplot.in.test b/tests/resources/ph/sio2_prova_qplot.in.test similarity index 100% rename from tests/examples/ph/sio2_prova_qplot.in.test rename to tests/resources/ph/sio2_prova_qplot.in.test diff --git a/tests/examples/ph/sio2_prova_qplot.xml b/tests/resources/ph/sio2_prova_qplot.xml similarity index 100% rename from tests/examples/ph/sio2_prova_qplot.xml rename to tests/resources/ph/sio2_prova_qplot.xml diff --git a/tests/examples/pw/Al001_relax_bfgs-input.yml b/tests/resources/pw/Al001_relax_bfgs-input.yml similarity index 100% rename from tests/examples/pw/Al001_relax_bfgs-input.yml rename to tests/resources/pw/Al001_relax_bfgs-input.yml diff --git a/tests/examples/pw/Al001_relax_bfgs.in.test b/tests/resources/pw/Al001_relax_bfgs.in.test similarity index 100% rename from tests/examples/pw/Al001_relax_bfgs.in.test rename to tests/resources/pw/Al001_relax_bfgs.in.test diff --git a/tests/examples/pw/Al001_relax_bfgs.json b/tests/resources/pw/Al001_relax_bfgs.json similarity index 100% rename from tests/examples/pw/Al001_relax_bfgs.json rename to tests/resources/pw/Al001_relax_bfgs.json diff --git a/tests/examples/pw/Al001_relax_bfgs.xml b/tests/resources/pw/Al001_relax_bfgs.xml similarity index 100% rename from tests/examples/pw/Al001_relax_bfgs.xml rename to tests/resources/pw/Al001_relax_bfgs.xml diff --git a/tests/examples/pw/Al001_relax_bfgs.yml b/tests/resources/pw/Al001_relax_bfgs.yml similarity index 100% rename from tests/examples/pw/Al001_relax_bfgs.yml rename to tests/resources/pw/Al001_relax_bfgs.yml diff --git a/tests/examples/pw/Al001_rlx_damp.in.test b/tests/resources/pw/Al001_rlx_damp.in.test similarity index 100% rename from tests/examples/pw/Al001_rlx_damp.in.test rename to tests/resources/pw/Al001_rlx_damp.in.test diff --git a/tests/examples/pw/Al001_rlx_damp.xml b/tests/resources/pw/Al001_rlx_damp.xml similarity index 100% rename from tests/examples/pw/Al001_rlx_damp.xml rename to tests/resources/pw/Al001_rlx_damp.xml diff --git a/tests/examples/pw/Al_bands.in.test b/tests/resources/pw/Al_bands.in.test similarity index 100% rename from tests/examples/pw/Al_bands.in.test rename to tests/resources/pw/Al_bands.in.test diff --git a/tests/examples/pw/Al_bands.xml b/tests/resources/pw/Al_bands.xml similarity index 100% rename from tests/examples/pw/Al_bands.xml rename to tests/resources/pw/Al_bands.xml diff --git a/tests/examples/pw/CO_bgfs_relax.in.test b/tests/resources/pw/CO_bgfs_relax.in.test similarity index 100% rename from tests/examples/pw/CO_bgfs_relax.in.test rename to tests/resources/pw/CO_bgfs_relax.in.test diff --git a/tests/examples/pw/CO_bgfs_relax.xml b/tests/resources/pw/CO_bgfs_relax.xml similarity index 100% rename from tests/examples/pw/CO_bgfs_relax.xml rename to tests/resources/pw/CO_bgfs_relax.xml diff --git a/tests/examples/pw/CO_bgfs_relax_with_external_forces.in.test b/tests/resources/pw/CO_bgfs_relax_with_external_forces.in.test similarity index 100% rename from tests/examples/pw/CO_bgfs_relax_with_external_forces.in.test rename to tests/resources/pw/CO_bgfs_relax_with_external_forces.in.test diff --git a/tests/examples/pw/CO_bgfs_relax_with_external_forces.xml b/tests/resources/pw/CO_bgfs_relax_with_external_forces.xml similarity index 100% rename from tests/examples/pw/CO_bgfs_relax_with_external_forces.xml rename to tests/resources/pw/CO_bgfs_relax_with_external_forces.xml diff --git a/tests/examples/pw/ESM_2Dxy.in.test b/tests/resources/pw/ESM_2Dxy.in.test similarity index 100% rename from tests/examples/pw/ESM_2Dxy.in.test rename to tests/resources/pw/ESM_2Dxy.in.test diff --git a/tests/examples/pw/ESM_2Dxy.xml b/tests/resources/pw/ESM_2Dxy.xml similarity index 100% rename from tests/examples/pw/ESM_2Dxy.xml rename to tests/resources/pw/ESM_2Dxy.xml diff --git a/tests/examples/pw/FeO_LDAU_standard.in.test b/tests/resources/pw/FeO_LDAU_standard.in.test similarity index 100% rename from tests/examples/pw/FeO_LDAU_standard.in.test rename to tests/resources/pw/FeO_LDAU_standard.in.test diff --git a/tests/examples/pw/FeO_LDAU_standard.xml b/tests/resources/pw/FeO_LDAU_standard.xml similarity index 100% rename from tests/examples/pw/FeO_LDAU_standard.xml rename to tests/resources/pw/FeO_LDAU_standard.xml diff --git a/tests/examples/pw/FeO_LDAU_with_no_U.in.test b/tests/resources/pw/FeO_LDAU_with_no_U.in.test similarity index 100% rename from tests/examples/pw/FeO_LDAU_with_no_U.in.test rename to tests/resources/pw/FeO_LDAU_with_no_U.in.test diff --git a/tests/examples/pw/FeO_LDAU_with_no_U.xml b/tests/resources/pw/FeO_LDAU_with_no_U.xml similarity index 100% rename from tests/examples/pw/FeO_LDAU_with_no_U.xml rename to tests/resources/pw/FeO_LDAU_with_no_U.xml diff --git a/tests/examples/pw/FeO_LDAU_with_starting_ns.in.test b/tests/resources/pw/FeO_LDAU_with_starting_ns.in.test similarity index 100% rename from tests/examples/pw/FeO_LDAU_with_starting_ns.in.test rename to tests/resources/pw/FeO_LDAU_with_starting_ns.in.test diff --git a/tests/examples/pw/FeO_LDAU_with_starting_ns.xml b/tests/resources/pw/FeO_LDAU_with_starting_ns.xml similarity index 100% rename from tests/examples/pw/FeO_LDAU_with_starting_ns.xml rename to tests/resources/pw/FeO_LDAU_with_starting_ns.xml diff --git a/tests/examples/pw/Fe_Im-3m_0_dftd3.in.test b/tests/resources/pw/Fe_Im-3m_0_dftd3.in.test similarity index 100% rename from tests/examples/pw/Fe_Im-3m_0_dftd3.in.test rename to tests/resources/pw/Fe_Im-3m_0_dftd3.in.test diff --git a/tests/examples/pw/Fe_Im-3m_0_dftd3.xml b/tests/resources/pw/Fe_Im-3m_0_dftd3.xml similarity index 100% rename from tests/examples/pw/Fe_Im-3m_0_dftd3.xml rename to tests/resources/pw/Fe_Im-3m_0_dftd3.xml diff --git a/tests/examples/pw/Fe_crystal_crystal_positions.in.test b/tests/resources/pw/Fe_crystal_crystal_positions.in.test similarity index 100% rename from tests/examples/pw/Fe_crystal_crystal_positions.in.test rename to tests/resources/pw/Fe_crystal_crystal_positions.in.test diff --git a/tests/examples/pw/Fe_crystal_crystal_positions.xml b/tests/resources/pw/Fe_crystal_crystal_positions.xml similarity index 100% rename from tests/examples/pw/Fe_crystal_crystal_positions.xml rename to tests/resources/pw/Fe_crystal_crystal_positions.xml diff --git a/tests/examples/pw/Fe_non_collinear_penalty.in.test b/tests/resources/pw/Fe_non_collinear_penalty.in.test similarity index 100% rename from tests/examples/pw/Fe_non_collinear_penalty.in.test rename to tests/resources/pw/Fe_non_collinear_penalty.in.test diff --git a/tests/examples/pw/Fe_non_collinear_penalty.xml b/tests/resources/pw/Fe_non_collinear_penalty.xml similarity index 100% rename from tests/examples/pw/Fe_non_collinear_penalty.xml rename to tests/resources/pw/Fe_non_collinear_penalty.xml diff --git a/tests/examples/pw/Fe_noncolin.in.test b/tests/resources/pw/Fe_noncolin.in.test similarity index 100% rename from tests/examples/pw/Fe_noncolin.in.test rename to tests/resources/pw/Fe_noncolin.in.test diff --git a/tests/examples/pw/Fe_noncolin.xml b/tests/resources/pw/Fe_noncolin.xml similarity index 100% rename from tests/examples/pw/Fe_noncolin.xml rename to tests/resources/pw/Fe_noncolin.xml diff --git a/tests/examples/pw/Ni.xml b/tests/resources/pw/Ni.xml similarity index 100% rename from tests/examples/pw/Ni.xml rename to tests/resources/pw/Ni.xml diff --git a/tests/examples/pw/PbTiO3_BerryPhase.in.test b/tests/resources/pw/PbTiO3_BerryPhase.in.test similarity index 100% rename from tests/examples/pw/PbTiO3_BerryPhase.in.test rename to tests/resources/pw/PbTiO3_BerryPhase.in.test diff --git a/tests/examples/pw/PbTiO3_BerryPhase.xml b/tests/resources/pw/PbTiO3_BerryPhase.xml similarity index 100% rename from tests/examples/pw/PbTiO3_BerryPhase.xml rename to tests/resources/pw/PbTiO3_BerryPhase.xml diff --git a/tests/examples/pw/PbTiO3_bc3_fcp_opt.in.test b/tests/resources/pw/PbTiO3_bc3_fcp_opt.in.test similarity index 100% rename from tests/examples/pw/PbTiO3_bc3_fcp_opt.in.test rename to tests/resources/pw/PbTiO3_bc3_fcp_opt.in.test diff --git a/tests/examples/pw/PbTiO3_bc3_fcp_opt.xml b/tests/resources/pw/PbTiO3_bc3_fcp_opt.xml similarity index 100% rename from tests/examples/pw/PbTiO3_bc3_fcp_opt.xml rename to tests/resources/pw/PbTiO3_bc3_fcp_opt.xml diff --git a/tests/examples/pw/PbTiO3_scf.in.test b/tests/resources/pw/PbTiO3_scf.in.test similarity index 100% rename from tests/examples/pw/PbTiO3_scf.in.test rename to tests/resources/pw/PbTiO3_scf.in.test diff --git a/tests/examples/pw/PbTiO3_scf.xml b/tests/resources/pw/PbTiO3_scf.xml similarity index 100% rename from tests/examples/pw/PbTiO3_scf.xml rename to tests/resources/pw/PbTiO3_scf.xml diff --git a/tests/examples/pw/Pt_spinorbit.in.test b/tests/resources/pw/Pt_spinorbit.in.test similarity index 100% rename from tests/examples/pw/Pt_spinorbit.in.test rename to tests/resources/pw/Pt_spinorbit.in.test diff --git a/tests/examples/pw/Pt_spinorbit.xml b/tests/resources/pw/Pt_spinorbit.xml similarity index 100% rename from tests/examples/pw/Pt_spinorbit.xml rename to tests/resources/pw/Pt_spinorbit.xml diff --git a/tests/examples/pw/Si.xml b/tests/resources/pw/Si.xml similarity index 100% rename from tests/examples/pw/Si.xml rename to tests/resources/pw/Si.xml diff --git a/tests/examples/pw/Si_md.in.test b/tests/resources/pw/Si_md.in.test similarity index 100% rename from tests/examples/pw/Si_md.in.test rename to tests/resources/pw/Si_md.in.test diff --git a/tests/examples/pw/Si_md.xml b/tests/resources/pw/Si_md.xml similarity index 100% rename from tests/examples/pw/Si_md.xml rename to tests/resources/pw/Si_md.xml diff --git a/tests/examples/tddfpt/Ag.tddfpt-eels.in.test b/tests/resources/tddfpt/Ag.tddfpt-eels.in.test similarity index 100% rename from tests/examples/tddfpt/Ag.tddfpt-eels.in.test rename to tests/resources/tddfpt/Ag.tddfpt-eels.in.test diff --git a/tests/examples/tddfpt/Ag.tddfpt-eels.xml b/tests/resources/tddfpt/Ag.tddfpt-eels.xml similarity index 100% rename from tests/examples/tddfpt/Ag.tddfpt-eels.xml rename to tests/resources/tddfpt/Ag.tddfpt-eels.xml diff --git a/tests/examples/tddfpt/Benzene.dav.in.test b/tests/resources/tddfpt/Benzene.dav.in.test similarity index 100% rename from tests/examples/tddfpt/Benzene.dav.in.test rename to tests/resources/tddfpt/Benzene.dav.in.test diff --git a/tests/examples/tddfpt/Benzene.dav.xml b/tests/resources/tddfpt/Benzene.dav.xml similarity index 100% rename from tests/examples/tddfpt/Benzene.dav.xml rename to tests/resources/tddfpt/Benzene.dav.xml diff --git a/tests/examples/tddfpt/CH4.tddfpt.in.test b/tests/resources/tddfpt/CH4.tddfpt.in.test similarity index 100% rename from tests/examples/tddfpt/CH4.tddfpt.in.test rename to tests/resources/tddfpt/CH4.tddfpt.in.test diff --git a/tests/examples/tddfpt/CH4.tddfpt.xml b/tests/resources/tddfpt/CH4.tddfpt.xml similarity index 100% rename from tests/examples/tddfpt/CH4.tddfpt.xml rename to tests/resources/tddfpt/CH4.tddfpt.xml diff --git a/tests/examples/tddfpt/CH4.tddfpt_pp.in.test b/tests/resources/tddfpt/CH4.tddfpt_pp.in.test similarity index 100% rename from tests/examples/tddfpt/CH4.tddfpt_pp.in.test rename to tests/resources/tddfpt/CH4.tddfpt_pp.in.test diff --git a/tests/examples/tddfpt/CH4.tddfpt_pp.xml b/tests/resources/tddfpt/CH4.tddfpt_pp.xml similarity index 100% rename from tests/examples/tddfpt/CH4.tddfpt_pp.xml rename to tests/resources/tddfpt/CH4.tddfpt_pp.xml From 94eb33c5bb821e413587ed57209c92cf7b75d36b Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Fri, 24 Dec 2021 12:34:26 +0100 Subject: [PATCH 6/9] Update Authors section --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index b55de73..b9272ea 100644 --- a/README.rst +++ b/README.rst @@ -56,6 +56,7 @@ Authors Davide Brunato Pietro Delugas Giovanni Borghi +Alexandr Fonari License From 3a650c1bd9ab038f9c3ab1db0077e77491410ff8 Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Fri, 24 Dec 2021 12:38:24 +0100 Subject: [PATCH 7/9] Add tests for untested parts of QeDocument/PwDocument --- .coveragerc | 3 +- qeschema/documents.py | 13 ++- tests/test_converters.py | 6 +- tests/test_documents.py | 165 ++++++++++++++++++++++++++------------- 4 files changed, 127 insertions(+), 60 deletions(-) diff --git a/.coveragerc b/.coveragerc index 1cd4855..7cb3004 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,7 +5,8 @@ source = qeschema/ [report] exclude_lines = # Exclude not implemented features - raise NotImplementedError + pragma: no cover + raise NotImplementedError() # Exclude lines where yaml library is not installed except ImportError\: diff --git a/qeschema/documents.py b/qeschema/documents.py index cf683c8..a1fdf7e 100644 --- a/qeschema/documents.py +++ b/qeschema/documents.py @@ -498,7 +498,7 @@ def get_fortran_input(self, use_defaults=True): rel_path = path.replace(input_path, '.') xsd_element = schema_root.find(path) if xsd_element is None: - logger.error("%r doesn't match any element!" % path) + logger.error("%r doesn't match any element!", path) continue else: value = xsd_element.decode(elem, use_defaults=use_defaults) @@ -594,6 +594,7 @@ def get_forces(self): if elem is not None: forces = self.schema.find(path).decode(elem) path = './/output//atomic_positions' + breakpoint() atomic_positions = self.schema.find(path).decode(self.find(path)) atoms = atomic_positions.get('atom', []) if not isinstance(atoms, list): @@ -622,7 +623,15 @@ def get_ks_eigenvalues(self): :return: nested list of KS eigenvalues for each k_point in Hartree Units """ path = './/output//ks_energies/eigenvalues' - return [self.schema.find(path).decode(e)['$'] for e in self.findall(path)] + eigenvalues = [] + for e in self.findall(path): + obj = self.schema.find(path).decode(e) + if isinstance(obj, dict): + eigenvalues.append(obj['$']) # pragma: no cover + else: + eigenvalues.append(obj) + + return eigenvalues @requires_xml_data def get_total_energy(self): diff --git a/tests/test_converters.py b/tests/test_converters.py index cbdacdc..1bfd8fd 100755 --- a/tests/test_converters.py +++ b/tests/test_converters.py @@ -65,7 +65,7 @@ def setUpClass(cls): cls.pkg_folder = os.path.dirname(cls.test_dir) def test_xml2qeinput_script(self): - xml_filename = os.path.join(self.test_dir, 'examples/pw/Al001_relax_bfgs.xml') + xml_filename = os.path.join(self.test_dir, 'resources/pw/Al001_relax_bfgs.xml') in_filename = xml_filename[:-4] + '.in' py_filename = os.path.join(self.pkg_folder, 'scripts/xml2qeinput.py') if os.path.isfile(in_filename): @@ -85,7 +85,7 @@ def test_xml2qeinput_script(self): 'Test output file %r missing!' % in_filename) def test_yaml2qeinput_script(self): - xml_filename = os.path.join(self.test_dir, 'examples/pw/Al001_relax_bfgs.yml') + xml_filename = os.path.join(self.test_dir, 'resources/pw/Al001_relax_bfgs.yml') in_filename = xml_filename[:-4] + '.in' py_filename = os.path.join(self.pkg_folder, 'scripts/yaml2qeinput.py') if os.path.isfile(in_filename): @@ -110,7 +110,7 @@ def test_yaml2qeinput_script(self): # test_dir = os.path.dirname(os.path.abspath(__file__)) -for filename in glob.glob(os.path.join(test_dir, "examples/*/*.xml")): +for filename in glob.glob(os.path.join(test_dir, "resources/*/*.xml")): qe_input_filename = '%s.in.test' % filename[:-4] if not os.path.isfile(qe_input_filename): continue diff --git a/tests/test_documents.py b/tests/test_documents.py index 97fff65..0c51a21 100755 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -25,7 +25,7 @@ def setUpClass(cls): cls.test_dir = os.path.dirname(os.path.abspath(__file__)) cls.pkg_folder = os.path.dirname(cls.test_dir) cls.schemas_dir = os.path.join(cls.pkg_folder, 'qeschema/schemas') - cls.output_file = os.path.join(cls.test_dir, 'examples/dummy/write_test_file') + cls.output_file = os.path.join(cls.test_dir, 'resources/dummy/write_test_file') def setUp(self): if os.path.isfile(self.output_file): @@ -90,7 +90,7 @@ def test_pw_document_init(self): self.assertIsInstance(PwDocument(), PwDocument) self.assertTrue(document.schema.url.endswith("qeschema/schemas/qes.xsd")) - source = os.path.join(self.test_dir, 'examples/pw/Al001_relax_bfgs.xml') + source = os.path.join(self.test_dir, 'resources/pw/Al001_relax_bfgs.xml') document = PwDocument(source) if platform.system() == 'Linux': self.assertEqual(document.filename, source) @@ -105,7 +105,7 @@ def test_pw_document_init(self): self.assertTrue(document.filename.endswith('Al001_relax_bfgs.xml')) self.assertTrue(document.schema.url.endswith("qeschema/schemas/qes.xsd")) - source = os.path.join(self.test_dir, 'examples/pw/Al001_rlx_damp.xml') + source = os.path.join(self.test_dir, 'resources/pw/Al001_rlx_damp.xml') document = PwDocument(source) if platform.system() == 'Linux': self.assertEqual(document.filename, source) @@ -138,7 +138,7 @@ def test_td_spectrum_document_init(self): self.assertIsInstance(TdSpectrumDocument(schema=schema), TdSpectrumDocument) def test_init_from_xml_resource(self): - xml_file = os.path.join(self.test_dir, 'examples/pw/CO_bgfs_relax.xml') + xml_file = os.path.join(self.test_dir, 'resources/pw/CO_bgfs_relax.xml') document = PwDocument(source=XMLResource(xml_file)) if platform.system() == 'Linux': self.assertEqual(document.filename, xml_file) @@ -213,22 +213,22 @@ def test_exception_class(self): schema = os.path.join(self.schemas_dir, 'qes.xsd') document = TdSpectrumDocument(schema=schema) - document.read(os.path.join(self.test_dir, 'examples/pw/Al001_relax_bfgs.xml')) + document.read(os.path.join(self.test_dir, 'resources/pw/Al001_relax_bfgs.xml')) with self.assertRaises(XmlDocumentError): document.get_fortran_input() def test_read_method(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') document = XmlDocument(schema=schema) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') with open(filename) as f: with self.assertRaises(TypeError): document.read(f) with self.assertRaises(ValueError): - document.read(os.path.join(self.test_dir, 'examples/unknown.xml')) + document.read(os.path.join(self.test_dir, 'resources/unknown.xml')) document.read(filename) self.assertTrue(hasattr(document.root, 'tag')) @@ -238,7 +238,7 @@ def test_read_method(self): else: self.assertTrue(document.filename.endswith('instance.xml')) - filename = os.path.join(self.test_dir, 'examples/dummy/instance_xml') + filename = os.path.join(self.test_dir, 'resources/dummy/instance_xml') document.read(filename) self.assertTrue(hasattr(document.root, 'tag')) self.assertEqual(document.format, 'xml') @@ -247,7 +247,7 @@ def test_read_method(self): else: self.assertTrue(document.filename.endswith('instance_xml')) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.json') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.json') document.read(filename) self.assertTrue(hasattr(document.root, 'tag')) self.assertEqual(document.root.tag, 'root') @@ -257,7 +257,7 @@ def test_read_method(self): else: self.assertTrue(document.filename.endswith('instance.json')) - filename = os.path.join(self.test_dir, 'examples/dummy/instance_json') + filename = os.path.join(self.test_dir, 'resources/dummy/instance_json') document.read(filename) self.assertTrue(hasattr(document.root, 'tag')) self.assertEqual(document.root.tag, 'root') @@ -267,7 +267,7 @@ def test_read_method(self): else: self.assertTrue(document.filename.endswith('instance_json')) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.yaml') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.yaml') document.read(filename) self.assertTrue(hasattr(document.root, 'tag')) self.assertEqual(document.root.tag, 'root') @@ -277,7 +277,7 @@ def test_read_method(self): else: self.assertTrue(document.filename.endswith('instance.yaml')) - filename = os.path.join(self.test_dir, 'examples/dummy/instance_yaml') + filename = os.path.join(self.test_dir, 'resources/dummy/instance_yaml') document.read(filename) self.assertTrue(hasattr(document.root, 'tag')) self.assertEqual(document.root.tag, 'root') @@ -287,14 +287,14 @@ def test_read_method(self): else: self.assertTrue(document.filename.endswith('instance_yaml')) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.csv') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.csv') with self.assertRaises(ValueError): document.read(filename) def test_from_xml_method(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') document = XmlDocument(schema=schema) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') document.from_xml(filename) self.assertTrue(hasattr(document.root, 'tag')) @@ -319,8 +319,8 @@ def test_from_xml_method(self): self.assertEqual(len(document.errors), 1) def test_from_json_method(self): - document = XmlDocument(schema=os.path.join(self.test_dir, 'examples/dummy/schema.xsd')) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.json') + document = XmlDocument(schema=os.path.join(self.test_dir, 'resources/dummy/schema.xsd')) + filename = os.path.join(self.test_dir, 'resources/dummy/instance.json') document.from_json(filename) self.assertTrue(hasattr(document.root, 'tag')) @@ -340,8 +340,8 @@ def test_from_json_method(self): self.assertGreaterEqual(len(document.errors), 1) def test_from_yaml_method(self): - document = XmlDocument(schema=os.path.join(self.test_dir, 'examples/dummy/schema.xsd')) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.yaml') + document = XmlDocument(schema=os.path.join(self.test_dir, 'resources/dummy/schema.xsd')) + filename = os.path.join(self.test_dir, 'resources/dummy/instance.yaml') document.from_yaml(filename) self.assertTrue(hasattr(document.root, 'tag')) @@ -366,7 +366,7 @@ def test_from_yaml_method(self): self.assertGreaterEqual(len(document.errors), 1) def test_from_dict_method(self): - document = XmlDocument(schema=os.path.join(self.test_dir, 'examples/dummy/schema.xsd')) + document = XmlDocument(schema=os.path.join(self.test_dir, 'resources/dummy/schema.xsd')) document.from_dict({'root': {'node': [None, None, None]}}) self.assertTrue(hasattr(document.root, 'tag')) @@ -382,8 +382,8 @@ def test_from_dict_method(self): self.assertGreaterEqual(len(document.errors), 1) def test_write_method(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') document = XmlDocument(schema=schema) with self.assertRaises(RuntimeError): @@ -395,8 +395,8 @@ def test_write_method(self): self.assertIsInstance(ElementTree.parse(self.output_file), ElementTree.ElementTree) def test_write_method_from_unbound(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') with open(filename) as fp: xml_data = fp.read() @@ -412,8 +412,8 @@ def test_write_method_from_unbound(self): self.assertTrue(document.filename.endswith('write_test_file')) def test_write_other_formats(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') document = XmlDocument(filename, schema) document.write(self.output_file, output_format='json') @@ -433,9 +433,9 @@ def test_write_other_formats(self): document.write(self.output_file, output_format='csv') def test_to_dict_method(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') document = XmlDocument(schema=schema) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') document.read(filename) self.assertEqual(document.to_dict(keep_unknown=True), @@ -444,9 +444,9 @@ def test_to_dict_method(self): {'node': [{"@a":10}, "value", None]}) def test_to_json_method(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') document = XmlDocument(schema=schema) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') document.read(filename) self.assertEqual(document.to_json().replace(' ', '').replace('\n', ''), @@ -473,8 +473,8 @@ def test_to_json_method(self): '{"root":{"node":[{"@a":10},"value",null]}}') def test_to_yaml_method(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') document = XmlDocument(filename, schema) self.assertEqual(document.to_yaml(), "root:\n node:\n - '@a': 10\n - value\n - null\n") @@ -498,27 +498,27 @@ def test_to_yaml_method(self): self.assertEqual(f.read(), "root:\n node:\n - '@a': 10\n - value\n - null\n") def test_iter_method(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') document = XmlDocument(schema=schema) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') document.read(filename) root = document.root self.assertEqual(list(document.iter()), [root, root[0], root[1], root[2]]) def test_find_method(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') document = XmlDocument(schema=schema) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') document.read(filename) self.assertEqual(document.find('.'), document.root) self.assertEqual(document.find('/node'), document.root[0]) def test_findall_method(self): - schema = os.path.join(self.test_dir, 'examples/dummy/schema.xsd') + schema = os.path.join(self.test_dir, 'resources/dummy/schema.xsd') document = XmlDocument(schema=schema) - filename = os.path.join(self.test_dir, 'examples/dummy/instance.xml') + filename = os.path.join(self.test_dir, 'resources/dummy/instance.xml') document.read(filename) self.assertEqual(document.findall('.'), [document.root]) @@ -526,13 +526,28 @@ def test_findall_method(self): def test_unsupported_schema(self): with self.assertRaises(NotImplementedError): - PwDocument(schema=os.path.join(self.test_dir, 'examples/dummy/schema.xsd')) + PwDocument(schema=os.path.join(self.test_dir, 'resources/dummy/schema.xsd')) - def test_pw_document(self): - xml_filename = os.path.join(self.test_dir, 'examples/pw/Al001_relax_bfgs.xml') - document = PwDocument() + def test_incomplete_schema(self): + schema_path = os.path.join(self.test_dir, 'resources/dummy/incomplete.xsd') + document = PwDocument(schema=schema_path) + xml_filename = os.path.join(self.test_dir, 'resources/dummy/incomplete.xml') document.read(xml_filename) + + with self.assertRaises(XmlDocumentError) as ctx: + document.get_fortran_input() + self.assertEqual(str(ctx.exception), "Missing input './input' in XML data!") + + document.root.append(ElementTree.Element('input')) + with self.assertRaises(XmlDocumentError) as ctx: + document.get_fortran_input() + self.assertEqual(str(ctx.exception), "Missing input element in XSD schema!") + + def test_pw_document(self): + xml_filename = os.path.join(self.test_dir, 'resources/pw/Al001_relax_bfgs.xml') + document = PwDocument(source=xml_filename) + self.assertTrue(hasattr(document.root, 'tag')) self.assertEqual(document.root.tag, '{http://www.quantum-espresso.org/ns/qes/qes-1.0}espresso') @@ -546,8 +561,50 @@ def test_pw_document(self): self.assertEqual(document.input_path, 'input') self.assertEqual(document.output_path, 'output') + def test_pw_output_get_forces(self): + xml_filename = os.path.join(self.test_dir, 'resources/pw/Si.xml') + document = PwDocument(source=xml_filename) + + self.assertIsNone(document.get_forces()) + + # TODO: add a case with ./output/forces/ section + + def test_pw_output_get_k_points(self): + xml_filename = os.path.join(self.test_dir, 'resources/pw/Ni.xml') + document = PwDocument(source=xml_filename) + + k_points = document.get_k_points() + expected = [ + [-0.1666666666666667, 0.1666666666666667, 0.1666666666666667], + [0.5, -0.5, 0.8333333333333333], + [0.1666666666666667, -0.1666666666666667, 0.5], + [-0.1666666666666666, -1.166666666666667, 0.1666666666666666], + [-0.4999999999999999, -0.8333333333333334, -0.1666666666666666], + [0.5, -0.5, -0.5] + ] + self.assertListEqual(k_points, expected) + + def test_pw_output_get_ks_eigenvalues(self): + xml_filename = os.path.join(self.test_dir, 'resources/pw/Ni.xml') + document = PwDocument(source=xml_filename) + + ks_eigenvalues = document.get_ks_eigenvalues() + + self.assertEqual(len(ks_eigenvalues), 6) + for row in ks_eigenvalues: + self.assertEqual(len(row), 18) + for value in row: + self.assertIsInstance(value, float) + + def test_pw_output_get_total_energy(self): + xml_filename = os.path.join(self.test_dir, 'resources/pw/Ni.xml') + document = PwDocument(source=xml_filename) + + total_energy = document.get_total_energy() + self.assertEqual(total_energy, -30.44558256272531) + def test_phonon_document(self): - xml_filename = os.path.join(self.test_dir, 'examples/ph/al.elph.xml') + xml_filename = os.path.join(self.test_dir, 'resources/ph/al.elph.xml') document = PhononDocument(xml_filename) self.assertTrue(hasattr(document.root, 'tag')) @@ -564,7 +621,7 @@ def test_phonon_document(self): self.assertEqual(document.output_path, 'outputPH') def test_neb_document(self): - xml_filename = os.path.join(self.test_dir, 'examples/neb/Al001_plus_H_bc3.xml') + xml_filename = os.path.join(self.test_dir, 'resources/neb/Al001_plus_H_bc3.xml') document = NebDocument() document.read(xml_filename) @@ -581,7 +638,7 @@ def test_neb_document(self): self.assertEqual(document.output_path, 'output') def test_td_document(self): - xml_filename = os.path.join(self.test_dir, 'examples/tddfpt/Ag.tddfpt-eels.xml') + xml_filename = os.path.join(self.test_dir, 'resources/tddfpt/Ag.tddfpt-eels.xml') document = TdDocument(source=xml_filename) self.assertTrue(hasattr(document.root, 'tag')) @@ -598,7 +655,7 @@ def test_td_document(self): self.assertEqual(document.output_path, 'output') def test_td_spectrum_document(self): - xml_filename = os.path.join(self.test_dir, 'examples/tddfpt/CH4.tddfpt_pp.xml') + xml_filename = os.path.join(self.test_dir, 'resources/tddfpt/CH4.tddfpt_pp.xml') document = TdSpectrumDocument() document.read(xml_filename) @@ -616,7 +673,7 @@ def test_td_spectrum_document(self): self.assertEqual(document.output_path, 'output') def test_fortran_input_generator(self): - xml_filename = os.path.join(self.test_dir, 'examples/pw/Al001_relax_bfgs.xml') + xml_filename = os.path.join(self.test_dir, 'resources/pw/Al001_relax_bfgs.xml') document = PwDocument() document.read(xml_filename) @@ -634,23 +691,23 @@ def test_fortran_input_generator(self): self.assertEqual(fortran_input, document.get_fortran_input()) def test_pw_get_atomic_positions(self): - source = os.path.join(self.test_dir, 'examples/pw/Al001_relax_bfgs.xml') + source = os.path.join(self.test_dir, 'resources/pw/Al001_relax_bfgs.xml') document = PwDocument(source) positions = document.get_atomic_positions() self.assertIsNone(positions) - source = os.path.join(self.test_dir, 'examples/pw/Ni.xml') + source = os.path.join(self.test_dir, 'resources/pw/Ni.xml') document = PwDocument(source) positions = document.get_atomic_positions() self.assertEqual(positions, (['Ni'], [[0.0, 0.0, 0.0]])) def test_pw_get_cell_parameters(self): - source = os.path.join(self.test_dir, 'examples/pw/Al001_relax_bfgs.xml') + source = os.path.join(self.test_dir, 'resources/pw/Al001_relax_bfgs.xml') document = PwDocument(source) cells = document.get_cell_parameters() self.assertIsNone(cells) - source = os.path.join(self.test_dir, 'examples/pw/Ni.xml') + source = os.path.join(self.test_dir, 'resources/pw/Ni.xml') document = PwDocument(source) cells = document.get_cell_parameters() self.assertListEqual( @@ -658,12 +715,12 @@ def test_pw_get_cell_parameters(self): ) def test_pw_get_stress(self): - source = os.path.join(self.test_dir, 'examples/pw/Al001_relax_bfgs.xml') + source = os.path.join(self.test_dir, 'resources/pw/Al001_relax_bfgs.xml') document = PwDocument(source) stress = document.get_stress() self.assertIsNone(stress) - source = os.path.join(self.test_dir, 'examples/pw/Si.xml') + source = os.path.join(self.test_dir, 'resources/pw/Si.xml') document = PwDocument(source) stress = document.get_stress() self.assertListEqual( From 973de414c746106955f08f5cc6009dfce61a4f66 Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Fri, 24 Dec 2021 14:46:47 +0100 Subject: [PATCH 8/9] Clean and split hdf5 subpackage - Remove postqe related functions - Keep HDF5 utils in hdf5.py - Keep UPF utils in upf.py - Delete old hdf5/ subpackage - Add h5py to package requirements --- qeschema/__init__.py | 2 +- qeschema/hdf5.py | 89 +++++++++ qeschema/hdf5/__init__.py | 18 -- qeschema/hdf5/charge.py | 162 --------------- qeschema/hdf5/readutils.py | 288 -------------------------- qeschema/upf.py | 128 ++++++++++++ setup.py | 2 +- tests/resources/upf/N.pz-vbc.UPF | 333 +++++++++++++++++++++++++++++++ tests/test_hdf5.py | 37 ++++ tests/test_upf.py | 37 ++++ 10 files changed, 626 insertions(+), 470 deletions(-) create mode 100644 qeschema/hdf5.py delete mode 100644 qeschema/hdf5/__init__.py delete mode 100644 qeschema/hdf5/charge.py delete mode 100644 qeschema/hdf5/readutils.py create mode 100644 qeschema/upf.py create mode 100644 tests/resources/upf/N.pz-vbc.UPF create mode 100755 tests/test_hdf5.py create mode 100755 tests/test_upf.py diff --git a/qeschema/__init__.py b/qeschema/__init__.py index 428ea3f..3ad127f 100644 --- a/qeschema/__init__.py +++ b/qeschema/__init__.py @@ -20,5 +20,5 @@ 'XmlDocument', 'QeDocument', 'PwDocument', 'PhononDocument', 'NebDocument', 'TdDocument', 'TdSpectrumDocument', 'RawInputConverter', 'PwInputConverter', 'PhononInputConverter', 'TdInputConverter', 'TdSpectrumInputConverter', - 'NebInputConverter', 'QESchemaError', 'XmlDocumentError', 'set_logger' + 'NebInputConverter', 'QESchemaError', 'XmlDocumentError', 'set_logger', 'hdf5' ] diff --git a/qeschema/hdf5.py b/qeschema/hdf5.py new file mode 100644 index 0000000..10e64e8 --- /dev/null +++ b/qeschema/hdf5.py @@ -0,0 +1,89 @@ +# +# Copyright (c), 2021, Quantum Espresso Foundation and SISSA (Scuola +# Internazionale Superiore di Studi Avanzati). All rights reserved. +# This file is distributed under the terms of the MIT License. See the +# file 'LICENSE' in the root directory of the present distribution, or +# http://opensource.org/licenses/MIT. +# +import numpy as np +import h5py + +__all__ = ['read_charge_file', 'get_wf_attributes', 'get_wavefunctions', + 'get_wfc_miller_indices'] + + +def read_charge_file(filename): + """ + Reads a PW charge file in HDF5 format. + + :param filename: the name of the HDF5 file to read. + :return: a dictionary describing the content of file \ + keys=[nr, ngm_g, gamma_only, rhog_, MillerIndexes] + """ + with h5py.File(filename, "r") as h5f: + MI = h5f.get('MillerIndices')[:] + nr1 = 2 * max(abs(MI[:, 0])) + 1 + nr2 = 2 * max(abs(MI[:, 1])) + 1 + nr3 = 2 * max(abs(MI[:, 2])) + 1 + nr = np.array([nr1, nr2, nr3]) + res = dict(h5f.attrs.items()) + res.update({'MillInd': MI, 'nr_min': nr}) + rhog = h5f['rhotot_g'][:].reshape(res['ngm_g'], 2).dot([1.e0, 1.e0j]) + res['rhotot_g'] = rhog + if 'rhodiff_g' in h5f.keys(): + rhog = h5f['rhodiff_g'][:].reshape(res['ngm_g'], 2).dot([1.e0, 1.e0j]) + res['rhodiff_g'] = rhog + return res + + +# TODO update to the new format +def get_wf_attributes(filename): + """ + Read attributes from a wfc HDF5 file. + + :param filename: the path to the wfc file + :return: a dictionary with all attributes included reciprocal vectors + """ + with h5py.File(filename, "r") as f: + res = dict(f.attrs) + mi_attrs = f.get('MillerIndices').attrs + bg = np.array(mi_attrs.get(x) for x in ['bg1', 'bg2', 'bg3']) + res.update({'bg': bg}) + return res + + +def get_wavefunctions(filename, start_band=None, stop_band=None): + """ + Returns a numpy array with the wave functions for bands from start_band to + stop_band. If not specified starts from 1st band and ends with last one. + Band numbering is Python style starts from 0.abs + + :param filename: path to the wfc file + :param start_band: first band to read, default first band in the file + :param stop_band: last band to read, default last band in the file + :return: a numpy array with shape [nbnd,npw] + """ + with h5py.File(filename, "r") as f: + igwx = f.attrs.get('igwx') + if start_band is None: + start_band = 0 + if stop_band is None: + stop_band = f.attrs.get('nbnd') + if stop_band == start_band: + stop_band = start_band + 1 + res = f.get('evc')[start_band:stop_band, :] + + res = np.asarray(x.reshape([igwx, 2]).dot([1.e0, 1.e0j]) for x in res[:]) + return res + + +def get_wfc_miller_indices(filename): + """ + Reads miller indices from the wfc file + + :param filename: path to the wfc HDF5 file + :return: a np.array of integers with shape [igwx,3] + """ + with h5py.File(filename, "r") as f: + res = f.get("MillerIndices")[:, :] + return res diff --git a/qeschema/hdf5/__init__.py b/qeschema/hdf5/__init__.py deleted file mode 100644 index 1e7bc0f..0000000 --- a/qeschema/hdf5/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# -# Copyright (c), 2021, Quantum Espresso Foundation and SISSA (Scuola -# Internazionale Superiore di Studi Avanzati). All rights reserved. -# This file is distributed under the terms of the MIT License. See the -# file 'LICENSE' in the root directory of the present distribution, or -# http://opensource.org/licenses/MIT. -# -from .charge import read_charge_file_hdf5, get_minus_indexes, \ - get_charge_r, write_charge -from .readutils import get_wf_attributes, get_wavefunctions, \ - get_wfc_miller_indices, read_pseudo_file, create_header, \ - read_postqe_output_file, read_etotv - -__all__ = [ - 'read_charge_file_hdf5', 'get_minus_indexes', 'get_charge_r', 'write_charge', - 'get_wf_attributes', 'get_wavefunctions', 'get_wfc_miller_indices', - 'read_pseudo_file', 'create_header', 'read_postqe_output_file', 'read_etotv' -] diff --git a/qeschema/hdf5/charge.py b/qeschema/hdf5/charge.py deleted file mode 100644 index 42246c2..0000000 --- a/qeschema/hdf5/charge.py +++ /dev/null @@ -1,162 +0,0 @@ -# -# Copyright (c), 2021, Quantum Espresso Foundation and SISSA (Scuola -# Internazionale Superiore di Studi Avanzati). All rights reserved. -# This file is distributed under the terms of the MIT License. See the -# file 'LICENSE' in the root directory of the present distribution, or -# http://opensource.org/licenses/MIT. -# -import numpy as np - -try: - import h5py -except ImportError: - h5py = None - H5PY_ERR = 'h5py module is missing' - - -def read_charge_file_hdf5(filename): - """ - Reads a PW charge file in HDF5 format. - - :param filename: the name of the HDF5 file to read. - :return: a dictionary describing the content of file \ - keys=[nr, ngm_g, gamma_only, rhog_, MillerIndexes] - """ - - if not h5py: - raise ImportError(H5PY_ERR) - - with h5py.File(filename, "r") as h5f: - MI = h5f.get('MillerIndices')[:] - nr1 = 2 * max(abs(MI[:, 0])) + 1 - nr2 = 2 * max(abs(MI[:, 1])) + 1 - nr3 = 2 * max(abs(MI[:, 2])) + 1 - nr = np.array([nr1, nr2, nr3]) - res = dict(h5f.attrs.items()) - res.update({'MillInd': MI, 'nr_min': nr}) - rhog = h5f['rhotot_g'][:].reshape(res['ngm_g'], 2).dot([1.e0, 1.e0j]) - res['rhotot_g'] = rhog - if 'rhodiff_g' in h5f.keys(): - rhog = h5f['rhodiff_g'][:].reshape(res['ngm_g'], 2).dot([1.e0, 1.e0j]) - res['rhodiff_g'] = rhog - return res - - -def get_minus_indexes(g1, g2, g3): - """ - Used for getting the corresponding minus Miller Indexes. It is meant - to be used for converting Gamma Trick grids and is defined only for - the for i >=0, in the i =0 plan is defined only for j >=0 and when - i=0 j=0 k must be >=0. Out of this domain returns None. - - :param g1: rank 1 array containing first Miller Index - :param g2: rank 1 array containing second Miller Index - :param g3: rank 1 array containing third Miller Index - :return: a rank 2 array with dimension (ngm/2,3) containing mirrored Miller indexes - """ - - def scalar_func(i, j, k): - """ - scalar function to be vectorized - :param i: 1st Miller Index - :param j: 2nd - :param k: 3rd - :return: the mirrored mirror indexes - """ - if i > 0: - return -i, j, k - elif i == 0 and j > 0: - return 0, -j, k - elif i == 0 and j == 0 and k > 0: - return 0, 0, -k - else: - return i, j, k - - vector_func = np.vectorize(scalar_func) - - res = np.array(vector_func(g1, g2, g3)) - return res.transpose() - - -def get_charge_r(filename, nr=None): - """ - Reads a charge file written with QE in HDF5 format. *nr = [nr1,nr2,nr3]* (the dimensions of - the charge k-points grid) are given as parameter (taken for the xml output file by the caller). - - Notes: In the new format, the values of the charge in the reciprocal space are stored. - Besides, only the values of the charge > cutoff are stored, together with the Miller indexes. - Hence - """ - cdata = read_charge_file_hdf5(filename) - if nr is None: - nr1, nr2, nr3 = cdata['nrmin'] - else: - nr1, nr2, nr3 = nr - gamma_only = 'TRUE' in str(cdata['gamma_only']).upper() - - # Load the total charge - rho_temp = np.zeros([nr1, nr2, nr3], dtype=np.complex128) - for (i, j, k), rho in zip(cdata['MillInd'], cdata['rhotot_g']): - try: - rho_temp[i, j, k] = rho - except IndexError: - pass - - if gamma_only: - rhotot_g = cdata['rhotot_g'].conjugate() - MI = get_minus_indexes( - cdata['MillInd'][:, 0], cdata['MillInd'][:, 1], cdata['MillInd'][:, 2] - ) - print("MI", MI) - for (i, j, k), rho in zip(MI, rhotot_g): - try: - rho_temp[i, j, k] = rho - except IndexError: - pass - - rhotot_r = np.fft.ifftn(rho_temp) * nr1 * nr2 * nr3 - - # Read the charge difference spin up - spin down if present (for magnetic calculations) - if 'rhodiff_g' in cdata.keys(): - rho_temp = np.zeros([nr1, nr2, nr3], dtype=np.complex128) - for (i, j, k), rho in zip(cdata['MillInd'], cdata['rhodiff_g']): - try: - rho_temp[i, j, k] = rho - except IndexError: - pass - - if gamma_only: - rhodiff_g = cdata['rhodiff_g'].conjugate() - for (i, j, k), rho in zip(MI, rhodiff_g): - try: - rho_temp[i, j, k] = rho - except IndexError: - pass - - rhodiff_r = np.fft.ifftn(rho_temp) * nr1 * nr2 * nr3 - return rhotot_r.real, rhodiff_r.real - else: - return rhotot_r.real, None - - -def write_charge(filename, charge, header): - """ - Write the charge or another quantity calculated by postqe into a text file *filename*. - """ - - fout = open(filename, "w") - - # The header contains some information on the system, the grid nr, etc. - fout.write(header) - nr = charge.shape - count = 0 - # Loop with the order as in QE files - for z in range(0, nr[2]): - for y in range(0, nr[1]): - for x in range(0, nr[0]): - fout.write(" {:.9E}".format(charge[x, y, z])) - count += 1 - if count % 5 == 0: - fout.write("\n") - - fout.close() diff --git a/qeschema/hdf5/readutils.py b/qeschema/hdf5/readutils.py deleted file mode 100644 index dc92a46..0000000 --- a/qeschema/hdf5/readutils.py +++ /dev/null @@ -1,288 +0,0 @@ -# -# Copyright (c), 2021, Quantum Espresso Foundation and SISSA (Scuola -# Internazionale Superiore di Studi Avanzati). All rights reserved. -# This file is distributed under the terms of the MIT License. See the -# file 'LICENSE' in the root directory of the present distribution, or -# http://opensource.org/licenses/MIT. -# -""" -A collection of functions for reading different files and quantities. -""" -import numpy as np -from xml.etree import ElementTree - -try: - import h5py -except ImportError: - h5py = None - H5PY_ERR = 'h5py module is missing' - - -# TODO update to the new format -def get_wf_attributes(filename): - """ - Read attributes from a wfc file. - - :param filename: the path to the wfc file - :return: a dictionary with all attributes included reciprocal vectors - """ - - if not h5py: - raise ImportError(H5PY_ERR) - - with h5py.File(filename, "r") as f: - res = dict(f.attrs) - mi_attrs = f.get('MillerIndices').attrs - bg = np.array(mi_attrs.get(x) for x in ['bg1', 'bg2', 'bg3']) - res.update({'bg': bg}) - return res - - -def get_wavefunctions(filename, start_band=None, stop_band=None): - """ - Returns a numpy array with the wave functions for bands from start_band to - stop_band. If not specified starts from 1st band and ends with last one. - Band numbering is Python style starts from 0.abs - - :param filename: path to the wfc file - :param start_band: first band to read, default first band in the file - :param stop_band: last band to read, default last band in the file - :return: a numpy array with shape [nbnd,npw] - """ - - if not h5py: - raise ImportError(H5PY_ERR) - - with h5py.File(filename, "r") as f: - igwx = f.attrs.get('igwx') - if start_band is None: - start_band = 0 - if stop_band is None: - stop_band = f.attrs.get('nbnd') - if stop_band == start_band: - stop_band = start_band + 1 - res = f.get('evc')[start_band:stop_band, :] - - res = np.asarray(x.reshape([igwx, 2]).dot([1.e0, 1.e0j]) for x in res[:]) - return res - - -def get_wfc_miller_indices(filename): - """ - Reads miller indices from the wfc file - - :param filename: path to the wfc file - :return: a np.array of integers with shape [igwx,3] - """ - - if not h5py: - raise ImportError(H5PY_ERR) - - with h5py.File(filename, "r") as f: - res = f.get("MillerIndices")[:, :] - return res - - -def read_pseudo_file(xmlfile): - """ - This function reads a pseudopotential XML-like file in the QE UPF format (text), - returning the content of each tag in a dictionary. The file is read in strings - and completed with a root UPF tag when it lacks, to avoids an XML syntax error. - - TODO: add support for UPF-schema files - """ - def iter_upf_file(): - """ - Creates an iterator over the lines of an UPF file, - inserting the root tag when missing. - """ - with open(xmlfile, 'r') as f: - fake_root = None - for line in f: - if fake_root is not None: - line = line.replace('&input', '&input') - line = line.replace('&inputp', '&inputp') - yield line - else: - line = line.strip() - if line.startswith("', ' '): - yield line - fake_root = False - elif line: - yield "" - yield line - fake_root = True - if fake_root is True: - yield "" - - pseudo = {} - psroot = ElementTree.fromstringlist(list(iter_upf_file())) - - # PP_INFO - try: - pp_info = psroot.find('PP_INFO').text - except AttributeError: - pp_info = "" - try: - pp_input = psroot.find('PP_INFO/PP_INPUTFILE').text - except AttributeError: - pp_input = "" - pseudo.update(PP_INFO=dict(INFO=pp_info, PP_INPUT=pp_input)) - - # PP_HEADER - pseudo.update(PP_HEADER=dict(psroot.find('PP_HEADER').items())) - - # PP_MESH - pp_mesh = dict(psroot.find('PP_MESH').items()) - pp_r = np.array([float(x) for x in psroot.find('PP_MESH/PP_R').text.split()]) - pp_rab = np.array([float(x) for x in psroot.find('PP_MESH/PP_RAB').text.split()]) - pp_mesh.update(PP_R=pp_r, PP_RAB=pp_rab) - pseudo.update(PP_MESH=pp_mesh) - - # PP_LOCAL - node = psroot.find('PP_LOCAL') - if node is not None: - pp_local = np.array([x for x in map(float, node.text.split())]) - else: - pp_local = None - pseudo.update(PP_LOCAL=pp_local) - - # PP_RHOATOM - node = psroot.find('PP_RHOATOM') - if node is not None: - pp_rhoatom = np.array([v for v in map(float, node.text.split())]) - else: - pp_rhoatom = None - pseudo.update(PP_RHOATOM=pp_rhoatom) - - # PP_NONLOCAL - node = psroot.find('PP_NONLOCAL') - if node is not None: - betas = list() - dij = None - pp_aug = None - pp_q = None - for el in node: - if 'PP_BETA' in el.tag: - beta = dict(el.items()) - val = np.array(x for x in map(float, el.text.split())) - beta.update(beta=val) - betas.append(beta) - elif 'PP_DIJ' in el.tag: - text = '\n'.join(el.text.strip().split('\n')[1:]) - dij = np.array([x for x in map(float, text.split())]) - elif 'PP_AUGMENTATION' in el.tag: - pp_aug = dict(el.items()) - pp_qijl = list() - pp_qij = list() - for q in el: - if 'PP_QIJL' in q.tag: - qijl = dict(q.items()) - val = np.array(x for x in map(float, q.text.split())) - qijl.update(qijl=val) - pp_qijl.append(qijl) - elif 'PP_QIJ' in q.tag: - qij = dict(q.items()) - val = np.array(x for x in map(float, q.text.split())) - qij.update(qij=val) - pp_qij.append(qij) - elif q.tag == 'PP_Q': - pp_q = np.array(x for x in map(float, q.text.split())) - pp_aug.update(PP_QIJL=pp_qijl, PP_QIJ=pp_qij, PP_Q=pp_q) - pp_nonlocal = dict(PP_BETA=betas, PP_DIJ=dij, PP_AUGMENTATION=pp_aug) - else: - pp_nonlocal = None - - pseudo.update(PP_NONLOCAL=pp_nonlocal) - return pseudo - - -def create_header(prefix, nr, nr_smooth, ibrav, celldms, nat, ntyp, - atomic_species, atomic_positions): - """ - Creates the header lines for the output charge (or potential) text file as in pp.x. - The format is: - - system_prefix - fft_grid (nr1,nr2,nr3) fft_smooth (nr1,nr2,nr3) nat ntyp - ibrav celldms (6 real as in QE) - missing line with respect to pp.x - List of atoms - List of positions for each atom - """ - text = "# " + prefix + "\n" - text += "# {:8d} {:8d} {:8d} {:8d} {:8d} {:8d} {:8d} {:8d}\n".format( - nr[0], nr[1], nr[2], nr_smooth[0], nr_smooth[1], nr_smooth[2], nat, ntyp - ) - text += "# {:6d} {:8E} {:8E} {:8E} {:8E} {:8E} {:8E}\n".format(ibrav, *celldms) - - # TODO This line is to be implemented - text += "# " + 4 * "XXXX " + "\n" - - ityp = 1 - for typ in atomic_species: - text += "# {:4d} ".format(ityp) + typ["@name"] + "\n" - ityp += 1 - - ipos = 1 - for pos in atomic_positions: - text += "# {:4d} ".format(ipos) - coords = [float(x) for x in pos['$']] - text += " {:9E} {:9E} {:9E} ".format(*coords) - text += pos["@name"] + "\n" - ipos += 1 - - return text - - -def read_postqe_output_file(filename): - """ - This function reads the output charge (or other quantity) as the output - format of postqe. - """ - tempcharge = [] - count = 0 - nr = np.zeros(3, dtype=int) - with open(filename, "r") as lines: - for line in lines: - words = line.split() - if count == 1: - nr[0] = int(words[1]) - nr[1] = int(words[2]) - nr[2] = int(words[3]) - if words[0] != '#': # skip the first lines beginning with # - for j in range(len(words)): # len(words)=5 except maybe for the last line - tempcharge.append(float(words[j])) - count += 1 - - charge = np.zeros((nr[0], nr[1], nr[2])) - count = 0 - - # Loops according to the order it is done in QE - for z in range(nr[2]): - for y in range(nr[1]): - for x in range(nr[0]): - charge[x, y, z] = tempcharge[count] - count += 1 - - return charge - - -def read_etotv(fname): - """ - Read cell volumes and the corresponding energies from input file *fname* - (1st col, volumes, 2nd col energies). Units must be :math:`a.u.^3` and - :math:`Ryd/cell` - """ - Vx = [] - Ex = [] - - with open(fname, "r") as lines: - for line in lines: - linesplit = line.split() - V = float(linesplit[0]) - E = float(linesplit[1]) - Vx.append(V) - Ex.append(E) - - return np.array(Vx), np.array(Ex) diff --git a/qeschema/upf.py b/qeschema/upf.py new file mode 100644 index 0000000..a93a50a --- /dev/null +++ b/qeschema/upf.py @@ -0,0 +1,128 @@ +# +# Copyright (c), 2021, Quantum Espresso Foundation and SISSA (Scuola +# Internazionale Superiore di Studi Avanzati). All rights reserved. +# This file is distributed under the terms of the MIT License. See the +# file 'LICENSE' in the root directory of the present distribution, or +# http://opensource.org/licenses/MIT. +# +""" +A collection of functions for reading different files and quantities. +""" +import numpy as np +from xml.etree import ElementTree + +__all__ = ['read_pseudo_file'] + + +def read_pseudo_file(xml_file): + """ + Reads a pseudo-potential XML-like file in the QE UPF format (text), returning + the content of each tag in a dictionary. The file is read in strings and + completed with a root UPF tag when it lacks, to avoids an XML syntax error. + + TODO: add support for UPF-schema files + """ + def iter_upf_file(): + """ + Creates an iterator over the lines of an UPF file, + inserting the root tag when missing. + """ + with open(xml_file, 'r') as f: + fake_root = None + for line in f: + if fake_root is not None: + line = line.replace('&input', '&input') + line = line.replace('&inputp', '&inputp') + yield line + else: + line = line.strip() + if line.startswith("', ' '): + yield line + fake_root = False + elif line: + yield "" + yield line + fake_root = True + if fake_root is True: + yield "" + + pseudo = {} + psroot = ElementTree.fromstringlist(list(iter_upf_file())) + + # PP_INFO + try: + pp_info = psroot.find('PP_INFO').text + except AttributeError: + pp_info = "" + try: + pp_input = psroot.find('PP_INFO/PP_INPUTFILE').text + except AttributeError: + pp_input = "" + pseudo.update(PP_INFO=dict(INFO=pp_info, PP_INPUT=pp_input)) + + # PP_HEADER + pseudo.update(PP_HEADER=dict(psroot.find('PP_HEADER').attrib)) + + # PP_MESH + pp_mesh = dict(psroot.find('PP_MESH').attrib) + pp_r = np.array([float(x) for x in psroot.find('PP_MESH/PP_R').text.split()]) + pp_rab = np.array([float(x) for x in psroot.find('PP_MESH/PP_RAB').text.split()]) + pp_mesh.update(PP_R=pp_r, PP_RAB=pp_rab) + pseudo.update(PP_MESH=pp_mesh) + + # PP_LOCAL + node = psroot.find('PP_LOCAL') + if node is not None: + pp_local = np.array([x for x in map(float, node.text.split())]) + else: + pp_local = None + pseudo.update(PP_LOCAL=pp_local) + + # PP_RHOATOM + node = psroot.find('PP_RHOATOM') + if node is not None: + pp_rhoatom = np.array([v for v in map(float, node.text.split())]) + else: + pp_rhoatom = None + pseudo.update(PP_RHOATOM=pp_rhoatom) + + # PP_NONLOCAL + node = psroot.find('PP_NONLOCAL') + if node is not None: + betas = list() + dij = None + pp_aug = None + pp_q = None + for el in node: + if 'PP_BETA' in el.tag: + beta = dict(el.attrib) + val = np.array(x for x in map(float, el.text.split())) + beta.update(beta=val) + betas.append(beta) + elif 'PP_DIJ' in el.tag: + text = '\n'.join(el.text.strip().split('\n')[1:]) + dij = np.array([x for x in map(float, text.split())]) + elif 'PP_AUGMENTATION' in el.tag: + pp_aug = dict(el.attrib) + pp_qijl = list() + pp_qij = list() + for q in el: + if 'PP_QIJL' in q.tag: + qijl = dict(q.attrib) + val = np.array(x for x in map(float, q.text.split())) + qijl.update(qijl=val) + pp_qijl.append(qijl) + elif 'PP_QIJ' in q.tag: + qij = dict(q.attrib) + val = np.array(x for x in map(float, q.text.split())) + qij.update(qij=val) + pp_qij.append(qij) + elif q.tag == 'PP_Q': + pp_q = np.array(x for x in map(float, q.text.split())) + pp_aug.update(PP_QIJL=pp_qijl, PP_QIJ=pp_qij, PP_Q=pp_q) + pp_nonlocal = dict(PP_BETA=betas, PP_DIJ=dij, PP_AUGMENTATION=pp_aug) + else: + pp_nonlocal = None + + pseudo.update(PP_NONLOCAL=pp_nonlocal) + return pseudo diff --git a/setup.py b/setup.py index c1f9ae8..0addf2f 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name='qeschema', version='1.3.0', - install_requires=['xmlschema>=1.6.4', 'pyyaml', 'numpy'], + install_requires=['xmlschema>=1.6.4', 'pyyaml', 'numpy', 'h5py'], packages=['qeschema'], package_data={'qeschema': ['schemas/*.xsd', 'schemas/releases/*.xsd']}, scripts = ['scripts/xml2qeinput.py', 'scripts/yaml2qeinput.py'], diff --git a/tests/resources/upf/N.pz-vbc.UPF b/tests/resources/upf/N.pz-vbc.UPF new file mode 100644 index 0000000..868143f --- /dev/null +++ b/tests/resources/upf/N.pz-vbc.UPF @@ -0,0 +1,333 @@ + + +Generated by new atomic code, or converted to UPF format +Author: +Generation date: +Pseudopotential type: NC +Element: N +Functional: SLA PZ NOGX NOGC +Suggested minimum cutoff for wavefunctions: 60. Ry +Suggested minimum cutoff for charge density: 240. Ry +The Pseudo was generated with a Non-Relativistic Calculation +L component and cutoff radius for Local Potential: 0 0.0000 +Valence configuration: +nl pn l occ Rcut Rcut US E pseu +2S 0 0 2.00 1.120 0.000 0.000000 +2P 0 1 3.00 0.000 0.000 0.000000 +Generation configuration: not available. + + + + + +2.616519841250000e-3 2.785270872660000e-3 2.964905410530000e-3 3.156125380720000e-3 +3.359677979430000e-3 3.576358592850000e-3 3.807013905190000e-3 4.052545207100000e-3 +4.313911917470000e-3 4.592135332410000e-3 4.888302615950000e-3 5.203571048190001e-3 +5.539172547390000e-3 5.896418483690001e-3 6.276704803339999e-3 6.681517483419999e-3 +7.112438338270000e-3 7.571151200479999e-3 8.059448500540000e-3 8.579238270760001e-3 +9.132551600959999e-3 9.721550575000000e-3 1.034853671920000e-2 1.101595999550000e-2 +1.172642837480000e-2 1.248271802790000e-2 1.328778417300000e-2 1.414477262340000e-2 +1.505703208030000e-2 1.602812721720000e-2 1.706185260950000e-2 1.816224756170000e-2 +1.933361189090000e-2 2.058052272880000e-2 2.190785240640000e-2 2.332078749340000e-2 +2.482484906430000e-2 2.642591427250000e-2 2.813023931490000e-2 2.994448387870000e-2 +3.187573716410000e-2 3.393154558510000e-2 3.611994225780000e-2 3.844947838990000e-2 +4.092925669430000e-2 4.356896695870000e-2 4.637892390830000e-2 4.937010751100001e-2 +5.255420588160000e-2 5.594366095380000e-2 5.955171709690000e-2 6.339247286870000e-2 +6.748093610590001e-2 7.183308256730001e-2 7.646591835990001e-2 8.139754639010000e-2 +8.664723710180001e-2 9.223550377540001e-2 9.818418268440000e-2 1.045165184210000e-1 +1.112572547240000e-1 1.184327311690000e-1 1.260709860840000e-1 1.342018661160000e-1 +1.428571428570000e-1 1.520706369880000e-1 1.618783504380000e-1 1.723186070600000e-1 +1.834322023840000e-1 1.952625630250000e-1 2.078559163740000e-1 2.212614712330000e-1 +2.355316101000000e-1 2.507220938510000e-1 2.668922796330000e-1 2.841053527970000e-1 +3.024285738020000e-1 3.219335410300000e-1 3.426964705670000e-1 3.647984940090000e-1 +3.883259754940000e-1 4.133708491670000e-1 4.400309784170000e-1 4.684105382770000e-1 +4.986204224950000e-1 5.307786768490001e-1 5.650109604170001e-1 6.014510365920001e-1 +6.402412957630000e-1 6.815333117100000e-1 7.254884338830000e-1 7.722784178770000e-1 +8.220860965720000e-1 8.751060945550000e-1 9.315455886190001e-1 9.916251173140001e-1 +1.055579442700000e0 1.123658467710000e0 1.196128212590000e0 1.273271854460000e0 +1.355390833770000e0 1.442806032210000e0 1.535859026580000e0 1.634913423480000e0 +1.740356280100000e0 1.852599616710000e0 1.972082026580000e0 2.099270389830000e0 +2.234661697740000e0 2.378784994800000e0 2.532203445920000e0 2.695516537040000e0 +2.869362417600000e0 3.054420394160000e0 3.251413584790000e0 3.461111744660000e0 +3.684334273880000e0 3.921953419350000e0 4.174897683030000e0 4.444155450140000e0 +4.730778851240000e0 5.035887873510000e0 5.360674737090000e0 5.706408553690000e0 +6.074440285720000e0 6.466208025180000e0 6.883242613010000e0 7.327173620940000e0 +7.799735719020000e0 8.302775453920001e0 8.838258464340001e0 9.408277161770000e0 +1.001505890670000e1 1.066097471190000e1 1.134854850750000e1 1.208046700300000e1 +1.285959018580000e1 1.368896249670000e1 1.457182472610000e1 1.551162667730000e1 +1.651204064670000e1 1.757697577390000e1 1.871059331580000e1 1.991732290780000e1 +2.120187987180000e1 2.256928364220000e1 2.402487737880000e1 2.557434884600000e1 +2.722375263690000e1 2.897953383300000e1 3.084855318720000e1 3.283811393340001e1 +3.495599032350000e1 3.721045800530000e1 3.961032636040001e1 4.216497292660001e1 +4.488438004080001e1 4.777917384540000e1 5.086066581010001e1 5.414089693170000e1 +5.763268478470000e1 + + +1.635324900780000e-4 1.740794295410000e-4 1.853065881580000e-4 1.972578362950000e-4 +2.099798737140000e-4 2.235224120530000e-4 2.379383690750001e-4 2.532840754440000e-4 +2.696194948420001e-4 2.870084582760000e-4 3.055189134970000e-4 3.252231905120000e-4 +3.461982842120000e-4 3.685261552300001e-4 3.922940502090000e-4 4.175948427140000e-4 +4.445273961420000e-4 4.731969500300000e-4 5.037155312840000e-4 5.362023919220000e-4 +5.707844750600000e-4 6.075969109379999e-4 6.467835449490000e-4 6.884974997170000e-4 +7.329017734279999e-4 7.801698767450000e-4 8.304865108090000e-4 8.840482889630000e-4 +9.410645050170000e-4 1.001757951070000e-3 1.066365788100000e-3 1.135140472610000e-3 +1.208350743180000e-3 1.286282670550000e-3 1.369240775400000e-3 1.457549218340000e-3 +1.551553066520000e-3 1.651619642030000e-3 1.758139957180000e-3 1.871530242420000e-3 +1.992233572750000e-3 2.120721599070000e-3 2.257496391110000e-3 2.403092399370000e-3 +2.558078543390000e-3 2.723060434920000e-3 2.898682744270000e-3 3.085631719439999e-3 +3.284637867600000e-3 3.496478809610000e-3 3.721982318560000e-3 3.962029554300000e-3 +4.217558506620000e-3 4.489567660450000e-3 4.779119897490000e-3 5.087346649380001e-3 +5.415452318860002e-3 5.764718985960000e-3 6.136511417780000e-3 6.532282401310001e-3 +6.953578420280000e-3 7.402045698039999e-3 7.879436630219999e-3 8.387616632260000e-3 +8.928571428570001e-3 9.504414811769999e-3 1.011739690240000e-2 1.076991294130000e-2 +1.146451264900000e-2 1.220391018910000e-2 1.299099477340000e-2 1.382884195210000e-2 +1.472072563130000e-2 1.567013086570000e-2 1.668076747710000e-2 1.775658454980000e-2 +1.890178586260000e-2 2.012084631440000e-2 2.141852941040000e-2 2.279990587560000e-2 +2.427037346840000e-2 2.583567807300000e-2 2.750193615110001e-2 2.927565864230000e-2 +3.116377640590000e-2 3.317366730300000e-2 3.531318502610000e-2 3.759068978700000e-2 +4.001508098520000e-2 4.259583198190001e-2 4.534302711770000e-2 4.826740111730000e-2 +5.138038103580000e-2 5.469413090970000e-2 5.822159928870000e-2 6.197656983210001e-2 +6.597371516899999e-2 7.022865423170000e-2 7.475801328690000e-2 7.957949090360001e-2 +8.471192711030000e-2 9.017537701320000e-2 9.599118916140000e-2 1.021820889670000e-1 +1.087722675060000e-1 1.157874760440000e-1 1.232551266610000e-1 1.312043993640000e-1 +1.396663561090000e-1 1.486740621750000e-1 1.582627153700000e-1 1.684697835650000e-1 +1.793351511000000e-1 1.909012746350000e-1 2.032133490490000e-1 2.163194840410000e-1 +2.302708921180000e-1 2.451220887090000e-1 2.609311051900000e-1 2.777597156340000e-1 +2.956736782030000e-1 3.147429920950000e-1 3.350421710680000e-1 3.566505346060000e-1 +3.796525178580000e-1 4.041380015740000e-1 4.302026633130000e-1 4.579483513090000e-1 +4.874834824390001e-1 5.189234658700000e-1 5.523911540210000e-1 5.880173226110000e-1 +6.259411816669999e-1 6.663109194930001e-1 7.092842817170000e-1 7.550291876850000e-1 +8.037243866119999e-1 8.555601560450000e-1 9.107390453810000e-1 9.694766673280000e-1 +1.032002540420000e0 1.098560985870000e0 1.169412082240000e0 1.244832681740000e0 +1.325117491990000e0 1.410580227640000e0 1.501554836180000e0 1.598396802870000e0 +1.701484539810000e0 1.811220864560000e0 1.928034574200000e0 2.052382120840000e0 +2.184749395220000e0 2.325653625330000e0 2.475645397530000e0 2.635310807910000e0 +2.805273752550000e0 2.986198365340000e0 3.178791613130000e0 3.383806058230000e0 +3.602042799040000e0 + + + +-3.086944442370000e1 -3.086943243850000e1 -3.086941885750000e1 -3.086940346840001e1 +-3.086938603020000e1 -3.086936627020000e1 -3.086934387940000e1 -3.086931850730000e1 +-3.086928975700000e1 -3.086925717890000e1 -3.086922026320000e1 -3.086917843250000e1 +-3.086913103250000e1 -3.086907732170000e1 -3.086901645990000e1 -3.086894749510000e1 +-3.086886934870000e1 -3.086878079840000e1 -3.086868045920000e1 -3.086856676200000e1 +-3.086843792870000e1 -3.086829194450000e1 -3.086812652670000e1 -3.086793908890000e1 +-3.086772670050000e1 -3.086748604110000e1 -3.086721334860000e1 -3.086690436030000e1 +-3.086655424710000e1 -3.086615753700000e1 -3.086570803070000e1 -3.086519870440000e1 +-3.086462160020000e1 -3.086396770170000e1 -3.086322679320000e1 -3.086238729970000e1 +-3.086143610570000e1 -3.086035834870000e1 -3.085913718500001e1 -3.085775352350000e1 +-3.085618572160000e1 -3.085440923790000e1 -3.085239623590000e1 -3.085011512760000e1 +-3.084753004860000e1 -3.084460025100000e1 -3.084127939710000e1 -3.083751473370000e1 +-3.083324611950000e1 -3.082840487160000e1 -3.082291238600000e1 -3.081667847310000e1 +-3.080959933230000e1 -3.080155506630000e1 -3.079240660390000e1 -3.078199186530000e1 +-3.077012095010000e1 -3.075657007180000e1 -3.074107388300000e1 -3.072331574510000e1 +-3.070291538650000e1 -3.067941326250000e1 -3.065225078080000e1 -3.062074539420000e1 +-3.058405938120000e1 -3.054116095950000e1 -3.049077621520000e1 -3.043133021440000e1 +-3.036087062270000e1 -3.027690804010000e1 -3.017656162020000e1 -3.005619442320000e1 +-2.991136537790000e1 -2.973668814000000e1 -2.952568595010000e1 -2.927065456960000e1 +-2.896255258510000e1 -2.859094802000000e1 -2.814406241710000e1 -2.760896797730000e1 +-2.697200860300000e1 -2.621952882350000e1 -2.533900022010000e1 -2.432062468730000e1 +-2.315945595530000e1 -2.185800138070000e1 -2.042913233530000e1 -1.889893798090000e1 +-1.730891259100000e1 -1.571659672760000e1 -1.419352813680000e1 -1.281910244950000e1 +-1.166866294910000e1 -1.079396030730000e1 -1.019518390150000e1 -9.790279299530001e0 +-9.409572018480000e0 -8.899800144529999e0 -8.360447703549999e0 -7.853845216450000e0 +-7.377972754660000e0 -6.930949688680000e0 -6.511018515160000e0 -6.116533463660000e0 +-5.745950412750000e0 -5.397820598440000e0 -5.070783044810000e0 -4.763559803120000e0 +-4.474950292880000e0 -4.203826757380000e0 -3.949129764530000e0 -3.709864087530000e0 +-3.485094786780000e0 -3.273943571630000e0 -3.075585355010000e0 -2.889245054300000e0 +-2.714194543260000e0 -2.549749810930000e0 -2.395268274840000e0 -2.250146308390000e0 +-2.113816832240000e0 -1.985747143540000e0 -1.865436807580000e0 -1.752415705040000e0 +-1.646242205590000e0 -1.546501431820000e0 -1.452803647080000e0 -1.364782725120000e0 +-1.282094719730000e0 -1.204416527450000e0 -1.131444620260000e0 -1.062893855960000e0 +-9.984963731430000e-1 -9.380005361740000e-1 -8.811699569740000e-1 -8.277825683870001e-1 +-7.776297588740000e-1 -7.305155533290000e-1 -6.862558533880000e-1 -6.446777131080000e-1 +-6.056186650020000e-1 -5.689260849900000e-1 -5.344565960200000e-1 -5.020755078120001e-1 +-4.716562905620000e-1 -4.430800805140000e-1 -4.162352155130000e-1 -3.910167986600000e-1 +-3.673262884450000e-1 -3.450711136830000e-1 -3.241643117970000e-1 -3.045241890020000e-1 +-2.860740010940000e-1 -2.687416535600000e-1 -2.524594198780000e-1 -2.371636768640000e-1 +-2.227946560720000e-1 -2.092962102390000e-1 -1.966155938960000e-1 -1.847032572580000e-1 +-1.735126526120000e-1 + + + +5.782571626949999e-2 6.155519477950000e-2 6.552521263190001e-2 6.975128485530000e-2 +7.424992852200001e-2 7.903872169200000e-2 8.413638285820001e-2 8.956283757829999e-2 +9.533929535790000e-2 1.014883316580000e-1 1.080339827170000e-1 1.150018403710000e-1 +1.224191366260000e-1 1.303148743550000e-1 1.387199221160000e-1 1.476671448520000e-1 +1.571915268970000e-1 1.673303154820000e-1 1.781231667990000e-1 1.896122997580000e-1 +2.018426574160000e-1 2.148620991530000e-1 2.287215723420000e-1 2.434753275660000e-1 +2.591811363750000e-1 2.759004962060000e-1 2.936988788350000e-1 3.126460915280000e-1 +3.328163485400000e-1 3.542887833060000e-1 3.771476017200000e-1 4.014825940110000e-1 +4.273893388480000e-1 4.549696121290000e-1 4.843319746960000e-1 5.155919493890000e-1 +5.488727866690000e-1 5.843057421430000e-1 6.220307625300000e-1 6.621970669220000e-1 +7.049636994329999e-1 7.505003596530000e-1 7.989879968890000e-1 8.506197555680000e-1 +9.056016539690001e-1 9.641537100670000e-1 1.026510766100000e0 1.092923645550000e0 +1.163660325270000e0 1.239007109890000e0 1.319269969810000e0 1.404775941840000e0 +1.495874610650000e0 1.592939574980000e0 1.696370119540000e0 1.806592651320000e0 +1.924062198150000e0 2.049263818010000e0 2.182713560320000e0 2.324958984310000e0 +2.476578938760000e0 2.638182127640000e0 2.810404685200000e0 2.993903254780000e0 +3.189347771530000e0 3.397407070240000e0 3.618728095700000e0 3.853907326280000e0 +4.103448810790000e0 4.367705520910000e0 4.646798467940000e0 4.940507347840000e0 +5.248122373740000e0 5.568246689620000e0 5.898538298580000e0 6.235376730880000e0 +6.573441850180000e0 6.905193275580000e0 7.220255582680000e0 7.504722153830000e0 +7.740440093930000e0 7.904390390140000e0 7.968378983310000e0 7.899393334260000e0 +7.661163444730000e0 7.217658481460000e0 6.539368466100000e0 5.613063775530000e0 +4.454955107400000e0 3.125368046740000e0 1.739885878430000e0 4.678784802630000e-1 +-4.934516216890000e-1 -9.784974495810001e-1 -9.410329662530000e-1 -5.363043086400000e-1 +-1.183074049940000e-1 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 0.000000000000000e0 +0.000000000000000e0 + + +7.381333001930001e-1 + + + + +2.256372600000000e-3 2.401897700000000e-3 2.556808700000000e-3 2.721711000000000e-3 +2.897249100000000e-3 3.084108900000000e-3 3.283020800000000e-3 3.494762300000000e-3 +3.720161000000000e-3 3.960097800000000e-3 4.215510600000000e-3 4.487398000000001e-3 +4.776822600000000e-3 5.084916100000000e-3 5.412883000000001e-3 5.762005700000000e-3 +6.133649300000000e-3 6.529267200000000e-3 6.950406800000000e-3 7.398715500000000e-3 +7.875947000000000e-3 8.383968800000002e-3 8.924768900000000e-3 9.500464200000000e-3 +1.011330900000000e-2 1.076570300000000e-2 1.146020100000000e-2 1.219952700000000e-2 +1.298657700000000e-2 1.382443900000000e-2 1.471639900000000e-2 1.566596100000000e-2 +1.667685500000000e-2 1.775305300000000e-2 1.889879200000000e-2 2.011858100000000e-2 +2.141723100000000e-2 2.279986600000000e-2 2.427195000000000e-2 2.583931000000000e-2 +2.750815800000000e-2 2.928512400000000e-2 3.117728000000000e-2 3.319217800000001e-2 +3.533787800000000e-2 3.762299400000000e-2 4.005672900000000e-2 4.264892400000000e-2 +4.541010900000000e-2 4.835155599999999e-2 5.148534099999999e-2 5.482441200000000e-2 +5.838266500000000e-2 6.217502600000000e-2 6.621755000000000e-2 7.052752299999999e-2 +7.512358299999999e-2 8.002586000000001e-2 8.525612900000000e-2 9.083798699999999e-2 +9.679705700000001e-2 1.031612200000000e-1 1.099609100000000e-1 1.172293700000000e-1 +1.250030800000000e-1 1.333221500000000e-1 1.422307900000000e-1 1.517779100000000e-1 +1.620177700000000e-1 1.730107300000000e-1 1.848241100000000e-1 1.975332000000000e-1 +2.112223600000000e-1 2.259862000000000e-1 2.419308600000000e-1 2.591752700000000e-1 +2.778522800000000e-1 2.981093500000000e-1 3.201086500000000e-1 3.440257100000000e-1 +3.700460300000000e-1 3.983582600000000e-1 4.291422600000000e-1 4.625497000000000e-1 +4.986744200000000e-1 5.375094400000000e-1 5.788882700000000e-1 6.224107000000000e-1 +6.673584999999999e-1 7.126167400000000e-1 7.566302299999999e-1 7.974398500000000e-1 +8.328486000000000e-1 8.607446800000000e-1 8.795373600000001e-1 8.885422300000000e-1 +8.880406700000000e-1 8.787990400000000e-1 8.613780100000000e-1 8.362690400000000e-1 +8.041138199999999e-1 7.657051099999999e-1 7.219602800000001e-1 6.738908000000000e-1 +6.225692400000000e-1 5.690952400000000e-1 5.145616899999999e-1 4.600224600000001e-1 +4.064625000000000e-1 3.547714800000000e-1 3.057215300000000e-1 2.599498900000000e-1 +2.179471200000000e-1 1.800512000000000e-1 1.464479900000000e-1 1.171778500000000e-1 +9.214826199999999e-2 7.115167700000001e-2 5.388743900000001e-2 3.998643700000000e-2 +2.903675500000000e-2 2.060861800000000e-2 1.427697900000000e-2 9.640413700000000e-3 +6.335399200000000e-3 4.045547099999999e-3 2.505921400000000e-3 1.502999600000000e-3 +8.711926300000000e-4 4.870126200000000e-4 2.619889200000000e-4 1.353076400000000e-4 +6.692167800000002e-5 3.161162400000000e-5 1.422020500000000e-5 6.072656199999999e-6 +2.453116200000000e-6 9.344580599999999e-7 3.345965699999999e-7 1.127591600000000e-7 +3.766310100000000e-8 1.169806300000000e-8 3.362855499999999e-9 8.902874400000000e-10 +2.159094800000000e-10 4.769528200000001e-11 9.539504400000000e-12 1.716479800000000e-12 +2.759627000000000e-13 3.935555899999999e-14 4.940235200000000e-15 5.413776000000001e-16 +5.134035100000000e-17 4.174194600000000e-18 2.880912600000001e-19 1.670094900000000e-20 +8.041186000000000e-22 3.177357400000000e-23 1.017285200000000e-24 2.603495500000000e-26 +5.249705900000002e-28 + + +2.897399900000000e-5 3.283177600000000e-5 3.720319100000000e-5 4.215662900000000e-5 +4.776957900000000e-5 5.412984500000000e-5 6.133692000000000e-5 6.950353900000001e-5 +7.875744800000001e-5 8.924339099999999e-5 1.011253800000000e-4 1.145892700000000e-4 +1.298456100000000e-4 1.471330300000000e-4 1.667218600000000e-4 1.889184200000000e-4 +2.140698000000000e-4 2.425692500000000e-4 2.748623300000000e-4 3.114538700000000e-4 +3.529158099999999e-4 3.998961800000000e-4 4.531291199999999e-4 5.134463499999999e-4 +5.817901300000000e-4 6.592278700000000e-4 7.469687400000000e-4 8.463824199999998e-4 +9.590203600000001e-4 1.086639800000000e-3 1.231231000000000e-3 1.395047700000000e-3 +1.580642400000000e-3 1.790905100000000e-3 2.029108000000000e-3 2.298955200000000e-3 +2.604639700000000e-3 2.950907100000000e-3 3.343127200000000e-3 3.787375300000000e-3 +4.290523500000000e-3 4.860342999999999e-3 5.505619600000000e-3 6.236283199999999e-3 +7.063552400000001e-3 8.000097100000001e-3 9.060219499999999e-3 1.026005600000000e-2 +1.161780200000000e-2 1.315396000000000e-2 1.489161400000000e-2 1.685673500000000e-2 +1.907850700000000e-2 2.158969100000000e-2 2.442701300000000e-2 2.763157900000000e-2 +3.124932100000000e-2 3.533145500000000e-2 3.993495500000000e-2 4.512302800000001e-2 +5.096557100000000e-2 5.753959000000000e-2 6.492954700000000e-2 7.322759899999999e-2 +8.253367200000000e-2 9.295529600000002e-2 1.046071300000000e-1 1.176100500000000e-1 +1.320896600000000e-1 1.481741300000000e-1 1.659910400000000e-1 1.856632000000000e-1 +2.073030500000000e-1 2.310055200000000e-1 2.568391300000000e-1 2.848352100000000e-1 +3.149752300000000e-1 3.471766000000000e-1 3.812774700000000e-1 4.170217000000000e-1 +4.540457900000000e-1 4.918702300000001e-1 5.298986700000000e-1 5.674285000000000e-1 +6.036768200000000e-1 6.378244100000000e-1 6.690781900000000e-1 6.967483400000000e-1 +7.203306000000000e-1 7.395776200000000e-1 7.545377000000000e-1 7.655368200000000e-1 +7.730839000000000e-1 7.776947400000001e-1 7.796626800000000e-1 7.788625000000000e-1 +7.747488300000001e-1 7.667067300000000e-1 7.545479700000000e-1 7.383682900000000e-1 +7.183501300000001e-1 6.947390400000000e-1 6.678366900000000e-1 6.379927600000000e-1 +6.055964000000000e-1 5.710674800000000e-1 5.348480900000000e-1 4.973943400000000e-1 +4.591684600000000e-1 4.206313100000000e-1 3.822349100000000e-1 3.444150800000000e-1 +3.075839300000000e-1 2.721223800000000e-1 2.383726100000000e-1 2.066309600000000e-1 +1.771414600000000e-1 1.500904600000000e-1 1.256029300000000e-1 1.037408100000000e-1 +8.450356599999999e-2 6.783147100000000e-2 5.361118400000001e-2 4.168364100000000e-2 +3.185368300000000e-2 2.390082700000000e-2 1.759043500000000e-2 1.268454300000000e-2 +8.951627400000001e-3 6.174746799999999e-3 4.157674399999999e-3 2.728847400000000e-3 +1.743184900000000e-3 1.082008000000000e-3 6.514321399999999e-4 3.796751600000001e-4 +2.137556500000000e-4 1.161008500000000e-4 6.079706400000001e-5 3.083090800000000e-5 +1.558122000000000e-5 7.525940200000001e-6 3.463989600000001e-6 1.514535100000000e-6 +6.269202200000001e-7 2.448080400000000e-7 8.984022999999999e-8 3.085984700000000e-8 +9.879343200000001e-9 2.934187800000000e-9 8.045631100000000e-10 2.026263700000000e-10 +4.661250100000000e-11 9.737168400000002e-12 1.835593100000000e-12 3.102051300000000e-13 +4.666381700000001e-14 6.201584400000000e-15 7.223343999999999e-16 7.311146000000001e-17 +6.372415600000001e-18 + + + +1.018495309790000e-5 1.154145889910000e-5 1.307869368910000e-5 1.482075307910000e-5 +1.679495049290000e-5 1.903224553450000e-5 2.156773779970000e-5 2.444121929280000e-5 +2.769780393870000e-5 3.138864231959999e-5 3.557173826490000e-5 4.031287372320000e-5 +4.568664795109999e-5 5.177768787360000e-5 5.868199327920001e-5 6.650848988190000e-5 +7.538078510860000e-5 8.543917986109999e-5 9.684295727229999e-5 1.097729926390000e-4 +1.244347310000000e-4 1.410616165430000e-4 1.599189778350000e-4 1.813085214940000e-4 +2.055734771250000e-4 2.331044663220000e-4 2.643463008159999e-4 2.998060076500000e-4 +3.400615245070000e-4 3.857725854940000e-4 4.376925883799999e-4 4.966831423630000e-4 +5.637302765719999e-4 6.399638048730000e-4 7.266805159459999e-4 8.253701879419999e-4 +9.377480113150000e-4 1.065791337370000e-3 1.211784612030000e-3 1.378372517540000e-3 +1.568623288820000e-3 1.786105777620000e-3 2.034981117940000e-3 2.320115045220000e-3 +2.647212560610001e-3 3.022984015880000e-3 3.455345808520000e-3 3.953667684080001e-3 +4.529075968720000e-3 5.194825926290000e-3 5.966761178350000e-3 6.863880846869998e-3 +7.909039433050000e-3 9.129811988629999e-3 1.055956474830000e-2 1.223877547510000e-2 +1.421666563440000e-2 1.655321167470000e-2 1.932161695670000e-2 2.261134273210000e-2 +2.653180876980000e-2 3.121688787590000e-2 3.683034167690000e-2 4.357229414710001e-2 +5.168696106040001e-2 6.147165252460000e-2 7.328715018860001e-2 8.756943951090001e-2 +1.048425504280000e-1 1.257321437940000e-1 1.509789793550000e-1 1.814512017070000e-1 +2.181534343460000e-1 2.622301759920000e-1 3.149600981380000e-1 3.777369317260000e-1 +4.520319655430000e-1 5.393331438780001e-1 6.410566229980001e-1 7.584286730950000e-1 +8.923408668880001e-1 1.043187576100000e0 1.210703960040000e0 1.393829757780000e0 +1.590629463340000e0 1.798292730150000e0 2.013220131290000e0 2.231164906830000e0 +2.447363254930000e0 2.656570404270000e0 2.852960032060000e0 3.029960497060000e0 +3.180249730360000e0 3.296190134170000e0 3.370793619030000e0 3.398894970710000e0 +3.377939711910000e0 3.308093134890000e0 3.191972069320000e0 3.034255009560000e0 +2.841278798840000e0 2.620595632060000e0 2.380470825330000e0 2.129361906090000e0 +1.875425916270000e0 1.626092984520000e0 1.387734903760000e0 1.165444715800000e0 +9.629305517890000e-1 7.825177029000000e-1 6.252418870790000e-1 4.910131326160000e-1 +3.788255162150000e-1 2.869886383330000e-1 2.133585311450000e-1 1.555503579530000e-1 +1.111198949320000e-1 7.770656082890000e-2 5.313600023770000e-2 3.548429726630000e-2 +2.310882428200000e-2 1.465275564580000e-2 9.030141408380000e-3 5.398452933660001e-3 +3.124245928040001e-3 1.746481496530000e-3 9.408294945940000e-4 4.872109089520000e-4 +2.419128525220001e-4 1.148568567160000e-4 5.199604563769999e-5 2.237644071230000e-5 +9.125037808740000e-6 3.514222525740001e-6 1.273495927540000e-6 4.325334356699999e-7 +1.370864692790000e-7 4.043996853589999e-8 1.108907288280000e-8 2.851660093570000e-9 +7.283260870840000e-10 1.699196013710000e-10 3.599769446430000e-11 6.881451292619999e-12 +1.179086979970000e-12 1.797929338960000e-13 2.421380096140000e-14 2.856990476480000e-15 +2.928042663419999e-16 2.582837414010001e-17 1.941965393970000e-18 1.231723374590000e-19 +6.518175748430001e-21 2.844373453500001e-22 1.010820608630000e-23 2.886816680350001e-25 +6.532535451029997e-27 1.153789472110000e-28 1.565300956270000e-30 1.603585675000000e-32 +1.218230417370001e-34 + + diff --git a/tests/test_hdf5.py b/tests/test_hdf5.py new file mode 100755 index 0000000..4467f77 --- /dev/null +++ b/tests/test_hdf5.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +# +# Copyright (c), 2021, Quantum Espresso Foundation and SISSA (Scuola +# Internazionale Superiore di Studi Avanzati). All rights reserved. +# This file is distributed under the terms of the MIT License. See the +# file 'LICENSE' in the root directory of the present distribution, or +# http://opensource.org/licenses/MIT. +# Authors: Davide Brunato +# +import unittest +import numpy as np +from pathlib import Path + +from qeschema.hdf5 import read_charge_file, get_wavefunctions, \ + get_wf_attributes, get_wfc_miller_indices + + +# TODO: Fetch appropriate HDF5 files for testing + +@unittest.SkipTest +class TestHdf5Utils(unittest.TestCase): + + def test_read_charge_file(self): + hdf5_file = Path(__file__).parent.joinpath('resources/hdf5/???') + + def test_get_wf_attributes(self): + hdf5_file = Path(__file__).parent.joinpath('resources/hdf5/???') + + def test_get_wavefunctions(self): + hdf5_file = Path(__file__).parent.joinpath('resources/hdf5/???') + + def test_get_wfc_miller_indices(self): + hdf5_file = Path(__file__).parent.joinpath('resources/hdf5/???') + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_upf.py b/tests/test_upf.py new file mode 100755 index 0000000..58474cc --- /dev/null +++ b/tests/test_upf.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +# +# Copyright (c), 2021, Quantum Espresso Foundation and SISSA (Scuola +# Internazionale Superiore di Studi Avanzati). All rights reserved. +# This file is distributed under the terms of the MIT License. See the +# file 'LICENSE' in the root directory of the present distribution, or +# http://opensource.org/licenses/MIT. +# Authors: Davide Brunato +# +import unittest +import numpy as np +from pathlib import Path + +from qeschema.upf import read_pseudo_file + + +class TestUpfUtils(unittest.TestCase): + + def test_read_pseudo_file(self): + upf_file = Path(__file__).parent.joinpath('resources/upf/N.pz-vbc.UPF') + + obj = read_pseudo_file(str(upf_file)) + self.assertIsInstance(obj, dict) + self.assertListEqual(list(obj), ['PP_INFO', 'PP_HEADER', 'PP_MESH', + 'PP_LOCAL', 'PP_RHOATOM', 'PP_NONLOCAL']) + + self.assertIsInstance(obj['PP_INFO'], dict) + self.assertIsInstance(obj['PP_HEADER'], dict) + self.assertIsInstance(obj['PP_MESH'], dict) + self.assertIsInstance(obj['PP_MESH']['PP_R'], np.ndarray) + self.assertIsInstance(obj['PP_LOCAL'], np.ndarray) + self.assertIsInstance(obj['PP_RHOATOM'], np.ndarray) + self.assertIsInstance(obj['PP_NONLOCAL'], dict) + + +if __name__ == '__main__': + unittest.main() From eed50e82af954f8e878a17014fa2cc3be5cfecc6 Mon Sep 17 00:00:00 2001 From: Davide Brunato Date: Fri, 24 Dec 2021 14:55:41 +0100 Subject: [PATCH 9/9] Fix documentation tests --- docs/usage.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage.rst b/docs/usage.rst index de4021c..5a754d1 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -16,7 +16,7 @@ by qeschema. >>> import qeschema >>> doc = qeschema.PwDocument(schema='qes.xsd') - >>> doc.read('tests/examples/pw/Al001_relax_bfgs.xml') + >>> doc.read('tests/resources/pw/Al001_relax_bfgs.xml') >>> pw_data = doc.to_dict() >>> control_variables = pw_data['qes:espresso']['input']['control_variables'] @@ -28,6 +28,6 @@ the desired dictionary: >>> import qeschema >>> doc = qeschema.PwDocument() - >>> doc.read('tests/examples/pw/CO_bgfs_relax.xml') + >>> doc.read('tests/resources/pw/CO_bgfs_relax.xml') >>> path = './/input/atomic_species' >>> bsdict = doc.to_dict(path=path)