def setUp(self):
        struct = Structure.from_file(f"{dir_path}/full_path_files/MnO2_full_Li.vasp")
        self.fpm_li = MigrationGraph.with_distance(structure=struct, migrating_specie="Li", max_distance=4)

        # Particularity difficult pathfinding since both the starting and ending positions are outside the unit cell
        struct = Structure.from_file(f"{dir_path}/full_path_files/Mg_2atom.vasp")
        self.fpm_mg = MigrationGraph.with_distance(structure=struct, migrating_specie="Mg", max_distance=2)
Пример #2
0
    def test_m_graph_from_entries_failed(self):
        # only base
        s_list = MigrationGraph.get_structure_from_entries(
            entries=[self.test_ents_MOF["ent_base"]],
            migrating_ion_entry=self.li_ent,
        )
        self.assertEqual(len(s_list), 0)

        s_list = MigrationGraph.get_structure_from_entries(
            entries=self.test_ents_MOF["one_cation"],
            migrating_ion_entry=self.li_ent,
        )
        self.assertEqual(len(s_list), 0)
    def setUp(self):
        self.test_ents_MOF = loadfn(f"{dir_path}/full_path_files/Mn6O5F7_cat_migration.json")
        self.aeccar_MOF = Chgcar.from_file(f"{dir_path}/full_path_files/AECCAR_Mn6O5F7.vasp")
        self.li_ent = loadfn(f"{dir_path}/full_path_files/li_ent.json")["li_ent"]

        self.full_struct = MigrationGraph.get_structure_from_entries(
            base_entries=[self.test_ents_MOF["ent_base"]],
            inserted_entries=self.test_ents_MOF["one_cation"],
            migrating_ion_entry=self.li_ent,
        )[0]
def add_edge_data_from_sc(
    mg: MigrationGraph,
    i_sc: Structure,
    e_sc: Structure,
    data_array: list,
    key: str = "custom_key",
    use_host_sg: bool = True,
) -> None:
    """
    Add a data entry and key to edges within FullPathMapper object with the same hop_label.
    These hops are equivalent by symmetry to the 2 positions given in the supercell structures.

    Args:
        i_sc: Supercell structure containing working ion at initial position
        e_sc: Supercell structure containing working ion at ending position
        data_array: The data to be added to the edges
        key: Key of the edge attribute to be added
        use_host_sg: Flag t whether or not to use the host structure's spacegroup to initiate MigrationHop

    Returns:
        None
    """
    wi = list(mg.m_graph.graph.edges(data=True))[0][2]["hop"].isite.specie.name
    i_wi = [x for x in i_sc.sites if x.species_string == wi]
    e_wi = [x for x in e_sc.sites if x.species_string == wi]
    if len(i_wi) != 1 or len(e_wi) != 1:
        raise ValueError(
            "The number of working ions in each supercell structure should be one"
        )
    isite, esite = i_wi[0], e_wi[0]
    uhop_index, mh_from_sc = get_unique_hop(mg, i_sc, isite, esite,
                                            use_host_sg)
    add_dict = {key: data_array}
    mg.add_data_to_similar_edges(target_label=uhop_index,
                                 data=add_dict,
                                 m_hop=mh_from_sc)
Пример #5
0
 def setUp(self):
     self.lifepo = self.get_structure("LiFePO4")
     migration_graph = MigrationGraph.with_distance(self.lifepo,
                                                    max_distance=4.0,
                                                    migrating_specie="Li")
     gen = iter(migration_graph.migration_graph.graph.edges(data=True))
     u, v, d = next(gen)
     i_site = PeriodicSite("Li",
                           coords=d["ipos"],
                           lattice=self.lifepo.lattice)
     e_site = PeriodicSite("Li",
                           coords=d["epos"],
                           lattice=self.lifepo.lattice)
     a = SpacegroupAnalyzer(self.lifepo)
     symm_structure = a.get_symmetrized_structure()
     self.m_hop = MigrationHop(i_site, e_site, symm_structure)
Пример #6
0
 def test_m_graph_construction(self):
     self.assertEqual(self.full_struct.composition["Li"], 8)
     mg = MigrationGraph.with_distance(self.full_struct,
                                       migrating_specie="Li",
                                       max_distance=4.0)
     self.assertEqual(len(mg.m_graph.structure), 8)
Пример #7
0
 def setUp(self):
     struct = Structure.from_file(
         f"{dir_path}/full_path_files/MnO2_full_Li.vasp")
     self.fpm = MigrationGraph.with_distance(structure=struct,
                                             migrating_specie="Li",
                                             max_distance=4)
Пример #8
0
 def test_not_matching_first(self):
     structure = Structure.from_file(
         f"{dir_path}/pathfinder_files/Li6MnO4.json")
     fpm_lmo = MigrationGraph.with_distance(structure, "Li", max_distance=4)
     for u, v, d in fpm_lmo.m_graph.graph.edges(data=True):
         self.assertIn(d["hop"].eindex, {0, 1})
Пример #9
0
test_dir = os.path.dirname(os.path.realpath(__file__))

__author__ = "Haoming Li"
__version__ = "1.0"
__date__ = "February 17, 2021"

uc_full_sites = Structure.from_file(f"{test_dir}/test_files/Li4Sr3Fe2O7_uc.vasp")
input_struct_i = Structure.from_file(f"{test_dir}/test_files/Sr3Fe2O7_sc_i.vasp")
input_struct_e = Structure.from_file(f"{test_dir}/test_files/Sr3Fe2O7_sc_e.vasp")

mg_uc_full_sites = Structure.from_file(f"{test_dir}/test_files/Mg3VOPO4_uc.vasp")
mg_input_struct_i = Structure.from_file(f"{test_dir}/test_files/Mg3VOPO4_sc_i.vasp")
mg_input_struct_e = Structure.from_file(f"{test_dir}/test_files/Mg3VOPO4_sc_e.vasp")

mg_Li = MigrationGraph.with_distance(structure=uc_full_sites, migrating_specie="Li", max_distance=5)
mg_Mg = MigrationGraph.with_distance(structure=mg_uc_full_sites, migrating_specie="Mg", max_distance=4)


def test_add_edge_data_from_sc():
    errors = []

    test_key = "test_key"
    test_array = [0, 1, 2, 3, 4]
    add_edge_data_from_sc(
        mg_Li,
        i_sc=input_struct_i,
        e_sc=input_struct_e,
        data_array=test_array,
        key=test_key,
    )