Optimal Design of a New Rotating Magnetic Beacon Structure Based on Halbach Array

: At present, the magnetic signals generated by the common artiﬁcial magnetic beacons change periodically with sinusoidal law, and there is a multi-value problem in measuring the target orientation by using the phase information of the magnetic signals. According to the characteristics of Halbach array, a kind of artiﬁcial magnetic beacon based on Halbach array is studied. This beacon has the characteristics of magnetic signal aggregation, which can avoid the multi-value problem and facilitate the extraction of phase information. Firstly, the array model is established with MATLAB, the magnetization direction of each permanent magnet is adjusted, and particle swarm optimization is used to ﬁnd the structural parameters with the strongest magnetic ﬁeld characteristics. Finally, COMSOL physical simulation software is used to verify the usability of the proposed structure.


Introduction
Low-frequency magnetic field signals [1][2][3][4][5] have excellent properties such as high penetration, strong robustness, and easy extraction, and are suitable for positioning applications with high accuracy requirements in complex scenes. In the past, low-frequency magnetic field signals have been generated by energized solenoids [6,7], but, with this method, the energy loss is large and the magnetic field strength is limited. With the progress of material technology [8][9][10][11], permanent magnets made of strongly magnetic materials can now generate low-frequency magnetic field signals with longer propagation distances after rotation. In order to make better use of the advantages of low-frequency magnetic signals, experts and scholars worldwide have carried out research on this topic. In order to solve the problem of building walls blocking GPS signals in indoor navigation, the University of Michigan [12] proposed a method relying on multi-magnetic beacon area positioning based on electronic equipment. Within larger buildings, the positioning accuracy is higher, but, in practice, the complex electromagnetic environment will increase the computing load of electronic equipment, resulting in large errors. Starting from the principle of magnetic gradient tensor, P.W. Schmidt et al. [13] analyzed the advantages of magnetic gradient tensor in magnetic source representation and proposed the idea of applying magnetic gradient tensor to localization. By deploying multiple tensor gradiometers, R.F. Wiegert [14] designed a portable ranging and positioning robot based on artificial magnetic signal (MagSTAR), which could detect and calibrate magnetic targets. However, the site selected in the experiment was open, so the positioning performance of this machine in a complex electromagnetic environment could not be well proved. With the help of the magnetic gradient tensor algorithm, Deng Guoqing [15] of the China University of Geosciences proposed a real-time positioning method for horizontal directional drilling based on magnetic beacon positioning, which has important engineering application value. However, this method requires high-precision measurement of the ambient magnetic field in advance, and it is relatively complex. Weapon engineering student Lin Pengfei [16] applied magnetic beacon positioning to their ship, and considered a rotating propeller as a rotating magnetic dipole. The magnetic target location was calculated with the aid of magnetic gradient tensor inversion. However, in the process of ship motion, the next measurement point could only be determined by the preset value; with the increase in distance, the localization algorithm produces larger errors. Starting from the magnetic source, Wang Run [17] designed and optimized the structure of a magnetic beacon, providing an effective solution for the limited transmission distance of the magnetic signal and the difficulty of signal extraction. However, for now, the above location methods require a high precision magnetic signal amplitude value, so the increase of magnetic positioning accuracy is mainly restricted to signal measurement. Furthermore, at the time of the measurement of a magnetic signal amplitude magnetometer, the cluttered electromagnetic environment, strong magnetic anomalous field and rapid attenuation of magnetic signal with increasing increase need to be solved.
In radio navigation technology, the orientation information of the target is often combined with the position positioning, which has obvious positioning advantages. Therefore, in order to solve the problem that the amplitude positioning accuracy is not high enough, the radio navigation technology can be referred to, and the phase angle measurement method can be used to measure the target's orientation information. The literature [18] on low-frequency magnetic field signals verifies that the phase information of signals can correspond well with the orientation information of targets. However, the current magnetic signals generated by the existing magnetic beacons are all sinusoidal periodic changes, and there is a multi-value problem when using the phase information of the signal to measure the angle. Therefore, it is necessary to re-design the beacon so that it can generate the characteristic strong magnetic signal with only one maximum value within the period. A Halbach array is a kind of magnet structure that generates the strongest magnetic fields by arranging magnets with different magnetization directions in a certain pattern. Klaus [19] an American scholar, discovered this special structure in an electron acceleration experiment and gradually improved it, and finally formed the Halbach magnetic array, which enhanced the field strength in one direction and weakened the field strength on the other side. Zhu and Howe [20] calculated and analyzed the performance and potential applications of radial and axial fields, slotted and non-slotted, rotating and linear, and spherical Halbach magnetization arrays on the basis of commonly used Halbach arrays. Chen, Wang, and Bao [21] established the magnetic field model with the Fourier series method, analyzed the one-sided flux density characteristics of the Halbach array, and studied a new type of magnetic switchable device based on the Halbach array, which improved the utilization rate of a magnet. Chen [22] innovated the traditional Halbach array by placing the Halbach magnetic array on the upper and lower sides of the conductive plate and derived a threedimensional analysis of the model. By optimizing the geometric parameters of the model, the applicability of the model on the point dynamic suspension device was verified. With the development of magnetic material technology, Angelike S. [23] studied the tunable linear Halbach array of a kind of conductive nanoparticle. By adjusting the magnetization mode and field distribution of the particles in the array, a relatively large area of a high magnetic field could be generated.
Currently, Halbach arrays are mostly used in magnetic levitation and motor technologies, which are dedicated to unilateral magnetization enhancement capability and magnetic field utilization efficiency, but the characteristics of such magnetic fields are not strong enough to meet the signal requirements of phase-based goniometry methods. In this paper, a fiducial model consisting of seven permanent magnets is established by deriving the magnetic field distribution of the Halbach array, then changing the magnetization direction of permanent magnets in the structure and analyzing the variation of magnetic fields on both sides of the array, so that a magnetization angle with better unilateral magnetic aggregation effect is determined. On this basis, the particle swarm optimization algorithm is used to adjust and optimize the size of the permanent magnets in the structure to obtain a set of structural parameters with the strongest magnetic field characteristics. Finally, the Appl. Sci. 2022, 12, 10506 3 of 16 modeling data of the optimized structure are compared with the COMSOL finite element simulation results to prove the usability of the structure. The new beacon structure proposed in this paper has more important implications for further research based on the principle of artificial magnetic beacon direction finding.

