.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "master-tutorial/1_python-library/plot_5_dipdip.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_1_python-library_plot_5_dipdip.py: Magnetic dipole-dipole interaction ********************************** Magnetic dipole-dipole interaction can be written as a two-spin/two-sites parameter. To save the burden of manual conversion, magnopy has a convenience method that adds magnetic dipole-dipole interaction to the spin Hamiltonian. This interaction is of the long range. Magnopy implements its inclusion within the cut-off value. .. note:: Magnetic dipole dipole is added only to magnetic atoms, same as with :ref:`sphx_glr_master-tutorial_1_python-library_plot_4_magnetic_field.py`. .. GENERATED FROM PYTHON SOURCE LINES 18-40 .. code-block:: Python import numpy as np import magnopy # Cubic ferromagnet cell = np.eye(3) atoms = dict( names=["Fe"], positions=[[0.5, 0.5, 0.5]], spins=[2.5], g_factors=[2], ) # Choose convention convention = magnopy.Convention( multiple_counting=True, spin_normalized=False, c21=1, c22=1 ) # Create a Hamiltonian spinham = magnopy.SpinHamiltonian(cell=cell, atoms=atoms, convention=convention) .. GENERATED FROM PYTHON SOURCE LINES 41-45 Cut-off by distance =================== All interaction with the distance that is shorter than cut-off are added. .. GENERATED FROM PYTHON SOURCE LINES 46-65 .. code-block:: Python spinham.add_dipole_dipole(R_cut=2, alphas=[0]) print(len(spinham.p22)) for alpha, beta, nu, parameter in spinham.p22: print( f'Bond from "{spinham.atoms.names[alpha]}" to "{spinham.atoms.names[beta]}" in {nu}\n {parameter}' ) _, pe2 = magnopy.experimental.plot_spinham( spinham, distance_digits=3, _sphinx_gallery_fix=True ) pe2.show(axes_visible=False, legend_position="left") .. rst-class:: sphx-glr-script-out .. code-block:: none 32 Bond from "Fe" to "Fe" in (0, 0, 1) [[ 0.10736302 0. 0. ] [ 0. 0.10736302 0. ] [ 0. 0. -0.21472604]] Bond from "Fe" to "Fe" in (0, 0, 2) [[ 0.01342038 0. 0. ] [ 0. 0.01342038 0. ] [ 0. 0. -0.02684076]] Bond from "Fe" to "Fe" in (0, 1, -1) [[ 0.03795856 0. 0. ] [ 0. -0.01897928 0.05693784] [ 0. 0.05693784 -0.01897928]] Bond from "Fe" to "Fe" in (0, 1, 0) [[ 0.10736302 0. 0. ] [ 0. -0.21472604 0. ] [ 0. 0. 0.10736302]] Bond from "Fe" to "Fe" in (0, 1, 1) [[ 0.03795856 0. 0. ] [ 0. -0.01897928 -0.05693784] [ 0. -0.05693784 -0.01897928]] Bond from "Fe" to "Fe" in (0, 2, 0) [[ 0.01342038 0. 0. ] [ 0. -0.02684076 0. ] [ 0. 0. 0.01342038]] Bond from "Fe" to "Fe" in (1, -1, -1) [[-4.58789079e-18 2.06620232e-02 2.06620232e-02] [ 2.06620232e-02 -4.58789079e-18 -2.06620232e-02] [ 2.06620232e-02 -2.06620232e-02 -4.58789079e-18]] Bond from "Fe" to "Fe" in (1, -1, 0) [[-0.01897928 0.05693784 0. ] [ 0.05693784 -0.01897928 0. ] [ 0. 0. 0.03795856]] Bond from "Fe" to "Fe" in (1, -1, 1) [[-4.58789079e-18 2.06620232e-02 -2.06620232e-02] [ 2.06620232e-02 -4.58789079e-18 2.06620232e-02] [-2.06620232e-02 2.06620232e-02 -4.58789079e-18]] Bond from "Fe" to "Fe" in (1, 0, -1) [[-0.01897928 0. 0.05693784] [ 0. 0.03795856 0. ] [ 0.05693784 0. -0.01897928]] Bond from "Fe" to "Fe" in (1, 0, 0) [[-0.21472604 0. 0. ] [ 0. 0.10736302 0. ] [ 0. 0. 0.10736302]] Bond from "Fe" to "Fe" in (1, 0, 1) [[-0.01897928 0. -0.05693784] [ 0. 0.03795856 0. ] [-0.05693784 0. -0.01897928]] Bond from "Fe" to "Fe" in (1, 1, -1) [[-4.58789079e-18 -2.06620232e-02 2.06620232e-02] [-2.06620232e-02 -4.58789079e-18 2.06620232e-02] [ 2.06620232e-02 2.06620232e-02 -4.58789079e-18]] Bond from "Fe" to "Fe" in (1, 1, 0) [[-0.01897928 -0.05693784 0. ] [-0.05693784 -0.01897928 0. ] [ 0. 0. 0.03795856]] Bond from "Fe" to "Fe" in (1, 1, 1) [[-4.58789079e-18 -2.06620232e-02 -2.06620232e-02] [-2.06620232e-02 -4.58789079e-18 -2.06620232e-02] [-2.06620232e-02 -2.06620232e-02 -4.58789079e-18]] Bond from "Fe" to "Fe" in (2, 0, 0) [[-0.02684076 0. 0. ] [ 0. 0.01342038 0. ] [ 0. 0. 0.01342038]] Bond from "Fe" to "Fe" in (0, 0, -1) [[ 0.10736302 0. 0. ] [ 0. 0.10736302 0. ] [ 0. 0. -0.21472604]] Bond from "Fe" to "Fe" in (0, 0, -2) [[ 0.01342038 0. 0. ] [ 0. 0.01342038 0. ] [ 0. 0. -0.02684076]] Bond from "Fe" to "Fe" in (0, -1, 1) [[ 0.03795856 0. 0. ] [ 0. -0.01897928 0.05693784] [ 0. 0.05693784 -0.01897928]] Bond from "Fe" to "Fe" in (0, -1, 0) [[ 0.10736302 0. 0. ] [ 0. -0.21472604 0. ] [ 0. 0. 0.10736302]] Bond from "Fe" to "Fe" in (0, -1, -1) [[ 0.03795856 0. 0. ] [ 0. -0.01897928 -0.05693784] [ 0. -0.05693784 -0.01897928]] Bond from "Fe" to "Fe" in (0, -2, 0) [[ 0.01342038 0. 0. ] [ 0. -0.02684076 0. ] [ 0. 0. 0.01342038]] Bond from "Fe" to "Fe" in (-1, 1, 1) [[-4.58789079e-18 2.06620232e-02 2.06620232e-02] [ 2.06620232e-02 -4.58789079e-18 -2.06620232e-02] [ 2.06620232e-02 -2.06620232e-02 -4.58789079e-18]] Bond from "Fe" to "Fe" in (-1, 1, 0) [[-0.01897928 0.05693784 0. ] [ 0.05693784 -0.01897928 0. ] [ 0. 0. 0.03795856]] Bond from "Fe" to "Fe" in (-1, 1, -1) [[-4.58789079e-18 2.06620232e-02 -2.06620232e-02] [ 2.06620232e-02 -4.58789079e-18 2.06620232e-02] [-2.06620232e-02 2.06620232e-02 -4.58789079e-18]] Bond from "Fe" to "Fe" in (-1, 0, 1) [[-0.01897928 0. 0.05693784] [ 0. 0.03795856 0. ] [ 0.05693784 0. -0.01897928]] Bond from "Fe" to "Fe" in (-1, 0, 0) [[-0.21472604 0. 0. ] [ 0. 0.10736302 0. ] [ 0. 0. 0.10736302]] Bond from "Fe" to "Fe" in (-1, 0, -1) [[-0.01897928 0. -0.05693784] [ 0. 0.03795856 0. ] [-0.05693784 0. -0.01897928]] Bond from "Fe" to "Fe" in (-1, -1, 1) [[-4.58789079e-18 -2.06620232e-02 2.06620232e-02] [-2.06620232e-02 -4.58789079e-18 2.06620232e-02] [ 2.06620232e-02 2.06620232e-02 -4.58789079e-18]] Bond from "Fe" to "Fe" in (-1, -1, 0) [[-0.01897928 -0.05693784 0. ] [-0.05693784 -0.01897928 0. ] [ 0. 0. 0.03795856]] Bond from "Fe" to "Fe" in (-1, -1, -1) [[-4.58789079e-18 -2.06620232e-02 -2.06620232e-02] [-2.06620232e-02 -4.58789079e-18 -2.06620232e-02] [-2.06620232e-02 -2.06620232e-02 -4.58789079e-18]] Bond from "Fe" to "Fe" in (-2, 0, 0) [[-0.02684076 0. 0. ] [ 0. 0.01342038 0. ] [ 0. 0. 0.01342038]] .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 66-71 Cut-off by energy ================= All interactions with energy larger that energy cut-off (in units of ``spinham.units``) are added .. GENERATED FROM PYTHON SOURCE LINES 72-94 .. code-block:: Python # Reset all parameter spinham = spinham.get_empty() spinham.add_dipole_dipole(E_cut=0.1, alphas=[0]) print(len(spinham.p22)) for alpha, beta, nu, parameter in spinham.p22: print( f'Bond from "{spinham.atoms.names[alpha]}" to "{spinham.atoms.names[beta]}" in {nu}\n {parameter}' ) _, pe2 = magnopy.experimental.plot_spinham( spinham, distance_digits=3, _sphinx_gallery_fix=True ) pe2.show(axes_visible=False, legend_position="left") .. rst-class:: sphx-glr-script-out .. code-block:: none 6 Bond from "Fe" to "Fe" in (0, 0, 1) [[ 0.10736302 0. 0. ] [ 0. 0.10736302 0. ] [ 0. 0. -0.21472604]] Bond from "Fe" to "Fe" in (0, 1, 0) [[ 0.10736302 0. 0. ] [ 0. -0.21472604 0. ] [ 0. 0. 0.10736302]] Bond from "Fe" to "Fe" in (1, 0, 0) [[-0.21472604 0. 0. ] [ 0. 0.10736302 0. ] [ 0. 0. 0.10736302]] Bond from "Fe" to "Fe" in (0, 0, -1) [[ 0.10736302 0. 0. ] [ 0. 0.10736302 0. ] [ 0. 0. -0.21472604]] Bond from "Fe" to "Fe" in (0, -1, 0) [[ 0.10736302 0. 0. ] [ 0. -0.21472604 0. ] [ 0. 0. 0.10736302]] Bond from "Fe" to "Fe" in (-1, 0, 0) [[-0.21472604 0. 0. ] [ 0. 0.10736302 0. ] [ 0. 0. 0.10736302]] .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 95-96 See ::py:meth:`magnopy.SpinHamiltonian.add_dipole_dipole` for more details. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.302 seconds) .. _sphx_glr_download_master-tutorial_1_python-library_plot_5_dipdip.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_5_dipdip.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_5_dipdip.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_5_dipdip.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_