Пример #1
0
 def setUp(self):
     mgo_latt = [[4.212, 0, 0], [0, 4.212, 0], [0, 0, 4.212]]
     mgo_specie = ["Mg"] * 4 + ["O"] * 4
     mgo_frac_cord = [[0, 0, 0], [0.5, 0.5, 0], [0.5, 0, 0.5], [0, 0.5, 0.5],
                      [0.5, 0, 0], [0, 0.5, 0], [0, 0, 0.5], [0.5, 0.5, 0.5]]
     self.mgo_uc = Structure(mgo_latt, mgo_specie, mgo_frac_cord, True, True)
     mgo_valrad_eval = ValenceIonicRadiusEvaluator(self.mgo_uc)
     val = mgo_valrad_eval.valences
     rad = mgo_valrad_eval.radii
     self.mgo_vac = Vacancy(self.mgo_uc, val, rad)
     self.mgo_vfe = VacancyFormationEnergy(self.mgo_vac)
Пример #2
0
 def setUp(self):
     """
     Setup MgO rocksalt structure for testing Vacancy
     """
     mgo_latt = [[4.212, 0, 0], [0, 4.212, 0], [0, 0, 4.212]]
     mgo_specie = ["Mg"] * 4 + ["O"] * 4
     mgo_frac_cord = [[0, 0, 0], [0.5, 0.5, 0], [0.5, 0, 0.5], [0, 0.5, 0.5],
                      [0.5, 0, 0], [0, 0.5, 0], [0, 0, 0.5], [0.5, 0.5, 0.5]]
     self._mgo_uc = Structure(mgo_latt, mgo_specie, mgo_frac_cord, True,
                              True)
     self._mgo_valrad_evaluator = ValenceIonicRadiusEvaluator(self._mgo_uc)
Пример #3
0
 def setUp(self):
     mgo_latt = [[4.212, 0, 0], [0, 4.212, 0], [0, 0, 4.212]]
     mgo_specie = ["Mg"] * 4 + ["O"] * 4
     mgo_frac_cord = [[0, 0, 0], [0.5, 0.5, 0], [0.5, 0, 0.5], [0, 0.5, 0.5],
                      [0.5, 0, 0], [0, 0.5, 0], [0, 0, 0.5], [0.5, 0.5, 0.5]]
     self.mgo_uc = Structure(mgo_latt, mgo_specie, mgo_frac_cord, True, True)
     mgo_valrad_eval = ValenceIonicRadiusEvaluator(self.mgo_uc)
     val = mgo_valrad_eval.valences
     rad = mgo_valrad_eval.radii
     self.mgo_val = val
     self.mgo_rad = rad
     self.mgo_inter = Interstitial(self.mgo_uc, val, rad)
     self.isr = InterstitialStructureRelaxer(self.mgo_inter, 'Mg', 2)
 def setUp(self):
     """
     Setup MgO rocksalt structure for testing Interstitial
     """
     mgo_latt = [[4.212, 0, 0], [0, 4.212, 0], [0, 0, 4.212]]
     mgo_specie = ["Mg"] * 4 + ["O"] * 4
     mgo_frac_cord = [[0, 0, 0], [0.5, 0.5, 0], [0.5, 0, 0.5],
                      [0, 0.5, 0.5], [0.5, 0, 0], [0, 0.5, 0], [0, 0, 0.5],
                      [0.5, 0.5, 0.5]]
     self._mgo_uc = Structure(mgo_latt, mgo_specie, mgo_frac_cord, True,
                              True)
     mgo_val_rad_eval = ValenceIonicRadiusEvaluator(self._mgo_uc)
     self._mgo_val = mgo_val_rad_eval.valences
     self._mgo_rad = mgo_val_rad_eval.radii
     self._mgo_interstitial = Interstitial(self._mgo_uc, self._mgo_val,
                                           self._mgo_rad)
Пример #5
0
    def setUp(self):
        """
        Setup MgO rocksalt structure for testing Vacancy
        """
        mgo_latt = [[4.212, 0, 0], [0, 4.212, 0], [0, 0, 4.212]]
        mgo_specie = ["Mg"] * 4 + ["O"] * 4
        mgo_frac_cord = [[0, 0, 0], [0.5, 0.5, 0], [0.5, 0, 0.5], [0, 0.5, 0.5],
                         [0.5, 0, 0], [0, 0.5, 0], [0, 0, 0.5], [0.5, 0.5, 0.5]]
        self._mgo_uc = Structure(mgo_latt, mgo_specie, mgo_frac_cord, True,
                                 True)

        bv = BVAnalyzer()
        self._mgo_uc = bv.get_oxi_state_decorated_structure(self._mgo_uc)
        self._mgo_val_rad_eval = ValenceIonicRadiusEvaluator(self._mgo_uc)
        self._mgo_val = self._mgo_val_rad_eval.valences
        self._mgo_rad = self._mgo_val_rad_eval.radii
        self._mgo_vac = Vacancy(self._mgo_uc, self._mgo_val, self._mgo_rad)