Derivation of Halbach Array Magnetic Field Strength Formulas
The general analytical calculation method to study the magnetic field distribution of rectangular permanent magnets is the surface current method, with basic principles based on Ampere's Molecular Circulation Hypothesis. Assuming that the interior of each permanent magnet consists of several particles with charged circulation, as shown in Figure 1, then each particle can be regarded as a tiny magnet, whose sides are equivalent to the N and S poles. When the internal particles are neatly arranged, as shown in Figure 2, it shows that there is only surface current but no internal current. Therefore, the external magnetic field can be regarded as the sum of the magnetic fields generated by the surface current. algorithm is used to adjust and optimize the size of the permanent magnets in the structure to obtain a set of structural parameters with the strongest magnetic field characteristics. Finally, the modeling data of the optimized structure are compared with the COM-SOL finite element simulation results to prove the usability of the structure. The new beacon structure proposed in this paper has more important implications for further research based on the principle of artificial magnetic beacon direction finding.

Derivation of Halbach Array Magnetic Field Strength Formulas
The general analytical calculation method to study the magnetic field distribution of rectangular permanent magnets is the surface current method, with basic principles based on Ampere's Molecular Circulation Hypothesis. Assuming that the interior of each permanent magnet consists of several particles with charged circulation, as shown in Figure  1, then each particle can be regarded as a tiny magnet, whose sides are equivalent to the N and S poles. When the internal particles are neatly arranged, as shown in Figure 2, it shows that there is only surface current but no internal current. Therefore, the external magnetic field can be regarded as the sum of the magnetic fields generated by the surface current. The magnetization current of a uniformly magnetized dielectric is only at the surface, and the magnetic field of a permanent magnet can be regarded as generated by the magnetization current on the surface. A permanent magnet with a magnetization of M is shown in Figure 3.  algorithm is used to adjust and optimize the size of the permanent magnets in the structure to obtain a set of structural parameters with the strongest magnetic field characteristics. Finally, the modeling data of the optimized structure are compared with the COM-SOL finite element simulation results to prove the usability of the structure. The new beacon structure proposed in this paper has more important implications for further research based on the principle of artificial magnetic beacon direction finding.

