Skip to main content
Scientific Reports logoLink to Scientific Reports
. 2022 Jan 21;12:1119. doi: 10.1038/s41598-021-04246-z

A topology optimization algorithm for magnetic structures based on a hybrid FEM–BEM method utilizing the adjoint approach

Gregor Wautischer 1,, Claas Abert 1,2, Florian Bruckner 1, Florian Slanovc 1, Dieter Suess 1,2
PMCID: PMC8782837  PMID: 35064136

Abstract

A method to optimize the topology of hard as well as soft magnetic structures is implemented using the density approach for topology optimization. The stray field computation is performed by a hybrid finite element–boundary element method. Utilizing the adjoint approach the gradients necessary to perform the optimization can be calculated very efficiently. We derive the gradients using a “first optimize then discretize” scheme. Within this scheme, the stray field operator is self-adjoint allowing to solve the adjoint equation by the same means as the stray field calculation. The capabilities of the method are showcased by optimizing the topology of hard as well as soft magnetic thin film structures and the results are verified by comparison with an analytical solution.

Subject terms: Applied physics, Condensed-matter physics

Introduction

In many applications like magnetic sensors, magnetic storage, electric machines and so on, magnetic fields with specific spatial profiles are exploited in order to achieve a specific goal. The properties of magnetic fields are defined by the properties of the involved magnetic structures. Most commonly, in order to obtain a certain magnetic field, the geometry of a magnetic structure is optimized. This can e.g. be the geometry of a permanent magnet producing a well defined magnetic field, or a soft magnetic structure shaping the field possibly generated by an electric current. The process of optimizing the geometry of these structures can be very time consuming. A common approach is called geometry parameterization where the structure’s geometry is parameterized with relatively few parameters and the parameter region is investigated until an optimal solution is found. Geometry parameterization is one representative of a group of techniques summarized as shape optimization1. Another approach is to directly optimize the distribution of material within a given domain. This approach is called topology optimization2. It drastically increases the degrees of freedom (dofs) but allows for possibly better, geometric realizations of the considered system, independent of any introduced parameterizations. Successful applications of topology optimization of magnetic structures include the optimization of magnetic recording write heads3, of rotors of brushless DC motors4 and of electromagnetic actuators5,6.

In this paper a method to optimize the topology of magnetic structures is presented. The presented method is based on a highly efficient hybrid finite element–boundary element method (FEM–BEM) approach7 solving the magnetostatic Maxwell’s problem. In contrast to already presented finite element3,8 and finite differences9 algorithms using a FEM–BEM approach has the advantage that only the regions of interest need to be discretized reducing the dofs dramatically. Furthermore, in order to efficiently calculate gradients during optimization, the adjoint approach is utilized. Our method takes the B/H curve of a hard or soft magnetic material linearized at the working point as input and is able to include external fields generated by electric coils. After optimization, the result is an optimized magnetic structure and its stray field dependent magnetization state.

The algorithm is implemented on the basis of magnum.fe10 which in turn utilizes the finite element library FEniCS11. In particular FEniCS is used for the definition of the objective functionals and to automatically differentiate the involved partial derivatives.

The paper is structured as follows. In the first section the solution of the forward problem–the calculation of the stray field of a magnetic structure—is presented. In the following section the density approach to topology optimization is introduced. After that the gradient necessary to perform the optimization and the adjoint equation are introduced. Thereafter details of the numerical optimization are discussed and numerical experiments showcasing the capabilities of the method are presented. A detailed derivation of the gradient using the adjoint approach within a “first optimize then discretize” scheme is given in the appendix.

Forward problem

The stray field of a magnetic body consisting of a magnetic material with linear magnetic susceptibility χ and possibly a remanence magnetization Mr within an external magnetic field Hext, can be calculated starting from the magnetostatic Maxwell’s equation. Using the reduced scalar potential formulation the total magnetic field H is split into an external part Hext (created via currents outside of Ωm) and the curl-free induced magnetic field Hd. Expressing the induced field as gradient of a scalar potential u, Hd=-u finally yields

