Skip to content

Commit 9177007

Browse files
committed
Move code to pymatgen
1 parent b06c76c commit 9177007

File tree

3 files changed

+36
-542
lines changed

3 files changed

+36
-542
lines changed

atomate/vasp/firetasks/parse_outputs.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
2727
from pymatgen.analysis.ferroelectricity.polarization import Polarization, get_total_ionic_dipole, \
2828
EnergyTrend
29-
from pymatgen.analysis.magnetism import CollinearMagneticStructureAnalyzer, Ordering
29+
from pymatgen.analysis.magnetism import CollinearMagneticStructureAnalyzer, Ordering, magnetic_deformation
3030
from pymatgen.command_line.bader_caller import bader_analysis_from_path
3131

3232
from atomate.common.firetasks.glue_tasks import get_calc_loc
@@ -950,23 +950,6 @@ class MagneticDeformationToDB(FiretaskBase):
950950
required_params = ["db_file", "wf_uuid"]
951951
optional_params = ["to_db"]
952952

953-
@staticmethod
954-
def magnetic_deformation(nm_struct, m_struct):
955-
""" Calculates 'magnetic deformation proxy',
956-
a measure of deformation (norm of finite strain)
957-
between 'non-magnetic' (non-spin-polarized) and
958-
ferromagnetic structures.
959-
Adapted from Bocarsly et al. 2017,
960-
doi: 10.1021/acs.chemmater.6b04729"""
961-
lmn = nm_struct.lattice.matrix.T
962-
lm = m_struct.lattice.matrix.T
963-
lmn_i = np.linalg.inv(lmn)
964-
p = np.dot(lmn_i, lm)
965-
eta = 0.5 * (np.dot(p.T, p) - np.identity(3))
966-
w, _ = np.linalg.eig(eta)
967-
deformation = 100 * (1. / 3.) * np.sqrt(w[0] ** 2 + w[1] ** 2 + w[2] ** 2)
968-
return deformation
969-
970953
def run_task(self, fw_spec):
971954

972955
uuid = self["wf_uuid"]
@@ -995,7 +978,7 @@ def run_task(self, fw_spec):
995978
success = False if msa.ordering == Ordering.NM else True
996979

997980
# calculate magnetic deformation
998-
magnetic_deformation = self.magnetic_deformation(nm_structure, m_structure)
981+
mag_def = magnetic_deformation(nm_structure, m_structure).deformation
999982

1000983
# get run stats (mostly used for benchmarking)
1001984
# using same approach as VaspDrone
@@ -1012,7 +995,7 @@ def run_task(self, fw_spec):
1012995
summary = {
1013996
"formula": nm_structure.composition.reduced_formula,
1014997
"success": success,
1015-
"magnetic_deformation": magnetic_deformation,
998+
"magnetic_deformation": mag_def,
1016999
"non_magnetic_task_id": d_nm["task_id"],
10171000
"non_magnetic_structure": nm_structure.as_dict(),
10181001
"magnetic_task_id": d_m["task_id"],
@@ -1021,7 +1004,6 @@ def run_task(self, fw_spec):
10211004
"created_at": datetime.utcnow()
10221005
}
10231006

1024-
# TODO: find a better way for passing tags of the entire workflow to db - albalu
10251007
if fw_spec.get("tags", None):
10261008
summary["tags"] = fw_spec["tags"]
10271009

0 commit comments

Comments
 (0)