Derivation of Halbach Array Magnetic Field Strength Formulas
The general analytical calculation method to study the magnetic field distribution of rectangular permanent magnets is the surface current method, with basic principles based on Ampere's Molecular Circulation Hypothesis. Assuming that the interior of each permanent magnet consists of several particles with charged circulation, as shown in Figure  1, then each particle can be regarded as a tiny magnet, whose sides are equivalent to the N and S poles. When the internal particles are neatly arranged, as shown in Figure 2, it shows that there is only surface current but no internal current. Therefore, the external magnetic field can be regarded as the sum of the magnetic fields generated by the surface current. The magnetization current of a uniformly magnetized dielectric is only at the surface, and the magnetic field of a permanent magnet can be regarded as generated by the magnetization current on the surface. A permanent magnet with a magnetization of M is shown in Figure 3. The magnetization current of a uniformly magnetized dielectric is only at the surface, and the magnetic field of a permanent magnet can be regarded as generated by the magnetization current on the surface. A permanent magnet with a magnetization of M is shown in Figure 3. According to the surface current method, assuming that the surface current is uniformly distributed and the density is k, the relationship between the magnetization M of the permanent magnet and the surface current density K can be expressed as follows: According to the surface current method, assuming that the surface current is uniformly distributed and the density is k, the relationship between the magnetization M of the permanent magnet and the surface current density K can be expressed as follows: where n is the tangent normal vector. Therefore, the components of magnetizing current density in the X direction and Y direction can be expressed as: A rectangular permanent magnet has six faces, and its three-dimensional magnetic field can be regarded as the superposition of the magnetic fields generated by the currents in the six faces. Since the object studied in this paper is used as a magnetic beacon, the commonly used magnetization direction does not include the Z component, so only the magnetization direction on the XOY plane is considered in this paper. As shown in Figure 4, the total magnetic field can be replaced by the superposition of magnetic fields of six surface currents: ABB A , BCC B , CDD C , DAA D , A B C D , ABCD. According to the surface current method, assuming that the surface current is uniformly distributed and the density is k, the relationship between the magnetization M of the permanent magnet and the surface current density K can be expressed as follows: where n is the tangent normal vector. Therefore, the components of magnetizing current density in the X direction and Y direction can be expressed as: A rectangular permanent magnet has six faces, and its three-dimensional magnetic field can be regarded as the superposition of the magnetic fields generated by the currents in the six faces. Since the object studied in this paper is used as a magnetic beacon, the commonly used magnetization direction does not include the Z component, so only the magnetization direction on the XOY plane is considered in this paper. As shown in Figure  4, the total magnetic field can be replaced by the superposition of magnetic fields of six surface currents:  According to Equation (2), the magnetic field generated by the permanent magnet at a certain point in space can be expressed as: can be generated by six surface currents, respectively: According to Equation (2), the magnetic field generated by the permanent magnet at a certain point in space can be expressed as: can be generated by six surface currents, respectively: As shown in Figure 5, each surface current can be equivalent to the superposition of a quantity of line current elements. According to Biot-Savart law, the magnetic field generated at P (x, y, z) by finite-length current elements can be expressed as follows: As shown in Figure 5, each surface current can be equivalent to the superposition of a quantity of line current elements. According to Biot-Savart law, the magnetic field generated at P (x, y, z) by finite-length current elements can be expressed as follows: Therefore, it can be known from Equation (5), that for the permanent magnet shown in Figure 4, the current density of surface ABB'A' is ky, and the magnetic field generated by the surface current ABB'A' at P (x, y, z) can be expressed as follows: where the vertical distance from point P to the line current satisfies By integrating the magnetic field generated by the line current source, the following can be obtained: By sorting out Equations (7) and (8), we can get: Therefore, it can be known from Equation (5), that for the permanent magnet shown in Figure 4, the current density of surface ABB A is k y , and the magnetic field generated by the surface current ABB A at P (x, y, z) can be expressed as follows: where the vertical distance from point P to the line current satisfies d = x−l/2 cosθ . By integrating the magnetic field generated by the line current source, the following can be obtained: By sorting out Equations (7) and (8), we can get: In Equation (9), the sign function sgn(λ) satisfies sgn(λ) = x−l/2 ). Similarly, by integrating the magnetic field generated by the current on the line of opposite BCC'B' at P (x, y, z), we can obtain: In Equation (10), variable symbol c = z+w/2 x+l/2 , d = z+w/2 x−l/2 , θ 2,1 = arctan( y+h/2 z+w/2 ), θ 2,2 = arctan( y−h/2 z+w/2 ). For the line current on surface CDD'C', it can be regarded as the reverse of the line current on surface ABB'A' and is obtained by translating l along the X-axis. Therefore, the magnetic field generated by surface CDD'C' can be expressed as: In Equation (11), variable symbol e = x+l/2 For the line current on surface ADD'A', it can be regarded as the reverse of the line current on surface BCC'B' and is obtained by translating w along the Z-axis. Therefore, the magnetic field generated by surface ADD'A' can be expressed as: In Equation (12), variable symbol For surface current A'B'C'D', its current density is k x , so the magnetic field generated by a line current on the surface is: By integrating the line current B l−A B C D , we can get: In Equation (14), variable symbol k = Similarly, by integrating the magnetic field generated by the current on the line of opposite ADD'A' at P (x, y, z), we can obtain: In Equation (15), variable symbol p = z−w/2 y+h/2 , q = z−w/2 y−h/2 , θ 6,1 = arctan( x+l/2 z−w/2 ), For the line current on surface ABCD, it can be regarded as the reverse of the line current on surface A'B'C'D' and is obtained by translating h along the Y-axis. Therefore, the magnetic field generated by surface ABCD can be expressed as: In Equation (16), variable symbol s = . For the line current on surface BCC'B', it can be regarded as the reverse of the line current on surface ADD'A' and is obtained by translating w along the Z-axis. Therefore, the magnetic field generated by surface BCC'B' can be expressed as: In Equation (17), (17) describe the distribution law of the magnetic field of a single permanent magnet. Then, seven identical permanent magnets are placed according to the Halbach array, as shown in Figure 6. The angles between the magnetization direction of each permanent magnet and the positive Y-axis are set as α n , then the total external magnetic field is the superposition of all monomer magnetic fields. If the first permanent magnet on the left is taken as the starting point, the magnetic field produced by other permanent magnets can be regarded as the current on each surface of the first permanent magnet generated by coordinate translation and rotation. For the line current on surface BCC'B', it can be regarded as the reverse of the line current on surface ADD'A' and is obtained by translating w along the Z-axis. Therefore, the magnetic field generated by surface BCC'B' can be expressed as: (17) In Equation (17) Equations (9-17) describe the distribution law of the magnetic field of a single permanent magnet. Then, seven identical permanent magnets are placed according to the Halbach array, as shown in Figure 6. The angles between the magnetization direction of each permanent magnet and the positive Y-axis are set as n α , then the total external magnetic field is the superposition of all monomer magnetic fields. If the first permanent magnet on the left is taken as the starting point, the magnetic field produced by other permanent magnets can be regarded as the current on each surface of the first permanent magnet generated by coordinate translation and rotation. When the magnetic fields generated by the seven magnetic blocks are superimposed successively, the external magnetic field of the array can be expressed as: B (x (n 1) , y, z,α )