·1+χu-Hext-Mr=0. 1

In order to use the hybrid FEM–BEM approach, next R3 is divided into a region Ωm containing all magnetic material and a region R3\Ωm. Outside Ωm Eq. (1) then reduces to

Δu=0inR3\Ωm 2

and the following boundary and jump conditions apply

uΩm=0 3
1+χunΩm=χΩmn·Hext+n·Mr 4
urO1rforr, 5

where n is the outward pointing normal vector and ·Ω denotes the jump over the boundary Ω. The resulting system is solved using a hybrid FEM–BEM algorithm7.

Topology optimization

Topology optimization tries to find, within a predefined spatial domain Ωopt, the optimal material distribution with respect to a design goal. This can be achieved using the density approach for topology optimization12. Here, a scalar indicator function

ρx0,1,whereρx=0: no material1: material 6

is introduced, transforming the remanence magnetization MrMrρ=ρpMr as well as the susceptibility χχρ=ρpχ. Here, p is a parameter introduced in order to penalize intermediate values of 0ρ1 that are allowed during optimization12. However, it turns out that the impact of p is more complex as is investigated for each presented numerical experiment (see “Numerical experiments” section).

The forward problem then reads

Fu,ρ=·1+ρpχu-Hext-ρpMr=0, 7

where u is an at least twice and ρ an at least once differentiable function. Note, that after transformation into its weak form and shifting of the divergence operator onto the test function by application of partial integration, these conditions are relaxed and after discretization piecewise linear basis function P1 can be used for the scalar potential u and the scalar indicator function ρ only has to be constant within each element.

The numerical optimization is performed by casting the design goal into an objective functional J^ρ=JHρ,ρ and minimizing it using an iterative, gradient based optimization algorithm.

Adjoint approach

In order to efficiently minimize the reduced objective functional J^ρ containing the design goal, its gradient with respect to the design variable ρ, ρJ^ is needed. This is where the adjoint approach comes into play, offering a very efficient method to calculate the gradient. As derived in detail in the appendix (“Appendix” section) within a “first optimize then discretize” scheme, the gradient is given by

ρJ^=pρp-1χu-Hext-Mr·λ+RJρ, 8

where λ is the adjoint variable that is obtained by solving the adjoint equation

·1+ρpχλ-RJH=0 9

with boundary condition

λrO1rforr. 10

Here R are the Riesz representers of the corresponding functionals as introduced in “Appendix” section. Note, that the adjoint equation has the same form as the forward problem. Therefore, the same algorithm can be utilized to solve the forward as well as the adjoint equation.

Numerical experiments

In the following, the topology of thin film magnetic flux guide concentrators is optimized towards maximization of the vertical (y-)component of the magnetic field Hy inside the target domain Ωh. The objective functional that is to be minimized reads J^=-ΩhHydV. The geometry and the mesh used is depicted in Fig. 1 where also the the optimization domain (Ωopt) and the domain in which the magnetic field is evaluated (Ωh) is specified. Note that Ωm=ΩoptΩh. Note, that we use an irregular mesh in order to avoid any solution bias introduced by a given regularity. The presented numerical experiments include the usage of hard as well as soft magnetic material.

Figure 1.

Figure 1

Mesh and geometry used for the numerical experiments. Dimensions are given in µm. The thickness (z-dimension) of the thin film is 12.5 µm. The field box Ωh consists of 91 cells and the optimization region Ωopt consists of 16505 cells.

The potential u and the adjoint variable λ are calculated using piecewise linear basis functions P1 and the scalar indicator function ρ as well as χ, Mr, Hext and the derived strayfield -u and λ are constant within each element.

