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 500THz 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 addon 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 LeonZapata, G. Gonzalez, A.G. Rodríguez, E. FloresGarcí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 LeonZapata 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 LeonZapata 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 LeonZapata 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 LeonZapata 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.
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 150km 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 twolayered 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 hightech applications, including semiconductor processing, mass spectrometry, and materials processing. This technology creates lowpressure 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.
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 ringlike 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 pointofcare 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). Builtin 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 ycomponent 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 tenturn 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 tenturn axisymmetric coil is driven by a single current source; that is, the same current flows through each turn. The initial coil design spaces the 1cmdiameter 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 z = 0 plane), we can use the reduced computational domain shown in the schematic below.
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, B_{0}, along a portion of the centerline by changing the coil current and zlocation of the five coils. Each coil can move and there must be a gap of G_{0} between the adjacent coils, so the first coil offset has a different lower bound. We also need to include a constraint on the peak current as well as constrain the current to be greater than zero. Although physically speaking, it isn’t necessary to constrain the current to be greater than zero, it’s a good optimization modeling practice to do so, since this keeps the constrained design space small.
More formally, these statements can be written as:
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 gradientbased 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 zcomponent 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.
The problem we will look at today is the optimization of a tenturn axisymmetric coil structure, as shown in the image below. Each of the five turns on either side of the xyplane is symmetrically but independently driven.
A tenturn 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 quartercircle 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 zcomponent 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:
Let’s state these optimization problems a bit more formally. The first optimization problem can be written as:
The objective here is to minimize the difference between the computed B_{z}field and the desired field, B_{0} = 250μT, integrated over a line along the center of the coil, stretching from z = 0 to z = L_{0}. Note that this objective is normalized with respect to L_{0} and B_{0}. This is done such that the magnitude of this objective function will be around one. The scaling of the objective function should always be done for any optimization problem.
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:
where P_{o} is the initial total power dissipated in all coils and is the power dissipated in the k^{th} coil.
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 builtin 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:
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 zdirection is taken with the derivative operator: 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 gradientbased approach and will approach different local minima for different initial conditions for the coil currents. Although a gradientbased 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 followup post in this blog series. Read it here: “How to Optimize the Spacing of 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 rightclick 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 2e2.
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 higherorder 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.
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:
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 rightclick 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 dropdown 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.
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 socalled 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
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 Ω, as visualized in the figure below.
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:
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 socalled 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
To help the binary design, we can use a socalled solid isotropic material with penalization (SIMP) interpolation
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 stiffnesstoweight 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 userdefined 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 frequencydependent solution with wave propagation in an acoustic media. The design variable is now related to the physics of acoustics. Instead of having a binary voidmaterial distribution of material, our goal is to have a binary airsolid 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 K_{2}. The density and bulk modulus K in the design domain will vary between the two states during the optimization via the design variable — similar to the variance of the Young’s modulus in our structural mechanics example. But a different interpolation is needed for an acoustics analysis so that the associated values do not tend to zero for a zerovalued design variable, but instead vary between air and the solid, so that
and
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 socalled 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
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 socalled transmission loss, denoted TL, which is a measure of power input to power output:
The transmission loss is calculated using the socalled threepoint method (see Ref. 2). We use this as our objective function, seeking to maximize it at a single frequency (in this case 420 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:
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 singlefrequency 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 Ω_{2}, defined at each corner at the right side of the room. The two objectives are as follows:
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 socalled minmax problem:
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 lowpressure zone (green) appearing in the upperright corner at the first frequency. At the same time, this optimized topology ensures a similar lowpressure zone in the lowerright corner at the second frequency. This would certainly be a challenging task if trialanderror 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 onaxis 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 LeastSquares Objective functionality in COMSOL Multiphysics, with the problem being stated as:
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 onaxis 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.
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 realworld 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)
where x and x’ are the transverse position and inclination angle of the particle, respectively. The Twiss parameters are further related by the CourantSnyder condition,
(2)
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 4rms 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 4rms 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)
The probability distribution function is then
(4)
where the constant C depends on the size of the ellipse. The probability g(x) of the particle having a given xcoordinate is
Considering the locations where Eq.(3) can take on real values, we get
Or, more simply,
(5)
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 outofplane (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 realworld beams. For example, suppose two particles are released at the same transverse position i.e., the same x and ycoordinates. 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 builtin 4D transverse phase space distributions. Some common distributions are the KapchinskijVladimirskij (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
where r_{x} and r_{y} are the maximum extents of the beam in the x and y directions, ε_{x} and ε_{y} are the beam emittances associated with the two transverse directions, and r’_{x} and r’_{y} are the inclination angles at the edge of the beam envelope.
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 xx’ and yy’ 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 ellipseshaped 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 realworld physics of highenergy ion and electron beams. For a more comprehensive overview of beam physics, references 13 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 47. To learn more about how these concepts apply in the COMSOL Multiphysics® software, browse the resources featured below or contact us for guidance.
A beam of ions or electrons is a group of particles with about the same kinetic energy that move in about the same direction. The total kinetic energy of each particle is usually much greater than the particle’s thermal energy at ordinary temperatures, giving the beam a good degree of directionality.
We’ll begin by examining a charged particle beam in 2D. Let the positive zaxis denote the direction of beam propagation (the axial direction) and the xaxis denote the direction perpendicular to the direction of propagation (the transverse direction). If this convention seems strange at first, remember that we’ll eventually discuss beams in 3D, and then it will be convenient to indicate the two transverse directions by x and y.
As mentioned earlier, a beam is characterized by a group of particles that have nearly the same direction and energy — emphasis on the word “nearly”! No realworld beam will have perfectly uniform velocities for all particles. In fact, almost all of the interesting mathematics involved in beam release and propagation relates to the small variations in position and velocity among the beam particles.
We can characterize the shape of a beam by the beam envelope, which indicates the outermost extents of the beam particles and gives us an idea of the beam’s shape. If the beam has a sharp cutoff — that is, the number density of particles in the beam abruptly decreases to zero at a welldefined location — the beam envelope may simply be a curve or surface that encompasses all of the particle trajectories. Very often, though, the density of beam particles decreases gradually out to a very large distance, so that there’s no clear border where the beam ends and the surrounding empty space begins. In that case, a beam envelope can be defined as the curve or surface that contains a sufficiently high percentage of the beam particles; 95% is quite common. A beam is converging if its envelope becomes smaller as the beam propagates forward; diverging if the beam envelope becomes larger; and at a waist if the beam has just finished converging and is about to start diverging. This is illustrated below.
The next plot shows some representative particle trajectories in a simple 2D beam. For now, space charge effects and external forces are neglected. Coordinate axis labels are shown to indicate the axial and transverse directions. We’ll treat this as an ideal sheet beam — that is, the beam extends infinitely in the outofplane (y) direction. The lines indicate the paths of beam electrons, with arrows indicating their velocities. The color expression along each line is the change in the xcoordinate, or transverse position, of an electron, also called its transverse displacement.
Note that the origin has been chosen so that the xcoordinates are measured from the center of the beam. It’s typically convenient to measure transverse particle positions from a point along the center line or nominal trajectory. The rate of change of the transverse position is the transverse velocity v_{x}.
In the previous image and the following ones, the transverse displacement and velocity are rather exaggerated so they are easier to see. In practice, they are usually extremely small compared to the displacement and velocity along the beam axis.
The beam shown above is called a laminar beam because it has the following properties:
The latter of these properties is important because it prevents the initial property from being violated later on. See the following diagram of a converging beam in which the transverse position and velocity have a quadratic relationship instead of a linear one. Even though no trajectories are crossing initially (at z = 0), they cross at a later point. At any one of these intersection points, there are multiple transverse velocity values possible for a single transverse position, and thus the first property is violated.
In contrast, for a laminar beam, the particles never cross, unless the beam is converging so that all trajectories cross at a single point, as shown below.
In practice, there is usually a distribution of transverse velocity values at any transverse position. Particle trajectories are constantly crossing each other. Thus, realworld beams are nonlaminar, and the laminar beam discussed earlier is just an idealization. A more realistic transverse velocity distribution for a nonlaminar beam is illustrated below.
To better understand the difference between laminar and nonlaminar beams, let’s look at their phase space distributions. Phase space distributions can take on many forms, but here we’ll examine the particles as points in a 2D space in which the axes are transverse position and velocity. (We could alternatively use position and momentum as the two axes. This changes the distribution’s dimensions but doesn’t fundamentally change its shape.) Plotting these phase space distributions in COMSOL Multiphysics is easy using the Phase Portrait plot type.
First, let’s examine the phase portrait for a laminar beam. The following plot is taken at a releasing boundary, at the time t = 0.
As expected, the points form a straight line that passes through the origin. (Remember that, by definition, the transverse position and velocity in a laminar beam have a linear relationship.) The next plot is a phase portrait for the nonlaminar beam.
The points no longer lie in a line but instead form a vaguely shaped cloud in phase space centered about the origin. The points seem randomly placed and there isn’t any obvious relationship between their positions. To get a clearer idea of the phase space distribution, let’s consider the same beam but with a much larger sample size of 1000 particles.
Now it has become much clearer; the particles form a phase space ellipse. Because the ellipse is thickest at the center, particles positioned closer to the beam axis have a larger velocity spread as compared to particles near the beam envelope’s edge. Such ellipseshaped distributions are extremely common in beam physics, although the proportions and orientation of the ellipse and the exact placement of particles relative to it can vary. As was the case when describing the beam envelope, the phase space ellipse may either have a sharp cutoff or gradual decrease in number density. In the latter case, an ellipse can be defined so that it encloses some arbitrary fraction of the beam particles, say 95%.
In practice, most charged particle beams are paraxial, meaning that the transverse velocity components are very small relative to the longitudinal velocity. In the paraxial limit, we can describe each particle by its transverse position x and inclination angle . (It’s fair to call this quantity an angle because in the paraxial limit.) The distribution of x and x’ values of particles in the beam is the trace space distribution, and the ellipse that encompasses this distribution is the trace space ellipse.
The ellipse shown in the previous image was approximately symmetric about the xaxis and v_{x}axis. However, this isn’t always the case; as the beam propagates, the ellipse changes shape even in the absence of any forces, simply because the expressions along the two axes are related to each other. Particles with positive transverse velocity (v_{x} > 0) will move to the right (the +x direction) in phase space because, by definition, . Similarly, particles with negative transverse velocity will move to the left. The following animation shows the evolution of a phase space ellipse over time for a drifting beam without space charge effects.
When the ellipse has reflection symmetry about the xaxis and v_{x}axis, we say that it’s upright. An upright phase space ellipse corresponds to a waist along the beam trajectory.
In beam physics, it’s often more convenient to work in trace space (the xx’ plane) than the xv_{x} or xp_{x} plane. This is partly because the inclination angle x’ is much more useful for visualizing the shape of the beam than the transverse velocity or momentum. A trace space ellipse (an ellipse drawn in the xx’ plane to encompass the particles in trace space) has the general form
where the parameters γ, β, and α, called the Twiss parameters or CourantSnyder parameters, are not all independent but are instead related by the CourantSnyder condition,
(1)
The quantity is also called the CourantSnyder invariant.
Altogether, the parameters γ, β, α, and ε describe the shape, size, and orientation of the trace space ellipse as follows:
Although beam emittance describes the size of the ellipse, there are several different conventions as to how the emittance and ellipse area are actually related. By one convention, the emittance is the product of the lengths of the semimajor and semiminor axes of the ellipse, with the result that A = 4πε. This is illustrated in the following diagram, which further shows how the Twiss parameters are related to the ellipse proportions and orientation.
It’s also extremely common to multiply the reported emittance by 4, so that A = πε. In some resources, the division by π is also omitted, so that A = ε. When entering or reading the reported beam emittance, it’s extremely important to keep track of which convention is used.
So far, we’ve seen that the beam emittance is an indication of the phase space area covered by the beam. However, in addition to this geometric interpretation, it’s possible to define a statistical interpretation in which the emittance is described in terms of averages over the ensemble of particles.
The rootmeansquare emittance (or RMS emittance) can be defined as
(2)
where the angle brackets represent arithmetic means, i.e.,
As in the geometrical definition of emittance, it’s extremely common to multiply the expression for RMS emittance by 4:
(3)
In COMSOL Multiphysics, we take extra precautions to ensure that the definition of the emittance is made clear by referring to Eq. (2) as the 1rms emittance and Eq. (3) as the 4rms emittance. If the trace space ellipse is positioned so that its center lies at the origin of the xx’ plane, then and Eq. (2) can be simplified to
where subscripts have been used to indicate more clearly that this is the 1rms emittance. Similarly, it’s possible to write statistical definitions of the Twiss parameters (again using the simplifying assumption ):
From the statistical definitions of the Twiss parameters, it’s much clearer that α is positive when most of the particles lie in the 2^{nd} and 4^{th} quadrants of trace space, which means that the beam is converging.
The advantage of the statistical interpretation of beam emittance is that it removes the ambiguity of drawing an ellipse around an arbitrary phase space distribution to find its area. A disadvantage is that if there is no obvious cutoff distance, then a small number of particles a great distance away from the beam center can considerably skew the emittance and Twiss parameters. Sometimes these particles, such as those found at the end of Gaussian “tails”, are intentionally excluded from the statistical definition of beam emittance.
A lower value of the beam emittance is associated with some combination of the following beam properties:
It’s typically desirable to reduce beam emittance whenever possible. However, most processes tend to either keep the emittance constant or increase it. Several techniques for beam cooling, or emittance reduction, are available, but delving too deeply into beam cooling methods is beyond the scope of this series.
Why are we so concerned with reducing beam emittance? Among other reasons, we must remember that fundamental research in particle physics has driven the development of particle accelerators to a large degree, especially in extremely highenergy applications. To make particles undergo collisions at extremely high energy, it’s often necessary to make two beams of particles intersect each other, rather than having one beam interact with a stationary target. However, the collision cross section for two intersecting beams is much smaller than the collision cross section for a single beam interacting with a stationary target.
A technical aim of modern accelerators is therefore to fit as many energetic particles into a narrow space as possible to maximize the collision probability. Higher emittance either means that the particles are spread over a large area or that there are big differences among the particle velocities that will cause them to occupy a large area later on. Either one of these outcomes is detrimental to the frequency of collisions between the intersecting beams.
So far, we’ve explored what particle beams are, how to distinguish between laminar and nonlaminar beams, and how the phase space distribution in a nonlaminar beam is tied to the concept of transverse beam emittance. We’ve learned that realworld beams typically occupy some finitesized area in phase space or trace space, and that the emittance is a figureofmerit that is usually proportional in some way to the phase space area. Furthermore, we’ve seen two different ways to interpret beam emittance: geometrically, as in a phase space area, or statistically, in terms of the averages over beam particles and their inclination angles.
We have, however, only discussed ideal sheet beams in 2D. When extending to 3D, we’ll have to consider emittance in two orthogonal transverse directions. Realworld beams also have some distribution of velocity in the axial direction, which gives rise to the longitudinal emittance.
Next, we’ll look at phase space distributions in particle beams in 3D for the first time and learn how to sample from phase space distributions to reproduce some of the phase space ellipses we’ve seen thus far.
Energetic beams of ions and electrons are a topic of great interest in the fundamental research of highenergy and nuclear physics. But they are also utilized in a wealth of application areas, including cathode ray tubes, the production of medical isotopes, and nuclear waste treatment. In the accurate computational modeling of beam propagation, the initial values of the particle position and velocity components are of particular importance.
When releasing ions or electrons in a beam for a particle tracing simulation, we’re often required to sample these particles as discrete points in phase space. However, before we delve too deeply into what phase space is and how ions or electrons fit into it, let’s learn more about probability distribution functions and how they can be utilized in COMSOL Multiphysics.
Let’s start with some definitions. A continuous random variable x is a random variable that can take on infinitely many values. For example, suppose that a point x_{1} is selected at random along a line segment of length L. Then a second point x_{2} is selected elsewhere along this line. Assuming that these two points are distinct, we can then select a third distinct point that is also on the line, then a fourth point , and so on, and thus infinitely many distinct points can be obtained. This is illustrated below.
As a side note, the other kind of random variable is called a discrete random variable and can only take on specified values. Think about flipping a coin or drawing a card from a deck; the number of outcomes is finite.
A 1D probability distribution function (PDF) or probability density function f(x) describes the likelihood that the value of the continuous random variable will take on a given value. For example, the probability distribution function
(1)
describes a variable x that has a uniform chance to take on any value in the open interval (0, 1) but has no chance of having any other value. This PDF, a uniform distribution, is plotted below.
Probability distribution functions can also be applied for discrete random variables, and even for variables that are continuous over some intervals and discrete elsewhere. An alternative way to interpret such a random variable is to treat it as a continuous random variable for which the PDF includes one or more Dirac delta functions. This blog series will only consider continuous random variables.
The PDF is normalized if
In other words, the total probability that the variable x takes on a value somewhere in the range (∞, ∞) is unity.
A cumulative distribution function (CDF) F(x) is the likelihood that the value of the continuous random variable lies in the interval (∞, x). The PDF and CDF are related by integration,
From the above definition, it is clear that if the probability distribution function is normalized, then
The PDF from Eq.(1) and the corresponding CDF are plotted below. It is clear that the PDF, as written, is normalized.
Selecting a value at random from a uniform distribution is usually quite easy. In most programming languages, routines to generate uniformly distributed random numbers are readily available. However, suppose that we have a much more arbitrary distribution like the one shown below.
The random number takes on values in the interval (0, 1), and the PDF is normalized because the CDF ends up at 1. However, the distribution is clearly not uniform; for example, the random number is much more likely to be in the range (0.2, 0.3) than the range (0.7, 0.8). Simply using a builtin routine that samples uniformly distributed random numbers from the interval (0, 1) would not be correct. Therefore, we must consider alternative ways to sample random numbers from this arbitrarylooking PDF.
This brings us to one of the most fundamental methods for sampling values from a probability distribution function, inverse transform sampling. Let U be a uniformly distributed random number between zero and one. (In other words, U follows the distribution function given by Eq.(1).) Then to sample a random number with a (possibly nonuniform) probability distribution function f(x), do the following:
To summarize, F^{1}(U) is a random number with a probability distribution function f(x) if . Let’s look at an example in which this method is used to sample from a nonuniform probability distribution function.
The Rayleigh distribution appears quite frequently in the equations of rarefied gas dynamics and beam physics. It is given by
(2)
where σ is a scale factor yet to be specified. We can verify that the Rayleigh distribution, as written above, is normalized,
The cumulative distribution function is
For σ = 1, the normalized Rayleigh distribution and its cumulative distribution function are plotted below. For larger values of x, it is apparent that the CDF approaches unity.
To compute the inverse normal CDF, set y = F(x) and solve for x:
Now substitute the uniformly distributed random number U for the variable y,
Since U is uniformly distributed in the interval (0, 1) and because its value has not yet been determined, we can further simplify this expression by noting that U and 1 – U follow exactly the same probability distribution function. Thus, we arrive at the final expression for the sampled value of x,
(3)
Next, we’ll discuss how Eq.(3) can be used in a COMSOL model to sample values from the Rayleigh distribution.
Note that when computing the inverse normal CDF, it is not always possible to do so analytically. There is not always a closedform analytical solution for the integral of any function, and it is not always possible to write an expression for the inverse of the cumulative distribution function. The Rayleigh distribution has intentionally been used here because its inverse normal CDF can be derived without the need for numerical or approximate methods.
We can use the results of the above analysis to sample from an arbitrary 1D distribution, such as the Rayleigh distribution, in COMSOL Multiphysics. To begin, let’s consider the builtin tools for sampling from specific types of distribution.
There are several ways to define pseudorandom numbers (we’ll talk more the meaning of “pseudorandom” later on) in COMSOL Multiphysics. You can use the Random function feature, available from the Global Definitions and Definitions nodes, to define a pseudorandom number with a uniform or normal distribution. When a Uniform distribution is used, specify the Mean and Range. For a mean value μ_{u} and a range σ_{u}, the PDF is
An example of a uniform distribution with a mean of 1 and range of 1.5 is shown below.
When a Normal, or Gaussian, distribution is used, specify the Mean and Standard Deviation. For a mean value of μ_{n} and standard deviation of σ_{n}, the PDF is
An example of a normal distribution with a mean of 1 and standard deviation of 1.5 is shown below. As with the uniform distribution, the curve is jagged and unpredictable. Unlike the uniform distribution, the points along the curve are very dense close to the line y = 1 and fall off gradually from there.
For the default settings, in which the mean is 0 and the range or standard deviation is 1, the two distributions are compared below.
Comparison of the uniform PDF with the unit range and the Gaussian PDF with the unit standard deviation.
Instead of using the Random function feature, you can also use the builtin functions random
and randomnormal
in any expression. The random
function is a uniform distribution with a mean of 0 and range of 1; the randomnormal
function is a normal distribution with a mean of 0 and standard deviation of 1.
Remembering that for Eq.(3) we need a number U that is sampled uniformly from the interval (0, 1), we have two options:
random
function and add 0.5.In the following case, we’ll assume that the second approach is used, although both are feasible.
We’ve mentioned that the above methods are used to generate pseudorandom numbers. Pseudorandom means that the random number is generated in a deterministic way from an initial value or seed. For the builtin random
function, the seed is the argument (or arguments) to the function. In comparison, truly random numbers cannot be generated by a program alone but require some natural source of entropy — that is, a natural process that is inherently unpredictable and unrepeatable, such as radioactive decay or atmospheric noise.
There are several reasons why it is more convenient to work with pseudorandom numbers than truly random numbers. Their reproducibility can be used to troubleshoot Monte Carlo simulations because the same result can be obtained by running a simulation several times in a row with the same seed, making it easier to identify changes elsewhere in the model. Because they don’t require a natural entropy source, which can only harvest a finite amount of entropy in the environment in a finite time, pseudorandom numbers are less likely than truly random numbers to increase the required simulation time.
In exchange for the convenience of pseudorandom numbers, some extra precautions must be taken. The pseudorandom number is different for distinct values of the seed, but the same seed will repeatedly produce the same number. To see this in any COMSOL model, create a Global Evaluation node and repeatedly evaluate the builtin random
function with a constant seed, say random(1)
. The output will have no obvious relationship with the number 1 (so in that sense, it would seem “random”), but the value will stay the same if the expression is evaluated multiple times (and thus the distribution of values doesn’t appear random). This is illustrated below.
If a different seed is used every time the random number is evaluated, you’ll get different results each time the random number is evaluated. See the table in the following screenshot, in which the time is used as an input argument to the random function, and compare it to the previous evaluation.
Monte Carlo simulations of particle systems often involve large groups of particles that are released with random initial conditions and subjected to random forces. Some examples of random phenomena involving groups of particles include:
Clearly, if each particle gets the same pseudorandom numbers, then the simulation will be completely nonphysical. In the case of ions interacting with a background gas, for example, each ion would undergo collisions with the gas molecules or atoms at exactly the same times as all of the other ions. To remedy this, any random numbers involved in the particle simulation must be given seeds that are unique for each particle.
One approach is to use the particle index, an integer that is unique for each particle, as part of the seed. The particle index variable is <scope>.pidx
, where <scope>
is a unique identifier for the instance of the physics interface. For the Mathematical Particle Tracing interface, the particle index is usually pt.pidx
. The function random(pt.pidx)
will give a different pseudorandom number for each particle.
A further complication arises when particles are subjected to random forces throughout their entire lifetime. For example, if a random number is used to determine whether a collision with a gas molecule occurs, you wouldn’t want to use the same random number for a given particle at each time — then the particle could only undergo a collision at every single time step or not at all! The solution is to define a random number seed that uses multiple arguments: at least one argument that is distinct among particles and one that is distinct among different simulated times. Additional arguments may be needed if the simulation requires multiple pseudorandom numbers to be sampled independently of each other. A typical use of the random function could then take a form such as random(pt.pidx,t,1)
, where the final argument 1
can be replaced with other numeric values if additional independent pseudorandom numbers are needed.
Let’s go back to the original problem of sampling from the Rayleigh distribution. Suppose that we have a particle population and want to sample one number per particle so that the resulting values follow the Rayleigh distribution. In this example, we’ll use Eq.(2) with σ = 3. In a COMSOL model, define the following variables:
Name  Expression  Description 

rn

0.5+random(pt.pidx)

Random argument

sigma

3

Scale parameter

val

sigma*sqrt(2*log(rn))

Value sampled from Rayleigh distribution

Note that the last line is just Eq.(3). The following plot is a histogram of the value of rn
for a population of 1000 particles. The smooth curve is the exact Rayleigh distribution, which has been defined using an Analytic function feature.
For curves with many fine details, a larger number of particles may be needed to accurately capture the probability distribution function.
If a probability distribution function is entered into COMSOL Multiphysics as an Interpolation function feature, instead of an Analytic or Piecewise function, then you can use builtin features to automatically define a random function that samples from the specified PDF.
Suppose we have an interpolation function that linearly interpolates between the following data points:
x  f(x) 

0  0 
0.2  0.6 
0.4  0.7 
0.6  1.2 
0.8  1.2 
1  0 
The following screenshot shows how this data can be entered into the Interpolation function. By selecting the Define random function check box in the settings window for the Interpolation function feature, you can automatically define a function rn_int1
that samples from this distribution. In the Graphics window, the histogram plot shows a random sampling of 1000 data points, and the continuous curve is the interpolation function itself. The extra factors 20 and 0.74 are included to correct for the number of bins and normalize the interpolation function, respectively.
So far we’ve seen how probability distribution functions, cumulative distribution functions, and their inverses are related. We’ve also discussed several techniques for sampling from both uniform and nonuniform probability distribution functions in COMSOL models. In the next post in our Phase Space Distributions in Beam Physics series, we’ll start explaining the physics of ion and electron beams and how an understanding of probability distribution functions is essential to accurately modeling beam systems.