The Effect of Changing the Direction of Magnetization on the Distribution of the Magnetic Field
A Halbach magnetic array is designed to achieve the enhancement of a unilateral magnetic field by adjusting the magnetization direction of each magnet. Therefore, in order to further strengthen the unilateral magnetic field cohesion of the array, the influence law of the magnetization direction of the permanent magnets on the magnetic field distribution of the array is first analyzed. Here, the ternary linear array is chosen, as shown in Figure 7. When the magnetic fields generated by the seven magnetic blocks are superimposed successively, the external magnetic field of the array can be expressed as:

The Effect of Changing the Direction of Magnetization on the Distribution of the Magnetic Field
A Halbach magnetic array is designed to achieve the enhancement of a unilateral magnetic field by adjusting the magnetization direction of each magnet. Therefore, in order to further strengthen the unilateral magnetic field cohesion of the array, the influence law of the magnetization direction of the permanent magnets on the magnetic field distribution of the array is first analyzed. Here, the ternary linear array is chosen, as shown in Figure 7. Appl. Sci. 2022, 12, x FOR PEER REVIEW 9 of 17 The angle between the magnetization direction of the three permanent magnets and the positive direction of the Y-axis is 1 α , 2 α , 3 α , and the magnetization direction is adjusted respectively for simulation. Firstly, the included angle is adjusted to °°−°1  Then, the included angle is adjusted to =°=°= −°1 2 3 α 90 ,α 180 ,α 90 , and the magnetic flux distribution of the ternary linear array is shown in Figure 9. Finally, the included angle is adjusted to =°=°= −°1 2 3 α 135 ,α 180 ,α 135 , and the magnetic flux distribution of the ternary linear array is shown in Figure 10. It can be seen from the magnetic flux distribution under different conditions that the magnetic accumulation effect is obvious on one side of the array under the three included angles. In order to further compare the effect, two measurement paths are set on both sides of the positive and negative Y-axis. That is, from P1 (−4, −4, 0) to P2 (4, −4, 0) and from P3 (−4, 4, 0) to P4 (4, 4, 0), the magnetic field intensity on both sides was collected and plotted, as shown in Figure 11. The angle between the magnetization direction of the three permanent magnets and the positive direction of the Y-axis is α 1 , α 2 , α 3 , and the magnetization direction is adjusted respectively for simulation. Firstly, the included angle is adjusted to α 1 = 45 • , α 2 = 180 • , α 3 = −45 • . The magnetic flux distribution of the three-element linear array is shown in Figure 8. The angle between the magnetization direction of the three permanent magnets and the positive direction of the Y-axis is 1 α , 2 α , 3 α , and the magnetization direction is adjusted respectively for simulation. Firstly, the included angle is adjusted to °°−°1  Then, the included angle is adjusted to =°=°= −°1 2 3 α 90 ,α 180 ,α 90 , and the magnetic flux distribution of the ternary linear array is shown in Figure 9. Finally, the included angle is adjusted to =°=°= −°1 2 3 α 135 ,α 180 ,α 135 , and the magnetic flux distribution of the ternary linear array is shown in Figure 10. It can be seen from the magnetic flux distribution under different conditions that the magnetic accumulation effect is obvious on one side of the array under the three included angles. In order to further compare the effect, two measurement paths are set on both sides of the positive and negative Y-axis. That is, from P1 (−4, −4, 0) to P2 (4, −4, 0) and from P3 (−4, 4, 0) to P4 (4, 4, 0), the magnetic field intensity on both sides was collected and plotted, as shown in Figure 11. Then, the included angle is adjusted to α 1 = 90 • , α 2 = 180 • , α 3 = −90 • , and the magnetic flux distribution of the ternary linear array is shown in Figure 9. The angle between the magnetization direction of the three permanent magnets and the positive direction of the Y-axis is 1 α , 2 α , 3 α , and the magnetization direction is adjusted respectively for simulation. Firstly, the included angle is adjusted to °°−°1  Then, the included angle is adjusted to =°=°= −°1 2 3 α 90 ,α 180 ,α 90 , and the magnetic flux distribution of the ternary linear array is shown in Figure 9. Finally, the included angle is adjusted to =°=°= −°1 2 3 α 135 ,α 180 ,α 135 , and the magnetic flux distribution of the ternary linear array is shown in Figure 10. It can be seen from the magnetic flux distribution under different conditions that the magnetic accumulation effect is obvious on one side of the array under the three included angles. In order to further compare the effect, two measurement paths are set on both sides of the positive and negative Y-axis. That is, from P1 (−4, −4, 0) to P2 (4, −4, 0) and from P3 (−4, 4, 0) to P4 (4, 4, 0), the magnetic field intensity on both sides was collected and plotted, as shown in Figure 11. Finally, the included angle is adjusted to α 1 = 135 • , α 2 = 180 • , α 3 = −135 • , and the magnetic flux distribution of the ternary linear array is shown in Figure 10. The angle between the magnetization direction of the three permanent magnets and the positive direction of the Y-axis is 1 α , 2 α , 3 α , and the magnetization direction is adjusted respectively for simulation. Firstly, the included angle is adjusted to °°−°1  Then, the included angle is adjusted to =°=°= −°1 2 3 α 90 ,α 180 ,α 90 , and the magnetic flux distribution of the ternary linear array is shown in Figure 9. Finally, the included angle is adjusted to =°=°= −°1 2 3 α 135 ,α 180 ,α 135 , and the magnetic flux distribution of the ternary linear array is shown in Figure 10. It can be seen from the magnetic flux distribution under different conditions that the magnetic accumulation effect is obvious on one side of the array under the three included angles. In order to further compare the effect, two measurement paths are set on both sides of the positive and negative Y-axis. That is, from P1 (−4, −4, 0) to P2 (4, −4, 0) and from P3 (−4, 4, 0) to P4 (4, 4, 0), the magnetic field intensity on both sides was collected and plotted, as shown in Figure 11. It can be seen from the magnetic flux distribution under different conditions that the magnetic accumulation effect is obvious on one side of the array under the three included angles. In order to further compare the effect, two measurement paths are set on both sides of the positive and negative Y-axis. That is, from P 1 (−4, −4, 0) to P 2 (4, −4, 0) and from P 3 (−4, 4, 0) to P 4 (4, 4, 0), the magnetic field intensity on both sides was collected and plotted, as shown in Figure 11. α = 135 ,α = 180 ,α = 135 , the magnetic field on the negative half-axis side of the Y-axis has the best aggregation effect, but the magnetic field on the positive half-axis side of the Y-axis is also larger, and the magnetic field is not strong enough in character; when °°−°1   −4, 0). So, the obtained comparison curve of magnetic field intensity change is shown in Figure 13.  It can be seen from the figure that when α 1 = 135 • , α 2 = 180 • , α 3 = −135 • , the magnetic field on the negative half-axis side of the Y-axis has the best aggregation effect, but the magnetic field on the positive half-axis side of the Y-axis is also larger, and the magnetic field is not strong enough in character; when α 1 = 45 • , α 2 = 180 • , α 3 = −45 • , the aggregation effect on the negative half-axis side of the Y-axis is better, and the weakening effect on the positive side of the Y-axis is the best. Generally, the Halbach array consists of seven parts, so, according to the simulation results of the ternary linear array, the magnetization direction of the seven-element linear array can be initially set as shown in Figure 12. It can be seen from the figure that when °°−°1 2 3 α = 135 ,α = 180 ,α = 135 , the magnetic field on the negative half-axis side of the Y-axis has the best aggregation effect, but the magnetic field on the positive half-axis side of the Y-axis is also larger, and the magnetic field is not strong enough in character; when °°−°1   −4, 0). So, the obtained comparison curve of magnetic field intensity change is shown in Figure 13.   −4, 0). So, the obtained comparison curve of magnetic field intensity change is shown in Figure 13. It can be seen from the figure that when =°Δα 45 , the magnetic field of the negative half-axis of the Y-axis has the best aggregation, and the magnetic field of the positive halfaxis of the Y-axis is weakened a lot, so the magnetic field has the best characteristics. On this basis, the length of the permanent magnet is adjusted so that the array can produce a magnetic field with better characteristics. In this paper, particle swarm optimization is chosen to optimize the structure.

