Walking into a video game tournament for the first time, I was surprised by the number of CRT televisions in the room. Why use box TVs instead of the current flat-screen versions? When I asked my brother — who had participated in these tournaments before — he told me that CRT TVs are better for displaying certain games, as they deliver the desired response time and frames per second. This advantage makes CRT TVs popular in the gaming community.

*A CRT television. Image by Daniel Oines — Own work. Licensed under CC BY 2.0, via Flickr Creative Commons.*

Unlike newer models, these televisions rely on CRTs, which are vacuum tubes that control how electron beams reach a screen. To focus charged particle beams, some CRTs use einzel lenses. These lenses are also found in ion propulsion systems as well as ion and electron beam experiments.

The focusing ability of an einzel lens depends on the following factors:

- Initial particle energy
- Initial beam collimation
- Voltage at each electrode

To accurately study these factors in einzel lens designs, we can use particle tracing simulation.

This einzel lens example consists of three cylinders aligned on the same axis. Of these cylinders, the middle one maintains a fixed voltage, while the outer two cylinders are grounded.

The electrons studied with this model have an initial kinetic energy of 20 keV. Their speed is an appreciable fraction of the speed of light. As such, relativistic effects are taken into account.

We can solve this model by using two different studies and interfaces. The first is a stationary study that uses the *Electrostatics* interface to calculate the electric potential and 3D electrostatic field. We then use the corresponding electric fields to exert an electric force on the modeled electrons. Second, a time-dependent study and the *Charged Particle Tracing* interface can be used to determine the electron particle trajectories.

In the next section, we see the results of these studies.

Let’s take a look at the area around the electrodes (cylinders, in this case) where the beam is focused. In the left image below, we see the equipotential surfaces that surround the electrodes. We can also study the electric potential and fringe fields by looking at a cross section near the electrodes (shown in the right image below).

*The isosurfaces of the electric potential (left) and electric potential and fringe fields (right) around the electrodes.*

Expanding the view helps to visualize the electron trajectories through the einzel lens. As shown below, the particles reduce their speed as they approach the lens. When passing through the lens, they begin to accelerate again, eventually reaching their initial speeds.

*The left image shows the electron trajectories in an einzel lens. The colors seen here represent the ratio of the particle kinetic energy to the initial kinetic energy. The right image shows the electron trajectories and the isosurfaces of the electric potential.*

Next, we examine the nominal beam trajectory of the electrons through the einzel lens. We also account for a common measurement of the area taken up by a charged particle beam in transverse phase space: hyperemittance.

*The nominal beam trajectory. Here, the color expression depicts the beam hyperemittance.*

With particle tracing modeling, we are able to better analyze einzel lenses and can use these results to improve our designs. Try the einzel lens example yourself by clicking on the button below.

- Check out the Phase Space Distributions in Beam Physics blog series
- Learn about modeling particles in a quadrupole mass spectrometer on the COMSOL Blog
- Read this blog post on modeling particle migration in inertial focusing

When performing laboratory experiments, you rely on the precision and accuracy of the — often used — measurement equipment. While plenty of information is available in the equipment specifications, it usually applies to new, well-calibrated systems. However, you might forget to calibrate your devices, or the system shows a systematic bias due to wear and other processes.

If you have a data set exhibiting such errors, it is important to correct them so that you can analyze the measured data accurately. An applied example is an experiment of flow through a column, where you inject a chemical and record the breakthrough curve at the outlet. For further analysis, the set flow rate of the pump is used. However, due to calcification, the flow rates are systematically biased. Performing a multiparameter optimization with various flow rates enables you to obtain a factor to correct all of the data.

This optimization problem is based on a transient model using the COMSOL Multiphysics® software and *Transport of Diluted Species* interface. A complete model is a prerequisite for the optimization step. The model discussed here is set in 1D and has a geometry with a column that is 1 m in length.

For the transport properties, you can set the flow velocity, which is simply the flow rate multiplied by the opening width of the column. Further, you can assign *Inflow* and *Outflow* boundary conditions and a *Dirichlet* boundary condition at the inlet, set to a fixed concentration.

*Setting up the physical problem prior to the optimization.*

While the true velocity of the problem is unknown, you can rewrite it as the product `u_in*tuning`

. Here, `u_in`

represents the set flow rate and tuning of the global correction factor, which derives directly from ` u_in=Q/(A*tuning)`

. Hence, tuning accounts for the area change of the system.

In optimization jargon, `u_in`

is the experimental parameter identifying the individual experimental runs. The obtained concentration is our least-squares objective, which is compared to measured data, and tuning is the control variable.

Starting with the complete physical model, you can add two items to transform it into an optimization model. First, the *Optimization* interface in our example has two nodes: *Objective* and *Control Variable*. For any optimization study, these nodes are a prerequisite.

While there are many feasible optimization objectives, the least-squares objective is well defined and from the shape `Sum_i(u_obs_i-u_sim_i)`

. Hence, it minimizes the sum of the distances between all given data points.^{ 2}

Due to the strict formal approach, there is no need to express the objective function. However, you need a data file that contains all information needed for a least-squares objective. It is important to note that the data file needs to be structured in columns. You can assign the individual columns in the subnodes.

Note that the order of nodes in the Model Builder tree (from top to bottom) corresponds to the order of columns in the data file (from left to right). It is also important that every column of the data file is identified by an appropriate subnode.

*Assign the nodes in the least-squares objective (top down) to the semicolon-separated columns (left to right) in the data file.*

The transport optimization example requires four columns:

In the example, you set the identifier `u_in`

in the parameter column. This is the flow rate of the pump used to discriminate between the different experiments as well as the same parameter that is assigned under *Global Definitions* > *Parameters*. You can also find this parameter used for the transport properties in the *Transport of Diluted Species* interface.

The times stated in the data file need to be in SI units, seconds. However, in general, these times don’t need to match the stored output times accurately. Nevertheless, good accuracy is still recommended.

In the value column, you give the expression, which is evaluated from the numerical model outcome. This should be entered in the way that it represents the exact metric of the recorded data. *Variable Name* refers to the measured data, which can be accessed during postprocessing by using such a name.

The stated coordinate in the file is the destination where measurements are made. There is also one specialty that must be considered: The number of coordinate columns in the data file must be the same as the dimension of the geometry, even when the selected *Least-Squares Objective* feature is on a lower dimension. In that case, model expressions are evaluated at the nearest points on the given selection.

Here, you make two adjustments by setting the method to the well-known Levenberg-Marquardt algorithm, designed to tackle least-square problems efficiently. Since the goal is to perform a multiparameter study, you can switch the least-squares time/parameter method to: *From least squares objective*. The other settings can be left as default for now.

The correct time-stepping and parameter sweeps are recognized directly from the data file and there is no need to set it individually in the *Step 1: Time dependent* settings. Eventually, using such settings, the solver can sum up all squared deviations for all time steps and parameters, as well as search and minimize such sums by finding a global correction factor that is appropriate for all individual experiments.

*Settings of the Optimization study step.*

With all of these settings, you have a very generic model that can be applied to many experimental runs by updating only the underlying data file. The settings automatically adjust the model to the experimental parameters. So far, this includes variations of the amount of experimental parameters’ recorded sample times.

Such models could be easily extended to consider more parameter variations; e.g., variations of input concentration or more measurement locations in an analog manner. Further steps could be used to transform a model into an application, where you can freely choose the length of the column, hence the geometry. This way, you end up with a powerful tool to evaluate your experiments and assure their quality.

*Results for a multiparameter fit based on three individual measurements (symbols) with the simulated and optimized output (lines).*

- Try a liquid chromatography tutorial model:
- Read this related blog post:

The idea behind natural selection is based on the fact that there is a great deal of variation in the world; even organisms of the same species differ from one another. The organisms with traits best suited for their environment are more likely to survive and pass those traits on to the next generation, which increases the occurrence of the beneficial traits in future generations. As a result, each successive generation becomes more adapted to their environment. That’s natural selection, in a nutshell.

*Over time, natural selection can result in the perpetuation of beneficial traits in a set of organisms, such as long necks in giraffes.*

Genetic algorithms take the principles of natural selection and apply them to optimization problems. They study a set of “individuals” in an environment that has known values and characteristics. The studied population of individuals represents potential solutions to the problem. Appropriate mathematical functions define the fitness of each individual by representing how well adapted they are to the environment.

