Skip to content

Commit

Permalink
Modify FHI-aims inputs to not use species string (#4177)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
tpurcell90 and shyuep authored Dec 11, 2024
1 parent 362bf54 commit 653714e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pymatgen/io/aims/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,22 @@ def from_structure(cls, structure: Structure | Molecule) -> Self:
content_lines.append(f"lattice_vector {lv[0]: .12e} {lv[1]: .12e} {lv[2]: .12e}")

for site in structure:
element = site.species_string
element = site.species_string.split(",spin=")[0]
charge = site.properties.get("charge", 0)
spin = site.properties.get("magmom", None)
coord = site.coords
v = site.properties.get("velocity", [0.0, 0.0, 0.0])

if isinstance(site.specie, Species) and site.specie.spin is not None:
if spin is not None and spin != site.specie.spin:
raise ValueError("species.spin and magnetic moments don't agree. Please only define one")
spin = site.specie.spin

if isinstance(site.specie, Species) and site.specie.oxi_state is not None:
if charge is not None and charge != site.specie.oxi_state:
raise ValueError("species.oxi_state and charge don't agree. Please only define one")
charge = site.specie.oxi_state

content_lines.append(f"atom {coord[0]: .12e} {coord[1]: .12e} {coord[2]: .12e} {element}")
if charge != 0:
content_lines.append(f" initial_charge {charge:.12e}")
Expand Down
1 change: 1 addition & 0 deletions src/pymatgen/symmetry/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from monty.design_patterns import cached_class
from monty.serialization import loadfn

from pymatgen.core.operations import SymmOp
from pymatgen.util.string import Stringify

if TYPE_CHECKING:
Expand Down

0 comments on commit 653714e

Please sign in to comment.