The Effect of Changing the Size of the Permanent Magnet on the Magnetic Field Distribution
Assuming that the measurement point P (x, y, z) is known, the height h, width w, and magnetization direction α of each permanent magnet are fixed, the material of the permanent magnet is consistent, and only the length l of each permanent magnet is changed, then the total magnetic field is an expression B(l) on the l variable, and the length l satisfies the constraint that: The length l is optimized by the particle swarm optimization algorithm, and the optimization process is shown in Figure 14. It can be seen from the figure that when ∆α = 45 • , the magnetic field of the negative half-axis of the Y-axis has the best aggregation, and the magnetic field of the positive half-axis of the Y-axis is weakened a lot, so the magnetic field has the best characteristics. On this basis, the length of the permanent magnet is adjusted so that the array can produce a magnetic field with better characteristics. In this paper, particle swarm optimization is chosen to optimize the structure.

The Effect of Changing the Size of the Permanent Magnet on the Magnetic Field Distribution
Assuming that the measurement point P (x, y, z) is known, the height h, width w, and magnetization direction α of each permanent magnet are fixed, the material of the permanent magnet is consistent, and only the length l of each permanent magnet is changed, then the total magnetic field is an expression B(l) on the l variable, and the length l satisfies the constraint that: The length l is optimized by the particle swarm optimization algorithm, and the optimization process is shown in Figure 14.  The optimal solution can be obtained through optimization as follows: l 1 = l 7 = l.55 cm, l 2 = l 6 = 1.95 cm, l 3 = l 5 = 2.2 cm, l 4 = 2.6 cm. Set the measurement point as: from P 9 (−8, −4.5, 0) to P 10 (8, −4.5, 0); from P 11 (−8, 4.5, 0) to P 12 (8, −4.5, 0). The parameters obtained by optimization are substituted into the model to obtain the magnetic field intensity change curve in the positive and negative directions of the Y-axis of the array structure, and are compared with the structure before optimization, as shown in Figure 15. The optimal solution can be obtained through optimization as follows: l l = = 1 7 1.55cm , l l = = 2 6 1.95cm , l l = = 3 5 2.2cm , l = 4 2.6cm . Set the measurement point as: from P9 (−8, −4.5, 0) to P10 (8, −4.5, 0); from P11 (−8, 4.5, 0) to P12 (8, −4.5, 0). The parameters obtained by optimization are substituted into the model to obtain the magnetic field intensity change curve in the positive and negative directions of the Y-axis of the array structure, and are compared with the structure before optimization, as shown in Figure 15. It can be seen from the figure that the optimized array produces a stronger magnetic field aggregation in the direction of the negative half-axis of the Y-axis, a weaker magnetic field in the direction of the positive half-axis of the Y-axis, and a stronger characteristic of the total magnetic field.
On this basis, the linear array is changed to a non-linear array, as shown in Figure 16. Each permanent magnet differs in Z-axis in turn; firstly, set = Δh 0.5cm , then simulate and collect the magnetic field intensity on both positive and negative sides of the Y-axis, as shown in Figure 17. It can be seen from the figure that the optimized array produces a stronger magnetic field aggregation in the direction of the negative half-axis of the Y-axis, a weaker magnetic field in the direction of the positive half-axis of the Y-axis, and a stronger characteristic of the total magnetic field.
On this basis, the linear array is changed to a non-linear array, as shown in Figure 16. Each permanent magnet differs in Z-axis in turn; firstly, set ∆h = 0.5cm, then simulate and collect the magnetic field intensity on both positive and negative sides of the Y-axis, as shown in Figure 17.   The comparison graph shows that adjusting the linear array to a non-linear array can significantly enhance the magnetic field aggregation in the negative half-axis of the Y-axis by about 8 times, and there is no significant change in the magnetic field in the positive half-axis of the Y-axis. Therefore, the characteristics of the total magnetic field can be further enhanced by adjusting the parameter h. Let the permanent magnets be translated along the Y-axis and set Δh as 0.5 cm, 1 cm, 1.5 cm, 2 cm respectively, and set the measurement point as: from P9 (−8, −4.5, 0) to P10 (8, −4.5, 0); from P11 (−8, 4.5, 0) to P12 (8, −4.5, 0). The corresponding magnetic field intensity variation curves are shown in Figure 18. The comparison graph shows that adjusting the linear array to a non-linear array can significantly enhance the magnetic field aggregation in the negative half-axis of the Y-axis by about 8 times, and there is no significant change in the magnetic field in the positive half-axis of the Y-axis. Therefore, the characteristics of the total magnetic field can be further enhanced by adjusting the parameter h. Let the permanent magnets be translated along the Y-axis and set ∆h as 0.5 cm, 1 cm, 1.5 cm, 2 cm respectively, and set the measurement point as: from P 9 (−8, −4.5, 0) to P 10 (8, −4.5, 0); from P 11 (−8, 4.5, 0) to P 12 (8, −4.5, 0). The corresponding magnetic field intensity variation curves are shown in Figure 18.  The comparison graph shows that adjusting the linear array to a non-linear array can significantly enhance the magnetic field aggregation in the negative half-axis of the Y-axis by about 8 times, and there is no significant change in the magnetic field in the positive half-axis of the Y-axis. Therefore, the characteristics of the total magnetic field can be further enhanced by adjusting the parameter h. Let the permanent magnets be translated along the Y-axis and set Δh as 0.5 cm, 1 cm, 1.5 cm, 2 cm respectively, and set the measurement point as: from P9 (−8, −4.5, 0) to P10 (8, −4.5, 0); from P11 (−8, 4.5, 0) to P12 (8, −4.5, 0). The corresponding magnetic field intensity variation curves are shown in Figure 18. It can be seen from the figure that as ∆h increases, the magnetic field intensity in the negative half-axis direction of the Y-axis becomes larger and more aggregated, but the corresponding magnetic field intensity at both ends of the array in the positive half-axis direction keeps increasing and the characteristic of the total magnetic field weakens. By analyzing the data, it can be concluded that the magnetic field is better characterized when ∆h = 1.5 cm.

