qzhu2017 / PyXtal

A code to generate atomic structure with symmetry
MIT License
234 stars 59 forks source link

generating an ensemble of structures with different space groups #167

Closed NikaRybin closed 2 years ago

NikaRybin commented 2 years ago

Dear all,

I tried to generate an ensemble of structures with identical composition and different space groups using: crystal.from_random(dim, space_group, currentSpecies, num_atoms, thickness = thickness, force_pass=True)

However, when trying this, I receive an error: pyxtal.msg.Comp_CompatibilityError: Compoisition [9 6] not compatible with symmetry 50

I found out that in the newest version of pyxtal in crystal.py there are lines: if not compat: self.valid = False msg = "Compoisition " + str(self.numIons) msg += " not compatible with symmetry " msg += str(self.group.number) raise Comp_CompatibilityError(msg)

Consequently, this error is raised up and my script fails while generating structures. In the previous version of pyxtal this worked smoothly. Could you, please, recommend me how to resolve this issue?

Thanks in advance. Sincerely, Nikita

qzhu2017 commented 2 years ago

@NickRybin
In the new version, we added a compatibility check to prevent the unnecessary attempts for structure generation. For your case, the space group of 50 have wyckoff choices as follows

>>> from pyxtal.symmetry import Group
>>> Group(50)
-- Spacegroup --# 50 (Pban)--
8m  site symm: 1
4l  site symm: ..2
4k  site symm: ..2
4j  site symm: .2.
4i  site symm: .2.
4h  site symm: 2..
4g  site symm: 2..
4f  site symm: -1
4e  site symm: -1
2d  site symm: 222
2c  site symm: 222
2b  site symm: 222
2a  site symm: 222

Obviously, there is no way to satisfy the composition of 9. This is the reason why the program complains.

To prevent such error, you can do something like the folloowing

from pyxtal.msg import Comp_CompatibilityError

try:
     #here you generate the structure
except Comp_CompatibilityError:
    print("Composition is imcompatible")
NikaRybin commented 2 years ago

@qzhu2017, thank you for fast response and it makes sense. I think the issue is resolved.

Nikita