As with natural selection, using genetic algorithms is an iterative process, with the individuals in each “generation” potentially experiencing mutations and exchanging design characteristics. The process continues until the algorithms find an optimized solution for the particular environment or reach a maximum number of generations.

A research group from Universidad Autónoma de San Luis Potosí and Instituto Tecnológico de San Luis Potosí used genetic algorithms to improve the geometry of an optical antenna (nanoantenna). They wanted a design that optimally concentrates the electromagnetic field of a dipole nanoantenna at a 500-THz resonance frequency, which is a variable that depends on the dimensions of the nanostructure.

As an additional point of study, the team investigated if conventional RF macroscopic antenna geometries can be efficiently used for nanoscale optical frequency regimes. Here’s what they found out…

In their research, the team used LiveLink™ *for* MATLAB® to seamlessly link the MATLAB® software and the COMSOL® software. In doing so, they were able to use MATLAB® software to automatically drive their COMSOL Multiphysics® simulations. Using MATLAB® software, the researchers designed a user interface and genetic algorithm. The genetic algorithm was programmed with the Global Optimization Toolbox, available as an add-on to the MATLAB® software. The algorithm performed analyses to suggest various iterative design changes for the dipole nanoantenna geometry in 2D. These genetic algorithm results were then compared with the optimal conditions to evaluate their fit.

*The lines show how mutations modify the antenna geometry during the genetic algorithm process. Image by R. Diaz de Leon-Zapata, G. Gonzalez, A.G. Rodríguez, E. Flores-García, and F.J. Gonzalez and taken from their COMSOL Conference 2016 Boston paper.*

Whenever the algorithm yielded a design possibility, the researchers could automatically solve the electromagnetic equations, generate antenna response data for a given frequency, and evaluate the fitness function without having to interact with the graphical user interface in COMSOL Multiphysics. The optimized fitness function determined the minimum loss of the electromagnetic field at a frequency of 500 THz. These findings were then used in MATLAB® software to perform further genetic algorithm adjustments. This entire iterative loop was performed automatically, increasing the efficiency of the study.

*The trend toward a minimized electromagnetic field loss for each new generation. Image by R. Diaz de Leon-Zapata et al. and taken from their COMSOL Conference 2016 Boston paper.*

The automatic process continued until the software reached convergent results for an improved antenna geometry. Using this procedure, the researchers obtained their final results at a lower computational cost and a shorter processing time than traditional analytical processes.

*The final antenna geometry attained from genetic algorithm optimization. Image by R. Diaz de Leon-Zapata et al. and taken from their COMSOL Conference 2016 Boston paper.*

Let’s take a closer look at the final design of the nanoantenna. The final design iteration (below, to the right) is quite different from the design of a conventional dipole antenna (below, to the left). The final design is the most fit in this case, since it has the lowest electromagnetic field loss at the center of the structure.

*Comparison of the electromagnetic field concentrations for a classical dipole antenna (left), the first design iteration from the genetic algorithm (middle), and the final geometry (right). Image by R. Diaz de Leon-Zapata et al. and taken from their COMSOL Conference 2016 Boston paper.*

To visualize this in a different way, the research group plotted the electromagnetic field concentration for a conventional dipole antenna and the finalized geometry over a range of frequencies. The comparison shows that while both geometries encompass the same effective area, the version created using the genetic algorithm represents an optimal concentration. Compared with previous studies, the final design also has an increased electromagnetic signal and bandwidth.

*Comparison of the electromagnetic field concentration for a classical dipole geometry (red) and the geometry generated from the genetic algorithm (blue). Image by R. Diaz de Leon-Zapata et al. and taken from their COMSOL Conference 2016 Boston paper.*

Using these findings, the researchers concluded that the genetic algorithm can enhance the maximum electromagnetic field concentration in the optical frequency regime. The team’s next step is to use the results of this analysis to study nanostructure fabrication and characterization, which could help foster the creation of renewable energy devices.

- Read the research team’s original work: “Genetic Algorithm for Geometry Optimization of Optical Antennas“
- Watch this 18-minute video to learn about using LiveLink™
*for*MATLAB® - Read a blog post to get an introduction to designing antennas in COMSOL Multiphysics

*MATLAB is a registered trademark of The MathWorks, Inc.*

Pipelines are an economic approach to transporting fluids like oil, natural gas, and water across land and sea, though they are expensive to build. These structures are comprised of steel or plastic tubes that are typically buried or run at the bottom of the sea, with pump stations distributed throughout the system to keep the fluid moving.

As a petroleum mixture is pumped through a pipeline, it generates heat as a result of internal friction forces. The origin of this heat is the energy supplied by the pump. This heat is quickly dissipated if the pipeline runs through cold environments. Eventually, the temperature of the mixture reaches the same temperature as that of the environment, if the pipeline is not insulated. At lower temperatures, oil becomes more viscous, which increases the energy consumption of the pumps. On top of that, cold petroleum mixtures require preheating before they can be used in the refinery. The preheating process consumes energy and requires investment to build and maintain.

*Pipelines are used to transport fluids throughout the world.*

It is an easy and obvious thing to insulate a pipeline to avoid the decrease in temperature of the oil by keeping the energy supplied by the pumps inside the pipe. The trick is to insulate the pipeline well enough, but not more, so that the return on investment motivates the cost of the insulation. If the petroleum mixture temperature can be kept at a high enough level, the cost of the preheating process can be eliminated and the pump’s energy consumption can be reduced substantially. The reduction of theses costs have to motivate the investment in insulation.

The fluid flow and heat transfer processes in the pipeline can be modeled and simulated accurately using the COMSOL Multiphysics® software. The models can be used to design an insulation that is as inexpensive as possible, yet as efficient as required to keep the oil at the desired temperature.

Our Insulation of a Pipeline Section tutorial model features a 150-km pipeline section that has an inlet temperature of 25°C. The oil that enters the pipeline flows at a rate of 2500 m^{3}/h. To set up and solve the energy and flow equations that describe the transport of the fluid within the pipeline, we use the *Nonisothermal Pipe Flow* interface.

This particular case involves analyzing one pipe wall and one insulation layer, as highlighted in the schematic below. Here, the dark and light gray layers represent a two-layered wall, while light blue represents the film resistances on the inside and outside of the walls. Note that the pipe wall is 2 cm thick in this example.

*Schematic of the pipeline cross section, where h _{int} and h_{ext} are the film heat transfer coefficients inside and outside of the tube and k_{ins} and k_{wall} are the thermal conductivity of the insulation and the wall, respectively.*

In the first study, we calculate the temperature along the pipeline for two different cases: one where perfect insulation is assumed and one where the pipeline has no insulation. The plot below shows that the heat resulting from friction forces in the fluid causes its temperature to increase by about 3°C over 150 km. When no insulation is added to the pipeline, the outlet temperature is similar to that of the surroundings.

*Plot comparing the fluid temperature when there is perfect insulation on the pipeline (green) and when there is no insulation (blue).*

With an understanding of the fluid flow and heat transfer processes, we can perform optimization calculations to identify the minimum insulation thickness required to keep the oil temperature at a constant level throughout the pipeline. The results from this particular optimization study indicate that the minimum insulation thickness is around 8.9 cm. We could also perform a similar optimization study, but for a minimum acceptable oil temperature level at the end of the pipeline, which could potentially reduce the insulation thickness (and the cost) even more.

Based on the calculated minimum thickness for the insulation, we may estimate the investment costs and decide if these costs are motivated by the reduced pumping and preheating costs. We can potentially reduce energy consumption in the pumping process and eliminate it for preheating, making the process more efficient and environmentally friendly.

]]>

Vacuum technology is found in many high-tech applications, including semiconductor processing, mass spectrometry, and materials processing. This technology creates low-pressure environments by using vacuum pumps to remove air molecules from enclosed vacuum chambers.

One type of vacuum pump is a turbomolecular pump, which consists of a bladed molecular turbine. The blades of modern turbomolecular pumps rotate extremely quickly, reaching speeds as high as 90,000 rpm.

*A turbomolecular pump.*