The optimizations are performed using the Scipy implementation of the limited-memory Broyden-Fletcher-Goldfarb-Shanno minimization algorithm with bounds (L-BFGS-B)13. Note, that as shown in14, common ready-to-use optimization algorithms such as this, are constructed to only receive coefficient vectors as input and internally use the euclidean (2) inner product to perform all necessary operations (e.g. approximation of the Hessian). Since here an optimization in a Hilbert spaces with the L2 inner product is performed, this leads to mesh dependent convergence rates. To prevent this, there exists the python package Moola15 that internally uses the correct inner product during optimization. However, in order to perform topology optimization bounds on the optimization variable ρ have to be enforced since 0ρ1 and so far, there is no optimization algorithm offered by Moola enabling bounds on the optimization variable. Furthermore, note that the L2 Riesz representer of the gradient is independent of the flux concentrator’s geometrical dimensions. However, the objective functional is not since it includes and integration over the volume Ωh. For the chosen geometry dimensions the gradient size is relatively large compared to the size of the objective functional. This leads to the L-BFGS-B algorithm terminating prematurely with problems during the line search, simply returning the initial distribution of ρ. This is since the Armijo rule, one of the Wolfe conditions necessary to end the line search is never met. The objective functional value exposed to the optimization algorithm, is therefore scaled to avoid this problem. This scaling does not alter the results since internally, the L-BFGS-B algorithm performs a quasi-Newton method on the gradient and the function value is only used during the line search.

For results of optimizations that terminate with dofs of ρ at intermediate values 0ρ1 a brute force regularization is applied where all dofs with ρ<0.5 are set to 0 and all dofs with ρ0.5 are set to 1.

Permanent magnet optimization

First, the topology for an ideal permanent magnet with susceptibility χ=0, remanence magnetization Mr=280000 A/m and the anisotropy axis chosen as the y-axis is optimized towards maximization of the vertical (y-)component of the magnetic field Hy inside the domain Ωh, as introduced above.

As presented in8 for a point like target domain, the optimal topology can be derived analytically by considering the magnetization inside Ωopt as being comprised of single dipoles μ. A dipole at a vertical (y-)distance produces a positive flux Byx at a point x for an horizontal (x-)distance of

x<2y. 11

The surface condition x=2y therefore shows that the analytical solution is a cone with an opening angle of α35.26. Note that the assumption of a point like target domain is still valid, since the changes due to the finite size of Ωh are too small to be resolved by the chosen mesh. The analytical solution is shown in Fig. 2, where it is compared to the optimal numerical solution.

Figure 2.

Figure 2

Optimized topology for the ideal permanent magnet and comparison with the analytical solution (green line).

For the ideal permanent magnet, the optimized topology, as shown in Fig. 2, produces a mean field H¯y=ΩhHydV/VΩh of 22.83 mT. This solution is found independently of the initial distribution of the density functional ρinit for a penalty parameter of p4. Furthermore, scaling the gradient has no influence on the obtained solution, but increasing the gradient size reduces the number of function evaluations nfev needed. This is since the size of the gradient determines how fast the dofs of ρ are set to 0 or 1. This shows, that the optimization problem in the case of zero susceptibility is linear in ρ as expected since for χ=0 the only source term in the forward problem (7) is given by ρpMr where Mr is constant. In Fig. 3 the value of the smallest dof in the gradient and nfev are plotted against the gradient scaling factor γ for p=1. As soon as the smallest dof is larger 1 for γ=103, all elements are set to 0 or 1 during the optimization, leaving no dofs with intermediate values of ρ and nfev reaches a minimum of 2.

Figure 3.

Figure 3

Dependence of nfev on γ and size of the gradient’s smallest dof value. The black horizontal line represents a value of 1.

Realistic hard magnetic material χ=0.2

Using a realistic hard magnetic material with a susceptibility of χ=0.2, the optimal solution found has a mean field of H¯y of 22.35 mT. This smaller mean field value compared to the ideal permanent magnet is due the effect of demagnetization. The optimal topology found (Fig. 4) differs only slightly from the topology obtained from the ideal permanent magnet optimization.

Figure 4.

Figure 4

Optimized topology for the optimization with χ=0.2.

