1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/// Formulas for volumetric sources.
/// These are context-heavy and require some care to apply
/// in a way that is consistent with assumptions,
/// so they are kept out of the public API.
use crateMU0_OVER_4PI;
/// Magnetic flux density inside a uniformly magnetized sphere
/// with some radius and total magnetic moment.
///
/// The field outside the sphere is consistent with an ideal dipole, and
/// there is a discontinuity in the field at the surface of the sphere
/// consistent with the apparent discontinuity in material properties.
///
/// The dipole moment of the magnetized sphere can be calculated as
/// m = 4/3 pi R^3 M, where R is the sphere's outer radius and M is
/// the (vector) uniform magnetization.
///
/// Based on Griffith's 5e eqn 6.16 with some manipulation to phrase
/// in terms of dipole moment and to reduce float roundoff and number of operations.
///
/// The formula implemented here is
/// B = 2/3 mu_0 M
/// where M is the vector magnetization and r is the vector
/// from the center of the sphere to the observation point.
/// The magnetization M is then replaced with the formula above
/// in terms of the total magnetic moment.
///
/// References
///
/// * \[1\] “Griffith, D.J. (2024) Introduction to Electrodynamics. 5th Edition”
///
/// Arguments
///
/// * moment: (A-m^2) magnetic moment vector of the sphere
/// * outer_radius: (m) the radius of the sphere
///
/// Returns
///
/// * (bx, by, bz) [T] magnetic field components anywhere inside the sphere
pub
/// Magnetic vector potential inside a uniformly magnetized sphere
/// with some radius and total magnetic moment.
///
/// The field outside the sphere is consistent with an ideal dipole, and
/// there is a discontinuity in the field at the surface of the sphere
/// consistent with the apparent discontinuity in material properties.
///
/// The dipole moment of the magnetized sphere can be calculated as
/// m = 4/3 pi R^3 M, where R is the sphere's outer radius and M is
/// the (vector) uniform magnetization.
///
/// Based on Griffith's 5e eqn 6.16 with some manipulation to phrase
/// in terms of dipole moment, reduce float roundoff and number of operations,
/// and to extract vector potential.
///
/// The formula implemented here is
/// A = 1/3 mu_0 cross(M, r)
/// where M is the vector magnetization and r is the vector
/// from the center of the sphere to the observation point.
/// The magnetization M is then replaced with the formula above
/// in terms of the total magnetic moment.
///
/// References
///
/// * \[1\] “Griffith, D.J. (2024) Introduction to Electrodynamics. 5th Edition”
///
/// Arguments
///
/// * mhat_cross_rhat: (dimensionless) precalculated direction of A-field
/// * mmag: (A-m^2) magnitude of magnetic moment of the sphere
/// * rmag: (m) magnitude of radius vector from dipole origin to observation point
/// * outer_radius: (m) the radius of the sphere
///
/// Returns
///
/// * (ax, ay, az) [V-s/m] magnetic vector potential components at the target location
pub