コード例 #1
0
 def test_convert_strain_to_deformation(self):
     strain = Tensor(np.random.random((3, 3))).symmetrized
     while not (np.linalg.eigvals(strain) > 0).all():
         strain = Tensor(np.random.random((3, 3))).symmetrized
     upper = convert_strain_to_deformation(strain, shape="upper")
     symm = convert_strain_to_deformation(strain, shape="symmetric")
     self.assertArrayAlmostEqual(np.triu(upper), upper)
     self.assertTrue(Tensor(symm).is_symmetric())
     for defo in upper, symm:
         self.assertArrayAlmostEqual(defo.green_lagrange_strain, strain)
コード例 #2
0
    def get_symmetric_wallace_tensor(self, tau):
        """
        Gets the symmetrized wallace tensor for determining
        yield strength criteria.

        Args:
            tau (3x3 array-like): stress at which to evaluate
                the wallace tensor.
        """
        wallace = self.get_wallace_tensor(tau)
        return Tensor(0.5 * (wallace + np.transpose(wallace, [2, 3, 0, 1])))
コード例 #3
0
    def process_item(self, item):
        """
        Process the tasks and materials into a dielectrics collection

        Args:
            item dict: a dict of material_id, structure, and tasks

        Returns:
            dict: a dieletrics dictionary  
        """
        def poly(matrix):
            diags = np.diagonal(matrix)
            return np.prod(diags) / np.sum(
                np.prod(comb) for comb in combinations(diags, 2))

        d = {self.dielectric.key: item[self.materials.key]}

        structure = Structure.from_dict(item["structure"])

        if item.get("dielectric", False):
            ionic = Tensor(
                item["dielectric"]["ionic"]).symmetrized.fit_to_structure(
                    structure).convert_to_ieee(structure)
            static = Tensor(
                item["dielectric"]["static"]).symmetrized.fit_to_structure(
                    structure).convert_to_ieee(structure)
            total = ionic + static

            d["dielectric"] = {
                "total": total,
                "ionic": ionic,
                "static": static,
                "e_total": poly(total),
                "e_ionic": poly(ionic),
                "e_static": poly(static)
            }

        sga = SpacegroupAnalyzer(structure)
        # Update piezo if non_centrosymmetric
        if item.get("piezo", False) and not sga.is_laue():
            static = PiezoTensor.from_voigt(np.array(
                item['piezo']["static"])).symmetrized.fit_to_structure(
                    structure).convert_to_ieee(structure).voigt
            ionic = PiezoTensor.from_voigt(np.array(
                item['piezo']["ionic"])).symmetrized.fit_to_structure(
                    structure).convert_to_ieee(structure).voigt
            total = ionic + static

            directions, charges, strains = np.linalg.svd(total)

            max_index = np.argmax(np.abs(charges))
            d["piezo"] = {
                "total": total,
                "ionic": ionic,
                "static": static,
                "e_ij_max": charges[max_index],
                "max_direction": directions[max_index],
                "strain_for_max": strains[max_index]
            }

        if len(d) > 1:
            return d

        return None
コード例 #4
0
    def process_item(self, item):
        """
        Process the tasks and materials into a dielectrics collection

        Args:
            item dict: a dict of material_id, structure, and tasks

        Returns:
            dict: a dieletrics dictionary  
        """
        def poly(matrix):
            diags = np.diagonal(matrix)
            return np.prod(diags) / np.sum(
                np.prod(comb) for comb in combinations(diags, 2))

        d = {"material_id": item["material_id"]}

        structure = Structure.from_dict(item["structure"])

        if item.get("dielectric") is not None:
            ionic = Tensor(d["dielectric"]["ionic"])
            static = Tensor(d["dielectric"]["static"])
            total = ionic + static

            d["dielectric"] = {
                "total":
                total.symmetrized.fit_to_structure(structure).convert_to_ieee(
                    structure),
                "ionic":
                ionic.symmetrized.fit_to_structure(structure).convert_to_ieee(
                    structure),
                "static":
                static.symmetrized.fit_to_structure(structure).convert_to_ieee(
                    structure),
                "e_total":
                poly(total),
                "e_ionic":
                poly(ionic),
                "e_static":
                poly(static)
            }

        # Update piezo if non_centrosymmetric
        if item.get("piezo") is not None:
            static = PiezoTensor.from_voigt(
                np.array(item['piezo']["piezo_tensor"]))
            ionic = PiezoTensor.from_voigt(
                np.array(item['piezo']["piezo_ionic_tensor"]))
            total = ionic + static

            d["piezo"] = {
                "total":
                total.symmetrized.fit_to_structure(structure).convert_to_ieee(
                    structure).voigt,
                "ionic":
                ionic.symmetrized.fit_to_structure(structure).convert_to_ieee(
                    structure).voigt,
                "static":
                static.symmetrized.fit_to_structure(structure).convert_to_ieee(
                    structure).voigt,
                "e_ij_max":
                np.max(total.voigt)
            }

            # TODO Add in more analysis: v_max ?
            # TODO: Add in unstable phonon mode analysis of piezoelectric for potentially ferroelectric

        if len(d) > 1:
            return d

        return None