How to use the pyxtal.symmetry.jk_from_i 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 / molecular_crystal.py View on Github external
position, and makes sure at least one valid combination of WP's exists.
        """
        # Store whether or not at least one degree of freedom exists
        has_freedom = False
        # Store the wp's already used that don't have any freedom
        used_indices = []
        # Loop over species
        for i_mol, numIon in enumerate(numMols):
            # Get lists of multiplicity, maxn and freedom
            l_mult0 = []
            l_maxn0 = []
            l_free0 = []
            indices0 = []
            for i_wp, wp in enumerate(group):
                # Check that at least one valid orientation exists
                j, k = jk_from_i(i_wp, group.wyckoffs_organized)
                if len(valid_orientations[i_mol][j][k]) > 0:
                    indices0.append(i_wp)
                    l_mult0.append(len(wp))
                    l_maxn0.append(numIon // len(wp))
                    if np.allclose(wp[0].rotation_matrix, np.zeros([3, 3])):
                        l_free0.append(False)
                    else:
                        l_free0.append(True)
            # Remove redundant multiplicities:
            l_mult = []
            l_maxn = []
            l_free = []
            indices = []
            for mult, maxn, free, i_wp in zip(l_mult0, l_maxn0, l_free0, indices0):
                if free is True:
                    if mult not in l_mult:
github qzhu2017 / PyXtal / pyxtal / test_cases / test_all.py View on Github external
fail()
        except Exception as e:
            fail(e)

    check()

    print("  i_from_jk")
    try:
        from pyxtal.symmetry import i_from_jk
    except Exception as e:
        fail(e)

    if passed():
        try:
            w = get_wyckoffs(2, organized=True)
            j, k = jk_from_i(1, w)
            i = i_from_jk(j, k, w)
            if i == 1:
                pass
            else:
                print(j, k)
                fail()
        except Exception as e:
            fail(e)

    check()

    print("  ss_string_from_ops")
    try:
        from pyxtal.symmetry import ss_string_from_ops
    except Exception as e:
        fail(e)
github qzhu2017 / PyXtal / pyxtal / molecular_crystal.py View on Github external
if i != j and y < tol:
                    passed_distance_check = False
                    break
            if passed_distance_check is False:
                break
        # if check_images([coor[0]], ['C'], lattice, PBC=PBC, tol=tol) is False:
        if check_images([coor[0]], [6], lattice, PBC=PBC, tol=tol) is False:
            passed_distance_check = False
        if passed_distance_check is False:
            mult1 = group[index].multiplicity
            # Find possible wp's to merge into
            possible = []
            for i, wp in enumerate(group):
                mult2 = wp.multiplicity
                # Check that a valid orientation exists
                j, k = jk_from_i(i, orientations)
                if orientations[j][k] == []:
                    continue
                # Only allow smaller WP's that are an integer factor of the current one
                if (mult2 < mult1) and (mult1 % mult2 == 0):
                    possible.append(i)
            if possible == []:
                return coor, False, None
            # Calculate minimum separation for each WP
            distances = []
            for i in possible:
                wp = group[i]
                projected_point = project_point(point, wp[0], lattice=lattice, PBC=PBC)
                # NOTE new coor never used?
                new_coor = apply_ops(projected_point, wp)
                d = distance(point - projected_point, lattice, PBC=PBC)
                distances.append(np.min(d))
github qzhu2017 / PyXtal / pyxtal / molecular_crystal.py View on Github external
(
                                    coords_toadd,
                                    good_merge,
                                    point,
                                ) = merge_coordinate_molecular(
                                    coords, cell_matrix, self.group, mtol, valid_ori
                                )
                                if good_merge is not False:
                                    wp_index = good_merge
                                    # scale the coordinates to [0,1], very important!
                                    coords_toadd = filtered_coords(
                                        coords_toadd, PBC=self.PBC
                                    )

                                    j, k = jk_from_i(
                                        wp_index, self.group.wyckoffs_organized
                                    )
                                    ori = random.choice(
                                        valid_ori[j][k]
                                    ).random_orientation()
                                    ms0 = mol_site(
                                        mol,
                                        point,
                                        symbols,
                                        ori,
                                        self.group[wp_index],
                                        cell_matrix,
                                        tols_mat,
                                        radius,
                                    )
                                    # Check distances within the WP