Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try:
import pyxtal.symmetry
except Exception as e:
fail(e)
print(" get_wyckoffs (may take a moment)")
try:
from pyxtal.symmetry import get_wyckoffs
except Exception as e:
fail(e)
if passed():
try:
for i in [1, 2, 229, 230]:
get_wyckoffs(i)
get_wyckoffs(i, organized=True)
except:
fail(" Could not access Wyckoff positions for space group # " + str(i))
check()
print(" get_wyckoff_symmetry (may take a moment)")
try:
from pyxtal.symmetry import get_wyckoff_symmetry
except Exception as e:
fail(e)
if passed():
try:
for i in [1, 2, 229, 230]:
get_wyckoff_symmetry(i)
get_wyckoff_symmetry(i, molecular=True)
else:
lattice = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
old_coords = np.array(crystal)
old_species = ["C"] * len(old_coords)
from pyxtal.symmetry import distance
from pyxtal.symmetry import filtered_coords
from copy import deepcopy
PBC = [1, 1, 1]
# Obtain the generators for the group
if dim == 3:
from pyxtal.symmetry import get_wyckoffs
generators = get_wyckoffs(group)[0]
elif dim == 2:
from pyxtal.symmetry import get_layer
generators = get_layer(group)[0]
PBC = [1, 1, 0]
elif dim == 1:
from pyxtal.symmetry import get_rod
generators = get_rod(group)[0]
PBC = [0, 0, 1]
elif dim == 0:
from pyxtal.symmetry import Group
generators = Group(group, dim=0)[0]
PBC = [0, 0, 0]
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)
if passed():
try:
strings = ["1", "4 . .", "2 3 ."]
for i, sg in enumerate([1, 75, 195]):
ops = get_wyckoffs(sg)[0]
ss_string_from_ops(ops, sg, dim=3)
except Exception as e:
fail(e)
check()
print(" Wyckoff_position")
try:
from pyxtal.symmetry import Wyckoff_position
except Exception as e:
fail(e)
if passed():
try:
wp = Wyckoff_position.from_group_and_index(20, 1)
except Exception as e:
reset()
try:
import pyxtal.symmetry
except Exception as e:
fail(e)
print(" get_wyckoffs (may take a moment)")
try:
from pyxtal.symmetry import get_wyckoffs
except Exception as e:
fail(e)
if passed():
try:
for i in [1, 2, 229, 230]:
get_wyckoffs(i)
get_wyckoffs(i, organized=True)
except:
fail(" Could not access Wyckoff positions for space group # " + str(i))
check()
print(" get_wyckoff_symmetry (may take a moment)")
try:
from pyxtal.symmetry import get_wyckoff_symmetry
except Exception as e:
fail(e)
if passed():
try:
for i in [1, 2, 229, 230]:
get_wyckoff_symmetry(i)
from time import time
from spglib import get_symmetry_dataset
from pyxtal.symmetry import get_wyckoffs
from pyxtal.crystal import random_crystal
from pyxtal.crystal import cellsize
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
slow = []
failed = []
print(" Spacegroup # |Generated (SPG)|Generated (PMG)| Time Elapsed")
skip = (
[]
) # [124, 139, 166, 167, 196, 202, 203, 204, 207, 209, 210, 216, 217, 219, 220, 221, 223, 225, 226, 227, 228, 229, 230] #slow to generate
for sg in range(1, 231):
if sg not in skip:
multiplicity = len(get_wyckoffs(sg)[0]) / cellsize(
sg
) # multiplicity of the general position
start = time()
rand_crystal = random_crystal(sg, ["C"], [multiplicity], 1.0)
end = time()
timespent = np.around((end - start), decimals=2)
t = str(timespent)
if len(t) == 3:
t += "0"
t += " s"
if timespent >= 1.0:
t += " ~"
if timespent >= 3.0:
t += "~"
if timespent >= 10.0:
t += "~"
else:
fail()
except Exception as e:
fail(e)
check()
print(" index_from_letter")
try:
from pyxtal.symmetry import index_from_letter
except Exception as e:
fail(e)
if passed():
try:
if index_from_letter("A", get_wyckoffs(47)) == 0:
pass
else:
fail()
except Exception as e:
fail(e)
check()
print(" jk_from_i")
try:
from pyxtal.symmetry import jk_from_i
except Exception as e:
fail(e)
if passed():
try:
def compare_wyckoffs(num1, num2, dim=3):
"""Given 2 groups, return whether the second point
group has equal or greater symmetry than the first group."""
from numpy import allclose
if num1 == "???":
print("Error: invalid value for num1 passed to compare_wyckoffs")
return
if num2 == "???":
return False
# Get general positions for both groups
if dim == 3:
from pyxtal.symmetry import get_wyckoffs
g1 = get_wyckoffs(num1)[0]
g2 = get_wyckoffs(num2)[0]
elif dim == 2:
from pyxtal.symmetry import get_layer
g1 = get_layer(num1)[0]
g2 = get_layer(num2)[0]
elif dim == 1:
from pyxtal.symmetry import get_rod
g1 = get_rod(num1)[0]
g2 = get_rod(num2)[0]
elif dim == 0:
from pyxtal.symmetry import get_point
g1 = get_point(num1)[0]
g2 = get_point(num2)[0]
# If group 2 has higher symmetry
def compare_wyckoffs(num1, num2, dim=3):
"""Given 2 groups, return whether the second point
group has equal or greater symmetry than the first group."""
from numpy import allclose
if num1 == "???":
print("Error: invalid value for num1 passed to compare_wyckoffs")
return
if num2 == "???":
return False
# Get general positions for both groups
if dim == 3:
from pyxtal.symmetry import get_wyckoffs
g1 = get_wyckoffs(num1)[0]
g2 = get_wyckoffs(num2)[0]
elif dim == 2:
from pyxtal.symmetry import get_layer
g1 = get_layer(num1)[0]
g2 = get_layer(num2)[0]
elif dim == 1:
from pyxtal.symmetry import get_rod
g1 = get_rod(num1)[0]
g2 = get_rod(num2)[0]
elif dim == 0:
from pyxtal.symmetry import get_point
g1 = get_point(num1)[0]
g2 = get_point(num2)[0]
for i in [1, 2, 229, 230]:
get_wyckoff_generators(i)
except:
fail("Could not access Wyckoff generators for space group # " + str(i))
check()
print(" letter_from_index")
try:
from pyxtal.symmetry import letter_from_index
except Exception as e:
fail(e)
if passed():
try:
if letter_from_index(0, get_wyckoffs(47)) == "A":
pass
else:
fail()
except Exception as e:
fail(e)
check()
print(" index_from_letter")
try:
from pyxtal.symmetry import index_from_letter
except Exception as e:
fail(e)
if passed():
try: