1 class MagneticDipoleDipoleInteraction_ConstantIdenticalDipoles:
3 Interactions between two constant and identical magnetic dipoles.
5 The general magnetic dipole-dipole interaction potential is given by
7 - \frac{ \mu_0 }{ 4 \pi r^3 }
10 \left(\vec{m_1} \cdot \hat{r} \right)
11 \left(\vec{m_2} \cdot \hat{r} \right)
13 \vec{m_1} \cdot \vec{m_2}
16 where \f$ \mu_0 \f$ is the vacuum permeability, \f$ \hat{r} \f$ and
17 \f$ r \f$ are, respectively, the unit vector and length of the vector
18 \f$ \vec{r} \f$ that points from one dipole's position to the other's,
19 \f$ \vec{m_1} \f$ and \f$ \vec{m_2} \f$ are the magnetic dipole moments, and
20 \f$ \cdot \f$ denotes the inner product.
22 In the special case treated in this class, the magnetic dipole moments are
23 assumed to be constant throughout time in size and orientation. Therefore,
24 with \f$ m \f$ being the magnitude of the individual dipole moments and with
25 \f$ \hat{m} \f$ being the unit vector of the individual dipole moments, the
26 interaction potential is given by
28 - \frac{ \mu_0 m^2 }{ 4 \pi r^3 }
29 \left( 3 \left(\hat{m} \cdot \hat{r} \right)^2 - 1 \right)
33 def __init__(self, prefactor, orientation):
38 Throws if `prefactor` is neither `int` nor `float`.
40 Throws if `orientation` is not an instance of `Vector3DReal`.
42 Throws if `prefactor` is negative.
44 Throws if `orientation` is not a unit vector.
47 The term \f$ \frac{\mu_0 m^2}{4 \pi} \f$, which must be
49 @param[in] orientation
50 The orientation unit vector \f$ \hat{m} \f$ of the dipole
56 if not isinstance(prefactor, (int, float)):
58 if not isinstance(orientation, Vector3DReal):
63 if orientation.getLengthSquared() != 1.0:
73 Returns the term \f$ \frac{\mu_0 m^2}{4 \pi} \f$ as a `float`.
81 Returns the orientation unit vector \f$ \hat{m} \f$ of the dipole
82 moments as an instance of `Vector3DReal`.
90 Returns the potential for an input value of \f$ r \f$.
93 Throws if `r` is neither `int` nor `float` or `Vector3DReal`.
95 Throws if `r` is the zero vector.
98 The input value, which must may be a non-zero vector of type
104 if not isinstance(r, Vector3DReal):
107 r2 = r.getLengthSquared()
115 r_m3 = r_m2 / math.sqrt(r2)
118 return -self.
getPrefactor() * r_m3 * (3 * dot * dot * r_m2 - 1)