Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MigrationHop MSONable again #312

Merged
merged 10 commits into from
Jul 21, 2022
4 changes: 2 additions & 2 deletions pymatgen/analysis/diffusion/neb/pathfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@ def __init__(
self.iindex = None
self.eindex = None
self.symm_structure = symm_structure
self.host_symm_struct = host_symm_struct
self.symprec = symprec
self.msite = PeriodicSite(esite.specie, (isite.frac_coords + esite.frac_coords) / 2, esite.lattice)
if host_symm_struct:
self.host_symm_structure = host_symm_struct
sg = self.host_symm_structure.spacegroup
sg = self.host_symm_struct.spacegroup
else:
sg = self.symm_structure.spacegroup
for i, sites in enumerate(self.symm_structure.equivalent_sites):
Expand Down
4 changes: 4 additions & 0 deletions pymatgen/analysis/diffusion/neb/tests/test_pathfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ def setUp(self):
symm_structure = a.get_symmetrized_structure()
self.m_hop = MigrationHop(i_site, e_site, symm_structure)

def test_msonable(self):
hop_dict = self.m_hop.as_dict()
assert type(hop_dict) == dict

def test_get_start_end_structs_from_hop(self):
dist_ref = self.m_hop.length
base = self.lifepo.copy()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "pymatgen.analysis.diffusion.neb.full_path_mapper", "@class": "MigrationGraph", "@version": null, "structure": {"@module": "pymatgen.core.structure", "@class": "Structure", "charge": 0, "lattice": {"matrix": [[5.050436, -0.001915, 2.918349], [1.670177, 4.756793, 2.918706], [0.008962, -0.012617, 5.837054]], "a": 5.832981085441817, "b": 5.8254111932647294, "c": 5.837074515975361, "alpha": 60.01961709382035, "beta": 59.89097940572302, "gamma": 60.089408967637354, "volume": 140.24737212088203}, "sites": [{"species": [{"element": "Mn", "occu": 1}], "abc": [0.500001, 0.5, 0.499999], "xyz": [3.3647925414740003, 2.371130510702, 5.837051581295], "label": "Mn", "properties": {"insertion_energy": null}}, {"species": [{"element": "Mn", "occu": 1}], "abc": [0.0, 0.500001, 0.499999], "xyz": [0.8395711612150001, 2.37209276941, 4.3778770816520005], "label": "Mn", "properties": {"insertion_energy": null}}, {"species": [{"element": "Mn", "occu": 1}], "abc": [0.5, 0.500001, 0.0], "xyz": [3.3603081701770003, 2.377443756793, 2.918530418706], "label": "Mn", "properties": {"insertion_energy": null}}, {"species": [{"element": "Mn", "occu": 1}], "abc": [0.499999, 0.0, 0.500001], "xyz": [2.5296939585260003, -0.0072660107020000005, 4.377704418705], "label": "Mn", "properties": {"insertion_energy": null}}, {"species": [{"element": "O", "occu": 1}], "abc": [0.295046, 0.734255, 0.735926], "xyz": [2.7230421220029997, 3.482848852783, 7.299761475087999], "label": "O", "properties": {"insertion_energy": null}}, {"species": [{"element": "O", "occu": 1}], "abc": [0.734772, 0.735927, 0.734254], "xyz": [4.946627694019, 3.489981231013, 8.578155929606002], "label": "O", "properties": {"insertion_energy": null}}, {"species": [{"element": "O", "occu": 1}], "abc": [0.734255, 0.295047, 0.734772], "xyz": [4.207673625163, 1.392800787622, 7.292871635865], "label": "O", "properties": {"insertion_energy": null}}, {"species": [{"element": "O", "occu": 1}], "abc": [0.735926, 0.734772, 0.295047], "xyz": [4.946590669594, 3.4900263999070003, 6.014477622744], "label": "O", "properties": {"insertion_energy": null}}, {"species": [{"element": "O", "occu": 1}], "abc": [0.265227, 0.264075, 0.265745], "xyz": [1.782945586937, 1.252289297105, 3.095950152403], "label": "O", "properties": {"insertion_energy": null}}, {"species": [{"element": "O", "occu": 1}], "abc": [0.704954, 0.265744, 0.264074], "xyz": [4.00653120782, 1.259407390424, 4.374344606206], "label": "O", "properties": {"insertion_energy": null}}, {"species": [{"element": "O", "occu": 1}], "abc": [0.264073, 0.265227, 0.704954], "xyz": [1.7829776187550002, 1.2522298325980001, 5.659631377255], "label": "O", "properties": {"insertion_energy": null}}, {"species": [{"element": "O", "occu": 1}], "abc": [0.265744, 0.704953, 0.265229], "xyz": [2.5218963333630002, 3.3494602016760004, 4.38124028284], "label": "O", "properties": {"insertion_energy": null}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.5, 0.0, 0.0], "xyz": [2.525218, -0.0009575, 1.4591745], "label": "Mg", "properties": {"insertion_energy": -5.761862743333339}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.0, 0.0, 0.5], "xyz": [0.004481, -0.0063085, 2.918527], "label": "Mg", "properties": {"insertion_energy": -5.761862743333339}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.125, 0.125, 0.125], "xyz": [0.8411968750000001, 0.592782625, 1.459263625], "label": "Mg", "properties": {"insertion_energy": -5.4666703683333395}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.875, 0.875, 0.875], "xyz": [5.888378125, 4.149478375, 10.214845375], "label": "Mg", "properties": {"insertion_energy": -5.4666703683333395}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.0, 0.0, 0.0], "xyz": [0.0, 0.0, 0.0], "label": "Mg", "properties": {"insertion_energy": -5.761862743333339}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.0, 0.5, 0.0], "xyz": [0.8350885, 2.3783965, 1.459353], "label": "Mg", "properties": {"insertion_energy": -5.761862743333339}}]}, "m_graph": {"@module": "pymatgen.analysis.graphs", "@class": "StructureGraph", "structure": {"@module": "pymatgen.core.structure", "@class": "Structure", "charge": 0, "lattice": {"matrix": [[5.050436, -0.001915, 2.918349], [1.670177, 4.756793, 2.918706], [0.008962, -0.012617, 5.837054]], "a": 5.832981085441817, "b": 5.8254111932647294, "c": 5.837074515975361, "alpha": 60.01961709382035, "beta": 59.89097940572302, "gamma": 60.089408967637354, "volume": 140.24737212088203}, "sites": [{"species": [{"element": "Mg", "occu": 1}], "abc": [0.5, 0.0, 0.0], "xyz": [2.525218, -0.0009575, 1.4591745], "label": "Mg", "properties": {"insertion_energy": -5.761862743333339}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.0, 0.0, 0.5], "xyz": [0.004481, -0.0063085, 2.918527], "label": "Mg", "properties": {"insertion_energy": -5.761862743333339}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.125, 0.125, 0.125], "xyz": [0.8411968750000001, 0.592782625, 1.459263625], "label": "Mg", "properties": {"insertion_energy": -5.4666703683333395}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.875, 0.875, 0.875], "xyz": [5.888378125, 4.149478375, 10.214845375], "label": "Mg", "properties": {"insertion_energy": -5.4666703683333395}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.0, 0.0, 0.0], "xyz": [0.0, 0.0, 0.0], "label": "Mg", "properties": {"insertion_energy": -5.761862743333339}}, {"species": [{"element": "Mg", "occu": 1}], "abc": [0.0, 0.5, 0.0], "xyz": [0.8350885, 2.3783965, 1.459353], "label": "Mg", "properties": {"insertion_energy": -5.761862743333339}}]}, "graphs": {"directed": true, "multigraph": true, "graph": [["edge_weight_name", null], ["edge_weight_units", null], ["name", "bonds"]], "nodes": [{"specie": "Mg", "coords": [2.525218, -0.0009575, 1.4591745], "properties": {"insertion_energy": -5.761862743333339}, "id": 0}, {"specie": "Mg", "coords": [0.004481, -0.0063085, 2.918527], "properties": {"insertion_energy": -5.761862743333339}, "id": 1}, {"specie": "Mg", "coords": [0.8411968750000001, 0.592782625, 1.459263625], "properties": {"insertion_energy": -5.4666703683333395}, "id": 2}, {"specie": "Mg", "coords": [5.888378125, 4.149478375, 10.214845375], "properties": {"insertion_energy": -5.4666703683333395}, "id": 3}, {"specie": "Mg", "coords": [0.0, 0.0, 0.0], "properties": {"insertion_energy": -5.761862743333339}, "id": 4}, {"specie": "Mg", "coords": [0.8350885, 2.3783965, 1.459353], "properties": {"insertion_energy": -5.761862743333339}, "id": 5}], "adjacency": [[{"to_jimage": [0, 0, 0], "ipos": [0.5, 0.0, 0.0], "epos": [0.0, 0.0, 0.5], "ipos_cart": [2.525218, -0.0009575, 1.4591745], "epos_cart": [0.004481, -0.0063085, 2.918527], "hop": "Path of 2.9127 A from Mg [0.500, 0.000, 0.000] (ind: 2, Wyckoff: 4c) to Mg [0.000, 0.000, 0.500] (ind: 2, Wyckoff: 4c)", "hop_label": 0, "iindex": 0, "eindex": 1, "hop_distance": 2.9127055078785857, "cost": 2.9127055078785857, "id": 1, "key": 0}, {"to_jimage": [1, 0, -1], "ipos": [0.5, 0.0, 0.0], "epos": [1.0, 0.0, -0.5], "ipos_cart": [2.525218, -0.0009575, 1.4591745], "epos_cart": [5.045955, 0.0043935, -0.00017800000000001148], "hop": "Path of 2.9127 A from Mg [0.500, 0.000, 0.000] (ind: 2, Wyckoff: 4c) to Mg [1.000, 0.000, -0.500] (ind: 2, Wyckoff: 4c)", "hop_label": 0, "iindex": 0, "eindex": 1, "hop_distance": 2.9127055078785857, "cost": 2.9127055078785857, "id": 1, "key": 1}, {"to_jimage": [0, 0, 0], "ipos": [0.5, 0.0, 0.0], "epos": [0.0, 0.0, 0.0], "ipos_cart": [2.525218, -0.0009575, 1.4591745], "epos_cart": [0.0, 0.0, 0.0], "hop": "Path of 2.9165 A from Mg [0.500, 0.000, 0.000] (ind: 2, Wyckoff: 4c) to Mg [0.000, 0.000, 0.000] (ind: 2, Wyckoff: 4c)", "hop_label": 1, "iindex": 0, "eindex": 4, "hop_distance": 2.9164905427209087, "cost": 2.9164905427209087, "id": 4, "key": 0}, {"to_jimage": [1, 0, 0], "ipos": [0.5, 0.0, 0.0], "epos": [1.0, 0.0, 0.0], "ipos_cart": [2.525218, -0.0009575, 1.4591745], "epos_cart": [5.050436, -0.001915, 2.918349], "hop": "Path of 2.9165 A from Mg [0.500, 0.000, 0.000] (ind: 2, Wyckoff: 4c) to Mg [1.000, 0.000, 0.000] (ind: 2, Wyckoff: 4c)", "hop_label": 1, "iindex": 0, "eindex": 4, "hop_distance": 2.9164905427209087, "cost": 2.9164905427209087, "id": 4, "key": 1}, {"to_jimage": [0, 0, 0], "ipos": [0.5, 0.0, 0.0], "epos": [0.125, 0.125, 0.125], "ipos_cart": [2.525218, -0.0009575, 1.4591745], "epos_cart": [0.8411968750000001, 0.592782625, 1.459263625], "hop": "Path of 1.7856 A from Mg [0.500, 0.000, 0.000] (ind: 2, Wyckoff: 4c) to Mg [0.125, 0.125, 0.125] (ind: 3, Wyckoff: 2a)", "hop_label": 2, "iindex": 0, "eindex": 2, "hop_distance": 1.7856243987537097, "cost": 1.7856243987537097, "id": 2, "key": 0}, {"to_jimage": [0, 0, 0], "ipos": [0.5, 0.0, 0.0], "epos": [0.0, 0.5, 0.0], "ipos_cart": [2.525218, -0.0009575, 1.4591745], "epos_cart": [0.8350885, 2.3783965, 1.459353], "hop": "Path of 2.9185 A from Mg [0.500, 0.000, 0.000] (ind: 2, Wyckoff: 4c) to Mg [0.000, 0.500, 0.000] (ind: 2, Wyckoff: 4c)", "hop_label": 3, "iindex": 0, "eindex": 5, "hop_distance": 2.918537855836121, "cost": 2.918537855836121, "id": 5, "key": 0}, {"to_jimage": [1, -1, 0], "ipos": [0.5, 0.0, 0.0], "epos": [1.0, -0.5, 0.0], "ipos_cart": [2.525218, -0.0009575, 1.4591745], "epos_cart": [4.2153475, -2.3803115, 1.4589960000000002], "hop": "Path of 2.9185 A from Mg [0.500, 0.000, 0.000] (ind: 2, Wyckoff: 4c) to Mg [1.000, -0.500, 0.000] (ind: 2, Wyckoff: 4c)", "hop_label": 3, "iindex": 0, "eindex": 5, "hop_distance": 2.9185378558361204, "cost": 2.918537855836121, "id": 5, "key": 1}, {"to_jimage": [0, -1, -1], "ipos": [0.5, 0.0, 0.0], "epos": [0.875, -0.125, -0.125], "ipos_cart": [2.525218, -0.0009575, 1.4591745], "epos_cart": [4.209239125000001, -0.594697625, 1.4590853750000001], "hop": "Path of 1.7856 A from Mg [0.500, 0.000, 0.000] (ind: 2, Wyckoff: 4c) to Mg [0.875, -0.125, -0.125] (ind: 3, Wyckoff: 2a)", "hop_label": 2, "iindex": 0, "eindex": 3, "hop_distance": 1.7856243987537102, "cost": 1.7856243987537097, "id": 3, "key": 0}], [{"to_jimage": [0, -1, 1], "ipos": [0.0, 0.0, 0.5], "epos": [0.0, -0.5, 1.0], "ipos_cart": [0.004481, -0.0063085, 2.918527], "epos_cart": [-0.8261265, -2.3910135, 4.377701], "hop": "Path of 2.9165 A from Mg [0.000, 0.000, 0.500] (ind: 2, Wyckoff: 4c) to Mg [0.000, -0.500, 1.000] (ind: 2, Wyckoff: 4c)", "hop_label": 1, "iindex": 1, "eindex": 5, "hop_distance": 2.916490274003541, "cost": 2.9164905427209087, "id": 5, "key": 0}, {"to_jimage": [0, 0, 0], "ipos": [0.0, 0.0, 0.5], "epos": [0.0, 0.5, 0.0], "ipos_cart": [0.004481, -0.0063085, 2.918527], "epos_cart": [0.8350885, 2.3783965, 1.459353], "hop": "Path of 2.9165 A from Mg [0.000, 0.000, 0.500] (ind: 2, Wyckoff: 4c) to Mg [0.000, 0.500, 0.000] (ind: 2, Wyckoff: 4c)", "hop_label": 1, "iindex": 1, "eindex": 5, "hop_distance": 2.916490274003541, "cost": 2.9164905427209087, "id": 5, "key": 1}, {"to_jimage": [-1, -1, 0], "ipos": [0.0, 0.0, 0.5], "epos": [-0.125, -0.125, 0.875], "ipos_cart": [0.004481, -0.0063085, 2.918527], "epos_cart": [-0.832234875, -0.605399625, 4.377790375], "hop": "Path of 1.7856 A from Mg [0.000, 0.000, 0.500] (ind: 2, Wyckoff: 4c) to Mg [-0.125, -0.125, 0.875] (ind: 3, Wyckoff: 2a)", "hop_label": 2, "iindex": 1, "eindex": 3, "hop_distance": 1.7856240447381895, "cost": 1.7856243987537097, "id": 3, "key": 0}, {"to_jimage": [0, 0, 0], "ipos": [0.0, 0.0, 0.5], "epos": [0.0, 0.0, 0.0], "ipos_cart": [0.004481, -0.0063085, 2.918527], "epos_cart": [0.0, 0.0, 0.0], "hop": "Path of 2.9185 A from Mg [0.000, 0.000, 0.500] (ind: 2, Wyckoff: 4c) to Mg [0.000, 0.000, 0.000] (ind: 2, Wyckoff: 4c)", "hop_label": 3, "iindex": 1, "eindex": 4, "hop_distance": 2.9185372579876807, "cost": 2.918537855836121, "id": 4, "key": 0}, {"to_jimage": [0, 0, 1], "ipos": [0.0, 0.0, 0.5], "epos": [0.0, 0.0, 1.0], "ipos_cart": [0.004481, -0.0063085, 2.918527], "epos_cart": [0.008962, -0.012617, 5.837054], "hop": "Path of 2.9185 A from Mg [0.000, 0.000, 0.500] (ind: 2, Wyckoff: 4c) to Mg [0.000, 0.000, 1.000] (ind: 2, Wyckoff: 4c)", "hop_label": 3, "iindex": 1, "eindex": 4, "hop_distance": 2.9185372579876807, "cost": 2.918537855836121, "id": 4, "key": 1}, {"to_jimage": [0, 0, 0], "ipos": [0.0, 0.0, 0.5], "epos": [0.125, 0.125, 0.125], "ipos_cart": [0.004481, -0.0063085, 2.918527], "epos_cart": [0.8411968750000001, 0.592782625, 1.459263625], "hop": "Path of 1.7856 A from Mg [0.000, 0.000, 0.500] (ind: 2, Wyckoff: 4c) to Mg [0.125, 0.125, 0.125] (ind: 3, Wyckoff: 2a)", "hop_label": 2, "iindex": 1, "eindex": 2, "hop_distance": 1.7856240447381897, "cost": 1.7856243987537097, "id": 2, "key": 0}], [{"to_jimage": [0, 0, 0], "ipos": [0.125, 0.125, 0.125], "epos": [0.0, 0.0, 0.0], "ipos_cart": [0.8411968750000001, 0.592782625, 1.459263625], "epos_cart": [0.0, 0.0, 0.0], "hop": "Path of 1.7856 A from Mg [0.125, 0.125, 0.125] (ind: 3, Wyckoff: 2a) to Mg [0.000, 0.000, 0.000] (ind: 2, Wyckoff: 4c)", "hop_label": 2, "iindex": 2, "eindex": 4, "hop_distance": 1.7856241906570927, "cost": 1.7856243987537097, "id": 4, "key": 0}, {"to_jimage": [-1, -1, -1], "ipos": [0.125, 0.125, 0.125], "epos": [-0.125, -0.125, -0.125], "ipos_cart": [0.8411968750000001, 0.592782625, 1.459263625], "epos_cart": [-0.8411968750000001, -0.592782625, -1.459263625], "hop": "Path of 3.5712 A from Mg [0.125, 0.125, 0.125] (ind: 3, Wyckoff: 2a) to Mg [-0.125, -0.125, -0.125] (ind: 3, Wyckoff: 2a)", "hop_label": 4, "iindex": 2, "eindex": 3, "hop_distance": 3.5712483813141853, "cost": 3.5712483813141853, "id": 3, "key": 0}, {"to_jimage": [-1, -1, 0], "ipos": [0.125, 0.125, 0.125], "epos": [-0.125, -0.125, 0.875], "ipos_cart": [0.8411968750000001, 0.592782625, 1.459263625], "epos_cart": [-0.832234875, -0.605399625, 4.377790375], "hop": "Path of 3.5712 A from Mg [0.125, 0.125, 0.125] (ind: 3, Wyckoff: 2a) to Mg [-0.125, -0.125, 0.875] (ind: 3, Wyckoff: 2a)", "hop_label": 4, "iindex": 2, "eindex": 3, "hop_distance": 3.571248089476379, "cost": 3.5712483813141853, "id": 3, "key": 1}, {"to_jimage": [-1, 0, -1], "ipos": [0.125, 0.125, 0.125], "epos": [-0.125, 0.875, -0.125], "ipos_cart": [0.8411968750000001, 0.592782625, 1.459263625], "epos_cart": [0.8289801249999998, 4.164010374999999, 1.4594423749999998], "hop": "Path of 3.5712 A from Mg [0.125, 0.125, 0.125] (ind: 3, Wyckoff: 2a) to Mg [-0.125, 0.875, -0.125] (ind: 3, Wyckoff: 2a)", "hop_label": 4, "iindex": 2, "eindex": 3, "hop_distance": 3.571248650444573, "cost": 3.5712483813141853, "id": 3, "key": 2}, {"to_jimage": [0, -1, -1], "ipos": [0.125, 0.125, 0.125], "epos": [0.875, -0.125, -0.125], "ipos_cart": [0.8411968750000001, 0.592782625, 1.459263625], "epos_cart": [4.209239125000001, -0.594697625, 1.4590853750000001], "hop": "Path of 3.5712 A from Mg [0.125, 0.125, 0.125] (ind: 3, Wyckoff: 2a) to Mg [0.875, -0.125, -0.125] (ind: 3, Wyckoff: 2a)", "hop_label": 4, "iindex": 2, "eindex": 3, "hop_distance": 3.57124879750742, "cost": 3.5712483813141853, "id": 3, "key": 3}, {"to_jimage": [0, 0, 0], "ipos": [0.125, 0.125, 0.125], "epos": [0.0, 0.5, 0.0], "ipos_cart": [0.8411968750000001, 0.592782625, 1.459263625], "epos_cart": [0.8350885, 2.3783965, 1.459353], "hop": "Path of 1.7856 A from Mg [0.125, 0.125, 0.125] (ind: 3, Wyckoff: 2a) to Mg [0.000, 0.500, 0.000] (ind: 2, Wyckoff: 4c)", "hop_label": 2, "iindex": 2, "eindex": 5, "hop_distance": 1.785624325222287, "cost": 1.7856243987537097, "id": 5, "key": 0}], [{"to_jimage": [1, 0, 1], "ipos": [0.875, 0.875, 0.875], "epos": [1.0, 0.5, 1.0], "ipos_cart": [5.888378125, 4.149478375, 10.214845375], "epos_cart": [5.894486500000001, 2.3638645, 10.214756000000001], "hop": "Path of 1.7856 A from Mg [0.875, 0.875, 0.875] (ind: 3, Wyckoff: 2a) to Mg [1.000, 0.500, 1.000] (ind: 2, Wyckoff: 4c)", "hop_label": 2, "iindex": 3, "eindex": 5, "hop_distance": 1.785624325222287, "cost": 1.7856243987537097, "id": 5, "key": 0}, {"to_jimage": [1, 1, 1], "ipos": [0.875, 0.875, 0.875], "epos": [1.0, 1.0, 1.0], "ipos_cart": [5.888378125, 4.149478375, 10.214845375], "epos_cart": [6.7295750000000005, 4.742261, 11.674109], "hop": "Path of 1.7856 A from Mg [0.875, 0.875, 0.875] (ind: 3, Wyckoff: 2a) to Mg [1.000, 1.000, 1.000] (ind: 2, Wyckoff: 4c)", "hop_label": 2, "iindex": 3, "eindex": 4, "hop_distance": 1.7856241906570929, "cost": 1.7856243987537097, "id": 4, "key": 0}], [{"to_jimage": [0, -1, 0], "ipos": [0.0, 0.0, 0.0], "epos": [0.0, -0.5, 0.0], "ipos_cart": [0.0, 0.0, 0.0], "epos_cart": [-0.8350885, -2.3783965, -1.459353], "hop": "Path of 2.9127 A from Mg [0.000, 0.000, 0.000] (ind: 2, Wyckoff: 4c) to Mg [0.000, -0.500, 0.000] (ind: 2, Wyckoff: 4c)", "hop_label": 0, "iindex": 4, "eindex": 5, "hop_distance": 2.9127055966323647, "cost": 2.9127055078785857, "id": 5, "key": 0}, {"to_jimage": [0, 0, 0], "ipos": [0.0, 0.0, 0.0], "epos": [0.0, 0.5, 0.0], "ipos_cart": [0.0, 0.0, 0.0], "epos_cart": [0.8350885, 2.3783965, 1.459353], "hop": "Path of 2.9127 A from Mg [0.000, 0.000, 0.000] (ind: 2, Wyckoff: 4c) to Mg [0.000, 0.500, 0.000] (ind: 2, Wyckoff: 4c)", "hop_label": 0, "iindex": 4, "eindex": 5, "hop_distance": 2.9127055966323647, "cost": 2.9127055078785857, "id": 5, "key": 1}], []]}}, "symprec": 0.1, "vac_mode": false}
21 changes: 21 additions & 0 deletions pymatgen/analysis/diffusion/tests/test_pathfinder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
import unittest

from monty.serialization import loadfn
from pymatgen.util.testing import PymatgenTest

module_dir = os.path.dirname(os.path.abspath(__file__))


class PathfinderTest(PymatgenTest):
def test_mhop_msonable(self):
file_path = os.path.join(module_dir, "migration_graph_spinel_MgMn2O4.json")
spinel_mg = loadfn(file_path)
hop = spinel_mg.unique_hops[0]["hop"]
hop_dict = hop.as_dict()

assert type(hop_dict) == dict


if __name__ == "__main__":
unittest.main()