def get_connectivity_description(connectivity_matrix, polyhedra, structure, sites_diff, radius=2.6, anions=None): """ Writes a verbal description of the connectivity between cations in a structure; connections between cation polyhedra and reflections of itself (and reflections of other cation polyhedra) are also counted; different sites of the same species are not differentiated (that is, connectivity for cations with different sites, not including reflections, are not counted separately) :param connectivity_matrix: (dict) dictionary of dictionaries containing connectivities between different cation polyhedra (should be output from get_connectivity_matrix) :param polyhedra: (List of Polyhedra) list of all Polyhedra in the supercell structure :param structure: (Structure) target structure :param sites_diff: (Boolean) whether sites with the same cation species should be differentiated :param radius: (float) radius within which to determine whether a nearby atom is a peripheral ion :param anions: (List of Strings) list of species strings of what we consider anions in the structure :return: (dict) dictionary of strings containing verbal descriptions of connectivites between cations in the given structure; keys = cation tag (eg: Li1, Na2, where the letters represent the species and the number distinguishes the species from the other instances of that same species in the unit cell); dict values = String descriptions of connectivity """ if anions is None: anions = ['O2-', 'O', 'F-', 'F', 'Cl-', 'Cl', 'I-', 'I', 'Br-', 'Br', 'S2-', 'S', 'N', 'N3-'] cn_list = EffectiveCoordFinder(structure).get_avg_cn(radius, anions) descriptions = {} for cation_1 in connectivity_matrix.keys(): descriptions[cation_1] = "" for cation_1 in connectivity_matrix.keys(): if sites_diff: cn1 = get_effective_cn(get_ex_poly(polyhedra, cation_1)) else: cn1 = cn_list[cation_1] descriptions[cation_1] += cation_1 + " are " + get_cn_description(cn1) + ". \n" for cation_2 in connectivity_matrix[cation_1].keys(): connected = False for connectivity_type in connectivity_matrix[cation_1][cation_2].keys(): if connectivity_matrix[cation_1][cation_2][connectivity_type] != 0: connected = True if connected: descriptions[cation_1] += "They are " first = True for connectivity_type in connectivity_matrix[cation_1][cation_2].keys(): if connectivity_matrix[cation_1][cation_2][connectivity_type] != 0: if first: descriptions[cation_1] += connectivity_type + "-connected " first = False else: descriptions[cation_1] += "and " + connectivity_type + "-connected " if sites_diff: cn2 = get_effective_cn(get_ex_poly(polyhedra, cation_2)) else: cn2 = cn_list[cation_2] descriptions[cation_1] += "to " + get_cn_description(cn2) + " " + cation_2 + ". " return descriptions
def test_econ_on_polyhedra(self): """Test Routine econ for single Polyhedra""" licoo2_matrix, licoo2_polyhedra = connectivity.get_connectivity_matrix(self.licoo2_structure, False) for polyhedra in licoo2_polyhedra: if polyhedra.central_ion_name == "Li": test_poly = polyhedra break cn = econ.get_effective_cn(test_poly) self.assertAlmostEqual(cn, 6.0, 2, "Li polyhedra should be 6-fold coordinated")