当前位置: 首页>>代码示例>>Python>>正文


Python VoronoiCoordFinder.get_coordination_number方法代码示例

本文整理汇总了Python中pymatgen.analysis.structure_analyzer.VoronoiCoordFinder.get_coordination_number方法的典型用法代码示例。如果您正苦于以下问题:Python VoronoiCoordFinder.get_coordination_number方法的具体用法?Python VoronoiCoordFinder.get_coordination_number怎么用?Python VoronoiCoordFinder.get_coordination_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymatgen.analysis.structure_analyzer.VoronoiCoordFinder的用法示例。


在下文中一共展示了VoronoiCoordFinder.get_coordination_number方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_ionic_radii

# 需要导入模块: from pymatgen.analysis.structure_analyzer import VoronoiCoordFinder [as 别名]
# 或者: from pymatgen.analysis.structure_analyzer.VoronoiCoordFinder import get_coordination_number [as 别名]
    def _get_ionic_radii(self):
        """
        Computes ionic radii of elements for all sites in the structure.
        If valence is zero, atomic radius is used.
        """
        radii = []
        coord_finder = VoronoiCoordFinder(self._structure)

        def nearest_key(sorted_vals, key):
            i = bisect_left(sorted_vals, key)
            if i == len(sorted_vals):
                i = -1
            return sorted_vals[i]

        for i in range(len(self._structure.sites)):
            site = self._structure.sites[i]
            el = site.specie.symbol
            oxi_state = int(round(site.specie.oxi_state))
            coord_no = int(round(coord_finder.get_coordination_number(i)))
            try:
                tab_oxi_states = map(int, _ion_radii[el].keys())
                tab_oxi_states.sort()
                oxi_state = nearest_key(tab_oxi_states, oxi_state)
                radius = _ion_radii[el][str(oxi_state)][str(coord_no)]
            except KeyError:
                if coord_finder.get_coordination_number(i)-coord_no > 0:
                    new_coord_no = coord_no + 1
                else:
                    new_coord_no = coord_no - 1
                try:
                    radius = _ion_radii[el][str(oxi_state)][str(new_coord_no)]
                    coord_no = new_coord_no
                except:
                    tab_coords = map(int, _ion_radii[el][str(oxi_state)].keys())
                    tab_coords.sort()
                    new_coord_no = nearest_key(tab_coords, coord_no)
                    i = 0
                    for val in tab_coords:
                        if  val > coord_no:
                            break
                        i = i + 1
                    if i == len(tab_coords):
                        key = str(tab_coords[-1])
                        radius = _ion_radii[el][str(oxi_state)][key]
                    elif i == 0:
                        key = str(tab_coords[0])
                        radius = _ion_radii[el][str(oxi_state)][key]
                    else:
                        key = str(tab_coords[i-1])
                        radius1 = _ion_radii[el][str(oxi_state)][key]
                        key = str(tab_coords[i])
                        radius2 = _ion_radii[el][str(oxi_state)][key]
                        radius = (radius1+radius2)/2

            #implement complex checks later
            radii.append(radius)
        return radii
开发者ID:zeroelement,项目名称:pymatgen,代码行数:59,代码来源:point_defects.py

示例2: _get_coord_no_sites_chrg

# 需要导入模块: from pymatgen.analysis.structure_analyzer import VoronoiCoordFinder [as 别名]
# 或者: from pymatgen.analysis.structure_analyzer.VoronoiCoordFinder import get_coordination_number [as 别名]
    def _get_coord_no_sites_chrg(self, site):
        """
        Compute the coordination number and coordination charge

        Args:
            site:
                pymatgen.core.sites.Site
        """
        struct = self._structure.copy()
        struct.append(site.specie.symbol, site.frac_coords)
        coord_finder = VoronoiCoordFinder(struct)
        coord_no = coord_finder.get_coordination_number(-1)
        coord_sites = coord_finder.get_coordinated_sites(-1)

        # In some cases coordination sites to interstitials include
        # interstitials also. Filtering them.
        def no_inter(site):
            return not site.specie.symbol == 'X'
        coord_sites = filter(no_inter, coord_sites)

        coord_chrg = 0
        for site, weight in coord_finder.get_voronoi_polyhedra(-1).items():
            if not site.specie.symbol == 'X':
                coord_chrg += weight * self._valence_dict[site.species_string]

        return coord_no, coord_sites, coord_chrg
开发者ID:zeroelement,项目名称:pymatgen,代码行数:28,代码来源:point_defects.py