The optimal solution is found independently of the initial distribution of the density functional ρ for p=1. For larger p-values the solution gets worse showing, that the optimization is no longer independent of the parameter p. However, for p4 the difference in the mean field is below 0.5%. Scaling the gradient again reduces the number of necessary function evaluations to perform the optimization nfev. However, since the optimization problem is no longer linear in ρ, the number of function evaluations nfev needed is larger than for the ideal permanent magnet case. In Fig. 5nfev in dependence of the gradient scaling factor γ for p=1 is shown. The optimization is fastest for a constant initial distribution of ρinit=1 where for γ10 nfev<250. Also, the optimization process terminates before all dofs of ρ are set to 0 or 1, although the number of dofs with an intermediate value of ρ is negligible for all simulations with p=1. It has been verified that no better solution is found by scaling the gradient down to γ=10-5. Note, that the topology obtained from the optimization using an ideal permanent magnetic material, for a realistic hard magnetic material with χ=0.2 produces a magnetic field that is only negligibly smaller (<0.1‰) than the optimal topology obtained using the realistic hard magnetic material during optimization. This confirms, that χ=0 is a good assumption for a permanent magnetic structure.

Figure 5.

Figure 5

Dependence of the number of necessary function evaluations nfev on γ with p=1 for the optimization with χ=0.2.

Optimization of a soft magnetic structure

Next, the topology of a soft magnetic thin film is optimized to act as a magnetic flux guide concentrator maximizing the magnetic flux in vertical (y-)direction inside Ωh. Such a structure can be used to e.g. improve the magnetic field detection limits of spin valve sensors16 by ehancing the external field at the sensor position.

The optimization is performed for three

different values of χ of 102, 103 and 104 with an external field of 10 mT applied. The optimized topologies for the three different χ-values are shown in Fig. 6. The found structures show the same “tanga” shape as reported in16 as optimal design. While the optimal topology differs only slightly for χ=103 and χ=104, for χ=102 the topology is significantly broader. In fact, switching the optimal topologies of χ=103 and χ=104 changes the generated mean field by under 0.2%. The generated mean field and the increase with respect to the full plate (ρ=1 in Ωopt) is shown in Table 1.

Figure 6.

Figure 6

Optimized topologies before (top row) and after regularization (bottom row) for (a) χ=102 (for p=5) (b) χ=103 (for p=14) and (c) χ=104 (for p=17) after regularization for γ=10-4.

Table 1.

Mean field values H¯y and increase with respect to the full plate for the optimized topologies.

χ H¯y (mT) Increase (%)
102 14.65 52.25
103 21.95 84.38
104 23.34 91.23

As opposed to the optimization of hard magnetic materials, the optimization using a soft magnetic material depends much more on the initial distribution of the density functional ρinit as well as on the p-parameter. In Fig. 7 the p-dependence of the mean field H¯y for the regularized solutions for χ=103 is plotted for different initial distributions of ρinit and for different values of the gradient scaling factor γ.

Figure 7.

Figure 7

p-dependency for different initial distributions and gradient scaling factors γ for the optimization performed for χ=103.

The solution found for a constant ρinit=1 and a randomly initialized ρinit are clearly inferior to the solutions found with a constant ρinit=0.5. For ρinit=0.5 the mean field increases with increasing p until it plateaus. While decreasing γ does not lead to a higher mean field, the p-value at which the mean field plateaus decreases with decreasing γ. At γ=1 the plateau starts at p=26 while for γ=10-4 the plateau value is 14. Further decreasing γ does not alter the plateau value anymore. In fact, as shown in Fig. 8 also for single p-values, the mean field increases with decreasing γ until a maximum is found for 10-4. Note, that for higher p-values than the plateau value, the mean field differs well under 1% from the mean field obtained by the optimization performed with the plateau value, except for individual outliers with very small mean field values for large p-values.

Figure 8.

Figure 8

Dependency of the mean field H¯y on γ individual p-values.

