Skip to content

Commit

Permalink
fix duplicated elements in vasp/xml (#575)
Browse files Browse the repository at this point in the history
Fix #480.

#250 doesn't handle this situation.

---------

Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz authored Nov 7, 2023
1 parent fb27e05 commit e948661
Show file tree
Hide file tree
Showing 3 changed files with 1,772 additions and 7 deletions.
14 changes: 7 additions & 7 deletions dpdata/vasp/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def analyze_atominfo(atominfo_xml):
check_name(atominfo_xml.find("array"), "atoms")
eles = []
types = []
visited = set()
for ii in atominfo_xml.find("array").find("set"):
eles.append(ii.findall("c")[0].text.strip())
types.append(int(ii.findall("c")[1].text))
uniq_ele = []
for ii in eles:
if ii not in uniq_ele:
uniq_ele.append(ii)
return uniq_ele, types
atom_type = int(ii.findall("c")[1].text)
if atom_type not in visited:
eles.append(ii.findall("c")[0].text.strip())
visited.add(atom_type)
types.append(atom_type)
return eles, types


def analyze_calculation(cc):
Expand Down
Loading

0 comments on commit e948661

Please sign in to comment.