示例3: _get_coord_no_sites_chrg

# 需要导入模块: from pymatgen.analysis.structure_analyzer import VoronoiCoordFinder [as 别名]
# 或者: from pymatgen.analysis.structure_analyzer.VoronoiCoordFinder import get_coordination_number [as 别名]
    def _get_coord_no_sites_chrg(self, site):
        """
        Compute the coordination number and coordination charge

        Args:
            site:
                pymatgen.core.sites.Site
        """
        struct = self._structure.copy()
        struct.append(site.species_string, site.frac_coords)
        coord_finder = VoronoiCoordFinder(struct)
        coord_no = coord_finder.get_coordination_number(-1)
        coord_sites = coord_finder.get_coordinated_sites(-1)

        # In some cases coordination sites to interstitials include 
        # interstitials also. 
        sites_to_be_deleted = []
        for i in range(len(coord_sites)):
            if coord_sites[i].species_string == 'X':
                sites_to_be_deleted.append(i)
        sites_to_be_deleted.reverse()  # So index won't change in between
        for ind in sites_to_be_deleted:
            del coord_sites[ind]

        coord_chrg = 0
        for site, weight in coord_finder.get_voronoi_polyhedra(-1).items():
            if not site.species_string == 'X':
                coord_chrg += weight * self._valence_dict[site.species_string]

        return coord_no, coord_sites, coord_chrg
开发者ID:akashneo,项目名称:pymatgen,代码行数:32,代码来源:point_defects.py

示例4: VoronoiCoordFinderTest

# 需要导入模块: from pymatgen.analysis.structure_analyzer import VoronoiCoordFinder [as 别名]
# 或者: from pymatgen.analysis.structure_analyzer.VoronoiCoordFinder import get_coordination_number [as 别名]
class VoronoiCoordFinderTest(unittest.TestCase):

    def setUp(self):
        filepath = os.path.join(test_dir, 'vasprun.xml')
        reader = Vasprun(filepath)
        s = reader.final_structure
        self.finder = VoronoiCoordFinder(s,[Element("O")])
    
    def test_get_voronoi_polyhedra(self):
        self.assertEqual(len(self.finder.get_voronoi_polyhedra(0).items()),10, "Incorrect number of results returned for get_voronoi_polyhedra")
        
    def test_get_coordination_number(self):
        print self.finder.get_coordination_number(0)
        self.assertAlmostEqual(self.finder.get_coordination_number(0), 5.60588600732, 7, "Incorrect coordination number returned!")                

    def test_get_coordinated_sites(self):
        self.assertEqual(len(self.finder.get_coordinated_sites(0)), 10)
开发者ID:chenweis,项目名称:pymatgen,代码行数:19,代码来源:test_structure_analyzer.py

示例5: _coord_find

# 需要导入模块: from pymatgen.analysis.structure_analyzer import VoronoiCoordFinder [as 别名]
# 或者: from pymatgen.analysis.structure_analyzer.VoronoiCoordFinder import get_coordination_number [as 别名]
 def _coord_find(self):
     """
     calls VoronoiCoordFinder to compute the coordination number,
     coordination charge
     """
     for i in range(self.defect_count()):
         struct = self._structs[i].copy()
         coord_finder = VoronoiCoordFinder(struct)
         self._coord_no.append(coord_finder.get_coordination_number(-1))
         self._coord_sites.append(coord_finder.get_coordinated_sites(-1))
         coord_chrg = 0
         for site, weight in coord_finder.get_voronoi_polyhedra(-1).items():
             coord_chrg += weight * self._valence_dict[site.species_string]
         self._coord_charge_no.append(coord_chrg)
开发者ID:zeroelement,项目名称:pymatgen,代码行数:16,代码来源:point_defects.py

示例6: VoronoiCoordFinderTest

# 需要导入模块: from pymatgen.analysis.structure_analyzer import VoronoiCoordFinder [as 别名]
# 或者: from pymatgen.analysis.structure_analyzer.VoronoiCoordFinder import get_coordination_number [as 别名]
class VoronoiCoordFinderTest(PymatgenTest):
    def setUp(self):
        s = self.get_structure('LiFePO4')
        self.finder = VoronoiCoordFinder(s, [Element("O")])

    def test_get_voronoi_polyhedra(self):
        self.assertEqual(len(self.finder.get_voronoi_polyhedra(0).items()), 8)

    def test_get_coordination_number(self):
        self.assertAlmostEqual(self.finder.get_coordination_number(0),
                               5.809265748999465, 7)

    def test_get_coordinated_sites(self):
        self.assertEqual(len(self.finder.get_coordinated_sites(0)), 8)