In Fig. 9, the amount of dofs with intermediate values of ρ after optimization is plotted in dependence of p. While the solutions with p4 show no dofs with intermediate values of ρ, with increasing p, their number increases and reaches over 60% for the optimal solutions. This is in contrast to the original purpose of the penalization factor p. However, since the changes of the mean field H¯y due to regularization is under 1% for all optimizations, the effect of the regularization is still negligible. This is since the remaining intermediate values are very close to 0 and 1 respectively. In Fig. 6 the optimized topologies are shown before and after regularization for comparison.

Figure 9.

Figure 9

p-dependency of nfev and the percentage of dofs with intermediate values of ρ after optimization for values of γ for the optimization performed for χ=103.

The dependence of the number of function evaluations necessary to perform the optimizations nfev on p is plotted in Fig. 9 for two different values of the gradient scaling factor. It can be seen nfev is lower with a smaller gradient scaling factor. With a gradient scaling factor of 10-4, the optimization with p=14 needs 325 nfev while with a gradient scaling factor of 1 for the optimization with p=26 nfev=14631. In Fig. 10 the iteration histories are plotted for selected values of p for a gradient scaling factor of 10-4. Note that the different starting values of the optimizations are due to factorization of ρ by p.

Figure 10.

Figure 10

Iteration histories for selected values of p for a gradient scaling factor of 10-4.

For χ=104 the p-dependence of the mean field plateaus in the same way as for χ=103, although with a different plateau value of p=17 for a gradient scaling factor of 10-4. The dependency on the gradient scaling factor is also similar as shown in Fig. 8. For χ=100 the situation is slightly different. Here, for gradient scaling factors smaller 10-4 the mean field increases with increasing p-value until a maximum is found at p=5 and the mean field decreases when further increasing p.

Conclusion

An algorithm to optimize the topology of magnetic structures based on a hybrid FEM–BEM method and the density approach for topology optimization has been presented. The gradients necessary to efficiently solve the optimization are obtained very efficiently using the adjoint approach. It has been shown that within a “first optimize then discretize” scheme the continuous forward operator is self-adjoint and therefore, the same method can be used to solve the forward as well as the adjoint problem.

The dependence on the p-parameter, originally introduced to penalize intermediate values of the density indicator function 0ρ1 has been investigated for the presented numerical experiments. For ideal permanent magnetic structures (χ=0) the linearity of the optimization problem can be utilized by enlarging the gradient. Scaling the gradient by a factor >103, with p=1 the optimization needs only two function evaluations and the found solution is in accordance with analytical expectations and shows no intermediate values of the indicator function ρ. For a realistic permanent magnetic material with χ=0.2 the optimized topology produces a magnetic field that differs by <0.1‰ from the topology found for the ideal permanent magnetic material. This shows that for thin films with negligible demagnetization, χ=0 is good approximation for a realistic permanent magnetic material with χ=0.2. Furthermore, the number of function evaluation needed using a realistic hard magnetic material is in the hundreds and hence much larger than the number of evaluations needed for the assumption of an ideal permanent magnetic material.

For the optimization of soft magnetic materials the optimal solutions are found for a gradient scaling factor 10-4. The solutions found get better with increasing value of the p-parameter. For χ=102 the best solution is found for p=5 and gets worse for larger p-values. For χ=103 and χ=104 the solutions improve with p until it plateaus for p14 and p17 respectively. Note, that in contrast to its original purpose, the p-parameter does not decrease the number of dofs with intermediate values of ρ. On the contrary, the percentage of dofs with intermediate values of ρ increases with increasing p. However, using a brute force regularization forcing all dofs with ρ<0.5 to 0 and all dofs with ρ0.5 to 1 only negligibly impacts the field value created by the structures. The optimized topologies have a shape similar to the optimal shape found experimentally in16.

Acknowledgements

The financial support of the FWF project I 4917 is acknowledged.

Appendix

Deriving the gradient ρJ^ using the adjoint approach