Пример #6
0
    def featurize(self, s):
        """
        Get ReDF of input structure.

        Args:
            s: input Structure object.

        Returns: (dict) a copy of the electronic radial distribution
                functions (ReDF) as a dictionary. The distance list
                ("x"-axis values of ReDF) can be accessed via key
                'distances'; the ReDF itself is accessible via key
                'redf'.
        """
        if self.dr <= 0:
            raise ValueError("width of bins for ReDF must be >0")

        # Make structure primitive.
        struct = SpacegroupAnalyzer(s).find_primitive() or s

        # Add oxidation states.
        struct = ValenceIonicRadiusEvaluator(struct).structure

        if self.cutoff is None:
            # Set cutoff to longest diagonal.
            a = struct.lattice.matrix[0]
            b = struct.lattice.matrix[1]
            c = struct.lattice.matrix[2]
            self.cutoff = max(
                [np.linalg.norm(a + b + c), np.linalg.norm(-a + b + c),
                 np.linalg.norm(a - b + c), np.linalg.norm(a + b - c)])

        nbins = int(self.cutoff / self.dr) + 1
        redf_dict = {"distances": np.array(
            [(i + 0.5) * self.dr for i in range(nbins)]),
            "distribution": np.zeros(nbins, dtype=np.float)}

        for site in struct.sites:
            this_charge = float(site.specie.oxi_state)
            neighbors = struct.get_neighbors(site, self.cutoff)
            for nnsite, dist, *_ in neighbors:
                neigh_charge = float(nnsite.specie.oxi_state)
                bin_index = int(dist / self.dr)
                redf_dict["distribution"][bin_index] \
                    += (this_charge * neigh_charge) / (struct.num_sites * dist)

        return [redf_dict]
Пример #7
0
    def apply_transformation(self, structure, return_ranked_list=False):
        """
        :param structure:
        :param return_ranked_list (Logical or integer): Use big enough
         number to return all defect structures
        :return:
            scs: Supercells with one interstitial defect in each structure.
        """
        if not return_ranked_list:
            raise ValueError("InterstitialTransformation has no single best "
                             "structure output. Must use return_ranked_list.")
        try:
            num_to_return = int(return_ranked_list)
        except ValueError:
            num_to_return = 1

        if self.radii:
            inter = Interstitial(structure, self.valences, self.radii)
        else:
            s = structure.copy()
            valrad_eval = ValenceIonicRadiusEvaluator(s)
            s = valrad_eval.structure
            val = valrad_eval.valences
            rad = valrad_eval.radii
            inter = Interstitial(s, val, rad, oxi_state=True)

        scs = inter.make_supercells_with_defects(self.supercell_dim,
                                                 self.interstitial_specie)

        #if num_to_return < len(scs)-1:
        #    raise ValueError("InterstitialTransformation has no ordering "
        #            "of best structures. Must increase return_ranked_list.")

        structures = []
        num_to_return = min(num_to_return, len(scs) - 1)
        for sc in scs[1:num_to_return + 1]:
            structures.append({'structure': sc})
        return structures
Пример #8
0
    def featurize(self, s, cutoff=10.0):
        """
        Get minimum relative distances of all sites of the input structure.

        Args:
            s: Pymatgen Structure object.

        Returns:
            dists_relative_min: (list of floats) list of all minimum relative
                    distances (i.e., for all sites).
        """
        vire = ValenceIonicRadiusEvaluator(s)
        dists_relative_min = []
        for site in vire.structure:
            dists_relative = []
            for nnsite, dist, *_ in vire.structure.get_neighbors(site, self.cutoff):
                r_site = vire.radii[site.species_string]
                r_neigh = vire.radii[nnsite.species_string]
                radii_dist = r_site + r_neigh
                d_relative = dist / radii_dist
                dists_relative.append(d_relative)
            dists_relative_min.append(min(dists_relative))
        return [dists_relative_min]
Пример #9
0
def get_ionic_radii_pymatgen(filename):
    stru = Structure.from_file(filename)
    val_eval = ValenceIonicRadiusEvaluator(stru)
    return val_eval.radii