Esempio n. 1
0
    def _set_gruneisen(self):
        dV = self._volume_plus - self._volume_minus

        if self._is_band_connection:
            self._q_direction = self._qpoints[0] - self._qpoints[-1]
            band_order = range(self._dynmat.get_dimension())
            prev_eigvecs = None

        edDe = [] # <e|dD|e>
        eigvals = []
        eigvecs = []
        for i, q in enumerate(self._qpoints):
            if self._is_band_connection and self._dynmat.is_nac():
                self._dynmat.set_dynamical_matrix(
                    q, q_direction=self._q_direction)
            else:
                self._dynmat.set_dynamical_matrix(q)

            dm = self._dynmat.get_dynamical_matrix()
            evals, evecs = np.linalg.eigh(dm)
            evals_at_q = evals.real
            dD = self._get_dD(q, self._dynmat_minus, self._dynmat_plus)
            evecs_at_q, edDe_at_q = rotate_eigenvectors(evals_at_q, evecs, dD)

            if self._is_band_connection:
                if prev_eigvecs is not None:
                    band_order = estimate_band_connection(
                        prev_eigvecs,
                        evecs_at_q,
                        band_order)
                eigvals.append(evals_at_q[band_order])
                eigvecs.append(evecs_at_q[:, band_order])
                edDe.append(edDe_at_q[band_order])
                prev_eigvecs = evecs_at_q
            else:
                eigvals.append(evals_at_q)
                eigvecs.append(evecs_at_q)
                edDe.append(edDe_at_q)

        edDe = np.array(edDe, dtype='double', order='C')
        self._eigenvalues = np.array(eigvals, dtype='double', order='C')
        itemsize = self._eigenvalues.itemsize
        self._eigenvectors = np.array(eigvecs,
                                      dtype=("c%d" % (itemsize * 2)), order='C')
        self._gruneisen = -edDe / dV / self._eigenvalues * self._volume / 2
Esempio n. 2
0
    def _set_gruneisen(self):
        if self._is_band_connection:
            self._q_direction = self._qpoints[0] - self._qpoints[-1]
            band_order = range(len(self._dynmat.primitive) * 3)
            prev_eigvecs = None

        edDe = []  # <e|dD|e>
        eigvals = []
        eigvecs = []
        for i, q in enumerate(self._qpoints):
            if self._is_band_connection and self._dynmat.is_nac():
                self._dynmat.run(q, q_direction=self._q_direction)
            else:
                self._dynmat.run(q)

            dm = self._dynmat.dynamical_matrix
            evals, evecs = np.linalg.eigh(dm)
            evals_at_q = evals.real
            dD = self._get_dD(q, self._dynmat_minus, self._dynmat_plus)
            evecs_at_q, edDe_at_q = rotate_eigenvectors(evals_at_q, evecs, dD)

            if self._is_band_connection:
                if prev_eigvecs is not None:
                    band_order = estimate_band_connection(
                        prev_eigvecs, evecs_at_q, band_order
                    )
                eigvals.append(evals_at_q[band_order])
                eigvecs.append(evecs_at_q[:, band_order])
                edDe.append(edDe_at_q[band_order])
                prev_eigvecs = evecs_at_q
            else:
                eigvals.append(evals_at_q)
                eigvecs.append(evecs_at_q)
                edDe.append(edDe_at_q)

        edDe = np.array(edDe, dtype="double", order="C")
        self._eigenvalues = np.array(eigvals, dtype="double", order="C")
        itemsize = self._eigenvalues.itemsize
        self._eigenvectors = np.array(
            eigvecs, dtype=("c%d" % (itemsize * 2)), order="C"
        )
        self._gruneisen = -edDe / self._delta_strain / self._eigenvalues / 2