Simulation Experiment Verification
COMSOL physics simulation software is based on mathematical models to derive and represent the laws of physics, and the main way of working is to discretize the whole analysis, namely finite element analysis (FEA). By inputting the dimensional parameters of the permanent magnet, the direction and size of the magnetic flux, and the parameters of the environmental medium, an infinitely close model of the real permanent magnet can be simulated. In this paper, a structure that can generate signals that meet the requirements of phase-type angle measurement was obtained through MALAB modeling optimization, and then the structural parameters were input into the COMSOL physical simulation software to obtain the model as shown in Figure 19. The material used in this model is NdFeB (N50), the residual flux density Br is 1.4 T, and the mesh size needs to be set before the simulation of magnetic field; the maximum mesh size is set as 0.1 cm. After the simulation, we can obtain the magnetic flux distribution of the optimized structure, as shown in Figure 20.
field is obtained through a series of optimizations and comparisons: width of each permanent magnet is = w 2cm ; height of each permanent magnet is h = 2cm ; lengths of each permanent magnet are l l = = 1 7 1.55cm , 2 6 l l = = 1.95cm , 3 5 l l = = 2.2cm , l 4 = 2.6cm ; position difference between adjacent permanent magnets in the Z-axis Δh = 1.5cm ; the angles between the direction of magnetization of each permanent magnet and the positive direction of the Z-axis are