In the following the adjoint approach is applied to obtain the gradient ρJ^ of the reduced objective functional J^ρ with respect to the design variable ρ. A “first optimize then discretize” scheme17 is used, within which the gradient is derived using continuous operators. These operators are, as will turn out, self-adjoint where the discrete forward operator of the hybrid FEM–BEM algorithm is not. This simplifies the numerics involved in solving the adjoint equation.

Following17, in order to derive the gradient ρJ^ we consider the derivative

dJ^dρ=Jududρ+Jρ. 12

Here, dudρ is the numerically challenging term since u depends on ρ via the forward problem (7). In the discretized form, naive evaluation of dudρ by means of finite difference would require nρ solutions of the forward problem, where nρ is the number of dofs of ρ. Looking at the derivative of the forward problem

dFdρ=Fududρ+Fρ=0 13

the critical term can be expressed as

dudρ=-Fu-1Fρ. 14

Inserting this into Eq. (12) gives

dJ^dρ=-JuFu-1Fρ+Jρ, 15

an expression for the derivative where dudρ does not appear explicitly anymore.

Consider now that the goal is to perform an optimization on ρ, an at least once differentiable element of a suitable Hilbert space R. This means, that an initial guess ρ0 is updated iteratively using a suitable update candidate to obtain a new ρi that further reduces the objective functional. Since the derivative dJ^dρ:RR is a functional and therefore an element of the dual space R of R, it is not a suitable candidate to be used as update during optimization. What is needed is an element of the primal space similar to ρ, the gradient ρJ^R14.

Since within a finite element setting all function spaces are Hilbert spaces, the Riesz representation theorem can be used to obtain the gradient. The Riesz representation theorem states, that the dual space H of a Hilbert space H is isometric to itself. This means that the identification H=H can be done and for a functional IH applied to uH a unique element w of the primal space H can be found such that

Iu:=w,uHuH, 16

where ·,·H is the inner product defined on H and wH is the Riesz representer of I with respect to the inner product on H, also denoted as w=RHI. Note that, for the presented example the appropriate inner product is the L2 inner product that arises naturally when the forward problem is brought into its weak form by multiplication with a suitable test function. The specific reference is therefore dropped from this point on an each inner product as well as the Riesz representers are assumed to be with respect to L2 if not stated otherwise.

The gradient ρJ^R can now be identified as the Riesz representer of the derivative dJ^dρ17, pg. 99]

dJ^dρs=ρJ^,s=-RJu,Fu-1Fρs+(RJρ,s), 17

where also the Riesz representers of Ju and Jρ have to be used. Using, that for an operator A:H1H2 where H1 and H2 are Hilbert spaces, dual operator A:H2H1 is defined as

Av,u=v,AuuH1,vH2, 18

one can continue with

ρJ^,s=-FρFu-RJu,s+(RJρ,s) 19

and the gradient can be written as

ρJ^=FρFu-RJu+RJρ. 20

The adjoint equation is now obtained by expressing the term Fu-RJu as a new variable λ and rearranging to get

Fuλ=RJu. 21

This is the adjoint equation that can be used to calculate the adjoint variable λ and obtain the gradient via

ρJ^=Fρλ+RJρ. 22

Obtaining the dual operators

In order to calculate the gradient ρJ^, the continuous dual operators Fu and Fρ are needed. Starting with Fu, first the operator Fu has to be calculated using the definition of the Fréchet derivative

Fuh=limϵ0+Fuρ+ϵh,ρ-Fuρ,ρϵ=·1+ρpχh 23

Using the definition of dual operators in Hilbert space (18) to calculate Fu gives

Fuw,z=R3·1+ρpχwzdV=-R31+ρpχwzdV=R3w·1+ρpχzdV=w,Fuz, 24

where partial integration is applied twice and the boundary integrals vanish if the same boundary condition as valid for the scalar potential u is also also demanded from w and z18.

The adjoint equation becomes

·1+ρpχλ=RJu 25

with boundary condition

λrO1rforr. 26

Note that this equation has the same form as the forward problem F itself. This is a consequence of the self-adjointness of the operator Fu that is given since the above calculation shows that Fu=Fu. Therefore, λ also has to be twice differentiable and the adjoint equation can be solved by the same method as described in “Forward problem” section, as will be seen below in “Solving the adjoint equation” section.

