Example #1
0
    def add_random(self):
        """
        Creates a new set of variables to reconstruct the dmatpawu

        I (integers) is a matrix natpawu x ndim with entries are 0 or 1
        D (deltas) is a matrix natpawu x ndim with entries are [0, 0.5)
        P (matrices) is a set of matrices natpawu x ndim x ndim
        Those three matrices allow to reconstruct the variable 'dmatpawu' used by ABINIT

        :return:
        """
        I = np.zeros((self.natpawu, self.ndim), dtype=int)
        D = np.zeros((self.natpawu, self.ndim))
        eigvec = np.zeros((self.natpawu, self.ndim, self.ndim))

        # I and D for atoms 0 and 3
        if self.oxidations[0] < 0:
            nelect = self.ndim + self.oxidations[0]
        else:
            nelect = self.oxidations[0]
        val = [
            x for x in list(itertools.product(range(2), repeat=self.ndim))
            if sum(x) == nelect
        ]
        ii = val[np.random.randint(len(val))]
        dd = 0.0 * np.random.random_sample((self.ndim, ))
        I[0] = ii
        D[0] = dd
        I[3] = ii
        D[3] = dd

        # I and D for atoms 1 and 2
        if self.oxidations[1] < 0:
            nelect = self.ndim + self.oxidations[1]
        else:
            nelect = self.oxidations[1]
        val = [
            x for x in list(itertools.product(range(2), repeat=self.ndim))
            if sum(x) == nelect
        ]
        ii = val[np.random.randint(len(val))]
        dd = 0.0 * np.random.random_sample((self.ndim, ))
        I[1] = ii
        D[1] = dd
        I[2] = ii
        D[2] = dd

        p = gram_smith_qr(self.ndim)
        eigvec[0] = p
        eigvec[4] = np.dot(np.diag(self.connection), p)

        p = gram_smith_qr(self.ndim)
        eigvec[1] = p
        eigvec[2] = np.dot(np.diag(self.connection), p)

        data = {'eigvec': eigvec, 'I': I, 'D': D}

        return self.new_entry(data), None
Example #2
0
    def add_random(self):
        """
        Creates a new set of variables to reconstruct the dmatpawu

        I (integers) is a matrix natpawu x ndim with entries are 0 or 1
        D (deltas) is a matrix natpawu x ndim with entries are [0, 0.5)
        P (matrices) is a set of matrices natpawu x ndim x ndim
        Those three matrices allow to reconstruct the variable 'dmatpawu' used by ABINIT

        :return:
        """
        I = np.zeros((self.natpawu, self.ndim), dtype=int)
        D = np.zeros((self.natpawu, self.ndim))
        eigvec = np.zeros((self.natpawu, self.ndim, self.ndim))

        # I and D for atoms 0 and 3
        if self.oxidations[0] < 0:
            nelect = self.ndim + self.oxidations[0]
        else:
            nelect = self.oxidations[0]
        val = [x for x in list(itertools.product(range(2), repeat=self.ndim)) if sum(x) == nelect]
        ii = val[np.random.randint(len(val))]
        dd = 0.0 * np.random.random_sample((self.ndim,))
        I[0] = ii
        D[0] = dd
        I[3] = ii
        D[3] = dd

        # I and D for atoms 1 and 2
        if self.oxidations[1] < 0:
            nelect = self.ndim + self.oxidations[1]
        else:
            nelect = self.oxidations[1]
        val = [x for x in list(itertools.product(range(2), repeat=self.ndim)) if sum(x) == nelect]
        ii = val[np.random.randint(len(val))]
        dd = 0.0 * np.random.random_sample((self.ndim,))
        I[1] = ii
        D[1] = dd
        I[2] = ii
        D[2] = dd

        p = gram_smith_qr(self.ndim)
        eigvec[0] = p
        eigvec[4] = np.dot(np.diag(self.connection), p)

        p = gram_smith_qr(self.ndim)
        eigvec[1] = p
        eigvec[2] = np.dot(np.diag(self.connection), p)

        data = {'eigvec': eigvec, 'I': I, 'D': D}

        return self.new_entry(data), None
Example #3
0
    def add_random(self):
        """
        Creates a new set of variables to reconstruct the dmatpawu

        matrix_i (integers) is a matrix natpawu x ndim with entries are 0 or 1
        matrix_d (deltas) is a matrix natpawu x ndim with entries are [0, 0.5)
        P (matrices) is a set of matrices natpawu x ndim x ndim
        Those three matrices allow to reconstruct the variable 'dmatpawu' used by ABINIT

        :return:
        """
        matrices_defined = []

        matrix_i = self.num_indep_matrices*[None]
        matrix_d = self.num_indep_matrices*[None]
        euler = self.num_indep_matrices*[None]

        for i in range(self.num_indep_matrices):

            nelect = self.num_electrons_dftu[i]
            val = [x for x in list(itertools.product(range(2), repeat=self.ndim)) if sum(x) == nelect]
            ii = val[np.random.randint(len(val))]
            dd = np.zeros(self.ndim)
            matrix_i[i] = list(ii)
            matrix_d[i] = list(dd)
            matrices_defined.append(self.connections[i])
            p = gram_smith_qr(self.ndim)
            euler[i] = gea_all_angles(p)

        data = {'E': euler, 'O': matrix_i, 'D': matrix_d}

        return self.new_entry(data), None
Example #4
0
    def add_random(self):
        """
        Creates a new set of variables to reconstruct the dmatpawu

        matrix_i (integers) is a matrix natpawu x ndim with entries are 0 or 1
        matrix_d (deltas) is a matrix natpawu x ndim with entries are [0, 0.5)
        P (matrices) is a set of matrices natpawu x ndim x ndim
        Those three matrices allow to reconstruct the variable 'dmatpawu' used by ABINIT

        :return:
        """
        matrices_defined = []

        matrix_i = self.num_indep_matrices * [None]
        matrix_d = self.num_indep_matrices * [None]
        euler = self.num_indep_matrices * [None]

        for i in range(self.num_indep_matrices):
            nelect = self.num_electrons_dftu[i]
            val = [
                x for x in list(
                    itertools.product(list(range(2)), repeat=self.ndim))
                if sum(x) == nelect
            ]
            ii = val[np.random.randint(len(val))]
            dd = np.zeros(self.ndim)
            matrix_i[i] = list(ii)
            matrix_d[i] = list(dd)
            matrices_defined.append(self.connections[i])
            p = gram_smith_qr(self.ndim)
            euler[i] = gea_all_angles(p)

        data = {
            'euler_angles': euler,
            'occupations': matrix_i,
            'deltas': matrix_d,
            'num_matrices': self.num_indep_matrices,
            'ndim': self.ndim
        }

        return self.new_entry(data), None