The momentum transfer from the rotating blades to the gas molecules compresses the gas, which is moved from the inlet to the outlet by the blades. As a result, the pump is able to generate and maintain a high vacuum on the inlet side of the blades. This pumping process is more efficient in the free molecular flow range, since the gas particles mostly collide with the rotor and not with each other.

We can better understand and design turbomolecular pumps by modeling them with COMSOL Multiphysics. But first, we need to figure out the best way to do so.

Instead of focusing on the whole turbomolecular pump, our model geometry depicts part of a single turbomolecular pump stage (a row of blades). Using the model, we calculate gas molecule trajectories in the empty space between the blades. This enables us to assume sector symmetry in the modeling domain.

*Model geometry of one sector of one stage of a turbomolecular pump. Gray represents the space between two blades, green represents the blade walls, and black represents the rotor root.*

While we don’t use it here, one way to solve the model equations and calculate the pump’s performance in a free molecular flow regime is with the *Free Molecular Flow* interface from the Molecular Flow Module. This interface is an efficient option and is useful in cases where the molecules of extremely rarefied gases move significantly faster than any object in the modeling domain. However, in turbomolecular pumps, the speed of the gas molecules is comparable with the blade speed. As such, we need a different approach for this problem.

*The turbomolecular pump example model.*

We use a Monte Carlo approach and the *Rotating Frame* feature (new to the Particle Tracing Module in version 5.3 of COMSOL Multiphysics®) to automatically apply the fictitious Coriolis and centrifugal forces to the particles. This enables us to compute the particle trajectories within a noninertial frame of reference that moves along with the blades.

This method provides accurate results on how the blade velocity ratio affects the pumping characteristics, such as the maximum compression ratio, transmission probability, and maximum speed factor. We base these characteristics on the transmission probability of argon atoms from the inlet to the outlet and vice versa.

For more information on how we created this model, including the geometric parameters and assumptions, check out the documentation for the turbomolecular pump tutorial.

Let’s begin by computing the transmission probabilities for particles propagating in the forward (inlet to outlet) and reverse (outlet to inlet) directions. As expected, when the blades are at rest, these probabilities are about equal. This is because there is no distinction between the two directions.

However, when the rotation of the blades begins to increase, the particles are more likely to be transported forward through the pump, as the walls successfully transfer momentum to the argon atoms. This corresponds to an increasing compression ratio.

*The fraction of particles transmitted in the forward direction (left) and the reverse direction (right) as a function of blade velocity ratio.*

We also investigate how the compression ratio and speed factor are affected by the blade velocity ratio. To produce enough compression and speed, pumps use multiple bladed structures comprised of several disks and different types of blades. Blades close to the inlet have a high pumping speed and low compression ratio, while blades close to the outlet have the opposite characteristics.

When the velocity of these blades increases, as seen in the plots below, the maximum compression and speed factor increase. This confirms that the two blade types work together to enhance the performance of the pump.

*The effect of blade velocity on the maximum compression ratio (left) and maximum speed factor (right).*

This example highlights the new modeling features that enable you to more easily analyze turbomolecular pumps. Try it yourself by clicking on the button below.

- Check out these blog posts on particle tracing:

In the 1960s, G. Segré and A. Silberberg observed a surprising effect: When carried through a laminar pipe flow, neutrally buoyant particles congregate in a ring-like structure with a radius of about 0.6 times the pipe radius. This correlates to a distance from the parallel walls of around 0.2 times the width of the flow channel. The reason for this behavior, as they would discover decades later, could be traced back to the forces that act on particles in an inertial flow.

Today, we use the term inertial focusing to describe the migration of particles to a position of equilibrium. This technique is widely used in clinical and point-of-care diagnostics as a way to concentrate and isolate particles of different sizes for further analysis and testing.

*Many types of medical diagnostics use inertial focusing for testing and analysis. Image in the public domain, via Wikimedia Commons.*

In order for inertial focusing to be effective in these and other applications, accurately analyzing the migration patterns of the particles is a key step. A new benchmark example from the latest version of COMSOL Multiphysics — version 5.3 — highlights why the COMSOL® software is the right tool for obtaining reliable results.

For this example, we consider the particle trajectories in a 2D Poiseuille flow. To account for relevant forces, we use derived expressions from a similar migration of particles in a 2D parabolic flow inside of two parallel walls (see Ref. 2 in the model documentation). Built-in corrections for both the lift and drag forces allow us to account for the presence of these walls in the simulation analysis.

Note: Lift and drag forces make up the total force acting on neutrally buoyant particles inside a creeping flow. By definition, the gravitational and buoyant forces cancel out one another.

We assume that the lift force acts only perpendicular to the direction of the fluid velocity. It is also assumed that the spherical particles are small in comparison to the width of the channel and that they are rotationally rigid.

To compute the velocity field, we use the *Laminar Flow* physics interface. This is then coupled to the *Particle Tracing for Fluid Flow* interface via the *Drag Force* node. Thanks to the *Laminar Inflow* boundary condition, we can automatically compute the complete velocity profile at the inlet boundary. For the laminar flow of a Newtonian fluid inside two parallel walls, it is known that the profile will be parabolic. This means that we could have directly entered the analytic expressions for fluid velocity. However, we opt to use the *Laminar Flow* physics interface in this case, as it demonstrates the workflow that is most appropriate for a general geometry.

Now let’s move on to the results. First, we can look at the fluid velocity magnitude in the channel. As expected, the velocity profile is parabolic. Note that the aspect ratio of the geometry is 1000:1, so the channel is very long compared to its height. The plot uses an automatic view scale to make the results easier to visualize.

*The parabolic fluid velocity profile within a channel that is bound by two parallel walls.*

We can then shift our attention to the trajectories of the neutrally buoyant particles. Note that in the plot below, the color expression represents the *y*-component of the particle velocity in mm/s. The results indicate that all of the particles are close to equilibrium positions at distances of about 0.3 D on either side of the center of the channel. (D represents the width of the channel). It does, however, take longer for particles released near the center of the channel to reach these positions. Their initial force is weaker as they are released in the area where the velocity gradient is smallest. From the plots, we can see that the particles converge at heights that are 0.2 and 0.8 times the width of the channel. These findings show good agreement with experimental observations.

*The trajectory of particles inside the channel.*

The last two plots show the average and standard deviation of the normalized distance between the particles and the center of the channel. These results verify that the equilibrium distance from the center of the channel is in fact around 0.3 D.

*The average (left) and standard deviation (right) of the normalized distance between the particles and center of the channel.*

In order to effectively use inertial focusing for medical and other applications, you need to first understand the behavior of particles as they migrate through a channel to positions of equilibrium. With COMSOL Multiphysics® version 5.3, you can perform these studies and generate reliable results. This accurate description of inertial focusing serves as a foundation for analyzing and optimizing designs that rely on this technique.

Now it’s your turn! Give our new benchmark model a try:

Interested in learning about further updates in version 5.3 of COMSOL Multiphysics? You can get the full scoop in our 5.3 Release Highlights.

]]>

Let’s suppose that we are tasked with designing a coil such that the magnetic field along part of the centerline is as close to a target value as possible. As we saw in an earlier blog post, we can achieve this by adjusting the current through each turn of the coil to be different. However, this requires that we include a separate current control for each turn in our physical design. Instead, we can use a single current control for the entire coil and adjust the physical spacing of the coils along the axial direction.

*A ten-turn axisymmetric coil. The objective is to alter the magnetic field at the centerline (green).*

