return remainder surf = Molecule.from_file('D:\\Users\\RyanTrottier\\Documents\\Scrap\\tmp.'+type) center_i = 787 center = surf[center_i] # pymatgen.core.sites.Site for radius in [3,4,5,6,8]: dr = 4 stoich = get_stoichiometry(surf) sites = [center] + [ x[0] for x in surf.get_neighbors(center, radius)] mol = Molecule.from_sites(sites) remainder = get_remainder(mol, stoich) i = 0 # going to iterate over all sites, starting with the closest add_sites = surf.get_neighbors_in_shell(center.coords, radius+dr, dr) add_sites.sort(key=lambda a: a[1]) while max(remainder.values()) > 0: # while atoms still need to be added (site, distance) = add_sites[i] # type: pymatgen.Site if remainder[site.specie] > 0 : # if site should be added mol.append(site.specie, site.coords, properties=site.properties) # Add site remainder[site.specie] = remainder[site.specie] - 1 i = i + 1 type='gjf' mol.to(type, 'D:\\Users\\RyanTrottier\\Documents\\Scrap\\feal2o4_{}.{}'.format(radius, type))
def site_layout(symmetrizer: StructureSymmetrizer): columns = [] distance_cutoff = 2.0 angle_cutoff = 0.3 cnn = CrystalNN() nn_info = cnn.get_all_nn_info(structure=symmetrizer.structure) for name, site in symmetrizer.sites.items(): wyckoff_contents = [] data = dict() data["Site Symmetry"] = site.site_symmetry data["Wyckoff Letter"] = site.wyckoff_letter wyckoff_contents.append(html.Label(f"{name}", className="mpc-label")) site_data = [] repr_idx = site.equivalent_atoms[0] for idx in site.equivalent_atoms: coords = symmetrizer.structure[idx].frac_coords site_data += [(pretty_frac_format(coords[0]), pretty_frac_format(coords[1]), pretty_frac_format(coords[2]))] # lgf = LocalGeometryFinder() # lgf.setup_structure(structure=symmetrizer.structure) # se = lgf.compute_structure_environments( # maximum_distance_factor=distance_cutoff + 0.01) # strategy = SimplestChemenvStrategy( # distance_cutoff=distance_cutoff, angle_cutoff=angle_cutoff # ) # lse = LightStructureEnvironments.from_structure_environments( # strategy=strategy, structure_environments=se) # represent the local environment as a molecule mol = Molecule.from_sites([symmetrizer.structure[repr_idx]] + [i["site"] for i in nn_info[repr_idx]]) mol = mol.get_centered_molecule() mg = MoleculeGraph.with_empty_graph(molecule=mol) for i in range(1, len(mol)): mg.add_edge(0, i) view = html.Div( [ StructureMoleculeComponent( struct_or_mol=mg, disable_callbacks=True, id= f"{symmetrizer.structure.composition.reduced_formula}_site_{repr_idx}", scene_settings={ "enableZoom": False, "defaultZoom": 0.6 }, )._sub_layouts["struct"] ], style={ "width": "300px", "height": "300px" }, ) # env = lse.coordination_environments[repr_idx] # all_ce = AllCoordinationGeometries() # co = all_ce.get_geometry_from_mp_symbol(env[0]["ce_symbol"]) # name = co.name data.update({ # "Environment": name, # "IUPAC Symbol": co.IUPAC_symbol_str, "Structure": view, }) wyckoff_contents.append(get_data_list(data)) wyckoff_contents.append( Reveal(get_table(site_data), title=f"Positions ({len(site_data)})", id=f"{name}-positions")) columns.append(Column(html.Div(wyckoff_contents))) _layout = Columns(columns) return Columns([Column([H4("Sites"), html.Div(_layout)])])