Simulation Experiment Verification
COMSOL physics simulation software is based on mathematical models to derive and represent the laws of physics, and the main way of working is to discretize the whole analysis, namely finite element analysis (FEA). By inputting the dimensional parameters of the permanent magnet, the direction and size of the magnetic flux, and the parameters of the environmental medium, an infinitely close model of the real permanent magnet can be simulated. In this paper, a structure that can generate signals that meet the requirements of phase-type angle measurement was obtained through MALAB modeling optimization, and then the structural parameters were input into the COMSOL physical simulation software to obtain the model as shown in Figure 19. The material used in this model is NdFeB (N50), the residual flux density Br is 1.4 T, and the mesh size needs to be set before the simulation of magnetic field; the maximum mesh size is set as 0.1 cm. After the simulation, we can obtain the magnetic flux distribution of the optimized structure, as shown in Figure 20.  To further verify the optimized structure, the magnetic field intensity on both sides of the array is collected to get the magnetic field intensity variation curve with measurement points: from P13 (−8, −6, 0) to P14 (8, −6, 0); from P15 (−8, 6, 0) to P16 (8, 6, 0). Meanwhile, the same measurement points are set in the mathematical model of the structure, so the comparative data plot of the mathematical modeling and simulation model can be obtained, as shown in Figure 21. The error analysis of both is shown in Figure 22. To further verify the optimized structure, the magnetic field intensity on both sides of the array is collected to get the magnetic field intensity variation curve with measurement points: from P 13 (−8, −6, 0) to P 14 (8, −6, 0); from P 15 (−8, 6, 0) to P 16 (8,6,0). Meanwhile, the same measurement points are set in the mathematical model of the structure, so the comparative data plot of the mathematical modeling and simulation model can be obtained, as shown in Figure 21. The error analysis of both is shown in Figure 22.
To further verify the optimized structure, the magnetic field intensity on both sides of the array is collected to get the magnetic field intensity variation curve with measurement points: from P13 (−8, −6, 0) to P14 (8, −6, 0); from P15 (−8, 6, 0) to P16 (8,6,0). Meanwhile, the same measurement points are set in the mathematical model of the structure, so the comparative data plot of the mathematical modeling and simulation model can be obtained, as shown in Figure 21. The error analysis of both is shown in Figure 22.  To further verify the optimized structure, the magnetic field intensity on both sides of the array is collected to get the magnetic field intensity variation curve with measurement points: from P13 (−8, −6, 0) to P14 (8, −6, 0); from P15 (−8, 6, 0) to P16 (8,6,0). Meanwhile, the same measurement points are set in the mathematical model of the structure, so the comparative data plot of the mathematical modeling and simulation model can be obtained, as shown in Figure 21. The error analysis of both is shown in Figure 22.  From Figure 21, it can be seen that the magnetic field strength generated by the magnetic array simulated with COMSOL physical simulation software is slightly smaller than that generated by the structure modeled with MATLAB software, and the error between the two can be controlled in the range of 0.0008 T-0.00115 T. Through analysis, the main reasons for the error may be the following: (1) the permanent magnet model derived from the mathematical equation is completely idealized, and not much consideration is given to the influence of the environment, while the simulation using COMSOL physics simulation software needs to consider the magnetic properties of the material of the permanent magnet, the environment in which it is located, and is not completely idealized, so there are differences in the data between the two; (2) COMSOL physical simulation software for permanent magnets is based on the principle of finite element analysis, which is essentially a partitioning of the structure. Since each cell is not infinitely small, there is an error in the analysis of the small cells compared with the derivation of the formula, so there is an error accumulation in the analysis of the whole array. However, in general, the difference between the two is very small, and it can be considered that the array structure obtained by the optimization adjustment in this paper has very good usability.

Conclusions
In this paper, the magnetic field expression of a single rectangular permanent magnet is derived based on the surface current method, and the magnetic field expression of a multivariate magnetic array is obtained by superposition, which is modeled by MATLAB