qzhu2017 / PyXtal

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

FEATURE REQUEST: Is there a way to combine the functionality of build and random_crystal ? #191

Closed Abhivega closed 2 years ago

Abhivega commented 2 years ago

Say I want to selectively fix the positions of some atoms and allow random_crystal to figure out the optimal positions of the unmasked atoms. Is this a desirable feature?

qzhu2017 commented 2 years ago

This sounds a good idea. We may be able to work on it some time later. But I don't want to promise anything at the moment.

If you want to work on it by yourself. I can also walk you through the places you need to change to get the function work.

Abhivega commented 2 years ago

Thank you. I would be happy to work on this. Please do share your thoughts.

qzhu2017 commented 2 years ago

@Abhivega

Here is a quick example to generate the structure with some constraints:

from pyxtal import pyxtal 
#a test example to produce Al2SiO5
struc = pyxtal()
struc.from_seed('pyxtal/database/cifs/Al2SiO5_mp-4753_symmetrized.cif')
print(struc)
# SPG: 58(Pnnm)
#Composition: Al8Si4O20
#Group: Pnnm (58)
#  7.8758,   7.9794,   5.6139,  90.0000,  90.0000,  90.0000, orthorhombic
#Wyckoff sites:
#   Al @ [ 0.0000  0.0000  0.2418], WP [4e] Site [..2]
#   Al @ [ 0.1294  0.6392  0.0000], WP [4g] Site [..m]
#   Si @ [ 0.2458  0.2522  0.0000], WP [4g] Site [..m]
#    O @ [ 0.2308  0.1342  0.2397], WP [8h] Site [1]
#    O @ [ 0.4241  0.3636  0.0000], WP [4g] Site [..m]
#    O @ [ 0.0760  0.8629  0.0000], WP [4g] Site [..m]
#    O @ [ 0.1025  0.4007  0.0000], WP [4g] Site [..m]

#Assume that we know about the occupation of Al and Si,
#and then generate the positions for O randomly

from pyxtal.lattice import Lattice
cell = Lattice.from_para(7.8758, 7.9794, 5.6139, 90, 90, 90, ltype='orthorhombic')
spg = 58
elements = ['Al', 'Si', 'O']
composition = [8, 4, 20]
sites1 = [{"4e": [0.0000,  0.0000,  0.2418],
           "4g": [0.1294,  0.6392,  0.0000],
          },
          {"4g": [0.2458,  0.2522,  0.0000]},
          None, #empty for oxygen
        ]

s = pyxtal()
s.from_random(3, spg, elements, composition, lattice=cell, sites=sites1)
print(s)

sites2 = [{"4e": [0.0000, 0.0000, 0.2418],
           "4g": [0.1294, 0.6392, 0.0000],
          },
          {"4g": [0.2458, 0.2522, 0.0000]},
          {"4g": [0.4241, 0.3636, 0.0000]},
         ]

s = pyxtal()
s.from_random(3, spg, elements, composition, lattice=cell, sites=sites2)
print(s)

Will this work for you?

Abhivega commented 2 years ago

Thank you!!