Skip to content

Commit 73b87cc

Browse files
committed
❌ ASE: remove old converter code
The `get_outputs_ase` function is now superseded by the new `ASEConverter`, so we can remove it. The units approach with `pint` that was used here still has to be designed more generally.
1 parent e7bc432 commit 73b87cc

File tree

1 file changed

+0
-75
lines changed

1 file changed

+0
-75
lines changed

src/qe_tools/converters/ase.py

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
from __future__ import annotations
22

3-
import contextlib
4-
53
import numpy as np
6-
import pint
74

8-
from qe_tools import CONSTANTS, ELEMENTS
95
from qe_tools.converters.base import BaseConverter
106

117
try:
@@ -29,74 +25,3 @@ class ASEConverter(BaseConverter):
2925
},
3026
),
3127
}
32-
33-
34-
def get_output_ase(self):
35-
"""Convert the parsed data to ASE objects."""
36-
37-
ureg = pint.UnitRegistry()
38-
39-
converted_outputs = {}
40-
41-
xml_dict = self.raw_data.get("xml")
42-
43-
with contextlib.suppress(KeyError):
44-
cell = (
45-
np.array(list(xml_dict["output"]["atomic_structure"]["cell"].values()))
46-
* CONSTANTS.bohr_to_ang
47-
)
48-
symbols = [
49-
el["@name"]
50-
for el in xml_dict["output"]["atomic_structure"]["atomic_positions"]["atom"]
51-
]
52-
# This is to handle the case where symbols are not only
53-
# atom symbols (e.g., Ni1 and Ni2 in the case of an AFM computation).
54-
symbols_new = []
55-
for s in symbols:
56-
s_low = s.lower()
57-
s_elem = ""
58-
for e in ELEMENTS:
59-
e_low = e.lower()
60-
if e_low in s_low and len(e_low) > len(s_elem):
61-
s_elem = e
62-
if s_elem == "":
63-
s_elem = s
64-
symbols_new.append(s_elem)
65-
symbols = symbols_new
66-
67-
positions = (
68-
np.array(
69-
[
70-
el["$"]
71-
for el in xml_dict["output"]["atomic_structure"][
72-
"atomic_positions"
73-
]["atom"]
74-
]
75-
)
76-
* CONSTANTS.bohr_to_ang
77-
)
78-
converted_outputs["ase_structure"] = Atoms(
79-
cell=cell,
80-
positions=positions,
81-
symbols=symbols,
82-
pbc=True,
83-
)
84-
85-
with contextlib.suppress(KeyError):
86-
converted_outputs["energy"] = (
87-
xml_dict["output"]["total_energy"]["etot"] * CONSTANTS.ry_to_ev * ureg.eV
88-
)
89-
90-
with contextlib.suppress(KeyError):
91-
converted_outputs["forces"] = (
92-
np.array(xml_dict["output"]["forces"]["$"]).reshape(
93-
xml_dict["output"]["forces"]["@dims"]
94-
)
95-
* 2
96-
* CONSTANTS.ry_to_ev
97-
/ CONSTANTS.bohr_to_ang
98-
* ureg.eV
99-
/ ureg.angstrom
100-
)
101-
102-
return converted_outputs

0 commit comments

Comments
 (0)