Magnet
Contents
Magnet#
Summary#
Here we are assuming the magnets are:
uniformly magnetized
magnetized in the z direction
Currently the two types of magnets supported
Spherical magnet object with its Bz, Bzx, Bzxx calculations. |
|
Rectangular magnet object with the bz, bzx, bzxx calculations. |
Example Usage#
Create a radius \(r = 50 \: \mathrm{nm}\) sphere of cobalt (\(\mu_0 M_s = 1800 \: \mathrm{mT}\))
magnet = SphereMagnet(radius=50., mu0_Ms=1800., origin=[0., 0., 0.])
Print the magnet information:
print(magnet)
magnet
module#
- class mrfmsim_marohn.component.magnet.RectangularMagnet(length, mu0_Ms, origin)[source]#
Bases:
mrfmsim.component.ComponentBase
Rectangular magnet object with the bz, bzx, bzxx calculations.
- Bz_method(x, y, z)[source]#
Calculate magnetic field \(B_z\) [mT].
The magnetic field is calculated following Ravaud2009. Using the Coulombian model, assuming a uniform magnetization throughout the volume of the magnet and modeling each face of the magnet as a layer of continuous current density. The total field is found by summing over the faces. The magnetic field is given by:
\[B_z = \dfrac{\mu_0 M_s}{4\pi} \sum_{i=1}^{2} \sum_{j=1}^2 \sum_{k=1}^2(-1)^{i+j+k} arctan \left( \dfrac{(x - x_i)(y - y_i))}{(z - z_k)R} \right)\]Here \((x,y,z)\) are the coordinates for the location at which we want to know the field; The magnet spans from x1 to x2 in the
x
-direction, y1 to y2 in they
-direction, and z1 to z2 in thez
-direction;\[R = \sqrt{(x - x_i)^2 + (y - y_j)^2 + (z - z_k)^2}\]where \(\mu_0 M_s\) is the magnet’s saturation magnetization in mT.
Reference: Ravaud, R. and Lemarquand, G. “Magnetic field produced by a parallelepipedic magnet of various and uniform polarization” , PIER, 2009, 98, 207-219 [10.2528/PIER09091704].
set the magnet up so that the x and y dimensions are centered about the zero point.
The translation in z should shift the tip of the magnet in the z-direction to be the given distance from the surface.
- Parameters
x (float) – x coordinate of sample grid [nm]
y (float) – y coordinate of sample grid [nm]
z (float) – z coordinate of sample grid [nm]
- Bzx_method(x, y, z)[source]#
Calculate magnetic field gradient \(B_{zx}\).
\(B_{zx} \equiv \partial B_z / \partial x\) [\(\mathrm{mT} \: \mathrm{nm}^{-1}\)]. The magnetic field gradient \(B_{zx} = \dfrac{\partial{B_z}}{\partial x}\) is given by the following:
\[B_{zx} = \dfrac{\mu_0 M_s}{4 \pi} \sum_{i=1}^2 \sum_{j=1}^2 \sum_{k=1}^2(-1)^{i+j+k} \left( \dfrac{(y-y_j)(z-z_k)}{ R((x-x_i)^2 + (z-z_k)^2))} \right)\]As described above, \((x,y,z)\) are coordinates for the location at which we want to know the field gradient; the magnet spans from x1 to x2 in the
x
-direction, y1 to y2 in they
-direction, and from z1 to z2 in thez
-direction;\[R = \sqrt{(x - x_i) + (y - y_j) + (z - z_k)}\]\(\mu_0 M_s\) is the magnet’s saturation magnetization in mT.
- Parameters
x (float) –
x
coordinate [nm]y (float) –
y
coordinate [nm]z (float) –
z
coordinate [nm]
- Bzxx_method(x, y, z)[source]#
Calculate magnetic field second derivative \(B_{zxx}\)/
\(B_{zxx} \equiv \partial^2 B_z / \partial x^2\) [ \(\mathrm{mT} \; \mathrm{nm}^{-2}\)] The magnetic field’s second derivative is given by the following:
\[B_{zxx} = \dfrac{\partial B_z}{\partial z} = \dfrac{\mu_0 M_s}{4 \pi} \sum_{i=1}^2 \sum_{j=1}^2 \sum_{k=1}^2(-1)^{i+j+k} \left( \dfrac{-(x-x_i)(y-y_j)(z-z_k) (3(x-x_i)^2 +2(y-y_j)^2 + 3(z-z_k)^2)} {((x-x_i)^2 + (y-y_j)^2 + (z-z_k)^2)^{3/2} ((x-x_i)^2 + (z-z_k)^2)^2} \right)\]with the variables defined above. :param float x:
x
coordinate [nm] :param float y:y
coordinate [nm] :param float z:z
coordinate [nm]
- class mrfmsim_marohn.component.magnet.SphereMagnet(radius, mu0_Ms, origin)[source]#
Bases:
mrfmsim.component.ComponentBase
Spherical magnet object with its Bz, Bzx, Bzxx calculations.
- Bz_method(x, y, z)[source]#
Calculate magnetic field \(B_z\) [mT]. :param float x: x coordinate of sample grid [nm] :param float y: y coordinate of sample grid [nm] :param float z: z coordinate of sample grid [nm] The magnetic field is calculated as
\[B_z = \dfrac{\mu_0 M_s}{3} \left( 3 \dfrac{Z^2}{R^5} - \dfrac{1}{R^3} \right) R = \sqrt{X^2+Y^2+Z^2}\]Here \((x,y,z)\) is the location at which we want to know the field; \((x_0, y_0, z_0)\) is the location of the center of the magnet; \(r\) is the radius of the magnet; \(X = (x-x_0)/r\), \(Y = (y-y_0)/r\), and \(Z = (z-z_0)/r\) are normalized distances to the center of the magnet; \(\mu_0 M_s\) is the magnetic sphere’s saturation magnetization in mT.
- Bzx_method(x, y, z)[source]#
Calcualte magnetic field gradient \(B_{zx}\).
\(B_{zx} \equiv \partial B_z / \partial x\) [ \(\mathrm{mT} \: \mathrm{nm}^{-1}\) ]. With \(X\), \(Y\), \(Z\), \(R\), \(r\), and \(\mu_0 M_s\) defined in Bz(x, y, z), the magnetic field gradient is calculated as
\[B_{zx} = \dfrac{\partial B_z}{\partial z} = \dfrac{\mu_0 M_s}{r} X \: \left( \dfrac{1}{R^5} - 5 \dfrac{Z^2}{R^7} \right) R = \sqrt{X^2+Y^2+Z^2}\]- Parameters
x (float) – x coordinate of sample grid [nm]
y (float) – y coordinate of sample grid [nm]
z (float) – z coordinate of sample grid [nm]
- Returns
magnetic field gradient
- Return type
np.array
- Bzxx_method(x, y, z)[source]#
Calculate magnetic field second derivative \(B_{zxx}\).
\(B_{zxx} \equiv \partial^2 B_z / \partial x^2\) [\(\mathrm{mT} \: \mathrm{nm}^{-2}\)]. The inputs are With \(X\), \(Y\), \(Z\), \(R\), \(r\), and \(\mu_0 M_s\) defined as above, the magnetic field second derivative is calculated as
\[B_{zxx} = \dfrac{\partial B_z}{\partial z} = \dfrac{\mu_0 M_s}{r^2} \: \left( \dfrac{1}{R^5} - 5 \dfrac{X^2}{R^7} - 5 \dfrac{Z^2}{R^7} + 35 \dfrac{X^2 Z^2}{R^9} \right) R = \sqrt{X^2+Y^2+Z^2}\]- Parameters
x (float) – x coordinate of sample grid [nm]
y (float) – y coordinate of sample grid [nm]
z (float) – z coordinate of sample grid [nm]
- Returns
magnetic field second derivative
- Return type
np.array