qzhu2017 / PyXtal

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

How to get the 3D coordinate from a crystal #216

Closed lamthuy closed 1 year ago

lamthuy commented 1 year ago

Hi I follow the example to create an atomic crystal of Carbon

C1 = pyxtal()
C1.from_random(3, 225, ['C'], [12])

I would like to get 3D coordinates of all the carbons in the crystal of size 3x3x3 or size 5x5x5, how do I do that with the constructed crystal?

qzhu2017 commented 1 year ago

Hi I follow the example to create an atomic crystal of Carbon


C1 = pyxtal()

C1.from_random(3, 225, ['C'], [12])

I would like to get 3D coordinates of all the carbons in the crystal of size 3x3x3 or size 5x5x5, how do I do that with the constructed crystal?

This is actually very easy. After you generate the crystal, you can convert it to ase object.

ase_atoms = C1.to_ase()
ase_atoms *= 3
coords = ase_atoms.get_positions()

You can also do a lot of other things via the ase_atoms object.

lamthuy commented 1 year ago

Thank you, I tried the given code. It gave me a tensor of size (324, 3), could you please explain why we get 324 3D coordinates? Also what is the meaning of the line:

ase_atoms *= 3

If I just want to get a crystal of size 3x3x3 (27 atoms) or size 5x5x5 (125 atoms), is that possible?

lamthuy commented 1 year ago

I found the reason why we have 324 atoms, since we do

C1.from_random(3, 225, ['C'], [12])

which mean we have a composition of 12 Carbon atoms, the

ase_atoms *= 3

will replicate these 12 composition to 12x3x3x3 = 324 atoms.

My next question is if I only need a crystal of 3x3x3 how can I do that, I have tried to create as follows

C1 = pyxtal()
C1.from_random(3, 225, ['C'], [1])

but I got the message:

pyxtal.msg.Comp_CompatibilityError: Compoisition [1] not compatible with symmetry 225

I guess each symmetry group is compatible with specific number of atoms in the composition, but I could not find that information anywhere in the documentation.

qzhu2017 commented 1 year ago

PyXtal is mainly designed to generate the random crystal structures with the desired symmetry and perform some nontrivial symmetry analysis. I don't really understand your purpose.

If you just want to build a 333 FCC crystal supercell, I believe you may just use ase as follows,

https://wiki.fysik.dtu.dk/ase/ase/build/build.html