Skip to content

Commit 653714e

Browse files
tpurcell90shyuep
andauthored
Modify FHI-aims inputs to not use species string (materialsproject#4177)
* Modify FHI-aims inputs to not use species string FHI-aims does not read spin from the species and that causes issues with magnetic calculations * Add the option for oxidation state to still be in species Issue is only with spin * Fix lint errors --------- Signed-off-by: Shyue Ping Ong <[email protected]> Co-authored-by: Shyue Ping Ong <[email protected]>
1 parent 362bf54 commit 653714e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/pymatgen/io/aims/inputs.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,22 @@ def from_structure(cls, structure: Structure | Molecule) -> Self:
154154
content_lines.append(f"lattice_vector {lv[0]: .12e} {lv[1]: .12e} {lv[2]: .12e}")
155155

156156
for site in structure:
157-
element = site.species_string
157+
element = site.species_string.split(",spin=")[0]
158158
charge = site.properties.get("charge", 0)
159159
spin = site.properties.get("magmom", None)
160160
coord = site.coords
161161
v = site.properties.get("velocity", [0.0, 0.0, 0.0])
162+
162163
if isinstance(site.specie, Species) and site.specie.spin is not None:
163164
if spin is not None and spin != site.specie.spin:
164165
raise ValueError("species.spin and magnetic moments don't agree. Please only define one")
165166
spin = site.specie.spin
166167

168+
if isinstance(site.specie, Species) and site.specie.oxi_state is not None:
169+
if charge is not None and charge != site.specie.oxi_state:
170+
raise ValueError("species.oxi_state and charge don't agree. Please only define one")
171+
charge = site.specie.oxi_state
172+
167173
content_lines.append(f"atom {coord[0]: .12e} {coord[1]: .12e} {coord[2]: .12e} {element}")
168174
if charge != 0:
169175
content_lines.append(f" initial_charge {charge:.12e}")

src/pymatgen/symmetry/groups.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from monty.design_patterns import cached_class
1919
from monty.serialization import loadfn
2020

21+
from pymatgen.core.operations import SymmOp
2122
from pymatgen.util.string import Stringify
2223

2324
if TYPE_CHECKING:

0 commit comments

Comments
 (0)