Skip to content

Commit

Permalink
Update script for generating semicore json
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaojunfeng committed Sep 18, 2024
1 parent 9861b01 commit 08f0008
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions src/aiida_wannier90_workflows/utils/pseudo/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Utility functions for pseudo potential metadata."""

from pathlib import Path
import json
import os
import typing as ty
Expand Down Expand Up @@ -344,6 +344,39 @@ def generate_dojo_metadata():
json.dump(result, handle, indent=2)


def generate_dojo_semicore():
"""Scan the folder and generate a json file containing metainfo of pseudos of pslibrary.
:param dirname: folder to be scanned, if None download from QE website
:type dirname: str
"""
from aiida import orm
from aiida_wannier90_workflows.utils.workflows.group import standardize_groupname

group_label = "PseudoDojo/0.4/PBEsol/FR/standard/upf"
pseudos = orm.load_group(group_label)

result = {}
# use xml.sax to parse upf file
parser = xml.sax.make_parser()
handler = PSHandler()
parser.setContentHandler(handler)

for pp in pseudos:
element = pp.element
parser.parse(pp.get_content())
result[element] = {
"filename": pp.filename,
"md5": pp.md5,
"pswfcs": handler.pswfcs,
"semicores": handler.semicores,
}

path = Path(__file__).parent / "semicore" / f"{standardize_groupname(group_label)}.json"
with open(path, "w", encoding="utf-8") as handle:
json.dump(result, handle, indent=2)


def _print_exclude_semicore():
"""Print semicore."""
periodic_table = "H He Li Be B C N O F Ne "
Expand All @@ -364,6 +397,8 @@ def _print_exclude_semicore():
print(f"{kind:2s} {' '.join(remaining)}")


# if __name__ == '__main__':
if __name__ == '__main__':
# generate_pslibrary_metadata()
# # generate_dojo_metadata()

generate_dojo_semicore()

0 comments on commit 08f0008

Please sign in to comment.