Exemplo n.º 1
0
    def is_commutative(self):
        """True if operations in self commute with each other."""
        for op1, op2 in iuptri(self, diago=False):
            if op1 * op2 != op2 * op1:
                return False

        return True
Exemplo n.º 2
0
    def is_commutative(self):
        """True if operations in self commute with each other."""
        for op1, op2 in iuptri(self, diago=False):
            if op1 * op2 != op2 * op1:
                return False

        return True
Exemplo n.º 3
0
    def auto_test(self):
        """
        Returns:
            Return code (0 if success).
        """
        rot_group = LatticePointGroup(self.rotations)
        if not rot_group.is_group():
            print("rotations do not form a group!")
            return 1

        # Symmetries should be ordered in classes.
        # Here we recompute the classes by calling rot_group.class_indices.
        # We then sort the indices and we compare the results with the ref data stored in the Bilbao database.
        calc_class_inds = [sorted(l) for l in rot_group.class_indices]
        #print(calc_class_inds)
        assert len(calc_class_inds) == len(self.class_range)

        for calc_inds, ref_range in zip(calc_class_inds, self.class_range):
            ref_inds = list(range(ref_range[0], ref_range[1]))
            if calc_inds != ref_inds:
                print("Rotations are not ordered in classes.", calc_inds,
                      ref_inds)
                return 2

        # Do we have a representation of the Group?
        mult_table = rot_group.mult_table
        max_err = 0.0

        for idx1, rot1 in enumerate(rot_group):
            for idx2, rot2 in enumerate(rot_group):
                idx_prod = mult_table[idx1, idx2]
                for irrep in self.irreps:
                    mat_prod = np.dot(irrep.mats[idx1], irrep.mats[idx2])
                    err = (mat_prod - irrep.mats[idx_prod]).max()
                    max_err = max(max_err, abs(err))

        if max_err > 1e-5:
            print(
                "Irreps do not form a representation of the group, max_err: ",
                max_err)
            return 3

        # TODO
        # Test orthogonality theorem

        # Test the orthogonality relation of traces.
        max_err = 0.0
        for (ii, jj), (irp1, irp2) in iuptri(self.irreps, with_inds=True):
            trac1, trac2 = irp1.traces, irp2.traces
            err = np.vdot(trac1, trac2) / self.num_rots
            if ii == jj: err -= 1.0
            max_err = max(max_err, abs(err))

        if max_err > 1e-5:
            print("Error in orthogonality relation of traces: ", max_err)
            return 4

        # Success.
        return 0
Exemplo n.º 4
0
    def auto_test(self):
        """
        Returns:
            Return code (0 if success).
        """
        rot_group = LatticePointGroup(self.rotations)
        if not rot_group.is_group():
            print("rotations do not form a group!")
            return 1

        # Symmetries should be ordered in classes.
        # Here we recompute the classes by calling rot_group.class_indices.
        # We then sort the indices and we compare the results with the ref data stored in the Bilbao database.
        calc_class_inds = [sorted(l) for l in rot_group.class_indices]
        # print(calc_class_inds)
        assert len(calc_class_inds) == len(self.class_range)

        for calc_inds, ref_range in zip(calc_class_inds, self.class_range):
            ref_inds = list(range(ref_range[0], ref_range[1]))
            if calc_inds != ref_inds:
                print("Rotations are not ordered in classes.", calc_inds, ref_inds)
                return 2

        # Do we have a representation of the Group?
        mult_table = rot_group.mult_table
        max_err = 0.0

        for idx1, rot1 in enumerate(rot_group):
            for idx2, rot2 in enumerate(rot_group):
                idx_prod = mult_table[idx1, idx2]
                for irrep in self.irreps:
                    mat_prod = np.dot(irrep.mats[idx1], irrep.mats[idx2])
                    err = (mat_prod - irrep.mats[idx_prod]).max()
                    max_err = max(max_err, abs(err))

        if max_err > 1e-5:
            print("Irreps do not form a representation of the group, max_err: ", max_err)
            return 3

        # TODO
        # Test orthogonality theorem

        # Test the orthogonality relation of traces.
        max_err = 0.0
        for (ii, jj), (irp1, irp2) in iuptri(self.irreps, with_inds=True):
            trac1, trac2 = irp1.traces, irp2.traces
            err = np.vdot(trac1, trac2) / self.num_rots
            if ii == jj:
                err -= 1.0
            max_err = max(max_err, abs(err))

        if max_err > 1e-5:
            print("Error in orthogonality relation of traces: ", max_err)
            return 4

        # Success.
        return 0