The operator Fρ is obtained by again first deriving the operator Fρ using the Fréchet derivative

Fρr=limϵ0+Fuρ,ρ+ϵr-Fuρ,ρϵ=·pρp-1rχu-Hext-Mr. 27

Using Eq. (18) gives

Fρr,s=R3·pρp-1rχu-Hext-MrsdV=-R3pρp-1rχu-Hext-Mr·sdV=-R3rpρp-1χu-Hext-Mr·sdV=r,Fρs. 28

Here again partial integration was applied and the boundary integral vanished for s satisfying the boundary condition (26), which is fulfilled since in the expression for the gradient Fρ is applied to λ that also satisfies this boundary condition.

Finally, the gradient can be written as

ρJ^=pρp-1χu-Hext-Mr·λ+RJρR. 29

Solving the adjoint equation

In order to solve the adjoint Eq. (25) we first have a closer look at it. On the right hand side is the partial derivative of the objective functional J with respect to the scalar potential u. However, we will not directly impose conditions on the potential u but on the magnetic field H that is defined as H=-u. Consider the weak form of the adjoint equation

R3·1+ρpχλvdV=R3RJuvdV 30

where v is a suitable test function. Performing partial integration on the left hand side and inserting Juv=JHHuv=-JHv on the right hand side we get

-R31+ρpχλ·vdV=-R3RJHvdV, 31

where the boundary term vanishes due to the boundary condition on λ. Assuming that the objective functional J is defined locally on an area Ωopt, this is the weak form of

·1+ρpχλ-RJH=0, 32

that is identical to the forward problem in Eq. (7) with λ instead of u, RJH replacing ρpMr and Hext=0. We can therefore use the same algorithm to solve the adjoint equation as is used to solve the forward problem. Note, that it is perfectly fine to assume the same jump conditions on λ as on u since they are contained in the weak form of the forward problem anyways as shown in19.

Obtaining the Riesz representers

To obtain the Riesz representers RJH and RJρ appearing inside the adjoint equation and the expression for the gradient, the coefficient vectors JH and Jρ belonging to the functionals JH and Jρ respecively, are calculated using FEniCS11. These coefficient vectors can be used to calculate the action of the functionals onto an element of the primal space r14. For the functional Jρ this reads

Jρr=Jρ,r2=JρTr, 33

where ·,·2 represents the euclidiean inner product. On the other hand, using the Riesz representer RJρ the action can be written as

Jρr=RJρ,rL2=ΩiRiJρψixjrjψjxdx=iRiJρjrjΩψixψjxdx=RL2TJρMr 34

with ψix being the discrete basis functions and M=ΩψiψjdV being the mass matrix. Since the two equations must deliver the same result and furthermore MT=M, the Riesz representer with respect to the L2 inner product can be obtained from the coefficient vector as

RL2Jρ=M-1Jρ. 35

The Riesz representer RJH is obtained in the same way.

Author contributions

G.W. and F.S. applied the adjoint approach deriving the necessary expressions for the gradient with consultation from D.S., C.A. and F.B., G.W., F.B. and C.A. developed the numerical simulation code and G.W. conducted the numerical experiments. The manuscript was written by G.W. All authors reviewed the manuscript.

Competing interests

The authors declare no competing interests.

Footnotes

Publisher's note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

