Skip to content

Commit 08f0008

Browse files
committed
Update script for generating semicore json
1 parent 9861b01 commit 08f0008

File tree

1 file changed

+37
-2
lines changed
  • src/aiida_wannier90_workflows/utils/pseudo/data

1 file changed

+37
-2
lines changed

Diff for: src/aiida_wannier90_workflows/utils/pseudo/data/__init__.py

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Utility functions for pseudo potential metadata."""
2-
2+
from pathlib import Path
33
import json
44
import os
55
import typing as ty
@@ -344,6 +344,39 @@ def generate_dojo_metadata():
344344
json.dump(result, handle, indent=2)
345345

346346

347+
def generate_dojo_semicore():
348+
"""Scan the folder and generate a json file containing metainfo of pseudos of pslibrary.
349+
350+
:param dirname: folder to be scanned, if None download from QE website
351+
:type dirname: str
352+
"""
353+
from aiida import orm
354+
from aiida_wannier90_workflows.utils.workflows.group import standardize_groupname
355+
356+
group_label = "PseudoDojo/0.4/PBEsol/FR/standard/upf"
357+
pseudos = orm.load_group(group_label)
358+
359+
result = {}
360+
# use xml.sax to parse upf file
361+
parser = xml.sax.make_parser()
362+
handler = PSHandler()
363+
parser.setContentHandler(handler)
364+
365+
for pp in pseudos:
366+
element = pp.element
367+
parser.parse(pp.get_content())
368+
result[element] = {
369+
"filename": pp.filename,
370+
"md5": pp.md5,
371+
"pswfcs": handler.pswfcs,
372+
"semicores": handler.semicores,
373+
}
374+
375+
path = Path(__file__).parent / "semicore" / f"{standardize_groupname(group_label)}.json"
376+
with open(path, "w", encoding="utf-8") as handle:
377+
json.dump(result, handle, indent=2)
378+
379+
347380
def _print_exclude_semicore():
348381
"""Print semicore."""
349382
periodic_table = "H He Li Be B C N O F Ne "
@@ -364,6 +397,8 @@ def _print_exclude_semicore():
364397
print(f"{kind:2s} {' '.join(remaining)}")
365398

366399

367-
# if __name__ == '__main__':
400+
if __name__ == '__main__':
368401
# generate_pslibrary_metadata()
369402
# # generate_dojo_metadata()
403+
404+
generate_dojo_semicore()

0 commit comments

Comments
 (0)