.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "master-tutorial/3_exercises/plot_8_lswt.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_master-tutorial_3_exercises_plot_8_lswt.py: Linear Spin Wave theory *********************** .. include:: ../../exercises/8.inc .. GENERATED FROM PYTHON SOURCE LINES 7-13 .. code-block:: Python import numpy as np import magnopy import wulfric import matplotlib.pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 14-16 Exercise 1 ========== .. GENERATED FROM PYTHON SOURCE LINES 17-49 .. code-block:: Python # Cubic cell with a = 1 cell = np.eye(3) # One atom per unit cell in the center of the cell atoms = dict( names=["Fe"], positions=[[0.5, 0.5, 0.5]], spins=[1.0], g_factors=[2.0], ) # Choose a convention convention = magnopy.Convention( multiple_counting=True, spin_normalized=False, c21=1, c22=1 ) # Create an empty spin Hamiltonian spinham = magnopy.SpinHamiltonian(cell=cell, atoms=atoms, convention=convention) # Add a Heisenberg exchange interaction between nearest neighbors parameter = magnopy.converter22.from_iso(iso=-1.0) # Ferromagnetic exchange for nu in [(1, 0, 0), (0, 1, 0), (0, 0, 1)]: spinham.add_22(alpha=0, beta=0, nu=nu, parameter=parameter) # Add an on-site anisotropy term spinham.add_21(alpha=0, parameter=np.diag([0.0, 0.0, -0.5])) # Visualize the spin Hamiltonian pe1, pe2 = magnopy.experimental.plot_spinham(spinham=spinham, _sphinx_gallery_fix=True) .. GENERATED FROM PYTHON SOURCE LINES 50-51 On-site terms .. GENERATED FROM PYTHON SOURCE LINES 52-54 .. code-block:: Python pe1.show(axes_visible=False) .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 55-56 Bilinear terms .. GENERATED FROM PYTHON SOURCE LINES 56-58 .. code-block:: Python pe2.show(axes_visible=False) .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 59-60 Next, work with linear spin wave theory to compute magnon dispersion. .. GENERATED FROM PYTHON SOURCE LINES 61-100 .. code-block:: Python # Create a linear spin wave theory object lswt = magnopy.LSWT(spinham=spinham, spin_directions=[[0, 0, 1]]) # Get high-symmetry points kp = wulfric.Kpoints.from_crystal(cell=spinham.cell, atoms=spinham.atoms) kp.n = 20 omegas = np.array( [lswt.omega(k=k, relative=False) for k in kp.points(relative=False)] ).T.real # Plot the magnon dispersion fig, ax = plt.subplots() for omega in omegas: ax.plot(kp.flat_points(), omega) ax.set_xlim(kp.ticks()[0], kp.ticks()[-1]) ax.set_ylim(0, None) ax.set_xticks(kp.ticks(), kp.labels, fontsize=15) ax.vlines( kp.ticks(), 0, 1, color="grey", lw=0.5, transform=ax.get_xaxis_transform(), ) ax.set_ylabel("Energy (meV)", fontsize=15) ax.set_title("Magnon Dispersion - Simple Ferromagnet", fontsize=15) fig.tight_layout() fig.show() .. image-sg:: /master-tutorial/3_exercises/images/sphx_glr_plot_8_lswt_001.png :alt: Magnon Dispersion - Simple Ferromagnet :srcset: /master-tutorial/3_exercises/images/sphx_glr_plot_8_lswt_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 101-106 Exercise 2 ========== For this exercise, we will make a model for the 1D chain antiferromagnet with an easy magnetic axis along :math:`\mathbf{z}`. .. GENERATED FROM PYTHON SOURCE LINES 107-147 .. code-block:: Python # Cubic cell with a = 2 cell = np.eye(3) # Two atoms per unit cell atoms = dict( names=["Fe1", "Fe2"], positions=[[0.25, 0.5, 0.5], [0.75, 0.5, 0.5]], spins=[1.0, 1.0], g_factors=[2.0, 2.0], # Different, to get correct high-symmetry points and k-path spglib_types=[1, 2], ) # Choose a convention convention = magnopy.Convention( multiple_counting=True, spin_normalized=False, c21=1, c22=1 ) # Create an empty spin Hamiltonian spinham = magnopy.SpinHamiltonian(cell=cell, atoms=atoms, convention=convention) # Add a Heisenberg exchange interaction between nearest neighbors parameter = magnopy.converter22.from_iso(iso=1.0) # Antiferromagnetic exchange # No need to add all four bonds, the rest are generated automatically spinham.add_22(alpha=0, beta=1, nu=(0, 0, 0), parameter=parameter) spinham.add_22(alpha=0, beta=1, nu=(-1, 0, 0), parameter=parameter) # Add an on-site anisotropy term, to both atoms spinham.add_21(alpha=0, parameter=np.diag([0.0, 0.0, -0.1])) spinham.add_21(alpha=1, parameter=np.diag([0.0, 0.0, -0.1])) # Add some magnetic field to lift the degeneracy of the modes spinham.add_magnetic_field(B=(0, 0, 1)) # Visualize the spin Hamiltonian pe1, pe2 = magnopy.experimental.plot_spinham(spinham=spinham, _sphinx_gallery_fix=True) .. GENERATED FROM PYTHON SOURCE LINES 148-149 On-site terms .. GENERATED FROM PYTHON SOURCE LINES 150-153 .. code-block:: Python pe1.show(axes_visible=False) .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 154-155 Bilinear terms .. GENERATED FROM PYTHON SOURCE LINES 156-159 .. code-block:: Python pe2.show(axes_visible=False) .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 160-161 Next, work with linear spin wave theory to compute magnon dispersion. .. GENERATED FROM PYTHON SOURCE LINES 162-203 .. code-block:: Python # Create a linear spin wave theory object lswt = magnopy.LSWT(spinham=spinham, spin_directions=[[0, 0, 1], [0, 0, -1]]) # Get high-symmetry points kp = wulfric.Kpoints.from_crystal(cell=spinham.cell, atoms=spinham.atoms) kp.n = 20 for name, pos in zip(kp.hs_names, kp.hs_coordinates.values()): print(f"{name}: {pos}") omegas = np.array( [lswt.omega(k=k, relative=False) for k in kp.points(relative=False)] ).T.real # Plot the magnon dispersion fig, ax = plt.subplots() for omega in omegas: ax.plot(kp.flat_points(), omega) ax.set_xlim(kp.ticks()[0], kp.ticks()[-1]) ax.set_ylim(0, None) ax.set_xticks(kp.ticks(), kp.labels, fontsize=15) ax.vlines( kp.ticks(), 0, 1, color="grey", lw=0.5, transform=ax.get_xaxis_transform(), ) ax.set_ylabel("Energy (meV)", fontsize=15) ax.set_title("Magnon Dispersion - Simple Antiferromagnet", fontsize=15) fig.tight_layout() fig.show() .. image-sg:: /master-tutorial/3_exercises/images/sphx_glr_plot_8_lswt_002.png :alt: Magnon Dispersion - Simple Antiferromagnet :srcset: /master-tutorial/3_exercises/images/sphx_glr_plot_8_lswt_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none GAMMA: [0. 0. 0.] Z: [0.5 0. 0. ] M: [0. 0.5 0.5] A: [0.5 0.5 0.5] R: [0.5 0. 0.5] X: [0. 0. 0.5] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.370 seconds) .. _sphx_glr_download_master-tutorial_3_exercises_plot_8_lswt.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_8_lswt.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_8_lswt.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_8_lswt.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_