Exemplo n.º 1
0
def anion_inter(x, *args):
    cations = args[0]
    anions = args[1]
    lattice = args[2]
    Species_list = args[3]
    num_atoms = args[4]
    cutoff_distance = args[5]
    BVpara = args[6]
    Formal_Valence = args[7]
    wycks = args[8]
    space_group = args[9]
    b0 = args[10]
    center_atom_in_regular_poly = args[11]
    max_angle = args[12]
    nearest_neighbor_distance = args[13]
    Shannon_anion_anion = args[14]

    pymat_structure = Structure(lattice, Species_list, x.reshape(num_atoms, 3))

    anions_indx = pymat_structure.indices_from_symbol(anions[0])
    logic = 0
    for anion in anions_indx:

        NN = pymat_structure.get_neighbors(pymat_structure.sites[anion],
                                           4,
                                           include_index=True)
        #print len(NN)
        for neigh in NN:
            if str(neigh[0].specie.symbol) in anions:
                #print neigh[1]
                logic += 0.25 / (1 + np.exp(50 *
                                            (neigh[1] - Shannon_anion_anion)))
    #print logic
    return logic / 10
Exemplo n.º 2
0
    def check_hydrogens(s: Structure,
                        neighbor_threshold: float = 2.0,
                        strictness: str = 'CH') -> bool:
        """
        checks if there are any hydrogens in a structure object.

        Args:
            s (pymatgen structure object): structure to be checked
            neighbor_threshold (float): threshold for distance that is still considered to be bonded
            strictness (str): available levels: 'tight': returns false if there is no H at all, 'medium'
                returns false if there are carbons but no hydrogens, 'CH' (default) checks if there are
                carbons with less or equal 2 non-hydrogen neighbors (e.g. the most common case for aromatic rings).
                If those have also no hydrogen bonded to them, it will return False

        Returns:

        """

        symbols = s.symbol_set

        return_val = True

        if strictness == 'tight':
            logger.debug('running H check with tight strictness')
            if not 'H' in symbols:
                return False
        elif strictness == 'medium':
            logger.debug('running H check with medium strictness')
            if 'C' in symbols:
                if not 'H' in symbols:
                    return False
        elif strictness == 'CH':
            logger.debug('running H check with CH strictness')
            if 'C' in symbols:
                c_sites = s.indices_from_symbol('C')
                for c_site in c_sites:
                    neighbors = s.get_neighbors(s[c_site], neighbor_threshold)
                    neighbors_symbol_list = [
                        neighbor_site[0].species_string
                        for neighbor_site in neighbors
                    ]
                    neighbors_no_h = [
                        neighbor_site for neighbor_site in neighbors
                        if neighbor_site[0].species_string != 'H'
                    ]
                    if len(neighbors_symbol_list) == 0:
                        return False
                    if len(neighbors_no_h) <= 2:
                        if len(neighbors) - len(neighbors_no_h) == 0:
                            return False
        return return_val
Exemplo n.º 3
0
def calc_orbital_character(orbitals,
                           structure: Structure,
                           spin: Spin,
                           kpt_index: int,
                           band_index: int):
    """ Consider the two pattern of orbitals.

    LORBIT 10 -> consider only "s", "p", "d" orbitals
    LORBIT >=11 -> consider "s", "px", "py", "pz",.. orbitals

    """

    def projection_sum(atom_indices: tuple, first: int, last: int):
        end = last + 1
        procar_sum = np.sum(orbitals[spin]
                            [kpt_index, band_index, atom_indices, first:end])
        return float(procar_sum)

    orbital_components = {}
    azimuthal = len(orbitals[Spin.up][0, 0, 0]) > 5

    for element in structure.symbol_set:
        # get list of index
        indices = structure.indices_from_symbol(element)
        if azimuthal:
            orbital_components[element] = \
                [round(projection_sum(indices, 0, 0), 3),
                 round(projection_sum(indices, 1, 3), 3),
                 round(projection_sum(indices, 4, 8), 3)]
            try:
                orbital_components[element].append(round(projection_sum(indices, 9, 16), 3))
            except KeyError:
                pass
        else:
            orbital_components[element] = \
                [round(projection_sum(indices, 0, 0), 3),
                 round(projection_sum(indices, 1, 1), 3),
                 round(projection_sum(indices, 2, 2), 3)]
    return orbital_components