Note
Go to the end to download the full example code.
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 Magnetic field.
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)
Cut-off by distance¶
All interaction with the distance that is shorter than cut-off are added.
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")
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]]
Cut-off by energy¶
All interactions with energy larger that energy cut-off (in units of spinham.units)
are added
# 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")
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]]
See :magnopy.SpinHamiltonian.add_dipole_dipole() for more details.
Total running time of the script: (0 minutes 0.302 seconds)