MaterSim / PyXtal

A code to generate atomic structure with symmetry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in check_wyckoff_position() for space groups P1 (1), P-1 (2), P2(3) and unexpected result for C2(5)

kiryph opened this issue · comments

>>> import pyxtal
>>> pyxtal.print_logo()

             ______       _    _          _
            (_____ \     \ \  / /        | |
             _____) )   _ \ \/ / |_  ____| |
            |  ____/ | | | )  (|  _)/ _  | |
            | |    | |_| |/ /\ \ |_( (_| | |___
            |_|     \__  /_/  \_\___)__|_|_____)
                   (____/


-------------------(version 0.6.1 )--------------------

A Python package for random crystal generation
The source code is available at https://github.com/qzhu2017/pyxtal
Developed by Zhu's group at University of Nevada Las Vegas

Consider the point (1/2, 1/2, 1/2) in different space groups and which Wyckoff position the point belongs to (always assuming conventional unit cell choices):

>>> pnt = [0.5,0.5,0.5]
>>> pyxtal.symmetry.check_wyckoff_position([pnt],pyxtal.symmetry.Group(1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kiryph/.local/share/virtualenvs/pyxtal-HOHLXKiT/lib/python3.9/site-packages/pyxtal/symmetry.py", line 3278, in check_wyckoff_position
    dw = distance_matrix(points, pw, None, PBC=PBC, metric="sqeuclidean")
  File "/Users/kiryph/.local/share/virtualenvs/pyxtal-HOHLXKiT/lib/python3.9/site-packages/pyxtal/operations.py", line 217, in distance_matrix
    l1 = np.dot(l1, lattice)
TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

The same error for pyxtal.symmetry.Group(2) and pyxtal.symmetry.Group(3).

Assign Wyckoff position to coordinate

Actually, I am not sure about the possible/intended usage of the method pyxtal.symmetry.check_wyckoff_position(...).

Could I use it to assign a Wyckoff position to a coordinate? Do I really need a list of points or can I give a single representative (point) of an orbit to get the Wyckoff index which can be used to get the ITC Wyckoff letter with get_label():

Expectation

>>> pnt = [0,0.5,0.5] # deliberately choosing this point which is not in general position in conventional unit cell choice
>>> res = pyxtal.symmetry.check_wyckoff_position([pnt],pyxtal.symmetry.Group(5))
(1, [0,0.5,0.5])
>>> pyxtal.symmetry.Wyckoff_position.from_group_and_index(5, 1).get_label()
'2b'

compare Bilbao WPASSIGN https://www.cryst.ehu.es/cryst/wpassign.html

# Space Group ITA number 
5
# Lattice parameters (lengths in angstroems and angles in degrees)
1 1 1 90 90 90
# Number of independent atoms in the asymmetric unit
1
# [atom type] [number] [WP] [x] [y] [z]
XYZ  1 - 0.0 0.5 0.5

Screenshot 2023-12-07 at 12 30 15

The standard setting for C2 should be unique axis b, cell choice 1 as given in ITC Vol. A.

Observation

>>> pnt = [0,0.5,0.5]
>>> pyxtal.symmetry.check_wyckoff_position([pnt],pyxtal.symmetry.Group(5))
(False, None)

First of all, for space group 5, I do not get an error but no successful assignment to an index. Even if the unit cell choice is different, the assignment to the index of the general position should happen.

I suspect there is another issue next to the error. But maybe I use it incorrectly and this is actually the expected result.

Any fix, clarification is appreciated. Thanks.

HI, @kiryph

The function of pyxtal.symmetry.check_wyckoff_position was created by my student long ago to run some internal checking.

Can I confirm that you want to have a function which can tell you the corresponding wyckoff symbol?

>>> from pyxtal.symmetry import Group
>>> g = Group(5)
>>> wp = g.get_wyckoff_position_from_xyz([0, 0.5, 0.5])
>>> wp.get_label()
'2b'

If this is your goal, we may need to create such a utility.

Can I confirm that you want to have a function which can tell you the corresponding wyckoff symbol?

Yes, that is correct. I will try your recent commit 145c37c and will let you know if I get the expected results from get_wyckoff_position_from_xyz. Thank you.