Skip to content

Commit

Permalink
My conclusion is that MagOrderingTrans has never worked, even from 20
Browse files Browse the repository at this point in the history
commits ago. Reverting to old code and letting someone else deal with
this.
  • Loading branch information
shyuep committed Jun 29, 2023
1 parent c7322c7 commit 9d0461f
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions pymatgen/transformations/advanced_transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,19 +836,22 @@ def _add_spin_magnitudes(self, structure: Structure):
Structure: Structure with spin magnitudes added.
"""
for idx, site in enumerate(structure):
spin = getattr(site.specie, "spin", None)
sign = int(spin) if spin else 0
# this very hacky bit of code only works because we know
# that on disordered sites in this class, all species are the same
# but have different spins, and this is comma-delimited
sp = str(site.specie).split(",", maxsplit=1)[0]
new_spin = sign * self.mag_species_spin.get(sp, 0)
new_specie = Species(
site.specie.symbol,
getattr(site.specie, "oxi_state", None),
spin=new_spin,
)
structure.replace(idx, new_specie, properties=site.properties)
if getattr(site.specie, "spin", None):
spin = site.specie.spin
spin = getattr(site.specie, "spin", None)
sign = int(spin) if spin else 0
if spin:
# this very hacky bit of code only works because we know
# that on disordered sites in this class, all species are the same
# but have different spins, and this is comma-delimited
sp = str(site.specie).split(",", maxsplit=1)[0]
new_spin = sign * self.mag_species_spin.get(sp, 0)
new_specie = Species(
site.specie.symbol,
getattr(site.specie, "oxi_state", None),
spin=new_spin,
)
structure.replace(idx, new_specie, properties=site.properties)
logger.debug(f"Structure with spin magnitudes:\n{structure}")
return structure

Expand Down

0 comments on commit 9d0461f

Please sign in to comment.