How to use the pyxtal.operations.SymmOp.from_xyz_string function in pyxtal

To help you get started, we’ve selected a few pyxtal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qzhu2017 / PyXtal / pyxtal / symmetry.py View on Github external
self.lattice_type = "spherical"
                    # Add 2, 3, and 5-fold rotations
                    gens.append(SymmOp.from_xyz_string("-x,-y,z"))
                    gens.append(SymmOp.from_xyz_string("z,x,y"))
                    tau = 0.5 * (np.sqrt(5) + 1)
                    m = aa2matrix([1.0, tau, 0.0], 2 * np.pi / 5)
                    gens.append(SymmOp.from_rotation_and_translation(m, [0, 0, 0]))
                    # Add Wyckoff generating operations
                    op_c = SymmOp.from_xyz_string("x,0,0")
                    op_b = SymmOp.from_xyz_string("x,x,x")
                    m = [[0, 0, 0, 0], [0, 1, 0, 0], [0, tau, 0, 0], [0, 0, 0, 0]]
                    op_a = SymmOp(m)
                    gen_ops = [Identity, op_c, op_b, op_a, op_o]
                    if symbol == "Ih":
                        # Add horizontal mirror plane
                        mirror = SymmOp.from_xyz_string("x,y,-z")  # m x,y,0
                        gens.append(mirror)
                        op_d = SymmOp.from_xyz_string("0,y,z")
                        gen_ops = [Identity, op_d, op_c, op_b, op_a, op_o]

                elif symbol[0] == "C" and symbol[-1] != "i":
                    # n-fold rotation
                    if num == 1:
                        self.lattice_type = "spherical"
                    else:
                        self.lattice_type = "ellipsoidal"
                    op_b = SymmOp.from_xyz_string("0,y,z")
                    op_c = SymmOp.from_xyz_string("x,0,z")
                    op_d = SymmOp.from_xyz_string("x,x,z")
                    if symbol[-1] == "d":
                        printx("Error: Invalid point group symbol.", priority=1)
                        return
github qzhu2017 / PyXtal / pyxtal / symmetry.py View on Github external
)
rod_df = read_csv(resource_filename("pyxtal", "database/rod.csv"))
rod_symmetry_df = read_csv(resource_filename("pyxtal", "database/rod_symmetry.csv"))
rod_generators_df = read_csv(resource_filename("pyxtal", "database/rod_generators.csv"))
point_df = read_csv(resource_filename("pyxtal", "database/point.csv"))
point_symmetry_df = read_csv(resource_filename("pyxtal", "database/point_symmetry.csv"))
point_generators_df = read_csv(
    resource_filename("pyxtal", "database/point_generators.csv")
)
symbols = loadfn(resource_filename("pyxtal", "database/symbols.json"))

Identity = SymmOp.from_xyz_string("x,y,z")
Inversion = SymmOp.from_xyz_string("-x,-y,-z")
op_o = SymmOp.from_xyz_string("0,0,0")
op_x = SymmOp.from_xyz_string("x,0,0")
op_y = SymmOp.from_xyz_string("0,y,0")
op_z = SymmOp.from_xyz_string("0,0,z")