The case that we will consider here is shown in the image above. A ten-turn axisymmetric coil is driven by a single current source; that is, the same current flows through each turn. The initial coil design spaces the 1-cm-diameter coil turns a distance of *S _{0}* = 4 cm apart. Since the coil is axisymmetric (and we are only interested in solutions that are symmetric about the

*The computational model. We want to change the five coil positions and the coil current.*

Our optimization objective is to get the *B _{z}* field as close as possible to a desired value,

More formally, these statements can be written as:

\begin{aligned}

& \underset{I, \Delta Z_1, \ldots ,\Delta Z_5}{\text{minimize:}}

& & \frac{1}{L_0} \int_0^{L_0} \left( \frac{B_z}{B_0} -1 \right) ^2 d l \\

& \text{subject to:}

& & -(S_0-G_0)/2 \le \Delta Z_1 \leq \Delta Z_{max}\\

& & & -\Delta Z_{max} \leq \Delta Z_2, \ldots ,\Delta Z_5 \leq \Delta Z_{max}\\

& & & G_0 \le (Z_5-Z_4) \\

& & & G_0 \le (Z_4-Z_3) \\

& & & G_0 \le (Z_3-Z_2) \\

& & & G_0 \le (Z_2-Z_1) \\

& & & 0 \leq I \leq I_{max}\\

\end{aligned}

& \underset{I, \Delta Z_1, \ldots ,\Delta Z_5}{\text{minimize:}}

& & \frac{1}{L_0} \int_0^{L_0} \left( \frac{B_z}{B_0} -1 \right) ^2 d l \\

& \text{subject to:}

& & -(S_0-G_0)/2 \le \Delta Z_1 \leq \Delta Z_{max}\\

& & & -\Delta Z_{max} \leq \Delta Z_2, \ldots ,\Delta Z_5 \leq \Delta Z_{max}\\

& & & G_0 \le (Z_5-Z_4) \\

& & & G_0 \le (Z_4-Z_3) \\

& & & G_0 \le (Z_3-Z_2) \\

& & & G_0 \le (Z_2-Z_1) \\

& & & 0 \leq I \leq I_{max}\\

\end{aligned}

We solve this problem with a combination of parameter and shape optimization by using the *Optimization* and *Deformed Geometry* interfaces in COMSOL Multiphysics.

We can begin our implementation by reviewing the model developed here, which optimizes for a particular field value. We start with the same *Optimization* interface and *Integral Objective* feature introduced in the previous blog post. Two *Global Control Variable* features are then used. The first sets up the displacements of the five coils, using *Control Variables Scaling* to scale the optimization variables close to unity. The second *Global Control Variables* feature similarly defines and constrains the current.

*The definitions of the variables that control the five coils’ positions.*

The five *Control Variables* shown in the screenshot above define the displacements of the coils, as well as a small square region of space around each coil, which is shown as the green domains in the illustration below. As these green domains move up and down, the surrounding yellow domains must stretch and shrink to accommodate, while the surrounding blue domain is fixed. Since we know the displacements of the green domains, we can specify a linear variation of displacement along all of the red edges. This linear displacement variation is computed using a *Coefficient Form Boundary PDE* interface, as described in an earlier blog post on modeling translational motion.

*The definitions of the deformations for the various domains in the model.*

This information about the specified displacements of the various domains is set up using the *Deformed Geometry* interface, as shown in the screenshot below. The *Prescribed Deformation* domain features move the green domains and the yellow domains are allowed to deform due to the *Free Deformation* domains. The *Prescribed Mesh Displacement* boundary features apply to the black and red edges and completely define the deformations of the yellow domains.

*The control over the coil turn displacement via the Prescribed Deformation feature in the* Deformed Geometry *interface.*

As a consequence of setting up the *Deformed Geometry* interface in this way, the five control variables for the positions of the coils now represent a shape optimization problem. Previously, we have discussed shape optimization in a more general case from structural mechanics. Shape optimization takes advantage of the ability of COMSOL Multiphysics to compute design sensitivities with respect to changes in the shape of the geometry.

We also need to define a set of *Global Inequality Constraints* to prevent the green domains surrounding the coils from getting too close to each other and intersecting. The screenshot below shows this implementation. Note that the constraint is scaled with respect to the gap size *G _{0}* so that the constraint equation is also close to one in magnitude.

*One of the four constraints that keep the coils from getting too close to each other.*

Due to the large deformations that can occur in the domains around the coils that stretch and contract, it is also helpful to use a mapped mesh.

*A mapped mesh is used in the deforming domains around the coils. The infinite element domain also has a mapped mesh.*

We can then solve this problem using a gradient-based optimization solver (SNOPT), taking advantage of the analytically computed gradients. The current through the coil and the coil positions are adjusted to minimize the above objective function. The results of the optimization are shown in the figure below.

*The magnetic flux density’s* z*-component along the centerline for the optimized coil.*

*The optimized coil positions.*

We have introduced a model that uses a combination of shape and parameter optimization to adjust the coil current and spacing between the coils in a 2D axisymmetric coil. By taking advantage of the *Optimization* and *Deformed Geometry* interfaces, we are able to analytically compute the derivatives for this problem and converge to an optimum very quickly.

- Read a blog post on modeling a linear electromagnetic plunger
- Browse the Optimization category on the COMSOL Blog

The problem we will look at today is the optimization of a ten-turn axisymmetric coil structure, as shown in the image below. Each of the five turns on either side of the *xy*-plane is symmetrically but independently driven.

*A ten-turn coil with five independently driven coil pairs. The objective is to alter the magnetic field at the centerline (green highlight).*

The coil is both rotationally symmetric and symmetric about the *z* = 0 plane, so we can reduce the computational model to a 2D axisymmetric model, as shown in the schematic below. Our modeling domain is truncated with an *infinite element* domain. We use the Perfect Magnetic Conductor boundary condition to exploit symmetry about the *z* = 0 plane. Thus, our model reduces to a quarter-circle domain with five independent coils that are modeled using the *Coil Domain* feature.

*A schematic of the computational model.*

If all of the coils are driven with the same current of 10 A, we can plot the *z*-component of the magnetic flux density along the centerline, as shown in the image below. It is this field distribution along a part of the centerline that we want to change via optimization.

*The magnetic field distribution along the coil centerline. We want to adjust the magnetic field within the optimization zone.*

From the image above, we see the magnetic field along a portion of the centerline due to a current of 10 A through each coil. It is this field distribution that we want to change by adjusting the current flowing through the coils. Our design variables are the five unique coil currents: . These design variables have bounds: . That is, the current cannot be too great in magnitude, otherwise the coils will overheat.

We will look at three different optimization problem statements:

- To have the magnetic field at the centerline be as close to a desired target value as possible
- To minimize the power needed to drive the coil, along with a constraint on the field minimum at several points
- To minimize the gradient of the magnetic field along the centerline, along with a constraint on the field at one point

Let’s state these optimization problems a bit more formally. The first optimization problem can be written as:

\begin{aligned}

& \underset{I_1, \ldots ,I_5}{\text{minimize:}}

& & \frac{1}{L_0} \int_0^{L_0} \left( \frac{B_z}{B_0} -1 \right) ^2 d l \\

& \text{subject to:}

& & -I_{max} \leq I_1, \ldots ,I_5 \leq I_{max}\\

\end{aligned}

& \underset{I_1, \ldots ,I_5}{\text{minimize:}}

& & \frac{1}{L_0} \int_0^{L_0} \left( \frac{B_z}{B_0} -1 \right) ^2 d l \\

& \text{subject to:}

& & -I_{max} \leq I_1, \ldots ,I_5 \leq I_{max}\\

\end{aligned}

The objective here is to minimize the difference between the computed *B _{z}*-field and the desired field,

Now, let’s look at the implementation of this problem within COMSOL Multiphysics. We begin by adding an *Optimization* interface to our model, which contains two features. The first feature is the *Global Control Variables*, as shown in the screenshot below. We can see that five control variables are set up: `I1,...,I5`

. These variables are used to specify the current flowing through the five *Coil* features in the *Magnetic Fields* interface.

The *Initial Value*, *Upper Bound*, and *Lower Bound* to these variables are also specified by two *Global Parameters*, `I_init`

and ` I_max`

. Also note that the *Scale factor* is set such that the optimization variables also have a magnitude close to one. We will use this same setup for the control variables in all three examples.

*Setting up the Global Control Variables feature, which specifies the coil currents.*

Next, the objective function is defined via the *Integral Objective* feature over a boundary, as shown in the screenshot below. Note that the *Multiply by 2πr* option is toggled off.

*The implementation of the objective function to achieve a desired field along one boundary.*

We include an *Optimization* step in the Study, as shown in the screenshot below. Since our objective function can be analytically differentiated with respect to the design variables, we can use the SNOPT solver. This solver takes advantage of the analytically computed gradient and solves the optimization problem in a few seconds. All of the other solver settings can be left at their defaults.

*The Optimization study step.*

After solving, we can plot the fields and results. The figure below shows that the *B _{z}*-field matches the target value very well.

*Results of optimizing for a target value of magnetic flux along the centerline.*

Our second optimization problem is to minimize the total power needed to drive the coil and to include a constraint on the field minimum at several points along the centerline. This can be expressed as:

\begin{aligned}

& \underset{I_1, \ldots ,I_5}{\text{minimize:}}

& & \frac{1}{P_o}\sum_{k=1}^{5} P_{coil}^k \\

& \text{subject to:}

& & -I_{max} \leq I_1, \ldots ,I_5 \leq I_{max}\\

& & & 1 \le B_z^i/B_{0}, i=1, \ldots, M

\end{aligned}

& \underset{I_1, \ldots ,I_5}{\text{minimize:}}

& & \frac{1}{P_o}\sum_{k=1}^{5} P_{coil}^k \\

& \text{subject to:}

& & -I_{max} \leq I_1, \ldots ,I_5 \leq I_{max}\\

& & & 1 \le B_z^i/B_{0}, i=1, \ldots, M

\end{aligned}

where *P _{o}* is the initial total power dissipated in all coils and is the power dissipated in the k

We further want to constrain the fields at *M* number of points on the centerline to be above a value of *B*_{0}.

The implementation of this problem uses the same Global Control Variables feature as before. The objective of minimizing the total dissipated coil power is implemented via the *Global Objective* feature, as shown in the screenshot below. The built-in variables for the dissipated power (`mf.PCoil_1,...,mf.PCoil5`

) in each Coil feature can be used directly. The objective is normalized with respect to the initial total power so that it is close to unity.

*Implementation of the objective to minimize total power.*

The constraint on the field minimum has to be implemented at a set of discrete points within the model. In this case, we introduce five points evenly distributed over the optimization zone. Each of these constraints has to be introduced with a separate *Point Sum Inequality Constraint* feature, as shown below. We again apply a normalization such that this constraint has a magnitude of one. Note that the *Multiply by 2πr* option is toggled off, since these points lie on the centerline.

*The implementation of the constraint on the field minimum at a point.*

We can solve this problem using the same approach as before. The results are plotted below. It is interesting to note that the minimal dissipated power solution does not result in a very uniform field distribution over the target zone.

*Results of optimizing for a minimum power dissipation with a constraint on the field minimum.*

Finally, let’s consider minimizing the gradient of the field along the optimization zone, with a constraint on the field at the centerpoint. This can be expressed as:

\begin{aligned}

& \underset{I_1, \ldots ,I_5}{\text{minimize:}}

& & \frac{1}{L_0 B_{0}} \int_0^{L_0} \left( \frac{\partial B_z}{\partial z } \right) ^2 d l \\

& \text{subject to:}

& & -I_{max} \leq I_1, \ldots ,I_5 \leq I_{max}\\

& & & B_z(r=0,z=0) = B_0 \end{aligned}

& \underset{I_1, \ldots ,I_5}{\text{minimize:}}

& & \frac{1}{L_0 B_{0}} \int_0^{L_0} \left( \frac{\partial B_z}{\partial z } \right) ^2 d l \\

& \text{subject to:}

& & -I_{max} \leq I_1, \ldots ,I_5 \leq I_{max}\\

& & & B_z(r=0,z=0) = B_0 \end{aligned}

The constraint here fixes the field at the centerpoint of the coil. Although the *Optimization* interface does have an explicit equality constraint, we can achieve the same results with an inequality constraint with equal upper and lower bounds. We again apply a normalization such that our constraint is actually , as shown in the image below.

*The implementation of an equality constraint.*

The objective of minimizing the gradient of the field within the target zone is implemented via the Integral Objective feature (shown below). The gradient of the *B _{z}*-field with respect to the

`d(mf.Bz,z)`

.

*The objective of minimizing the gradient of the field.*

We can use the same solver settings as before. The results for this case are shown below. The field within the optimization zone is quite uniform and matches the target at the centerpoint.

*Results of optimizing for a minimum field gradient with a constraint on the field at a point.*

Although the field here appears almost identical to the first case, the solution in terms of the coil currents is quite different, which raises an interesting point. There are multiple combinations of coil currents that will give nearly identical solutions in terms of minimizing the field difference or gradient. Another way of saying this is that the objective function has multiple local minimum points.

The SNOPT optimization solver uses a type of gradient-based approach and will approach different local minima for different initial conditions for the coil currents. Although a gradient-based solver will converge to a local minimum, there is no guarantee that this is in fact the global minimum. In general (unless we perform an exhaustive search of the design space), it is never possible to guarantee that the optimized solution is a global minimum.

Furthermore, if we were to increase the number of coils in this problem, we can get into the situation where multiple combinations of coil currents are nearly equivalently optimal. That is, there is no single optimal point, but rather an “optimal line” or “optimal surface” in the design space (the combination of coil currents) that is nearly equivalent. The optimization solver does not provide direct feedback of this, but will tend to converge more slowly in such cases.

We have shown three different ways to optimize the currents flowing through the different turns of a coil. These three cases introduce different types of objective functions and constraints and can be adapted for a variety of other cases. Depending upon the overall goals and objectives of your coil design problem, you may want to use any one of these or even an entirely different objective function and constraint set. These examples show the power and flexibility of the Optimization Module in combination with the AC/DC Module.

Of course, there is even more that can be done with these problems. In an upcoming blog post, we will look at adjusting the locations of the coil turns — stay tuned.

*Editor’s note: We have published the follow-up post in this blog series. Read it here: “How to Optimize the Spacing of Electromagnetic Coils“.*

- Browse the COMSOL Blog for more information on modeling electromagnetic coils:

Topology optimization is a useful capability because it can help us find designs that we would not have reasonably been able to think of ourselves. When developing a design, however, this is only the first step. It may not be reasonable or possible to construct a particular design found through topology optimization, either because the design is too costly to produce or it is simply not possible to manufacture.

*Topology optimization results for an MBB beam.*

To address these concerns, we can come up with new designs that are based on the results of topology optimization, and then carry out further simulation analyses on them. But how do we do this? As it turns out, COMSOL Multiphysics makes it simple to create geometries from the 2D and 3D plots of your topology optimization results, which you can continue to work with directly in COMSOL Multiphysics or export to a wide range of CAD software platforms.

To view topology optimization results that are in 2D, we can create a contour plot. Let’s use the Minimizing the Flow Velocity in a Microchannel tutorial to demonstrate this process. The goal of the tutorial is to find an optimal distribution of a porous filling material to minimize the horizontal flow velocity in the center of a microchannel.

First, we open up the model file included in the tutorial and go to the *Contour 1* plot feature under the *Velocity (spf)* plot group.

*The horizontal velocity (surface plot) and velocity field (streamlines) after optimization. The black contours represent the filling material.*

In the above plot, the black contour is where the design variable, , equals 0.5. This indicates the border between the open channel and filling material. This is the result that we would like to incorporate into the geometry. In other applications, the expression and exact level to plot may differ, but the principle is the same: to find a contour that describes the limit between the solid and nonsolid materials (typically a fluid of some kind).

To create a geometry from this contour plot, we right-click the *Contour* feature node and choose *Add Plot Data to Export*. We need to make sure that we choose the data format as *Sectionwise* before we export the file.

The *Sectionwise* format describes the exported data using one section with coordinates, one with the element connectivity, and another that includes the data columns. It is important to note that the middle section, which describes how the coordinates of the first section are connected, will allow a contour plot with several closed loops or open curves.

The *Spreadsheet* export format is not suited for this particular use for several reasons, most importantly because it will assume that all coordinates are connected one after the other. This means that if there is more than one isolated contour, it will not be possible to build the *Interpolation Curve* feature. Also, the coordinates are scrambled, so the curve in the next step (discussed below) will not be drawn in the same way as seen in the contour plot.

To create the new geometry, we choose *Add Component* from the *Home* toolbar and choose a new *2D Component*. Then, we copy the geometry feature nodes from the original geometry and paste them to the geometry sequence of the new 2D component. After this, we add an *Interpolation Curve* from the *More Primitives* menu on the *Geometry* toolbar and set the type as *Open Curve*, data format as *Sectionwise*, and a tolerance of 2e-2.

A smaller tolerance will give a curve that is more true to the data, but the outcome might be an intricate or “wiggly” geometry. In turn, a higher tolerance may give a curve that is too simplified and quite far from the optimized result.

*Geometry with the interpolation curves representing the results of the topology optimization.*

The geometry can now be used to run further simulations and to verify the created geometry within COMSOL Multiphysics.

The DXF format is a 2D format that most CAD software platforms can read. DXF also describes the higher-order polygons between the points, so it usually gives a better representation than exporting only the points.

To export the optimized topology from this geometry to a DXF file, we can follow the steps below. Please note that there is an optional step for if you only want to include the shape of the optimized topology in your DXF file.

- Add a
*Union*from the*Booleans and Partitions*menu on the*Geometry*toolbar - Include all of the objects
- Use a
*Delete Entities*feature to remove the unwanted domains (optional) - Click the
*Export*button on the*Geometry*toolbar to write to the DXF format for a 2D geometry

Now, let’s see what to do when working with topology optimization results that are in 3D.

After performing a topology optimization in 3D, we usually view the resulting shape by creating a plot of the design variable; for example, an isosurface plot. We can directly export such a plot to a format that is compatible with COMSOL Multiphysics and CAD software and can even be used directly for 3D printing. This file format is the STL format, where the surfaces from the results plot are saved as a collection of triangles. It is a common standard file format for 3D printing and 3D scans in general.

In COMSOL Multiphysics, it is possible to export an STL file from the following plot features:

*Volume**Isosurface**Surface**Slice**Multislice**Far Field*

The software also supports adding a *Deformation* node on the plot feature, in case we want to export a deformed plot. The volume and isosurface plots are the most commonly used plot types for topology optimization, so we will focus our discussion on these two options.

To create an isosurface plot, we first add a 3D plot group to which we add an *Isosurface* feature node. In the *Expression* field, we then enter the design variable name, set the entry method as *Levels*, and fill in an appropriate value of the design variable representing the interface between the solid and nonsolid materials.

To demonstrate this process, let’s look at the example of the bridge shown below, where the optimal material distribution takes the familiar shape of an arch bridge. The optimization algorithm is maximizing the stiffness of the bridge subjected to a load to reach the displayed solution. To obtain the displayed isosurface plot, we use the expression 0.1 for the level of the design variable.

*An isosurface plot of the 3D topology optimization for a deck arch bridge.*

As you can see in the screenshot above, isosurface plots are not necessarily capped or airtight, so an exported volume plot may be a better choice, especially if we want to run further simulation analyses in COMSOL Multiphysics.

We can create a suitable plot by adding a *Volume* feature node to a 3D plot group. Then, we add a *Filter* node under *Volume* and set a suitable expression for inclusion. In this example, we use the expression rho_design > 0.1.

*A volume plot of the deck arch bridge.*

Exporting the data into an appropriate file format is simple. We right-click the *Volume* or *Isosurface* feature node and select *Add Plot Data to Export*. In the settings window of the resulting *Plot* node, we then select *STL Binary File (*.stl)* or *STL Text File (*.stl)* from the *Data format* drop-down list.

The exported STL file is readily readable by most CAD software platforms. To continue with the simulation of the geometry, import the STL file to a new COMSOL Multiphysics model, a process that we discuss in a previous blog post.

If you want to compare actual CAD drawings with your optimized results, you need to export the data in a format that can be imported into the CAD software you are using. The DXF format (for 2D) and the STL format (for 3D) are widely used formats and should be possible to import in almost any software platform.

In this blog post, we have discussed the steps needed to export topology optimization results in the DXF and STL formats. This will enable you to more efficiently analyze your model geometries within COMSOL Multiphysics and CAD software.

- Learn more about topology optimization and exporting geometries on the COMSOL Blog:

Topology optimization is a powerful tool that enables engineers to find optimal solutions to problems related to their applications. Here, we’ll take a closer look at topology optimization as it relates to acoustics and how we optimally distribute acoustic media to obtain a desired response. Several examples will further illustrate the potential of this optimization technique.

Many engineering tasks revolve around optimizing an existing design or a future design for a certain application. Best practices and experiences derived from years of working within a given industry are of great importance when it comes to improving designs. However, optimization problems are often so complex that it is impossible to know if design iterations are pushing things in the right direction. This is where *optimization* as a mathematical discipline comes into play.

Before we proceed, let’s review some important terminology. In optimization — be it parameter optimization, shape optimization, or in our case topology optimization — there is always at least one so-called *objective function*. Typically, we want to minimize this function. For acoustic problems, we may want to minimize the sound pressure in a certain region, whereas for structural mechanics problems, we may want to minimize the stresses in a part of a structure. We state this objective as

\min_{\chi} F (\chi)

with *F* being the objective function. A *design variable* is varied throughout the optimization process to reach an optimal solution. It is varied within a *design domain* denoted *Ω _{d}*, which generally does not make up the entire finite element space

*The design domain is generally a subset of the entire finite element domain.*

Note that since the design variable varies as a function of space over the finite element discretized design domain, it is as such a vector. For this particular case, we will simply address it as a variable.

The optimization problem may have more than one objective function, and so it will be up to the engineer to decide how large of a weight each of these objectives should carry. Note that because the objectives may oppose each other during the optimization, special care should be taken when setting up the problem.

In addition to the objective function(s), there will usually be some *constraints* associated with the optimization problem. These constraints reflect some inherent size and/or weight limitations for the problem in question. With the *Optimization* interface in COMSOL Multiphysics, we can input the design variable, the objective function(s), and the constraints in a systematic way.

With topology optimization, we have an iterative process where the design variable is varied throughout the design domain. The design variable is continuous throughout the domain and takes on values from zero to one over the domain:

0 < \chi \leq 1\ \forall\ (x, y)\ \varepsilon\ \Omega_d.

Ideally, we want the design variable to settle near values of either zero or one. In this way, we get a near discrete design, with two distinct (binary) states distributed over the design domain. The interpretation of these two states will depend on the physics related to our optimization. Since most literature addresses topology optimization within the context of structural mechanics, we will first look at this type of physics and address its acoustics counterpart in the next section.

Topology optimization in COMSOL Multiphysics for static structural mechanics was a previous topic of discussion on the COMSOL Blog. To give a brief overview: A so-called MBB beam is investigated with the objective of maximizing the stiffness by minimizing the total strain energy for a given load and boundary conditions. The design domain makes up the entire finite element domain. A constraint is applied to the total mass of the structure. In the design space, Young’s modulus is interpolated via the design variable as

E(\chi) = \left\{ \begin{array}{ll}E_0\ \textrm{for}\ \chi=1\\0\ \textrm{for}\ \chi=0 \end{array} \right..

To help the binary design, we can use a so-called solid isotropic material with penalization (SIMP) interpolation

E (\chi) = \chi^p E_0

where *p* is the penalization factor, typically taking on a value in the range of three to five. With this interpolation (and an implicit linear interpolation of the density), intermediate values of *X* are avoided by the solver as they provide less favorable stiffness-to-weight ratios. I have recreated the resulting MBB beam topology from the previous blog post below.

*Recreation of the optimized MBB beam.*

In this figure, black indicates a material with a user-defined Young’s modulus of *E _{0}*. Meanwhile, white corresponds to zero stiffness, indicating that there should be no material.

Let’s now move on to our discussion of acoustic topology optimization, where we have a frequency-dependent solution with wave propagation in an acoustic media. The design variable is now related to the physics of acoustics. Instead of having a binary *void-material* distribution of material, our goal is to have a binary *air-solid* distribution, where “solid” refers to a fluid with a high density and bulk modulus, which emulates a solid structure.

We define four parameters that describe the inertial and compressional behavior of the standard medium and the “solid” medium: Air is given a density of and a bulk modulus of *K _{1}*, and the “solid” medium has a higher density of and a higher bulk modulus of

\rho(\chi) = \left\{ \begin{array}{ll}\rho_2\ \textrm{for}\ \chi=1 \\ \rho_1\ \textrm{for} \ \chi=0 \end{array} \right.

and

K(\chi) = \left\{ \begin{array}{ll}K_2\ \textrm{for}\ \chi=1\\K_1\ \textrm{for}\ \chi=0 \end{array} \right..

The easiest way to obtain these characteristics is by linear interpolation between the two extreme values. This is not necessarily the best approach since intermediate values of will not be penalized and therefore the optimal design may not be binary. As such, it will not be feasible to manufacture. In the literature alternative, interpolation schemes are given. In the cases presented here, the so-called rational approximation of material properties (RAMP) interpolation is used (see Ref. 1).

Just as with structural optimization, we define a design domain where the material distribution can take place, while simultaneously satisfying the constraints. An area or volume constraints can be defined via the design variable. For example, an area constraint on the design domain can be stated as an *inequality constraint*

\int^{}_{\Omega_d} \chi d \Omega_d \leq S_r

where *S _{r}* is an area ratio between the area of the design that is assigned solid properties and the entire design domain.

Let’s first take a look at a silencer (or “muffler”) example. For simplicity, we limit ourselves to a 2D domain. A typical measure used when characterizing a silencer is the so-called transmission loss, denoted *TL*, which is a measure of power input to power output:

TL = 10 \log_{10} \left(\frac{W_i}{W_o} \right).

The transmission loss is calculated using the so-called three-point method (see Ref. 2). We use this as our objective function, seeking to maximize it at a single frequency (in this case 420 Hz):

\max_{\chi} TL (420 \text {Hz}).

Two design domains are defined above and below a tubular section. The design domain is constrained in such a way that a maximum of 5% of the 2D area is the structure and thus 95% must be air:

\int^{}_{\Omega_d} \chi d \Omega_d \leq 0.05.

The initial state for the design domain is 100% air, i.e., . The animation below shows the evolution from the initial state to the resulting topology.

*An animation depicting the evolution from the initial state to the optimized silencer topology.*

The optimized structure takes on a “double expansion chamber” (see Ref. 3) silencer topology. The transmission loss has increased by approximately 14 dB at the target frequency, as illustrated in the plot below. However, at all frequencies other than the target frequency, the transmission loss has also changed, which may be of great importance for the specific application. Therefore, a single-frequency optimization may not be the best choice for the typical design problem.

*Transmission loss for the initial state and optimized silencer.*

Shifting gears, let’s now look at how to optimize for two objective functions and two frequencies. Here, we again consider a 2D room with three hard walls and a pressure input at the left side of the room. The room also includes two objective areas, *Ω _{1}* and

- Minimize the sound pressure level at a frequency
*f*and_{1} - Minimize the sound pressure level at a frequency
*f*_{2}= 1.5 f_{1}

with the circular design domain *Ω _{d}* and an area constraint that is 10% structure. The initial state is , making the design domain 100% air.

*A square 2D room with a circular design domain and two objective domains.*

With more than one objective function, we must make some choices regarding the relative weights, or importance, of the different objectives. In this case, the two objectives are of equal weight in importance, and the problem is stated as a so-called *min-max* problem:

\begin{align}

\min_{\chi} \max_{f_1 f_2} SPL_i (\chi, f_i) \\

\text {subject to} \int^{}_{\Omega_d} \chi d\Omega_d \leq 0.1.

\end{align}

\min_{\chi} \max_{f_1 f_2} SPL_i (\chi, f_i) \\

\text {subject to} \int^{}_{\Omega_d} \chi d\Omega_d \leq 0.1.

\end{align}

The figures below show the optimized topology (blue) along with the sound pressure for both frequencies using the same pressure scale. Note how the optimized topology results in a low-pressure zone (green) appearing in the upper-right corner at the first frequency. At the same time, this optimized topology ensures a similar low-pressure zone in the lower-right corner at the second frequency. This would certainly be a challenging task if trial-and-error was the only choice.

*Sound pressure for frequency* f_{1} *(left) and for frequency* f_{2} *(right). The optimized topology is shown in blue.*

As a third and final example, we’ll optimize a single objective over a frequency range. A sound source is radiating into a 2D domain, where we initially have a cylindrical sound field. Two square design domains are present, but since there is symmetry, we only consider one half of the geometry in the simulation. In this case, we want a constant magnitude of the on-axis sound pressure of in a point 0.4 meter in front of the sound source. The optimization is carried out in a frequency range of 4,000 to 4,200 Hz (50 Hz steps, a total of five frequencies). We can accomplish this via the Global Least-Squares Objective functionality in COMSOL Multiphysics, with the problem being stated as:

\begin{align}

\min_{\chi} \sum_{i=1}^{5} (\mid p_i (\chi, f_i, 0, 0.4) \mid -\overline{p}_{obj})^2 \\

\text {subject to} \int^{}_{\Omega_d} \chi d\Omega_d \leq 0.1.

\end{align}

\min_{\chi} \sum_{i=1}^{5} (\mid p_i (\chi, f_i, 0, 0.4) \mid -\overline{p}_{obj})^2 \\

\text {subject to} \int^{}_{\Omega_d} \chi d\Omega_d \leq 0.1.

\end{align}

The initial state is again . The optimized topology is shown below, along with the sound field for both the initial state and optimized state.

*Sound pressure for the initial state (left) and optimized state (right) at 4 kHz, with the optimized topology shown in blue within the square design domains.*

Since the sound pressure magnitude in the observation point of the initial state is lower than the objective pressure, the topology optimization results in the creation of a reflector that focuses the on-axis sound. The sound pressure magnitudes before and after the optimization are shown below. The pressure magnitude is close to the desired objective pressure in the frequency range following the optimization.

*The pressure magnitude divided by for the initial and optimized topology.*

Acoustic topology optimization offers great potential for helping acoustic engineers come up with innovative designs. As I have demonstrated today, you can effectively use this technique in COMSOL Multiphysics. With proper formulations of objectives and constraints, it is possible to construct applications with new and innovative topologies — topologies that would most likely not have been found using traditional methods.

I would like to give special thanks to Niels Aage, an associate professor at the Technical University of Denmark, for several fruitful discussions on the topic of optimization.

To learn more about using acoustic topology optimization in COMSOL Multiphysics, we encourage you to download the following example from our Application Gallery: Topology Optimization of Acoustic Modes in a 2D Room.

- M.P. Bendsoe, O. Sigmund,
*Topology Optimization: Theory, Methods, and Applications*, Springer 2003. - T.W. Wu, G.C. Wan, Muffler, “Performance studies and using a direct mixed-body boundary element method and a three-point method for evaluating transmission loss”, Trans. ASME:
*J. Vib. Acoust.*118 (1996) 479-484. - Z. Tao, A.F. Seybert, “A review of current techniques for measuring muffler transmission loss”,
*SAE International*, 2003.

René Christensen has been working in the field of vibroacoustics for more than a decade, both as a consultant (iCapture ApS) and as an engineer in the hearing aid industry (Oticon A/S, GN ReSound A/S). He has a special interest in the modeling of viscothermal effects in microacoustics, which was also the topic of his PhD. René joined the hardware platform R&D acoustics team at GN ReSound as a senior acoustic engineer in 2015. In this role, he works with the design and optimization of hearing aids.

]]>

To start, let’s briefly review phase space distributions and ellipses in 2D, both of which are fully explained in the previous post in the Phase Space Distributions in Beam Physics series. The particles in real-world nonlaminar charged particle beams occupy a region in phase space that is often elliptical in shape. The equation for this phase space ellipse in 2D depends on the beam emittance ε and Twiss parameters,

(1)

\gamma x^2 + 2\alpha x x' + \beta x'^2 = \varepsilon

where *x* and *x’* are the transverse position and inclination angle of the particle, respectively. The Twiss parameters are further related by the Courant-Snyder condition,

(2)

\gamma \beta -\alpha^2 = 1

The actual positions of particles in the ellipse can vary. Two of the most common distributions of phase space density are a uniform density within the ellipse and a Gaussian distribution with a maximum at the ellipse’s center, both of which are illustrated below. The blue curve in each case is the phase space ellipse described in Eq.(1), where ε is the *4-rms transverse emittance*. For the Gaussian distribution, note that some particles still lie outside the ellipse. Since the Gaussian distribution decreases gradually without reaching exactly zero, there is always a chance that a few particles will lie outside the ellipse, no matter how large it is drawn. When using the 4-rms emittance to define the ellipse in Eq.(1), about 86% of the particles lie inside the ellipse.

*Comparison of a uniform and Gaussian distribution.*

Let’s consider a simpler case in which the probability of finding a particle at any point in phase space is constant inside the ellipse and zero outside of it. For this problem, substituting Eq.(2) into Eq.(1) and solving for *x’* yields

(3)

x' = -\frac{\alpha x}{\beta} \pm \frac{\sqrt{\varepsilon \beta -x^2}}{\beta}

The probability distribution function is then

(4)

f(x,x') = \left\{

\begin{array}{cc}

C & -\frac{\alpha x}{\beta} -\frac{\sqrt{\varepsilon \beta -x^2}}{\beta} < x' < -\frac{\alpha x}{\beta} + \frac{\sqrt{\varepsilon \beta -x^2}}{\beta}\\

0 & \textrm{otherwise}

\end{array}\right.

\begin{array}{cc}

C & -\frac{\alpha x}{\beta} -\frac{\sqrt{\varepsilon \beta -x^2}}{\beta} < x' < -\frac{\alpha x}{\beta} + \frac{\sqrt{\varepsilon \beta -x^2}}{\beta}\\

0 & \textrm{otherwise}

\end{array}\right.

where the constant *C* depends on the size of the ellipse. The probability *g(x)* of the particle having a given *x*-coordinate is

g(x) = \int_{-\infty}^{\infty} f(x,x')dx'

Considering the locations where Eq.(3) can take on real values, we get

g(x) = \left\{

\begin{array}{cc}

2C \frac{\sqrt{\varepsilon \beta -x^2}}{\beta} & -\sqrt{\varepsilon \beta} < x < \sqrt{\varepsilon \beta}\\

0 & \textrm{otherwise}

\end{array}\right.

\begin{array}{cc}

2C \frac{\sqrt{\varepsilon \beta -x^2}}{\beta} & -\sqrt{\varepsilon \beta} < x < \sqrt{\varepsilon \beta}\\

0 & \textrm{otherwise}

\end{array}\right.

Or, more simply,

(5)

g(x) \propto \frac{\sqrt{\varepsilon \beta -x^2}}{\beta}, \qquad -\sqrt{\varepsilon \beta} < x < \sqrt{\varepsilon \beta}

Suppose we have a population of model particles that we want to sample using the probability distribution function given by Eq.(4). More specifically, we’d like to first sample the initial transverse positions of the particles according to Eq.(5) and then assign appropriate inclination angles so that the particles lie within the phase space ellipse. One way to accomplish this is to compute a cumulative distribution function starting from Eq.(5) and then use the method of inverse random sampling. Another possible method is using Eq.(5) to define the density of particles, which we can enter directly into the *Inlet* and *Release* features in the particle tracing interfaces. In this case, the normalization is done automatically.

*Screenshot showing how to input the particle density in the Inlet feature.*

Still, the most convenient approach is using the *Particle Beam* feature available in the *Charged Particle Tracing* physics interface. The Particle Beam feature automatically distributes the particles in phase space, allowing you to specify the location of the beam center, emittance, and Twiss parameters.

*Screenshot showing how to input the particle density in the Particle Beam feature.*

So far, we’ve only considered charged particle beams as idealized sheet beams where the out-of-plane (*y*) component of the transverse position and velocity can be ignored. However, real beams propagate in 3D space and only extend a finite distance in both transverse directions. Thus, in order to get a complete picture of a beam, we must consider two orthogonal transverse directions *x* and *y* as well as the inclination angles and .

*Particle beam propagating in 3D space.*

The reason why simulating the release of particle beams in 3D is more complicated than in 2D is that the degrees of freedom for the two transverse directions are often coupled in real-world beams. For example, suppose two particles are released at the same transverse position i.e., the same *x*- and *y*-coordinates. Let’s say that one of these particles has a very large inclination angle in the *x* direction (*x’*) and the other particle has a very small inclination angle in the *x* direction. The particle with the large inclination angle in the *x* direction is more likely to have a small inclination angle in the *y* direction and vice versa. Hence, we can’t just sample from two different distributions for *x’* and *y’* because the value of each one affects the probability distribution of the other.

To phrase this problem in a more abstract sense: Instead of considering the two transverse directions as separate 2D phase space ellipses, we actually need to think about the transverse particle motion using distributions of phase space in four dimensions! Since we’re used to seeing objects only in 2D or 3D, distributions with more than three space dimensions are much harder to visualize.

This is where the Particle Beam feature is most useful. It includes settings for sampling the initial particle positions and inclination angles from a variety of built-in 4D transverse phase space distributions. Some common distributions are the Kapchinskij-Vladimirskij (KV) distribution, waterbag distribution, parabolic distribution, and Gaussian distribution. First, let’s consider the simplest distribution, the KV distribution, and then visualize the other distributions in this group.

Mathematically, the KV distribution considers the beam particles to be uniformly distributed on an infinitesimally thin, 4D hyperellipsoid in phase space. It’s written as

\left(\frac{x}{r_x} \right)^2

+\left(\frac{r_x x' -r'_x x}{\varepsilon_x} \right)^2

+\left(\frac{y}{r_y} \right)^2

+\left(\frac{r_y y' -r'_y y}{\varepsilon_y} \right)^2 = 1

+\left(\frac{r_x x' -r'_x x}{\varepsilon_x} \right)^2

+\left(\frac{y}{r_y} \right)^2

+\left(\frac{r_y y' -r'_y y}{\varepsilon_y} \right)^2 = 1

where *r _{x}* and

Because it is more difficult to visualize 4D probability distribution functions than functions of lower dimensions, it is often convenient to visualize the distribution indirectly by plotting its projection onto lower dimensions. An interesting property of the KV distribution is that its projection onto any 2D plane is an ellipse of uniform density. The projections onto six such planes are shown below. The projections of the 4D hyperellipsoid onto the *x-x’* and *y-y’* planes are tilted because nonzero values have been specified for the Twiss parameter *α* in each transverse direction.

*The KV distribution projected onto six 2D planes.*

Compare the distributions shown above to the following alternatives.

*The waterbag, parabolic, and Gaussian distributions projected onto six 2D planes.*

We see that the projection onto any 2D plane forms an ellipse-shaped distribution in all cases, but the ellipses are only uniformly filled in the KV distribution.

Even as this blog series on modeling charged particle beams comes to a close, we have only scratched the surface of the intricate and highly technical field of beam physics. While we’ve discussed transverse phase space distributions in 3D, we haven’t examined longitudinal emittance or the related phenomenon of bunching. We also haven’t categorized the phenomena that causes emittance to increase, decrease, or remain constant as the beam propagates.

This series is meant to be an introduction to the way in which random or pseudorandom sampling from probability distribution functions plays an important role in capturing the real-world physics of high-energy ion and electron beams. For a more comprehensive overview of beam physics, references 1-3 provide an excellent starting point. More technical details about each of the 4D transverse phase space distributions described above, including algorithms for sampling pseudorandom numbers from these distributions, can be found in references 4-7. To learn more about how these concepts apply in the COMSOL Multiphysics® software, browse the resources featured below or contact us for guidance.

- See previous posts in our Phase Space Distributions in Beam Physics series
- Browse additional blog posts in our Particle Tracing category

- Humphries, Stanley.
*Principles of charged particle acceleration*. Courier Corporation, 2013. - Humphries, Stanley.
*Charged particle beams*. Courier Corporation, 2013. - Davidson, Ronald C., and Hong Qin.
*Physics of intense charged particle beams in high energy accelerators*. Imperial college press, 2001. - Lund, Steven M., Takashi Kikuchi, and Ronald C. Davidson. “Generation of initial Vlasov distributions for simulation of charged particle beams with high space-charge intensity.”
*Physical Review Special Topics — Accelerators and Beams*, vol. 12, N/A, November 19, 2009, pp. 114801 12, no. UCRL-JRNL-229998 (2007). - Lund, Steven M., Takashi Kikuchi, and Ronald C. Davidson. “Generation of initial kinetic distributions for simulation of long-pulse charged particle beams with high space-charge intensity.”
*Physical Review Special Topics — Accelerators and Beams*, 12, no. 11 (2009): 114801. - Batygin, Y. K. “Particle distribution generator in 4D phase space.”
*Computational Accelerator Physics*, vol. 297, no. 1, pp. 419-426. AIP Publishing, 1993. - Batygin, Y. K. “Particle-in-cell code BEAMPATH for beam dynamics simulations in linear accelerators and beamlines.”
*Nuclear Instruments and Methods in Physics Research*. Section A: Accelerators, Spectrometers, Detectors and Associated Equipment 539, no. 3 (2005): 455-489.