PDF

Topology Optimization of a Magnetic Circuit
Introduction
This model presents an example of topology optimization of the magnetic circuit of a loudspeaker driver. Topology optimization is used to find the shape of a nonlinear iron yoke that maximizes its performance while minimizing the weight, obtaining a smaller and lighter design.
The geometry and simulation parameters are similar to the ones used in the Loudspeaker Driver application available in the Acoustic Module Application Library. More insight on the acoustics of that geometry can be found in the documentation relative to that model.
This model illustrates:
The final geometry features a loudspeaker with similar performance whose weight is 25% less than the original.
Model Definition
The magnetic circuit of a loudspeaker is used to concentrate the magnetic flux generated by a permanent magnet into an air gap in which a coil is placed, with the coil windings perpendicular to magnetic flux lines. The coil is mechanically connected to the membrane of the loudspeaker. When a current is run through the coil, electromagnetic forces act on it inducing movement. The movement of the coil is transferred to the membrane, which interacts with the air producing sound waves.
In a real device, the iron yoke that constitutes the magnetic circuit must be designed to maximize the flux concentrated at the coil, and to provide a uniform field across the coil. In order to estimate the performance of a loudspeaker magnetic circuit, it is useful to introduce the BL parameter, defined as the product of magnetic flux in the air gap B and coil length L. The larger this parameter, the higher the performance of the magnetic circuit.
If the magnetic circuit is axisymmetric and the coils are winded in the azimuthal direction inside the air gap, as in the present model, the BL parameter is defined as
where Br is the r-component of the magnetic flux density, N0 is the number of turns of the coil, and A the cross-section area of the coil.
In the present model, the electromagnetic problem is solved using the Magnetic Fields interface. The iron yoke is made of a soft iron with a specified B-H curve, in order to take into account magnetic saturation. In the model, it is explicitly shown that using a given magnetic B-H curve is equivalent to using a relative permeability:
Using the relative permeability instead of the B-H curve is useful for the purpose of topology optimization. The permeability of the yoke region is defined in terms of a control field p, with the formula:
The variable reduces to the permeability of air for p = 0 and the permeability of the nonlinear iron for p = 1. Topology optimization is performed by searching for the values of p in the interval [0, 1] at each point of the yoke, while constraining the integral of p. The latter is proportional to the total weight of the yoke, since the field p indicates the regions consisting of iron.
In the model three domains are made of iron, and it is shown that optimization can be performed just on one of them. For this domain, the best configuration for p is found in order to have a volume of about 37 cm3, which is the volume of the original geometry, or about 26 cm3. By scanning the optimal shape as function of the weight, it is possible to derive the Pareto front for a optimization process which uses both the BL parameter and the weight in the objective.
Results and Discussion
The magnetic fields for the initial configuration are investigated in the first two analyses computed in Study 1. In this configuration, the lower arm of the yoke has a volume of about 37 cm3. The first solution illustrates using the B-H curve functionality, readily available in the Ampère’s Law feature in the Magnetic Fields interface, while the second solution uses the approach of specifying an equivalent nonlinear relative permeability. The results are identical in the two cases. The norm of the magnetic flux density and the magnetic flux lines for this initial configuration are shown in Figure 1 and Figure 2.
The lowest part of the magnetic circuit is enclosed in a cylindrical annulus whose volume is about 52 cm3. Figure 3 illustrates the result of the optimization process, performed in Study 2. The plot shows the value of the control variable field p, with the constraint that the integral of p over the whole domain is the same as the initial configuration (about 37 cm3). The computed geometry differs marginally from the original configuration indicated by a gray line, meaning that the original configuration was already nearly optimal. Figure 4 shows the result of the optimization process with the constraint of a volume of yoke equal to 26 cm3.
The model also illustrates how to export the optimized shape as an interpolation function in a text file and import it as a geometry. The result is shown in Figure 5. The red line in Figure 5 represents the level set for p = 0.5. The line is explicitly added to the geometry, dividing the lower rectangle in two domains. For this final simulation, the H-B curve constitutive relation is used once again. The results are presented in Figure 6 and Figure 7.
A 3D representation of the final geometry and its magnetic fields is represented in Figure 8.
Figure 1: Magnetic flux lines for the initial configuration. The lower rectangle is divided in two domains: the left part, with volume of 37 cm3, is made of a nonlinear magnetic iron characterized by a B-H curve.
Figure 2: Magnetic flux density norm for the initial configuration.
Figure 3: Results of the optimization with the constraint that the iron volume must be 37 cm3. The regions with p = 1 (red) are made of iron, the region with p = 0 (blue) is air. The original shape is indicated by a solid gray line. The plot shows how the original configuration is nearly optimal.
Figure 4: Magnetic flux density norm for the configuration with the constraint on volume of 26 cm3.
Figure 5: Contour line at p = 0.5 (red line). This line is added in the geometry to divide the lower arm of the yoke in two domains.
Figure 6: Magnetic flux density for norm for the geometry in Figure 5. The volume of the lower arm of the iron yoke (left of the division line) is 29 cm3. The magnetic performance of this new lighter geometry is comparable with that of the configuration presented in Figure 1and Figure 2.
Figure 7: Magnetic flux lines colored proportionally to the magnetic flux density norm for the optimized configuration.
Figure 8: 3D revolution plot of the magnetic flux density norm in the final optimized geometry.
Notes About the COMSOL Implementation
Using smart selections
As the studies solve for different kinds of geometries, the entity naming and numbering differs between studies. In order to consistently address certain domains and boundaries for each study without having to manually reselect them, a smart use of selection features is implemented. This includes the selection of domains based on their coordinates or their adjacency to coordinate selected entities. The advantage of this approach is that for each of the five studies the corresponding geometry can be automatically generated with the proper selections for mesh and physics settings included. The state of the geometry is controlled by the parameters originalgeometry and optimizedgeometry. You can investigate the different states manually by setting these parameters to either 0 or 1 (and rebuilding the geometry). Optimization studies need the parameters to be set to 0.
Using complex split
Some studies include a relative permeability that is a function of the local magnetic flux density norm. Without solver adjustments, these studies would show poor nonlinear solver convergence. This happens as the magnetic flux density norm definition contains an operator that is not exactly differentiable; the realdot() operator1. In order to improve convergence, the solver is set to split complex variables in real and imaginary parts. This causes the variables to be reinterpreted so that the expression including the realdot() operator can be properly differentiated. Proper differentiated quantities result in an exact problem Jacobian. This is required for a good convergence rate. The complex split setting is needed in most gradient based electromagnetic optimization problems.
Smoothing the optimized profile
The optimized geometry is obtained using a discontinuous element-wise constant shape function for the optimizing variable field p. The resulting material interface shows a saw-tooth profile reminiscent of the underlying mesh. This is good for topological optimization. When extracting the geometrical shape however, a smooth shape is preferred. In order to achieve this, the solution is mapped on continuous linear shape functions. After exporting the curve, the discontinuous constant elements are set back to their original value (the solution corresponding to the optimization study).
Application Library path: ACDC_Module/Other_Industrial_Applications/magnetic_circuit_topology_optimization
Modeling Instructions
From the File menu, choose New.
New
In the New window, click Model Wizard.
Model Wizard
1
In the Model Wizard window, click 2D Axisymmetric.
2
In the Select Physics tree, select AC/DC>Electromagnetic Fields>Magnetic Fields (mf).
3
Click Add.
4
Click Study.
5
In the Select Study tree, select General Studies>Stationary.
6
Click Done.
Global Definitions
Parameters 1
1
In the Model Builder window, under Global Definitions click Parameters 1.
2
In the Settings window for Parameters, locate the Parameters section.
3
Geometry 1
Draw the yoke, the magnet and the coil as a series of rectangles.
1
In the Model Builder window, expand the Component 1 (comp1)>Geometry 1 node, then click Geometry 1.
2
Right-click Geometry 1 and add eight Rectangle nodes.
3
Rectangle 1 (r1)
As different geometries are going to be built automatically from the study, introduce an "If" instance, which is building an element depending on the value of a parameter.
If 1 (if1)
1
In the Geometry toolbar, click Programming and choose If + End If.
2
In the Settings window for If, locate the If section.
3
In the Condition text field, type originalgeometry.
Polygon 1 (pol1)
1
In the Geometry toolbar, click Polygon.
2
In the Settings window for Polygon, locate the Coordinates section.
3
4
Click Build Selected.
Generate some selection which will be used during the modeling. Some of these are empty depending on the value of parameters.
Definitions
Disk 1
1
In the Model Builder window, expand the Component 1 (comp1)>Definitions node.
2
Right-click Definitions and choose Selections>Disk.
3
In the Settings window for Disk, locate the Disk Center section.
4
In the r text field, type 0.03.
5
In the z text field, type -0.084.
6
Click the Zoom to Selection button in the Graphics toolbar.
Disk 2
1
Right-click Disk 1 and choose Duplicate.
2
In the Settings window for Disk, locate the Disk Center section.
3
In the r text field, type 0.05.
Box 1
1
In the Definitions toolbar, click Box.
2
In the Settings window for Box, locate the Box Limits section.
3
In the r minimum text field, type 0.01.
4
In the r maximum text field, type 0.06.
5
In the z minimum text field, type -0.09.
6
In the z maximum text field, type -0.07.
7
Locate the Output Entities section. From the Include entity if list, choose Entity inside box.
Difference 1
1
In the Definitions toolbar, click Difference.
2
In the Settings window for Difference, locate the Input Entities section.
3
Under Selections to add, click Add.
4
In the Add dialog box, select Box 1 in the Selections to add list.
5
6
In the Settings window for Difference, locate the Input Entities section.
7
Under Selections to subtract, click Add.
8
In the Add dialog box, select Disk 2 in the Selections to subtract list.
9
10
In the Settings window for Difference, type Left domain in the Label text field.
Left domain 1
1
Right-click Left domain and choose Duplicate.
2
In the Settings window for Difference, type Right domain in the Label text field.
3
Locate the Input Entities section. In the Selections to subtract list, select Disk 2.
4
Under Selections to subtract, click Delete.
5
Under Selections to subtract, click Add.
6
In the Add dialog box, select Disk 1 in the Selections to subtract list.
7
Difference 3
1
In the Definitions toolbar, click Difference.
2
In the Settings window for Difference, type Optimizing region in the Label text field.
3
Locate the Input Entities section. Under Selections to add, click Add.
4
In the Add dialog box, select Box 1 in the Selections to add list.
5
6
In the Settings window for Difference, locate the Input Entities section.
7
Under Selections to subtract, click Add.
8
In the Add dialog box, in the Selections to subtract list, choose Left domain and Right domain.
9
Explicit 1
1
In the Definitions toolbar, click Explicit.
2
3
In the Settings window for Explicit, type Fixed Yoke in the Label text field.
Union 1
1
In the Definitions toolbar, click Union.
2
In the Settings window for Union, type BH relationship region in the Label text field.
3
Locate the Input Entities section. Under Selections to add, click Add.
4
In the Add dialog box, in the Selections to add list, choose Left domain and Fixed Yoke.
5
Explicit 2
1
In the Definitions toolbar, click Explicit.
2
3
In the Settings window for Explicit, type Other solid parts in the Label text field.
Union 2
1
In the Definitions toolbar, click Union.
2
In the Settings window for Union, type Solid parts in the Label text field.
3
Locate the Input Entities section. Under Selections to add, click Add.
4
In the Add dialog box, in the Selections to add list, choose Optimizing region, BH relationship region, and Other solid parts.
5
6
Click the Zoom Extents button in the Graphics toolbar.
Add Material
1
In the Home toolbar, click Add Material to open the Add Material window.
2
Go to the Add Material window.
3
4
Click Add to Component 1 (comp1).
Materials
Air (mat1)
The magnetic circuit will be simulated using the BH curve constitutive relation and the magnet is set to use the Remanent Flux constitutive relation. Add materials in order to provide required quantities.
Add Material
1
Go to the Add Material window.
2
In the tree, select AC/DC>Soft Iron (With Losses).
3
Click Add to Component in the window toolbar.
4
In the Home toolbar, click Add Material to close the Add Material window.
Materials
Soft Iron (With Losses) (mat2)
1
In the Settings window for Material, locate the Geometric Entity Selection section.
2
From the Selection list, choose BH relationship region.
Material 3 (mat3)
1
In the Model Builder window, right-click Materials and choose Blank Material.
2
In order to have a faster convergence of the optimization process, use linear shape order elements for the discretization.
Magnetic Fields (mf)
Proceed to the physics setup.
1
In the Model Builder window, under Component 1 (comp1) click Magnetic Fields (mf).
2
In the Settings window for Magnetic Fields, click to expand the Discretization section.
3
From the Magnetic vector potential list, choose Linear.
Ampère’s Law 1
1
In the Model Builder window, under Component 1 (comp1)>Magnetic Fields (mf) click Ampère’s Law 1.
2
In the Settings window for Ampère’s Law, type Nonmagnetic domains in the Label text field.
Ampère’s Law 2
1
In the Physics toolbar, click Domains and choose Ampère’s Law.
2
In the Settings window for Ampère’s Law, type BH curve domains in the Label text field.
3
Locate the Domain Selection section. From the Selection list, choose BH relationship region.
4
Locate the Constitutive Relation B-H section. From the Magnetization model list, choose B-H curve.
Ampère’s Law 3
1
In the Physics toolbar, click Domains and choose Ampère’s Law.
2
In the Settings window for Ampère’s Law, type Permanent Magnet in the Label text field.
3
4
Locate the Constitutive Relation B-H section. From the Magnetization model list, choose Remanent flux density.
5
Specify the e vector as
Materials
Material 3 (mat3)
1
In the Model Builder window, under Component 1 (comp1)>Materials click Material 3 (mat3).
2
In the Settings window for Material, type Generic Ferrite in the Label text field.
3
Locate the Material Contents section. In the table, enter the following settings:
Mesh is created using parametric selections so to be independent of current geometry. Mapped mesh will be created in the following when optimization study will be setup.
Mesh 1
Proceed to the mesh setup.
Edge 1
1
In the Model Builder window, under Component 1 (comp1) right-click Mesh 1 and choose More Operations>Edge.
2
Size 1
1
Right-click Edge 1 and choose Size.
2
In the Settings window for Size, locate the Element Size section.
3
Click the Custom button.
4
Locate the Element Size Parameters section. Select the Maximum element size check box.
5
Mapped 1
1
In the Model Builder window, right-click Mesh 1 and choose Mapped.
2
In the Settings window for Mapped, locate the Domain Selection section.
3
From the Geometric entity level list, choose Domain.
4
From the Selection list, choose Optimizing region.
Free Triangular 1
1
Right-click Mesh 1 and choose Free Triangular.
2
Click Build All.
Study 1
1
In the Model Builder window, click Study 1.
2
In the Settings window for Study, type Original geometry BH curve description in the Label text field.
3
Locate the Study Settings section. Clear the Generate default plots check box.
Parametric Sweep
1
In the Study toolbar, click Parametric Sweep.
2
In the Settings window for Parametric Sweep, locate the Study Settings section.
3
Click Add.
4
5
In the Study toolbar, click Compute.
Results
The following instructions create a plot in which contour lines are used to visualize the magnetic flux density lines.
2D Plot Group 1
1
In the Home toolbar, click Add Plot Group and choose 2D Plot Group.
2
In the Settings window for 2D Plot Group, type Magnetic Flux Density, Direct Model in the Label text field.
3
Click to expand the Title section. From the Title type list, choose Manual.
4
In the Title text area, type Magnetic flux density lines and norm (T).
Contour 1
1
Right-click Magnetic Flux Density, Direct Model and choose Contour.
2
In the Settings window for Contour, locate the Expression section.
3
In the Expression text field, type Aphi*r.
Color Expression 1
1
Right-click Contour 1 and choose Color Expression.
2
In the Magnetic Flux Density, Direct Model toolbar, click Plot.
Contour 1
Create a plot for the magnetic flux density norm.
2D Plot Group 2
1
In the Home toolbar, click Add Plot Group and choose 2D Plot Group.
2
In the Settings window for 2D Plot Group, type Magnetic Flux Density, Direct Model (original geometry) in the Label text field.
3
Locate the Plot Settings section. Clear the Plot dataset edges check box.
Surface 1
1
Right-click Magnetic Flux Density, Direct Model (original geometry) and choose Surface.
2
In the Settings window for Surface, click to expand the Range section.
3
Select the Manual color range check box.
4
In the Maximum text field, type 2.
5
In the Magnetic Flux Density, Direct Model (original geometry) toolbar, click Plot.
Compute the loudspeaker’s BL according to definition presented in documentation.
Surface Average 1
1
In the Results toolbar, click More Derived Values and choose Average>Surface Average.
2
3
In the Settings window for Surface Average, locate the Expressions section.
4
5
Locate the Integration Settings section. Clear the Compute volume integral check box.
6
Click New Table.
Original geometry BH curve description
Solver Configurations
Proceed now to solving the same problem using a nonlinear relative permeability equivalent to the B-H curve. In order to preserve the solution just computed, create a copy of it using the Copy Solution functionality.
Add Study
1
In the Home toolbar, click Add Study to open the Add Study window.
2
Go to the Add Study window.
3
Find the Studies subsection. In the Select Study tree, select General Studies>Stationary.
4
Click Add Study in the window toolbar.
5
In the Home toolbar, click Add Study to close the Add Study window.
Study 2
1
In the Model Builder window, expand the Original geometry BH curve description>Solver Configurations node, then click Study 2.
2
In the Settings window for Study, type Original geometry nonlinear mur description in the Label text field.
3
Locate the Study Settings section. Clear the Generate default plots check box.
Parametric Sweep
1
In the Study toolbar, click Parametric Sweep.
2
In the Settings window for Parametric Sweep, locate the Study Settings section.
3
Click Add.
4
Import the nonlinear relative permeability as a function of B from an external file. The interpolation data is computed from the Soft Iron BH curve as B/(μ0H) .
Global Definitions
Interpolation 1 (int1)
1
In the Home toolbar, click Functions and choose Global>Interpolation.
2
In the Settings window for Interpolation, locate the Definition section.
3
In the Function name text field, type murOfB.
4
5
Locate the Units section. In the Arguments text field, type T.
6
In the Function text field, type 1.
Magnetic Fields (mf)
Ampère’s Law 4
1
In the Physics toolbar, click Domains and choose Ampère’s Law.
2
In the Settings window for Ampère’s Law, type Manual BH relationship in the Label text field.
3
Locate the Domain Selection section. From the Selection list, choose Box 1.
4
Locate the Constitutive Relation B-H section. From the μr list, choose User defined. In the associated text field, type murOfB(mf.normB).
Ampère’s Law 5
1
In the Physics toolbar, click Domains and choose Ampère’s Law.
2
In the Settings window for Ampère’s Law, locate the Domain Selection section.
3
From the Selection list, choose Right domain.
4
In the Label text field, type Extra Air Domain.
Adjust study 1 so that solution will not change because of the added nodes.
Original geometry BH curve description
Step 1: Stationary
1
In the Model Builder window, under Original geometry BH curve description click Step 1: Stationary.
2
In the Settings window for Stationary, locate the Physics and Variables Selection section.
3
Select the Modify model configuration for study step check box.
4
In the Physics and variables selection tree, select Component 1 (comp1)>Magnetic Fields (mf)>Manual BH relationship.
5
Click Disable.
Solve Study 2 and verify that the results are the same of the ones in the previous study. Before solving activate manual spit of complex variable to improve robustness of the nonlinear solution.
Original geometry nonlinear mur description
Solution 4 (sol4)
1
In the Study toolbar, click Show Default Solver.
2
In the Model Builder window, expand the Solution 4 (sol4) node, then click Compile Equations: Stationary.
3
In the Settings window for Compile Equations, locate the Study and Step section.
4
Select the Split complex variables in real and imaginary parts check box.
5
In the Study toolbar, click Compute.
Results
Magnetic Flux Density, Direct Model
1
In the Model Builder window, under Results click Magnetic Flux Density, Direct Model.
2
In the Settings window for 2D Plot Group, locate the Data section.
3
From the Dataset list, choose Original geometry nonlinear mur description/Solution 4 (sol4).
4
In the Magnetic Flux Density, Direct Model toolbar, click Plot.
5
In the Results toolbar, click Evaluate and choose Evaluate All.
Derived Values
Compute the volume of the lower arm of the yoke, as a reference for the next steps.
Surface Integration 1
1
In the Results toolbar, click More Derived Values and choose Integration>Surface Integration.
2
3
In the Settings window for Surface Integration, locate the Expressions section.
4
5
Click New Table.
Table
1
Go to the Table window.
2
3
Right-click Surface Integration 1 and choose Evaluate>Table 2 - Surface Integration 1.
The lower arm of the yoke has a volume of about 37 cm3, out of about 52 cm3 of the bottom region.
Add the optimization.
In the following, the solver is set so to optimize the topology of the yoke in the lower region, while keeping the volume of the arm fixed. First change the parameters which is making the original geometry disappear.
Global Definitions
Parameters 1
1
In the Model Builder window, under Global Definitions click Parameters 1.
2
In the Settings window for Parameters, locate the Parameters section.
3
Geometry 1
In the Home toolbar, click Build All.
Thanks to the added Parametric Sweep, Study 1 and 2 will continue using the original geometry, if solved again. Now add the Optimization Interface.
Add Physics
1
In the Home toolbar, click Add Physics to open the Add Physics window.
2
Go to the Add Physics window.
3
In the tree, select Mathematics>Optimization and Sensitivity>Optimization (opt).
4
Click Add to Component 1 in the window toolbar.
5
In the Model Builder window, click Component 1 (comp1).
6
In the Home toolbar, click Add Physics to close the Add Physics window.
Optimization (opt)
Control Variable Field 1
1
In the Physics toolbar, click Domains and choose Control Variable Field.
The control variable p is used as an indicator to determine if iron or air is present at a certain point in space.
2
3
In the Settings window for Control Variable Field, locate the Control Variable section.
4
In the Initial value text field, type 1.
The control variable field p is a logical variable and does not correspond to a physical field, so it is not necessary to require it to be continuous across elements. Moreover, it is expected to be piecewise constant. Choose a suitable shape function and discretization order for this purpose.
5
Locate the Discretization section. From the Shape function type list, choose Discontinuous Lagrange.
6
Find the Base geometry subsection. From the Element order list, choose Constant.
Specify that p must be bounded between 0 and 1.
Control Variable Bounds 1
1
Right-click Control Variable Field 1 and choose Control Variable Bounds.
2
In the Settings window for Control Variable Bounds, locate the Bounds section.
3
In the Upper bound text field, type 1.
Integral Inequality Constraint 1
1
In the Physics toolbar, click Domains and choose Integral Inequality Constraint.
Constrain the total volume of the iron region to a given fraction of the available 51.916 cm3 using an integral constraint. Fraction is specified via the parameter "filling".
2
3
In the Settings window for Integral Inequality Constraint, locate the Constraint section.
4
In the p text field, type p/51.916e-6.
5
Locate the Bounds section. In the Lower bound text field, type filling.
6
In the Upper bound text field, type filling.
Set the value of filling to 37.090 cm3.
Global Definitions
Parameters 1
1
In the Model Builder window, under Global Definitions click Parameters 1.
2
In the Settings window for Parameters, locate the Parameters section.
3
Optimization (opt)
Integral Objective 1
1
In the Physics toolbar, click Domains and choose Integral Objective.
Specify the objective function so that BL has the largest absolute value. Note that BL is negative.
2
3
In the Settings window for Integral Objective, locate the Objective section.
4
In the q text field, type mf.Br*N0/6.0E-6[m^2].
Define the variable p as 1 in all the domains where the optimization is not active.
Definitions
Variables 1
1
In the Model Builder window, under Component 1 (comp1) right-click Definitions and choose Variables.
2
In the Settings window for Variables, locate the Geometric Entity Selection section.
3
From the Geometric entity level list, choose Domain.
4
5
Locate the Variables section. In the table, enter the following settings:
Enter the permeability according to the formula Equation .
Magnetic Fields (mf)
Manual BH relationship
1
In the Model Builder window, under Component 1 (comp1)>Magnetic Fields (mf) click Manual BH relationship.
2
In the Settings window for Ampère’s Law, locate the Constitutive Relation B-H section.
3
In the μr text field, type 1-p^2+p^2*murOfB(mf.normB).
Root
Proceed with the setup of the optimization study. Add a third Stationary study step, controlled by an Optimization step.
Add Study
1
In the Home toolbar, click Add Study to open the Add Study window.
2
Go to the Add Study window.
3
Find the Studies subsection. In the Select Study tree, select General Studies>Stationary.
4
Click Add Study in the window toolbar.
5
In the Home toolbar, click Add Study to close the Add Study window.
Study 3
Step 1: Stationary
Specify again the value of filling so that this study will not change solution when filling is updated in parameters.
1
In the Settings window for Stationary, click to expand the Study Extensions section.
2
Select the Auxiliary sweep check box.
3
Click Add.
4
5
In the Model Builder window, click Study 3.
6
In the Settings window for Study, type Optimization with target 37[cm^3] in the Label text field.
Optimization
1
In the Study toolbar, click Optimization.
The typical optimization solver used for topology optimization is MMA.
2
In the Settings window for Optimization, locate the Optimization Solver section.
3
From the Method list, choose MMA.
4
In the Model Builder window, click Optimization with target 37[cm^3].
5
In the Settings window for Study, locate the Study Settings section.
6
Clear the Generate default plots check box.
Solution 7 (sol7)
1
In the Study toolbar, click Show Default Solver.
2
In the Model Builder window, expand the Solution 7 (sol7) node, then click Compile Equations: Stationary.
3
In the Settings window for Compile Equations, locate the Study and Step section.
4
Select the Split complex variables in real and imaginary parts check box.
5
In the Model Builder window, expand the Optimization with target 37[cm^3]>Solver Configurations>Solution 7 (sol7)>Optimization Solver 1>Stationary 1 node, then click Fully Coupled 1.
6
In the Settings window for Fully Coupled, click to expand the Method and Termination section.
7
From the Nonlinear method list, choose Constant (Newton).
8
In the Damping factor text field, type 0.5.
Results
2D Plot Group 3
1
In the Home toolbar, click Add Plot Group and choose 2D Plot Group.
2
In the Settings window for 2D Plot Group, locate the Data section.
3
From the Dataset list, choose Optimization with target 37[cm^3]/Solution 7 (sol7).
4
In the Label text field, type Topology Variable Distribution for Optimization with Target 37[cm^3].
Surface 1
1
Right-click Topology Variable Distribution for Optimization with Target 37[cm^3] and choose Surface.
2
In the Settings window for Surface, locate the Expression section.
3
In the Expression text field, type p.
Optimization with target 37[cm^3]
Optimization
1
In the Model Builder window, under Optimization with target 37[cm^3] click Optimization.
2
In the Settings window for Optimization, locate the Output While Solving section.
3
Select the Plot check box.
4
From the Plot group list, choose Topology Variable Distribution for Optimization with Target 37[cm^3].
5
In the Home toolbar, click Compute.
Results
Topology Variable Distribution for Optimization with Target 37[cm^3]
Add a gray line showing the original shape on top of the optimized shape.
Line 1
1
Right-click Topology Variable Distribution for Optimization with Target 37[cm^3] and choose Line.
2
In the Settings window for Line, locate the Data section.
3
From the Dataset list, choose Original geometry BH curve description/Parametric Solutions 1 (sol2).
4
Locate the Expression section. In the Expression text field, type 1.
5
Locate the Coloring and Style section. From the Coloring list, choose Uniform.
6
From the Color list, choose Gray.
7
In the Topology Variable Distribution for Optimization with Target 37[cm^3] toolbar, click Plot.
Global Definitions
Repeat the same operation for adding an optimization study. New study will search for an optimal speaker lower core geometry which is half in weight with respect the full available space.
Parameters 1
1
In the Model Builder window, under Global Definitions click Parameters 1.
2
In the Settings window for Parameters, locate the Parameters section.
3
Add Study
1
In the Home toolbar, click Add Study to open the Add Study window.
2
Go to the Add Study window.
3
Find the Studies subsection. In the Select Study tree, select General Studies>Stationary.
4
Click Add Study in the window toolbar.
5
In the Home toolbar, click Add Study to close the Add Study window.
Study 4
Step 1: Stationary
1
In the Settings window for Stationary, click to expand the Values of Dependent Variables section.
2
Find the Initial values of variables solved for subsection. From the Settings list, choose User controlled.
3
From the Method list, choose Solution.
4
From the Study list, choose Optimization with target 37[cm^3], Stationary.
5
In the Model Builder window, click Study 4.
6
In the Settings window for Study, type Optimization with target filling=0.5 in the Label text field.
Optimization
1
In the Study toolbar, click Optimization.
2
In the Settings window for Optimization, locate the Optimization Solver section.
3
From the Method list, choose MMA.
4
In the Model Builder window, click Optimization with target filling=0.5.
5
In the Settings window for Study, locate the Study Settings section.
6
Clear the Generate default plots check box.
Solution 8 (sol8)
In the Study toolbar, click Show Default Solver.
Results
Topology Variable Distribution for Optimization with Target 37[cm^3] 1
1
In the Model Builder window, expand the Solution 8 (sol8) node.
2
Right-click Topology Variable Distribution for Optimization with Target 37[cm^3] and choose Duplicate.
3
In the Settings window for 2D Plot Group, locate the Data section.
4
From the Dataset list, choose Optimization with target filling=0.5/Solution 8 (sol8).
5
In the Label text field, type Topology Variable Distribution for Optimization with Target Filling 50%.
Optimization with target filling=0.5
Optimization
1
In the Model Builder window, under Optimization with target filling=0.5 click Optimization.
2
In the Settings window for Optimization, locate the Output While Solving section.
3
Select the Plot check box.
4
From the Plot group list, choose Topology Variable Distribution for Optimization with Target Filling 50%.
5
In the Study toolbar, click Compute.
Results
Magnetic Flux Density, Direct Model (original geometry) 1
1
In the Model Builder window, right-click Magnetic Flux Density, Direct Model (original geometry) and choose Duplicate.
2
In the Settings window for 2D Plot Group, type Magnetic Flux Density Norm for Optimization with Target Filling 50% in the Label text field.
3
Locate the Data section. From the Dataset list, choose Optimization with target filling=0.5/Solution 8 (sol8).
4
Locate the Plot Settings section. Select the Plot dataset edges check box.
5
In the Magnetic Flux Density Norm for Optimization with Target Filling 50% toolbar, click Plot.
Exporting the optimized profile, then use it to modify the geometry.
Optimization (opt)
Control Variable Field 1
1
In the Model Builder window, under Component 1 (comp1)>Optimization (opt) click Control Variable Field 1.
2
In the Settings window for Control Variable Field, locate the Discretization section.
3
From the Shape function type list, choose Lagrange.
4
Find the Base geometry subsection. From the Element order list, choose Linear.
Optimization with target filling=0.5
In the Study toolbar, click Update Solution.
Optimization (opt)
Control Variable Field 1
1
In the Model Builder window, under Component 1 (comp1)>Optimization (opt) click Control Variable Field 1.
2
In the Settings window for Control Variable Field, locate the Discretization section.
3
From the Shape function type list, choose Discontinuous Lagrange.
4
Find the Base geometry subsection. From the Element order list, choose Constant.
Results
Contour 1
1
In the Results toolbar, click More Datasets and choose Contour.
2
In the Settings window for Contour, locate the Data section.
3
From the Dataset list, choose Optimization with target filling=0.5/Solution 8 (sol8).
4
Locate the Expression section. In the Expression text field, type p.
5
Locate the Levels section. From the Entry method list, choose Levels.
6
In the Levels text field, type 0.5.
7
Click Plot.
Data 1
1
Right-click Contour 1 and choose Add Data to Export.
2
In the Filename text field, enter a temporary filename, or use the Browse button to choose one.
3
In the Settings window for Data, locate the Output section.
4
From the Data format list, choose Sectionwise.
5
From the Space dimension list, choose 2.
6
From the Geometry level list, choose Line.
7
Click the Export button.
The data has been exported to a text file. Reimport it as an interpolation curve in the geometry. This interpolation will be put under the logical condition "optimizedgeometry" so that each study will work separately.
Geometry 1
Else If 1 (elseif1)
1
In the Geometry toolbar, click Programming and choose Add After Selected>Else If.
2
In the Settings window for Else If, locate the Else If section.
3
In the Condition text field, type optimizedgeometry.
4
Click Build Selected.
Interpolation Curve 1 (ic1)
1
In the Geometry toolbar, click More Primitives and choose Interpolation Curve.
2
In the Settings window for Interpolation Curve, locate the Interpolation Points section.
3
From the Data source list, choose File.
4
In the Filename text field, enter the path to the temporary file just exported, or click Browse and navigate to it.
5
From the Data format list, choose Sectionwise.
6
In the Relative tolerance text field, type 1e-3.
Add Study
1
In the Home toolbar, click Add Study to open the Add Study window.
2
Go to the Add Study window.
3
Find the Studies subsection. In the Select Study tree, select General Studies>Stationary.
4
Click Add Study in the window toolbar.
5
In the Home toolbar, click Add Study to close the Add Study window.
Study 5
Step 1: Stationary
1
In the Settings window for Stationary, locate the Physics and Variables Selection section.
2
Select the Modify model configuration for study step check box.
3
In the Physics and variables selection tree, select Component 1 (comp1)>Magnetic Fields (mf)>Manual BH relationship.
4
Click Disable.
Parametric Sweep
1
In the Study toolbar, click Parametric Sweep.
2
In the Settings window for Parametric Sweep, locate the Study Settings section.
3
Click Add.
4
5
In the Model Builder window, click Study 5.
6
In the Settings window for Study, type Direct solution built with surface extracted from optimization result in the Label text field.
7
In the Study toolbar, click Compute.
Results
Magnetic Flux Density Norm (mf)
In the Settings window for 2D Plot Group, type Magnetic Flux Density for Optimization with Target Filling 50% in the Label text field.
Surface 1
1
In the Model Builder window, expand the Results>Magnetic Flux Density for Optimization with Target Filling 50% node, then click Surface 1.
2
In the Settings window for Surface, locate the Range section.
3
Select the Manual color range check box.
4
In the Minimum text field, type 0.
5
In the Maximum text field, type 2.
6
In the Magnetic Flux Density for Optimization with Target Filling 50% toolbar, click Plot.
Magnetic Flux Density, Direct Model
1
In the Model Builder window, click Magnetic Flux Density, Direct Model.
2
In the Settings window for 2D Plot Group, locate the Data section.
3
From the Dataset list, choose Direct solution built with surface extracted from optimization result/Solution 9 (sol9).
4
In the Magnetic Flux Density, Direct Model toolbar, click Plot.
Selection
1
In the Model Builder window, right-click Direct solution built with surface extracted from optimization result/Parametric Solutions 3 (sol10) and choose Selection.
2
In the Settings window for Selection, locate the Geometric Entity Selection section.
3
From the Geometric entity level list, choose Domain.
4
From the Selection list, choose Solid parts.
5
Select the Propagate to lower dimensions check box.
Magnetic Flux Density Norm, Revolved Geometry (mf)
1
In the Model Builder window, under Results click Magnetic Flux Density Norm, Revolved Geometry (mf).
2
In the Settings window for 3D Plot Group, type Revolved Representation of Magnetic Flux Density for Optimization with Target Filling 50% in the Label text field.
3
Click the Zoom Extents button in the Graphics toolbar.
4
In the Revolved Representation of Magnetic Flux Density for Optimization with Target Filling 50% toolbar, click Plot.
 

1
For more information on the realdot operator, see the COMSOL Multiphysics reference manual.