.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "school-tutorials/trilmax-2025/1_python-library/plot_6_wulfric.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_school-tutorials_trilmax-2025_1_python-library_plot_6_wulfric.py: (extra) K-points with wulfric ***************************** .. admonition:: Tutorial tasks * Get kpoints for future dispersion calculations with |wulfric|_. * (extra) Visualize Brillouin zone, k-points and k-path with :py:class:`wulfric.PlotlyEngine`. * (extra) Create a crystal on |wulfric-FCC|_ lattice with |wulfric|_. Visualize and compare primitive and conventional cells. Compute k-points, k-path. Compare reciprocal cell of conventional cell, reciprocal cell of primitive cell and ``wulfric.Kpoints.rcell``. One way to get a set of k-points and a k-path in reciprocal space is to use |wulfric|_ package. We recommend to use its :py:class:`wulfric.Kpoints` interface. Here we provide not the most straightforward way to interact with it, but the one that gives access to symmetry information. Note that symmetry search in wulfric is powered by |spglib|_. Wulfric operates on the crystal structure. First, get the information from |spglib|_ via wulfric's interface to it. .. GENERATED FROM PYTHON SOURCE LINES 27-38 .. code-block:: Python import wulfric import magnopy spinham = magnopy.examples.cubic_ferro_nn(S=1) spglib_data = wulfric.get_spglib_data( cell=spinham.cell, atoms=spinham.atoms, ) .. GENERATED FROM PYTHON SOURCE LINES 39-40 Next, display the information about the space group or Bravais lattice type .. GENERATED FROM PYTHON SOURCE LINES 40-44 .. code-block:: Python print(spglib_data.space_group_number) print(spglib_data.crystal_family + spglib_data.centring_type) .. rst-class:: sphx-glr-script-out .. code-block:: none 221 cP .. GENERATED FROM PYTHON SOURCE LINES 45-48 Now you can create an instance of :py:class:`wulfric.Kpoints` class with one of the implemented |wulfric-conventions|_ for the automatic choice of the high-symmetry points and k-path. .. GENERATED FROM PYTHON SOURCE LINES 48-85 .. code-block:: Python kp_sc = wulfric.Kpoints.from_crystal( cell=spinham.cell, atoms=spinham.atoms, spglib_data=spglib_data, convention="SC", ) kp_hpkot = wulfric.Kpoints.from_crystal( cell=spinham.cell, atoms=spinham.atoms, spglib_data=spglib_data, convention="HPKOT", ) # magnopy.PlotlyEngine() can be used as well pe = wulfric.PlotlyEngine(_sphinx_gallery_fix=True) pe.plot_cell( cell=wulfric.cell.get_reciprocal(spinham.cell), legend_label="Reciprocal cell" ) pe.plot_kpath(kp_sc, legend_label="K-path (SC)", color="GoldenRod", legend_group="SC") pe.plot_kpoints( kp_sc, color="DarkBlue", legend_label="K-points (SC)", legend_group="SC" ) pe.plot_kpath( kp_hpkot, legend_label="K-path (HPKOT)", color="ForestGreen", legend_group="HPKOT" ) pe.plot_kpoints( kp_sc, color="Black", legend_label="K-points (HPKOT)", legend_group="HPKOT" ) pe.show(axes_visible=False) .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 86-87 Default convention is HPKOT .. GENERATED FROM PYTHON SOURCE LINES 87-95 .. code-block:: Python kp = wulfric.Kpoints.from_crystal( cell=spinham.cell, atoms=spinham.atoms, spglib_data=spglib_data, ) .. GENERATED FROM PYTHON SOURCE LINES 96-99 The objects above provide a simple interface * For calculations (:py:meth:`wulfric.Kpoints.points`) .. GENERATED FROM PYTHON SOURCE LINES 99-103 .. code-block:: Python lswt = magnopy.LSWT(spinham, spin_directions=[[0, 0, 1]]) omegas = [lswt.omega(k=kpoint)[0].real for kpoint in kp.points()] .. GENERATED FROM PYTHON SOURCE LINES 104-105 * And for plotting .. GENERATED FROM PYTHON SOURCE LINES 105-118 .. code-block:: Python import matplotlib.pyplot as plt _, ax = plt.subplots() ax.plot(kp.flat_points(), omegas) ax.set_xticks(kp.ticks(), kp.labels) ax.vlines(kp.ticks(), 0, 1, transform=ax.get_xaxis_transform(), color="grey", lw=0.5) ax.set_xlim(kp.ticks()[0], kp.ticks()[-1]) plt.show() .. image-sg:: /school-tutorials/trilmax-2025/1_python-library/images/sphx_glr_plot_6_wulfric_001.png :alt: plot 6 wulfric :srcset: /school-tutorials/trilmax-2025/1_python-library/images/sphx_glr_plot_6_wulfric_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.392 seconds) .. _sphx_glr_download_school-tutorials_trilmax-2025_1_python-library_plot_6_wulfric.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_6_wulfric.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_6_wulfric.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_6_wulfric.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_