test for get_uc_pos
testing for initial, mid and end sites behavior in get_uc_pos
# Distributed under the terms of the BSD License.
import os
-from pymatgen.core.structure import Structure
+import numpy as np
+from pymatgen.core.structure import Structure, PeriodicSite
+from pymatgen.analysis.structure_matcher import StructureMatcher
from pymatgen.analysis.diffusion.neb.full_path_mapper import MigrationGraph
-from pymatgen.analysis.diffusion.utils.edge_data_from_sc import add_edge_data_from_sc
+from pymatgen.analysis.diffusion.utils.edge_data_from_sc import add_edge_data_from_sc, get_uc_pos
test_dir = os.path.dirname(os.path.realpath(__file__))
@@ -46,4 +48,38 @@ def test_add_edge_data_from_sc():
if not all(i == hop_labels[0] for i in hop_labels):
errors.append("Not all data are added to the same unique hop")
- assert not errors, "errors occured:\n{}".format("\n".join(errors))
+ assert not errors, "errors occured:\n" + "\n".join(errors)
+
+
+def test_get_uc_pos():
+ errors = []
+
+ # set up parameters to initiate get_uc_pos
+ mg = MigrationGraph.with_distance(structure=uc_full_sites, migrating_specie="Li", max_distance=5)
+ uc_lattice = mg.symm_structure.lattice
+ isite = [x for x in input_struct_i.sites if x.species_string == "Li"][0]
+ esite = [x for x in input_struct_e.sites if x.species_string == "Li"][0]
+ sm = StructureMatcher(ignored_species=[list(mg.m_graph.graph.edges(data=True))[0][2]["hop"].isite.specie.name])
+ wi_specie = mg.symm_structure[-1].specie
+
+ p0, p1, p2 = get_uc_pos(isite, esite, mg.symm_structure, input_struct_i, sm)
+
+ # generate correct sites to compare
+ test_p0 = PeriodicSite(
+ wi_specie, np.array([2.91418875, 1.02974425, 4.4933425]), uc_lattice, coords_are_cartesian=True
+ )
+ test_p1 = PeriodicSite(
+ wi_specie, np.array([4.82950555, 1.0247028, 4.10369437]), uc_lattice, coords_are_cartesian=True
+ )
+ test_p2 = PeriodicSite(
+ wi_specie, np.array([6.74482475, 1.01967025, 3.7140425]), uc_lattice, coords_are_cartesian=True
+ )
+ print(test_p0)
+ if not test_p0.__eq__(p0):
+ errors.append("Initial site does not match")
+ if not test_p1.__eq__(p1):
+ errors.append("Middle site does not match")
+ if not test_p2.__eq__(p2):
+ errors.append("Ending site does not match")
+
+ assert not errors, "errors occured:\n" + "\n".join(errors)
