Note
Go to the end to download the full example code.
Plotting atoms#
This page explains how to plot a set of atoms.
import wulfric
import numpy as np
cell = np.array(
[
[0.000000, 4.744935, 0.000000],
[3.553350, 0.000000, 0.000000],
[0.000000, 0.000000, 8.760497],
]
)
atoms = {
"names": ["Cr1", "Br1", "S1", "Cr2", "Br2", "S2"],
"positions": np.array(
[
[0.000000, -0.500000, 0.882382],
[0.000000, 0.000000, 0.677322],
[-0.500000, -0.500000, 0.935321],
[0.500000, 0.000000, 0.117618],
[0.500000, 0.500000, 0.322678],
[0.000000, 0.000000, 0.064679],
]
),
}
pe = wulfric.PlotlyEngine(_sphinx_gallery_fix=True)
pe.plot_atoms(cell=cell, atoms=atoms)
pe.plot_cell(cell=cell)
pe.show()
Atoms'labels are deduced based on atoms["names"].
Atom's colors are deduced based on atom's species, but can be directly passed to the function as well.
atoms = dict(positions=atoms["positions"])
pe = wulfric.PlotlyEngine(_sphinx_gallery_fix=True)
pe.plot_atoms(cell=cell, atoms=atoms)
pe.plot_cell(cell=cell)
pe.show()
/home/docs/checkouts/readthedocs.org/user_builds/wulfric/envs/0.6/lib/python3.11/site-packages/wulfric/crystal/_atoms.py:114: RuntimeWarning: Atom species deduction failed for 'X1'. Set species to 'X'
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/wulfric/envs/0.6/lib/python3.11/site-packages/wulfric/crystal/_atoms.py:114: RuntimeWarning: Atom species deduction failed for 'X2'. Set species to 'X'
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/wulfric/envs/0.6/lib/python3.11/site-packages/wulfric/crystal/_atoms.py:114: RuntimeWarning: Atom species deduction failed for 'X3'. Set species to 'X'
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/wulfric/envs/0.6/lib/python3.11/site-packages/wulfric/crystal/_atoms.py:114: RuntimeWarning: Atom species deduction failed for 'X4'. Set species to 'X'
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/wulfric/envs/0.6/lib/python3.11/site-packages/wulfric/crystal/_atoms.py:114: RuntimeWarning: Atom species deduction failed for 'X5'. Set species to 'X'
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/wulfric/envs/0.6/lib/python3.11/site-packages/wulfric/crystal/_atoms.py:114: RuntimeWarning: Atom species deduction failed for 'X6'. Set species to 'X'
warnings.warn(
Total running time of the script: (0 minutes 0.061 seconds)