开发者ID:setten,项目名称:pymatgen,代码行数:16,代码来源:test_structure_analyzer.py

示例7: __init__

# 需要导入模块: from pymatgen.analysis.structure_analyzer import VoronoiCoordFinder [as 别名]
# 或者: from pymatgen.analysis.structure_analyzer.VoronoiCoordFinder import get_coordination_number [as 别名]
    def __init__(self, structure, valences, radii):
        """
        Args:
            structure:
                pymatgen.core.structure.Structure
            valences:
                valences of elements as a dictionary 
            radii:
                Radii of elements as a dictionary
        """

        self._structure = structure
        self._valence_dict = valences
        self._rad_dict = radii
        # Store symmetrically distinct sites, their coordination numbers
        # coordinated_sites, effective charge
        symm_finder = SymmetryFinder(self._structure)
        symm_structure = symm_finder.get_symmetrized_structure()
        equiv_site_seq = symm_structure.equivalent_sites

        self._defect_sites = []
        for equiv_sites in equiv_site_seq:
            self._defect_sites.append(equiv_sites[0])

        self._vac_site_indices = []
        for site in self._defect_sites:
            for i in range(len(self._structure.sites)):
                if site == self._structure[i]:
                    self._vac_site_indices.append(i)

        coord_finder = VoronoiCoordFinder(self._structure)
        self._defectsite_coord_no = []
        self._defect_coord_sites = []
        for i in self._vac_site_indices:
            self._defectsite_coord_no.append(
                coord_finder.get_coordination_number(i)
            )
            self._defect_coord_sites.append(
                coord_finder.get_coordinated_sites(i)
            )

        # Store the ionic radii for the elements in the structure
        # (Used to  computing the surface are and volume)
        # Computed based on valence of each element

        self._vac_eff_charges = None
        self._vol = None
        self._sa = None
开发者ID:hgfb,项目名称:pymatgen,代码行数:50,代码来源:point_defects.py

示例8: VoronoiCoordFinderTest

# 需要导入模块: from pymatgen.analysis.structure_analyzer import VoronoiCoordFinder [as 别名]
# 或者: from pymatgen.analysis.structure_analyzer.VoronoiCoordFinder import get_coordination_number [as 别名]
class VoronoiCoordFinderTest(unittest.TestCase):

    def setUp(self):
        filepath = os.path.join(test_dir, 'LiFePO4.cif')
        parser = CifParser(filepath)
        s = parser.get_structures()[0]
        self.finder = VoronoiCoordFinder(s, [Element("O")])

    def test_get_voronoi_polyhedra(self):
        self.assertEqual(len(self.finder.get_voronoi_polyhedra(0).items()), 8,
                         "Incorrect number of results returned for " +
                         "get_voronoi_polyhedra")

    def test_get_coordination_number(self):
        self.assertAlmostEqual(self.finder.get_coordination_number(0),
                               5.809265748999465, 7)

    def test_get_coordinated_sites(self):
        self.assertEqual(len(self.finder.get_coordinated_sites(0)), 8)
开发者ID:jesuansito,项目名称:pymatgen,代码行数:21,代码来源:test_structure_analyzer.py

示例9: get_coordination_numbers

# 需要导入模块: from pymatgen.analysis.structure_analyzer import VoronoiCoordFinder [as 别名]
# 或者: from pymatgen.analysis.structure_analyzer.VoronoiCoordFinder import get_coordination_number [as 别名]
def get_coordination_numbers(d):
    """
    Helper method to get the coordination number of all sites in the final
    structure from a run.

    Args:
        d:
            Run dict generated by VaspToDbTaskDrone.

    Returns:
        Coordination numbers as a list of dict of [{"site": site_dict,
        "coordination": number}, ...].
    """
    structure = Structure.from_dict(d["output"]["crystal"])
    f = VoronoiCoordFinder(structure)
    cn = []
    for i, s in enumerate(structure.sites):
        try:
            n = f.get_coordination_number(i)
            number = int(round(n))
            cn.append({"site": s.to_dict, "coordination": number})
        except Exception:
            logger.error("Unable to parse coordination errors")
    return cn
开发者ID:psear,项目名称:pymatgen-db,代码行数:26,代码来源:creator.py


注:本文中的pymatgen.analysis.structure_analyzer.VoronoiCoordFinder.get_coordination_number方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。