References

  • 1.Kang J, Wang S. Shape optimization of BLDC motor using 3-D finite element method. IIEEE Trans. Magn. 2000;36(4):1119–1123. doi: 10.1109/20.877637. [DOI] [Google Scholar]
  • 2.Campelo, F. Rmiírez, J. A. and Igarashi, H. A survey of topology optimization in electromagnetics: Considerationsand current trends (2010).
  • 3.Okamoto Y, Akiyama K, Takahashi N. 3-D topology optimization of singlepole- type head by using design sensitivity analysis. IEEE Trans. Magn. 2006;42(4):1087–1090. doi: 10.1109/TMAG.2006.871422. [DOI] [Google Scholar]
  • 4.Wang Semyung, et al. Topology optimization of electromagnetic systems considering magnetization direction. IEEE Trans. Magn. 2005;41(5):1808–1811. doi: 10.1109/TMAG.2005.846480. [DOI] [Google Scholar]
  • 5.Wang S, Kang J. Topology optimization of nonlinear magnetostatics. IEEE Trans. Magn. 2002;38(2):1029–1032. doi: 10.1109/20.996264. [DOI] [Google Scholar]
  • 6.Seebacher, P. et al. Optimization of an Electromagnetic Actuator using Topology- Optimization. In: 2019 22nd International Conference on the Computation of Electromagnetic Fields (COMPUMAG). 2019 22nd International Conference on the Computation of Electromagnetic Fields (COMPUMAG). Paris, France: IEEE, July 2019, pp. 1–4. 10.1109/COMPUMAG45669.2019.9032821. https://ieeexplore.ieee.org/document/9032821/ (visited on 10/25/2021).
  • 7.Bruckner Florian, et al. 3D FEM-BEM-coupling method to solve magnetostatic Maxwell equations. J. Magn. Magn. Mater. 2012;324(10):1862–1866. doi: 10.1016/j.jmmm.2012.01.016. [DOI] [Google Scholar]
  • 8.Huber C, et al. Topology optimized and 3D printed polymer-bonded permanent magnets for a predefined external field. J. Appl. Phys. 2017;122(5):053904. doi: 10.1063/1.4997441. [DOI] [Google Scholar]
  • 9.Abert Claas, et al. A fast finite-difference algorithm for topology optimization of permanent magnets. J. Appl. Phys. 2017;122(11):113904. doi: 10.1063/1.4998532. [DOI] [Google Scholar]
  • 10.Abert C, et al. magnum.fe: A micromagnetic finite-element simulation code based on FEniCS. J. Magn. Magn. Mater. 2013;345:29–35. doi: 10.1016/j.jmmm.2013.05.051. [DOI] [Google Scholar]
  • 11.Logg, A. et al. (eds) Automated Solution of Differential Equations by the Finite Element Method: The FEniCS Book. Lecture Notes in Computational Science and Engineering 84. OCLC: 794507863 723 (Springer, 2012).
  • 12.Bendsøe, M. P. & Sigmund, O. Topology Optimization (Springer, 2004). 10.1007/978-3-662-05086-6.
  • 13.Zhu Ciyou, et al. Algorithm 778: L-BFGS-B: Fortran subroutines for large-scale bound-constrained optimization. ACM Trans. Math. Softw. 1997;23(4):550–560. doi: 10.1145/279232.279236. [DOI] [Google Scholar]
  • 14.Schwedes, T. et al.Mesh Dependence in PDE-Constrained Optimisation (Springer, 2017). 10.1007/978-3-319-59483-5.
  • 15.Nordaas, M. & Funke, S. W. The Moola optimisation package (2016).
  • 16.Guedes A, et al. Improving magnetic field detection limits of spin valve sensors using magnetic flux guide concentrators. IEEE Trans. Magn. 2007;43(6):2376–2378. doi: 10.1109/TMAG.2007.893119. [DOI] [Google Scholar]
  • 17.Hinze, M. (ed.) Optimization with PDE Constraints. Mathematical modelling 23. OCLC: 255277417 270 (Springer, 2009).
  • 18.Giles MB, Pierce NA. An Introduction to the Adjoint Approach to Design. Flow Turbulence Combust. 2000;65(3):393–415. doi: 10.1023/A:1011430410075. [DOI] [Google Scholar]
  • 19.Bossavit, A. Computational Electromagnetism: Variational Formulations, Com-plementarity, Edge Elements. OCLC: 162128760 (Academic Press, 1998).

Articles from Scientific Reports are provided here courtesy of Nature Publishing Group

RESOURCES