Source code: https://github.com/qzhu2017/PyXtal
Created by Qiang Zhu (2020/11/23)
Last updated: 2022/08/11
To use the code, just import the following module
from pyxtal import pyxtal
s = pyxtal(molecular=True)
Ideally, one just needs to define the following parameters:
More details can be found at the following link
from pyxtal import pyxtal
h2o = pyxtal(molecular=True)
h2o.from_random(3, 19, ['h2o'], [4])
print(h2o)
------Crystal from random------ Dimension: 3 Composition: [h2o]4 Group: P 21 21 21 (19) 3.8693, 7.5272, 6.8579, 90.0000, 90.0000, 90.0000, orthorhombic Wyckoff sites: H2O1 @ [ 0.8354 0.0503 0.6503] WP [4a] Site [1] Euler [ 138.9 -51.6 46.1]
#display the structure
h2o.show()
#The crystal can also be exported to pymatgen or ase structure.
#pmg_struc = h2o.to_pymatgen()
#ase_struc = h2o.to_ase()
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
<py3Dmol.view at 0x7f9906b9c790>
# It is also fun to check how the structure is generated from a simple animation
h2o.show(size=(400, 300), animation=True, interval=1000)
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
<py3Dmol.view at 0x7f9906ba0f10>
In addition to the general Wyckoff positions
(WP), there are also special WPs which have the site symmetries
more than the identify operation. If the molecular symmetry
is compatible with the site symmetry, the molecules can also take the special WPs. In that event, the molecules have less degree of freedom and they can only rotate in a limited range. PyXtal
takes care of this when dealing the structural manipulation.
Below is an example to show the water molecules occupy the 4a site in space group Cmc21(36).
from pyxtal import pyxtal
h2o_36 = pyxtal(molecular=True)
h2o_36.from_random(3, 36, ['H2O'], [4])
print(h2o)
------Crystal from random------ Dimension: 3 Composition: [h2o]4 Group: P 21 21 21 (19) 3.8693, 7.5272, 6.8579, 90.0000, 90.0000, 90.0000, orthorhombic Wyckoff sites: H2O1 @ [ 0.8354 0.0503 0.6503] WP [4a] Site [1] Euler [ 138.9 -51.6 46.1]
# Below is a script to show how the molecules rotate around the allowed axis
ax = h2o_36.mol_sites[0].orientation.axis
strucs = []
for angle in [90, 180, 270, 360]:
struc = h2o_36.copy()
struc.mol_sites[0].rotate(ax_vector=ax, angle=angle)
strucs.append(struc)
from pyxtal.viz import display_mol_crystals
display_mol_crystals(strucs, axis=2*ax)
interactive(children=(IntSlider(value=0, description='id:', max=3), Output()), _dom_classes=('widget-interact'…
h2o_1D = pyxtal(molecular=True)
h2o_1D.from_random(1, 75, ['H2O'], [12])
#print(h2o_1D)
h2o_1D.show(supercell=(1,1,3))
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
<py3Dmol.view at 0x7f9906e855d0>
h2o_2D = pyxtal(molecular=True)
h2o_2D.from_random(2, 25, ['H2O'], [4], thickness=0)
#print(h2o_2D)
h2o_2D.show(supercell=(2,2,1))
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
<py3Dmol.view at 0x7f98e70eb690>
from pyxtal import pyxtal
C1 = pyxtal(molecular=True)
C1.from_seed(seed="aspirin.cif", molecules=["aspirin"])
print(C1)
C1.show()
------Crystal from Seed------ Dimension: 3 Composition: [aspirin]4 Group: P 1 21/c 1 (14) 11.2330, 6.5440, 11.2310, 90.0000, 95.8900, 90.0000, monoclinic Wyckoff sites: H8C9O4 @ [ 0.2414 0.5782 0.0168] WP [4e] Site [1] Euler [ 0.0 0.0 0.0]
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
<py3Dmol.view at 0x7f9906e9f950>
C2 = C1.subgroup_once(H=7, eps=0, mut_lat=False)
print(C2)
C2.show()
------Crystal from subgroup------ Dimension: 3 Composition: [aspirin]4 Group: P 1 c 1 (7) 11.2330, 6.5440, 11.2310, 90.0000, 95.8900, 90.0000, monoclinic Wyckoff sites: H8C9O4 @ [ 0.2414 0.3282 0.0168] WP [2a] Site [1] Euler [ 0.0 0.0 0.0] H8C9O4 @ [ 0.7586 0.8282 0.4832] WP [2a] Site [1] Euler [ 0.0 0.0 0.0]
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
<py3Dmol.view at 0x7f98e72a6510>
from pyxtal import pyxtal
C1 = pyxtal(molecular=True)
C1.from_seed(seed="aspirin.cif", molecules=["aspirin"])
print(C1)
C1.show()
------Crystal from Seed------ Dimension: 3 Composition: [aspirin]4 Group: P 1 21/c 1 (14) 11.2330, 6.5440, 11.2310, 90.0000, 95.8900, 90.0000, monoclinic Wyckoff sites: H8C9O4 @ [ 0.2414 0.5782 0.0168] WP [4e] Site [1] Euler [ 0.0 0.0 0.0]
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
<py3Dmol.view at 0x7f98e729a050>
# Now we apply the cell transformation
C1.transform([[1,0,0],[0,1,0],[1,0,1]])
print(C1)
C1.show()
------Crystal from Seed------ Dimension: 3 Composition: [aspirin]4 Group: P 1 21/n 1 (14) 11.2330, 6.5440, 15.0474, 90.0000, 47.9393, 90.0000, monoclinic Wyckoff sites: H8C9O4 @ [ 0.2246 0.5782 0.0168] WP [4e] Site [1] Euler [ 0.0 0.0 0.0]
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
<py3Dmol.view at 0x7f98e74d1750>
# We can always use the optimize_lattice function to
# change it to a cell reprentation that has an inclination
# angle close to 90 degree
C1.optimize_lattice()
print(C1)
C1.show()
------Crystal from Seed------ Dimension: 3 Composition: [aspirin]4 Group: P 1 21/c 1 (14) 11.2330, 6.5440, 11.2310, 90.0000, 95.8900, 90.0000, monoclinic Wyckoff sites: H8C9O4 @ [ 0.2414 0.5782 0.0168] WP [4e] Site [1] Euler [ 0.0 0.0 0.0]
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
<py3Dmol.view at 0x7f9906e23110>
BIPHEN = pyxtal(molecular=True)
#BIPHEN.from_random(3, 200, ['BIPHEN'], [24])
BIPHEN.from_random(3, 200, ['BIPHEN'], [12], sites=[['12k']])
print(BIPHEN)
------Crystal from random------ Dimension: 3 Composition: [BIPHEN]12 Group: P m -3 (200) 15.1676, 15.1676, 15.1676, 90.0000, 90.0000, 90.0000, cubic Wyckoff sites: H10C12 @ [ 0.5000 0.6120 0.1863] WP [12k] Site [m..] Euler [-180.0 -62.4 -0.0]
BIPHEN.show(size=(400, 300), animation=True, interval=1000)
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol
<py3Dmol.view at 0x7f98e7603250>