Exemplo n.º 1
0
 def calc_gii_pymatgen(self, struct, scale_factor=0.965):
     """Calculates global instability index using Pymatgen's bond valence sum
     Args:
         struct: Pymatgen Structure object
         scale: Float, tunable scale factor for bond valence
     Returns:
         gii: Float, global instability index
     """
     deviations = []
     cutoff=self.r_cut
     if struct.is_ordered:
         for site in struct:
             nn = struct.get_neighbors(site,r=cutoff)
             bvs = bond_valence.calculate_bv_sum(site,
                                                 nn,
                                                 scale_factor=scale_factor)
             deviations.append(bvs - site.species.elements[0].oxi_state)
         gii = np.linalg.norm(deviations) / np.sqrt(len(deviations))
     else:
         for site in struct:
             nn = struct.get_neighbors(site,r=cutoff)
             bvs = bond_valence.calculate_bv_sum_unordered(site,
                                                           nn,
                                                           scale_factor=scale_factor)
             min_diff = min(
                 [bvs - spec.oxi_state for spec in site.species.elements]
             )
             deviations.append(min_diff)
         gii = np.linalg.norm(deviations) / np.sqrt(len(deviations))
     return gii
Exemplo n.º 2
0
def oxstates(structure, Bsite):
# This function estimates the oxidation state of the Bsite using bond valence methods
    sites = structure.sites
    Bsite_indexes = []
    Bsite_ox = []
    oxstate = 0
    for site in sites:
        if Bsite in str(site):
            neighbors = structure.get_neighbors(site, r = 2.5)
            oxstate = calculate_bv_sum(site, neighbors)
            Bsite_ox.append(oxstate)
            Bsite_specie = site.specie
        if Bsite not in str(site) and 'O' not in str(site):
            Asite_specie = site.specie

    Bsite_ox = ceil(sum(Bsite_ox)/len(Bsite_ox))
    Asite_ox = 6-Bsite_ox
    # catch unusual oxidation states resulting from calculating on the Bsite oxidation state
    if Asite_ox not in Asite_specie.common_oxidation_states or Bsite_ox not in Bsite_specie.common_oxidation_states:
        if 3 in Asite_specie.common_oxidation_states:
            Asite_ox = 3
        else:
            Asite_ox = max(Asite_specie.common_oxidation_states)
        Bsite_ox = 6-Asite_ox
    final_ox = {str(Asite_specie): Asite_ox, Bsite: Bsite_ox, 'O': -2}
    return final_ox
Exemplo n.º 3
0
 def test_calculate_bv_sum(self):
     s = Structure.from_file(os.path.join(test_dir, "LiMn2O4.json"))
     neighbors = s.get_neighbors(s[0], 3.0)
     bv_sum = calculate_bv_sum(s[0], neighbors)
     self.assertAlmostEqual(bv_sum, 0.7723402182087497, places=5)
Exemplo n.º 4
0
        equi_sites = [[site] for site in structure]

    # Sort the equivalent sites by decreasing electronegativity.
    equi_sites = sorted(equi_sites,
                        key=lambda sites: -sites[0].species.average_electroneg)

    # Get a list of valences and probabilities for each symmetrically
    # distinct site.
    all_prob = []
    if structure.is_ordered:
        for sites in equi_sites:
            test_site = sites[0]
            # print(test_site)
            nn = structure.get_neighbors(test_site, 3.0)

            bv_sum.append(pma.calculate_bv_sum(test_site, nn))
            bv_elem.append(test_site.specie.symbol)
            bv_type.append('Mineral')

#protein
d = '/home/kenneth/proj/proMin/proteins/feS'
with open(os.path.join(d, 'pdbNames.txt')) as f:
    for i in f.readlines():
        fi = os.path.join(d, i.strip() + '.pdb')
        mol = Molecule.from_file(fi)
        # print(dir(parser))
        print('test1')
        print(list(BV_PARAMS.keys()))
        els = [
            Element(el.symbol) for el in mol.composition.elements
            if Element(el.symbol) in list(BV_PARAMS.keys())
Exemplo n.º 5
0
    # Sort the equivalent sites by decreasing electronegativity.
    equi_sites = sorted(equi_sites,
                        key=lambda sites: -sites[0].species.average_electroneg)

    # Get a list of valences and probabilities for each symmetrically
    # distinct site.
    all_prob = []
    if structure.is_ordered:
        for sites in equi_sites:
            test_site = sites[0]
            if test_site.specie.symbol in ['Fe']:
                # print(test_site)
                nn = structure.get_neighbors(test_site, 3.0)

                bv_sum.append(round(pma.calculate_bv_sum(test_site, nn), 2))
                bv_elem.append(test_site.specie.symbol)
                bv_type.append('Mineral')
                bv_name.append(m)
# print(bv_sum)
# exit()
#protein

# d = '/home/kenneth/proj/pro-min/proteins/feS/clusters/findGeo/combineFindGeoResults'
d = '/home/kenneth/proj/pro-min/proteins/feS/sites'
xyzs = glob(os.path.join(d, '*.xyz'))
for xyz in xyzs:
    print(xyz)
    if xyz != os.path.join(d, 'pdb.xyz'):

        xyzObj = XYZ.from_file(xyz)