pglist = [
    "C1",
    "Ci",
    "C2",
    "Cs",
    "C2h",
    "D2",
    "C2v",
    "D2h",
    "C4",
    "S4",
    "C4h",
    "D4",
    "C4v",
github qzhu2017 / PyXtal / pyxtal / molecule.py View on Github external
for op in pg:
            symm_m.append(op)
        # Add 12-fold  and reflections in place of ininitesimal rotation
        for axis in [[1, 0, 0], [0, 1, 0], [0, 0, 1]]:
            # op = SymmOp.from_rotation_and_translation(aa2matrix(axis, np.pi/6), [0,0,0])
            m1 = Rotation.from_rotvec(np.pi / 6 * axis).as_matrix()
            op = SymmOp.from_rotation_and_translation(m1, [0, 0, 0])
            if pga.is_valid_op(op):
                symm_m.append(op)
                # Any molecule with infinitesimal symmetry is linear;
                # Thus, it possess mirror symmetry for any axis perpendicular
                # To the rotational axis. pymatgen does not add this symmetry
                # for all linear molecules - for example, hydrogen
                if axis == [1, 0, 0]:
                    symm_m.append(SymmOp.from_xyz_string("x,-y,z"))
                    symm_m.append(SymmOp.from_xyz_string("x,y,-z"))
                    r = SymmOp.from_xyz_string("-x,y,-z")
                elif axis == [0, 1, 0]:
                    symm_m.append(SymmOp.from_xyz_string("-x,y,z"))
                    symm_m.append(SymmOp.from_xyz_string("x,y,-z"))
                    r = SymmOp.from_xyz_string("-x,-y,z")
                elif axis == [0, 0, 1]:
                    symm_m.append(SymmOp.from_xyz_string("-x,y,z"))
                    symm_m.append(SymmOp.from_xyz_string("x,-y,z"))
                    r = SymmOp.from_xyz_string("x,-y,-z")
                # Generate a full list of SymmOps for the molecule's pointgroup
                symm_m = generate_full_symmops(symm_m, 1e-3)
                break
        # Reorient the SymmOps into mol's original frame
        if not already_oriented:
            new = []
            for op in symm_m:
github qzhu2017 / PyXtal / pyxtal / symmetry.py View on Github external
dim: the periodicity dimension of the symmetry group. Used for consideration
            of "o" Wyckoff positions in point groups. Not used if group is a Group

    Returns:
        a single index specifying the location of the Wyckoff position within
        the spacegroup (0 is the general position)
    """
    letters1 = letters
    # See whether the group has an "o" Wyckoff position
    checko = False
    if type(group) == Group and group.dim == 0:
        checko = True
    elif dim == 0:
        checko = True
    if checko is True:
        if len(group[-1]) == 1 and group[-1][0] == SymmOp.from_xyz_string("0,0,0"):
            # o comes before a
            letters1 = "o" + letters
    length = len(group)
    return length - 1 - letters1.index(letter)
github qzhu2017 / PyXtal / pyxtal / symmetry.py View on Github external
op_a = SymmOp(m)
                    gen_ops = [Identity, op_c, op_b, op_a, op_o]
                    if symbol == "Ih":
                        # Add horizontal mirror plane
                        mirror = SymmOp.from_xyz_string("x,y,-z")  # m x,y,0
                        gens.append(mirror)
                        op_d = SymmOp.from_xyz_string("0,y,z")
                        gen_ops = [Identity, op_d, op_c, op_b, op_a, op_o]

                elif symbol[0] == "C" and symbol[-1] != "i":
                    # n-fold rotation
                    if num == 1:
                        self.lattice_type = "spherical"
                    else:
                        self.lattice_type = "ellipsoidal"
                    op_b = SymmOp.from_xyz_string("0,y,z")
                    op_c = SymmOp.from_xyz_string("x,0,z")
                    op_d = SymmOp.from_xyz_string("x,x,z")
                    if symbol[-1] == "d":
                        printx("Error: Invalid point group symbol.", priority=1)
                        return
                    if num == 0:
                        # infinite-order rotation
                        self.symbol = "C*"
                        generate = False
                        pass
                    else:
                        # Add rotation
                        self.symbol = "C" + str(num)
                        m = aa2matrix([0.0, 0.0, 1.0], 2 * np.pi / num)
                        gens.append(
                            SymmOp.from_rotation_and_translation(m, [0.0, 0.0, 0.0])
github qzhu2017 / PyXtal / pyxtal / symmetry.py View on Github external
if symbol == "Cs":
                        gens = [Identity, SymmOp.from_xyz_string("x,y,-z")]
                        gen_ops = [Identity, SymmOp.from_xyz_string("x,y,0")]

                elif symbol[0] == "C" and symbol[-1] == "i":
                    # n-fold rotinversion, usually just Ci
                    if num == 1:
                        self.lattice_type = "spherical"
                    else:
                        self.lattice_type = "ellipsoidal"
                    if "d" in symbol or "h" in symbol or "v" in symbol:
                        printx("Error: Invalid point group symbol.", priority=1)
                        return
                    if num == 0:
                        # infinite-order rotation
                        gens.append(SymmOp.from_xyz_string("-x,-y,-z"))
                        gens.append(SymmOp.from_xyz_string("x,y,-z"))
                        self.symbol = "C*i"
                        generate = False
                    else:
                        # Add rotoinversion
                        m = np.dot(
                            aa2matrix([0.0, 0.0, 1.0], 2 * np.pi / num),
                            [[-1.0, 0.0, 0.0], [0.0, -1.0, 0.0], [0.0, 0.0, -1.0]],
                        )
                        gens.append(
                            SymmOp.from_rotation_and_translation(m, [0.0, 0.0, 0.0])
                        )
                        if num == 1:
                            self.symbol = "Ci"
                        else:
                            self.symbol = "C" + str(num) + "i"
github qzhu2017 / PyXtal / pyxtal / symmetry.py View on Github external
1 / num
                    except:
                        printx(
                            "Error: invalid rotation order for point group symbol.",
                            priority=1,
                        )
                        return
                gens = [Identity]  # List of generator SymmOps
                generate = True
                # interpret symbol
                if symbol[0] == "I":
                    # Icosohedral
                    self.lattice_type = "spherical"
                    # Add 2, 3, and 5-fold rotations
                    gens.append(SymmOp.from_xyz_string("-x,-y,z"))
                    gens.append(SymmOp.from_xyz_string("z,x,y"))
                    tau = 0.5 * (np.sqrt(5) + 1)
                    m = aa2matrix([1.0, tau, 0.0], 2 * np.pi / 5)
                    gens.append(SymmOp.from_rotation_and_translation(m, [0, 0, 0]))
                    # Add Wyckoff generating operations
                    op_c = SymmOp.from_xyz_string("x,0,0")
                    op_b = SymmOp.from_xyz_string("x,x,x")
                    m = [[0, 0, 0, 0], [0, 1, 0, 0], [0, tau, 0, 0], [0, 0, 0, 0]]
                    op_a = SymmOp(m)
                    gen_ops = [Identity, op_c, op_b, op_a, op_o]
                    if symbol == "Ih":
                        # Add horizontal mirror plane
                        mirror = SymmOp.from_xyz_string("x,y,-z")  # m x,y,0
                        gens.append(mirror)
                        op_d = SymmOp.from_xyz_string("0,y,z")
                        gen_ops = [Identity, op_d, op_c, op_b, op_a, op_o]
github qzhu2017 / PyXtal / pyxtal / symmetry.py View on Github external
if symbol == "Ih":
                        # Add horizontal mirror plane
                        mirror = SymmOp.from_xyz_string("x,y,-z")  # m x,y,0
                        gens.append(mirror)
                        op_d = SymmOp.from_xyz_string("0,y,z")
                        gen_ops = [Identity, op_d, op_c, op_b, op_a, op_o]

                elif symbol[0] == "C" and symbol[-1] != "i":
                    # n-fold rotation
                    if num == 1:
                        self.lattice_type = "spherical"
                    else:
                        self.lattice_type = "ellipsoidal"
                    op_b = SymmOp.from_xyz_string("0,y,z")
                    op_c = SymmOp.from_xyz_string("x,0,z")
                    op_d = SymmOp.from_xyz_string("x,x,z")
                    if symbol[-1] == "d":
                        printx("Error: Invalid point group symbol.", priority=1)
                        return
                    if num == 0:
                        # infinite-order rotation
                        self.symbol = "C*"
                        generate = False
                        pass
                    else:
                        # Add rotation
                        self.symbol = "C" + str(num)
                        m = aa2matrix([0.0, 0.0, 1.0], 2 * np.pi / num)
                        gens.append(
                            SymmOp.from_rotation_and_translation(m, [0.0, 0.0, 0.0])
                        )
                        if num != 1: