Esempio n. 1
0
def get_m_graph_from_site_data(s_data):
    mol = Molecule.from_sites([Site.from_dict(isite)
                               for isite in s_data['local_graph']['sites']])
    mg = MoleculeGraph.with_empty_graph(mol)
    for i in range(1, len(mg)):
        mg.add_edge(0, i)
    return mg
Esempio n. 2
0
def get_scene(data, site_index):
    site_data = data['site_data'][site_index]
    mol = Molecule.from_sites([Site.from_dict(isite)
                               for isite in site_data['local_graph']['sites']])
    scene = get_m_graph_from_mol(mol).get_scene()
    scene.name = "ref-site"
    return scene
Esempio n. 3
0
 def compose_vasp_movie(self, diffusion_sites, empty_lattice):
     for i in diffusion_sites:
         site_from_dict = Site.from_dict(i)
         species = str(site_from_dict.specie)
         coords = site_from_dict.coords
         empty_lattice.append(species, coords, coords_are_cartesian=True)
     # writer.write_structure(empty_lattice, "POSCAR.path.vasp")
     return
Esempio n. 4
0
def get_closest_matched(ref_data, site_index, all_random_sites):
    """
    Find the 10 most similar sites
    Args:
        ref_data:
        site_index:
        all_random_sites:

    Returns:

    """
    ref_soap_vec = ref_data['site_data'][site_index]['soap_vec']

    def similarity(random_site_data):
        return np.abs(1 - np.dot(random_site_data, ref_soap_vec) / np.dot(ref_soap_vec, ref_soap_vec))

    all_sites_with_sim = [(isite, similarity(isite['soap_vec']))
                          for isite in all_random_sites]
    all_sites_with_sim.sort(key=lambda x: x[1])

    matched_res = []
    for itr, (site_info, proj) in enumerate(all_sites_with_sim[:3]):
        mol = Molecule.from_sites([Site.from_dict(isite)
                                   for isite in site_info['local_graph']['sites']])
        mg = get_m_graph_from_mol(mol)
        scene = mg.get_scene()
        scene.name = f"matched-site-{itr}"
        matched_res.append(site_info["task_id"] + "   " + f"{proj:0.4f}")
        matched_res.append(Simple3DScene(
            sceneSize=210,
            inletSize=150,
            inletPadding=0,
            axisView='SW',
            data=scene
        ))
    return matched_res