Skip to main content

Thank you for visiting You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

Inverse Design Tool for Ion Optical Devices using the Adjoint Variable Method


We present a computer-aided design tool for ion optical devices using the adjoint variable method. Numerical methods have been essential for the development of ion optical devices such as electron microscopes and mass spectrometers. Yet, the detailed computational analysis and optimization of ion optical devices is still onerous, since the governing equations of charged particle optics cannot be solved in closed form. Here, we show how to employ the adjoint variable method on the finite-element method and Störmer-Verlet method for electrostatic charged particle devices. This method allows for a full sensitivity analysis of ion optical devices, providing a quantitative measure of the effects of design parameters to device performance, at near constant computational cost with respect to the number of parameters. To demonstrate this, we perform such a sensitivity analysis for different freeform N-element Einzel lens systems including designs with over 13,000 parameters. We further show the optimization of the spot size of such lenses using a gradient-based method in combination with the adjoint variable method. The computational efficiency of the method facilitates the optimization of shapes and applied voltages of all surfaces of the device.


Electromagnetic fields have been applied to accelerate, guide and focus ions and electrons for over 100 years, with applications as far-ranging as vacuum tubes, electron microscopes, terahertz emitters, mass spectrometers and high-energy particle accelerators1,2. The (nonrelativistic) motion of charged particles obeys a nonlinear coupled system of equations, composed of the Laplace equation for the electrostatic potential and a combination of Newton’s and Coulomb’s laws for the equation of motion. Neither equation can be solved in closed form for any but the simplest devices. Instead, engineers and physicists rely on numerical modeling to understand and design ion optical devices3. To optimize a device, most commonly used approaches must analyze an extensive number of devices, which can be prohibitively slow. To avoid the effort of such an extensive analysis, the method introduced here computes the effects a design parameter variation, such as device dimensions or applied voltages, has on the physical behavior of ion optical devices. These effects are called design sensitivities and can be calculated efficiently using the adjoint variable method (AVM). Quantitative knowledge of the design sensitivities not only enables local optimization of devices, but also aids physical understanding. It helps visualizing how design parameters, such as each point on a surface, should be perturbed to enhance device performance. We present the application of AVM for the optimization of electrostatic ion optical, or more generally charged particle optical, systems. This is, to the best of our knowledge, the first application of AVM to ion optical device optimization and the first derivation of a discrete adjoint system for charged particle devices. In this work, we describe how the computational efficiency of the method allows us to not only analyze and optimize the key dimensions but also the shape and applied voltages of all surfaces of a design.

The described method easily integrates into the design process for ion optical systems, because it uses the discrete adjoint approach and is based on established simulation models4. With AVM, the design process not only contains numerical modelling of a device, but also a sensitivity analysis. In a sensitivity analysis, all design sensitivities of a device are computed. The geometry of a device is represented numerically first. Then, a simulator based on the governing differential equation predicts the electromagnetic fields with a rigorous technique such as the finite element method (FEM)5. Next, the equation of motion for the charged particles is solved, most commonly with a Runge-Kutta method or a Störmer-Verlet method (SVM)6. We can then calculate the design sensitivities by solving another set of systems posed using AVM.

Adjoint design sensitivity analysis has enabled design optimization in structural engineering7,8,9,10, aeronautics11,12,13, microwave engineering14,15,16,17, magnetic materials18 and photonics19,20,21,22,23,24,25,26,27,28,29,30. Here, we detail how to use AVM for any electrostatic ion optical design problem. This approach is extensible to RF and magnetic systems as well31, and to systems with space charge and other particle-particle interactions. We implemented a demonstration tool for electrostatic ion optical devices in 2D and cylindrical coordinates. We further demonstrate the AVM method with the optimization of N-element freeform Einzel lens systems, an example of ion optical devices. We provide a computational tool to design and optimize arbitrarily-shaped charged particle optics parts. The computer-aided optimization of shapes for ion optical devices complement the progress in additive manufacturing of metal parts, overcoming fabrication constraints that can prohibit the usage of inverse design tools in areas such as photonics.

Einzel lenses are used in different form and settings for nearly all ion and electron beam lensing applications, ranging from imaging32 to time-of-flight mass spectrometry33. They focus ions in flight by manipulating the electrostatic field along the ion trajectory. Einzel lenses are easy to manufacture and align, and their spherical aberrations are independent of the charge-to-mass ratio of the particles34. Einzel lenses are usually designed on a case by case basis for the application at hand. Yet, even with a few variable parameters, e.g. only the lens elements’ spacing and applied voltages, there can be hundreds of possible designs to consider as the optimal design for any application. Thus, despite Einzel lenses being one of the simplest ion optical devices, they remain difficult to optimize. In the past, a common strategy to mitigate the cost of analysis of many different designs was to use faster, but more specialized and approximative, numerical models, a compromise that pitted speed against ability to accurately model the physics of arbitrary devices34,35. Today it has become more common to employ brute force, modeling many devices in parallel on computer clusters and using slowly-converging optimization methods such as genetic algorithms36,37. With AVM, we can optimize Einzel lenses with a fast-converging algorithm, which requires low execution time. This can revivify the computer-aided optimization of ion optical lenses and related devices with even more complex geometries.


The calculation of accurate gradients lays at the core of any optimization routine and computer-aided design. The strength of the method detailed here is its ability to compute gradients accurate to machine precision. For ion optical systems, this is of high importance. Even small differences in field strength can cause an ion or electron to take a different trajectory. To ensure accurate gradients, we implemented full in-house simulations for the forward and adjoint FEM and SVM applying the discrete adjoint method. To test for accuracy, we compared the results of a demo forward system with an analogous SimIon simulation and obtained very good agreement (less than 1% error)38. We further tested the gradient calculation by solving perturbed systems and calculating finite differences. All appreciably nonzero gradient components agree with finite differences to within 1%. This agreement is extremely high and cannot be achieved with continuous adjoint approaches, yet a requirement to effectively optimize an ion optical system. Subtle changes in the geometry of such systems can have a significant effect on the electrostatic field distribution and ion trajectories, thus slightly inaccurate gradients would cause a diverging objective function during the optimization procedure.

In Fig. 1 we show the result of a sensitivity analysis of an electrostatic Einzel lens’ surface graphically. We conducted a sensitivity analysis of free-form N-element Einzel lens systems with over 13,000 moveable points. Using such a high number of degrees of freedom demonstrates the ability of the method to optimize highly-parameterized systems and shapes. We furthermore optimized several Einzel lenses with up to seven freeform elements.

Figure 1

Sensitivity analysis of an Einzel lens: Orange arrows push while red arrows pull the shape in the direction of a more optimal shape.


The Einzel lens shape as it is set up for an optimization is shown as a cross section in Fig. 2. This figure shows the upper half of a cylindrically-symmetric Einzel lens with the x-axis as symmetry axis. The total simulation space with a rectangular cross section and Neumann boundaries is 180 mm in length and 135 mm in height. The simulated Einzel lenses have three or more tubes with imposed voltages. The initial geometries are described in Table 1.

Figure 2

Upper half of the cross section of the initial design of a three element lens. The x-axis is the symmetry axis.

Table 1 Initial Einzel lens shape parameters (clc. Fig. 2).

In the electrostatic calculation, we chose Lagrange polynomials of order 5 to ensure accurate gradients. We interpolate the potential field onto a Cartesian grid with spacings of Δx = 0.29 mm and Δy = 13.5 nm. The incoming particle beam of radius 0.2 mm is comprised of 100 equally spaced particles flying with an initial kinetic energy of 30 keV in the x-direction and with a mass of 5.1477  10−26kg, representing Ga atoms. We chose the most general case of equally-spaced particles as any other beam shape can be achieved by weighting the particles in this beam profile. The SVM calculates the particle trajectories over a time span of 278 ns using 1500 time steps. The desired focal point lies on the x-axis 50 mm away from the center of the middle electrode. We tested the simulated system for convergence of the gradients by increasing the input parameters until changes to the gradient become marginal. The resulting mesh is shown in Fig. 3.

Figure 3

Simulation space, the upper half of a cross section of the geometry, showing the mesh.

Optimal designs

We simultaneously optimized shapes, positions and voltages of several N-element Einzel lens systems with freeform shapes. The shapes of the electrodes are polygons of N points; the points are parameterized as xi = xc + ricosΔθi, yi = yc + risinΔθi. During optimization the electrode centers xc, yc, the boundary displacements ri and Δθi and the applied voltages are designable, resulting in \(3N+2\sum _{i=1}^{N}\,{M}_{i}\) parameters, with M1, M2,..., MN, describing moveable points on the surface (see Fig. 2). The step size for the gradient descent is recalculated at each iteration using the Barzilai-Borwein method39.

We have optimized several different Einzel lens systems with varying degrees of freedom. In Fig. 4, we show the change of the RMS spot size during the optimization for systems with three, five and seven elements as illustrative examples. Each element side has seven moveable points, a coarse parameterization to limit feature size and allow for easier fabrication. As visible from Fig. 4, only about ten iterations of the gradient-descent method are required for a converged result. At each iteration, a sensitivity analysis using AVM is performed. The optimizations converged with a similar number of iterations independently of the number of elements of the initial geometry. In Figs 5 and 6, we show the result of a three-element and seven-element lens optimizations. The optimized designs include a relative shift of the Einzel lens tubes as well as a curving of the device shape. We reduce the RMS of quadratic spot sizes of our systems from a value of 10−9 to 10−15, corresponding to a focal spot of about 50 nm.

Figure 4

Progression of the objective function during the optimization for selected three-, five- and seven- element Einzel lens systems.

Figure 5

Optimized designs of a three element lens.

Figure 6

Optimized designs of a seven element lens.


The optimizations of tested Einzel lens systems remain mostly invariant of the degrees of freedom and number of lens elements. The accurate calculation of the gradient allowed them to converge to the same small spot size as the examples shown in Fig. 4. We thus conclude that we cannot further reduce the spot size. As described by Scherzer’s Theorem40, cylindrically-symmetric systems cannot reduce aberrations to zero. Further improvements of the system can be done by breaking the symmetry of the system or through the addition of time varying fields40. AVM is applicable to such systems as well.

In addition to highly-accurate gradients, high-dimensional sensitivity analysis is the strength of AVM. The execution time of the gradient calculation using AVM is not strongly affected by the dimensionality of the parameter vector. We demonstrate this for Einzel lens systems in Fig. 7. Here, we have conducted a sensitivity analysis for designs with a varying number of design parameters. Even for designs with over 13,000 design parameters, the execution time only moderately increased in comparison to designs with fewer parameters. This increase is mostly due to the growing number of elements in the mesh as lens elements are added. In Fig. 8, the execution time for the sensitivity analysis of a lens with 250 design parameters is broken down into three parts: the forward system, the system differentiation together with the adjoint system, and the gradient calculation. For a single system, the computations to pose and solve the adjoint system generally require a longer execution time than the forward system. The gradient calculation is, as expected, comparably cheap. If the execution time of the forward system increases due to more mesh elements, the execution time for the differentiation and adjoint system will also increase.

Figure 7

Comparison of runtimes of the adjoint and a finite differences approach to calculation design sensitivities.

Figure 8

Runtime for a sensitivity analysis separated by its two components. The runtimes are normalized to a forward system solve to account for different machine hardware.

In Fig. 7, for further illustration and comparison, we show the execution time of a brute-force finite differences sensitivity analysis obtained through repeating the shared forward calculation. As expected, the execution time scales strongly with the parameter vector dimension in this case. For the case of an Einzel lens device with 13,530 design parameters the sensitivity analysis with AVM runs roughly 30,000 times faster and could become too burdensome to conduct with finite differences unless vast computing power is used. The optimizations using AVM, as shown here, can run on a simple laptop or desktop computer.

Unlike optimization algorithms such as genetic algorithms, gradient descent using AVM is not based on a randomized exploration of the design space. Instead, we rely on a sensitivity analysis. This allows for rapid local optimization. Because the design space for ion optical devices is not convex — many device designs appear optimal compared to their nearest neighbor in design space — we are not guaranteed to find the global optimum41. However, the AVM enables the computationally cheap optimization of a diverse variety of initial designs, making it likely that a (near) global optimum will be found.

Sensitivity analysis has applications beyond optimization. With it we can also visualize and quantitatively compare the effects of all design parameters. This allows us to understand which degree of freedom has strong effects on a device design. This physical insight can also be further used for tolerancing. Without the AVM, exact effects of changes in the geometry of the ion optical device to its behavior are opaque to a engineer or physicist as the governing equations cannot be posed or solved in closed form.

The AVM we have shown here allows choosing any arbitrary initial geometry, initial incoming particle distribution as well as objective function. Any of these can be changed in the setup and a optimization program can be run. Thus, many other ion optical devices with more intricate geometries or particle beams than an Einzel lens can be optimized using AVM. Since the parameter vector for the design optimization of such geometries can be large, it has been shown in other engineering fields that optimal designs can exhibit fine-grained features that would not be achievable by a sophisticated guess or through human intuition42. With the work shown here, this is possible for ion optical devices. Recently, advances in additive manufacturing for metal parts made it possible to built nearly any shape, including those with fine-grained features43. With computational, computer-aided, design for ion optical devices, the full range of the capabilities of this layer-by-layer production of parts can be seized.

In this paper, we build the first ion optical device design tool based on the discrete adjoint variable method building on FEM and SVM. We applied this tool for sensitivity analysis of Einzel lens systems, quantifying how their performance changes with changes to their shape and applied voltages. We analyze the execution time with respect to the length of the parameter vector and show that longer parameter vectors (up to 13,520) only cause a small increase in execution time, allowing for the analysis and optimization of designs that would be too computationally burdensome (>30,000 times slower) with approaches such as finite differences. We further show how to use sensitivity analysis in combination with steepest gradient descent to built a computer-aided design and optimization tool for electrostatic ion optical devices. The potential applications for a design tool using AVM’s range from electron focusing devices to mass spectrometers to electron source design. The AVM tool here could be added as an extra layer to most conventional ion optics tools, which use the same numerical methods as their basis. Thus, the computer-aided design tool can help engineers or physicists to search, explore and understand the space of device designs by reducing the nearly intractable problem of device design to the usage of the presented tool. In combination with additive manufacturing techniques, computer-generated designs will allow for rapid prototyping of charged particle devices and thus facilitate innovation in charged particle optics.


Physical system of ion optical devices

The trajectories of charged particles in vacuum will bend in an electric field imposed by electrodes at fixed applied voltages. Consider the flight of charged particles through a space Ω. Electric potentials are imposed on electrodes with surfaces ∂Ω. For a particle of charge q and mass m, its trajectory is determined by Newton’s second law and Coulomb’s law,


The electric fields are derived from the electric potential ϕ, a solution to the Laplace equation,

$$\begin{array}{cccc}{\nabla }^{2}\varphi & =\, & 0 & {\rm{on}}\,{\rm{\Omega }}\,\\ \varphi & =\, & {V}_{{\rm{applied}}} & {\rm{on}}\,\delta {\rm{\Omega }}.\,\end{array}$$

In this paper, we assume that only the electrostatic field from the electrodes exerts a force on the particles and neglect the electromagnetic field caused by the particles themselves (e.g. from space charge). This approximation is accurate for devices operating in the low beam current limit.

Optimization using a sensitivity analysis

The performance of an ion optical device can be altered by varying its design parameters. All the changeable parameters, such as sizes and applied voltages of a device design are concatenated into a vector p. A performance benchmark to be optimized is called an objective function Q(x), e.g. the focus quality, depending on the device behavior x. An optimization attempts to find the design of the device which minimizes Q(x), but still obeys constraint functions f1,2,3,..., n(x), such as physical equations and boundary conditions. The setup to find such an optimal design can be summarized in an optimization program,

$$\begin{array}{ll}{\rm{minimize}} & Q({\bf{x}}({\bf{p}}))\\ {\rm{subjectto}} & {f}_{1,2,3,\mathrm{..},n}({\bf{x}})=0.\end{array}$$

Global optimization methods, such as simulated annealing44, guarantee an optimal solution to such a program but converge very slowly. Faster convergence is achieved by applying local optimization techniques. They only reach local optima, unless the optimization problem is convex41. Local optimization techniques such as steepest gradient descent, or gradient descent, require knowledge of the full gradient of Q(x(p)) at each step of the algorithm. For ion optical devices, the gradient describes how the device performance changes under perturbations to its shape, dimensions and operating conditions.

Optimization of einzel lenses

A three element Einzel lens is show in Fig. 9. Collimated charged particles enter the lens from the left, are redirected by the electric fields between elements and are focused to a small spot. The size of this spot determines the quality of the lens. A smaller spot has a smaller objective function Q(s). The spot size can be converted into the spherical aberration coefficient, commonly used to quantify the quality of a focus, if spherical aberrations are the dominant aberration. Here s describes the particle trajectories.

Figure 9

An ion beam focused with initial positions s0 and velocities vo by a three-element Einzel lens.

For a single particle, Q can be defined as:

$$Q=\parallel \hat{{\bf{s}}}-{{\bf{s}}}^{\ast }{\parallel }_{2}^{2}\,\mathrm{with}\,\hat{{\bf{s}}}={\bf{s}}\,{\rm{at}}\,{s}_{1}={s}_{{\rm{f}}}$$

where s* describes the desired focal point at a focal plane defined by the position s1 = sf . For a beam of several particles, we calculate the RMS of s − s* over all particles.

The partial derivatives of Q under changes in the element geometry and voltage are the design sensitivities of the Einzel lens illustrated in Fig. 10.

Figure 10

Design sensitivities for an Einzel lens system. Top: sensitivity of Q to shape changes. Bottom: sensitivity of Q to voltage changes.

Adjoint variable method for ion optical devices

The adjoint variable method poses equations for the efficient calculation of design sensitivities. Because the governing equations of ion optical devices cannot be solved in closed form, there is no closed form for their gradient either. The gradient can be approximated numerically by finite differences, which requires solving a forward system composed of the physical equations with the current parameter vector and, in addition, at least one extra system simulation per design parameter. If the device design is described by a system subject to N parameters, N + 1 full system simulations are required to calculate the gradient by this brute force technique. Yet, a system solve is a relatively costly operation and the number of design parameters can become virtually infinite, when not only the dimensions of a device or applied voltages, but also points on the device’s surfaces are parameterized. In this case, a sensitivity analysis can be conducted by using AVM. The calculation of the gradient with this method only requires solving one additional system after the forward system, the adjoint system. The workflow for this technique is described in Fig. 11. This suffices for any number of design sensitivities, so calculating hundreds or thousands of sensitivities scarcely takes more time than calculating one45.

Figure 11

Flow diagram of the sensitivity analysis and optimization of ion optical devices using AVM. The resulting design sensitivities are visualized as arrows.

To conduct a sensitivity analysis of an ion optical system and optimize it, we first calculate the forward system by simulating the electrostatic field and, subsequently, the particle trajectories. By evaluating the objective function Q(s) and its derivative \(\frac{{\rm{\partial }}Q}{{\rm{\partial }}{\bf{s}}}\), we gain an understanding of how the trajectories would need to be bent to optimize the design [Eq. (15)]. This direction of error, the discrepancy between the particle position and the desired focal point \((\frac{\partial Q}{\partial {\bf{s}}}\propto (\hat{{\bf{s}}}-{{\bf{s}}}^{\ast }))\), gets backpropagated into an adjoint particle solver [Eqs (8) & (14)]. We gain an insight into how to change the electric fields to cause the desired behavior, \(\frac{\partial Q}{\partial {\bf{E}}}\). Using an adjoint electrostatics solver, we can backpropagate again and calculate how the error depends on different parts of the system, e.g. the shape or applied voltage. Since we can analytically determine the influence of the system parameters to the system, we can calculate the design sensitivities \(\frac{{\rm{d}}Q}{{\rm{d}}{\bf{p}}}\) using computationally cheap vector-matrix-vector products [Eqs (9) & (16)]. For large system matrices, solving a large partial differential equation (PDE) system is likely to be so much slower than evaluating matrix-vector or vector-vector products that these products can be seen as instantaneous. Thus, the execution time for a sensitivity analysis with AVM is practically O(1) as compared to O(N) with other approaches. An optimization technique using AVM for sensitivity analysis is oftentimes referred to as inverse design, since we start the design process with a desired change in outcome and then proceed by calculating the required pertubations to the system.

Mathematical formulation of the adjoint variable method

The adjoint variable method makes use of the mathematical concept of duality, which describes a relationship between the solutions of two linear systems. We employ this concept to pose a dual or adjoint system that allows for a efficient gradient calculation45,46.

Again let Q(x) be the objective function operating on the vector x. Here, x is the numerical solution of a physical model of the system, so its values are state variables such as numerical values of positions, velocities and electric potentials. The simulated physical system, called the forward system, can be written as


where the function \({\mathfrak{L}}\) expresses all governing equations, boundary conditions and their dependencies on the design parameters p. We seek the parameters that minimize Q(x(p)) by gradient descent, so we need the design sensitivity \(\frac{{\rm{d}}Q}{{\rm{d}}{p}_{i}}\) for each element pi of p. It follows by the chain rule,

$$\frac{{\rm{d}}Q}{{\rm{d}}{p}_{i}}=\frac{{\rm{\partial }}Q}{{\rm{\partial }}{\bf{x}}}\frac{{\rm{d}}{\bf{x}}}{{\rm{d}}{p}_{i}}.$$

While the derivative \(\frac{\partial Q}{\partial {\bf{x}}}\) can be found easily, the sensitivity of state \(\frac{{\rm{d}}{\bf{x}}}{{\rm{d}}{p}_{i}}\) is the solution of a directly-differentiated system19 and is only obtained with effort comparable to solving (5) again. We do so by differentiating (5) to discover a linear system

$$\frac{{\rm{\partial }}{\mathfrak{L}}}{{\rm{\partial }}{\bf{x}}}\frac{{\rm{d}}{\bf{x}}}{{\rm{d}}{p}_{i}}=-\frac{{\rm{\partial }}{\mathfrak{L}}}{{\rm{\partial }}{p}_{i}},$$

with a matrix \(\frac{\partial {\mathfrak{L}}}{\partial {\bf{x}}}\) commonly renamed11 A. The crux of AVM is consolidating much of the effort of (6) into the solution of an adjoint system that solves for a adjoint variable v,

$${A}^{T}{\bf{v}}=\frac{\partial Q}{\partial {\bf{x}}}.$$

Calculation of the sensitivities is expedited by knowledge of v, as it need not be recalculated for each i. The derivative components now are easily computed with the vector products

$$\frac{{\rm{d}}Q}{{\rm{d}}{p}_{i}}={{\bf{v}}}^{T}(\,-\frac{{\rm{\partial }}{\mathfrak{L}}}{{\rm{\partial }}{p}_{i}}-\frac{{\rm{\partial }}A}{{\rm{\partial }}{p}_{i}}{\bf{x}}),$$

as can be verified by glancing at equations (5), (6) and (8).

All required components for the gradient calculation using AVM can be derived analytically by differentiating the physical equations and implemented directly.

Sensitivity analysis of ion optical systems

In the case of ion optical devices, the objective function depends only on the particle trajectories; its dependence on design parameters is indirect, mediated by the equation of motion and the Laplace equation, which constrain all designs to obey physical laws. We need to simulate forward and adjoint systems for both of these equations. We can then optimize the ion optical system according to the workflow process outlined in Fig. 11. The simulators are detailed in the following subsections. We implemented fully discrete adjoint systems for both components to ensure accurate gradients to machine precision. To reduce memory requirements and allow our system to run on a simple laptop computer, we calculated equation (9) in a step-wise approach for each FEM element and only using relevant sub-matricies.

Electrostatics simulations

The finite element method (FEM) approximates the exact solution of a PDE (partial differential equation), e.g. the Laplace equation (2), on a mesh5,47. We choose an unstructured triangular mesh, created by the software gmsh48, for simplicity. Inside each triangle, the field is approximated by a polynomial and represented by its value at a fixed number of points called nodes distributed on the corners, edges and interiors of the triangles. We chose Lagrange polynomials as our basis. With these restrictions, the problem can be posed as a linear system:

$$\begin{array}{l}M\varphi =f\end{array}$$

wherein the system matrix M consists of the discretizations of the Laplace equation and f describes the boundary values of the problem. The boundaries can satisfy either a Neumann or a Dirichlet condition. The solution of this linear system, ϕ, is the vector of the electrostatic potentials at every node. The values of ϕ in combination with the Lagrange basis functions are used to interpolate the values of the electrostatic field onto a 2D cartesian grid of field values as required for the particle tracer.

To differentiate the finite-element method, we study how design changes affect the underlying system of equations. Such changes may cause modifications in shape or changes in the applied voltages. If one corner of an electrode shifts, the edges of all adjacent mesh elements shift. This mesh deformation is illustrated in Fig. 12, where the mesh elements affected by the change in shape are marked in light orange. As the mesh deforms, the field nodes — used for the Lagrange basis functions — move with it. Each moving node effects several rows in the FEM system matrix M. The imposed potential on electrode surfaces may also be adjusted, causing the inhomogenous term of equation to vary. All these changes to the system have to be accounted for when differentiating the system5,45,47. The adjoint electrostatics simulation takes input from the adjoint particle tracer and then calculates the adjoint system variable for the gradient calculation.

Figure 12

A change of design parameters: Boundary shape changes affect rows of the system matrix. Boundary voltage changes affect rows of the inhomogeneous term.

Particle tracer

The particle equations of motion are solved with SVM6. SVM is an iterative method that divides the examined time into N time steps of size Δt. Starting with the initial position and velocity of each particle, the method calculates the particle positions and velocities at subsequent time steps,

$$\begin{array}{l}{{\bf{s}}}_{n+1}={{\bf{s}}}_{n}+{{\bf{v}}}_{n}{\rm{\Delta }}t+\frac{1}{2}{{\bf{a}}}_{n}{\rm{\Delta }}{t}^{2},\\ {{\bf{v}}}_{n+1}={{\bf{v}}}_{n}+\frac{1}{2}({{\bf{a}}}_{n}+{{\bf{a}}}_{n+1}){\rm{\Delta }}t.\end{array}$$

The acceleration vector a is interpolated from the grid of electrostatic field values. After calculating the trajectories, the forward simulation is complete and the device performance can be evaluated.

To find \(\frac{{\rm{d}}Q}{{\rm{d}}{\bf{E}}}\), we pose an adjoint SVM system. With the forward solution of the non-linear SVM, we can determine a interpolation matrix \(\Im \) used to represent the interpolation of the electric field required to obtain the acceleration vector a. The values of the electric field are stored in a vector E calculated by the electrostatics solver. The positions of the particles at each time step determine the interpolation weights incorporated in \(\Im \) and the indices of the interpolated field values the structure of \(\Im \). We write:

$${\bf{a}}=\Im {\bf{E}}.$$

We can then write the system of equations using a movement matrix W to describe the continuing movement of particles at each time step without added accelerations and an acceleration matrix Wa to introduce accelerations:


Here, the vector s contains positions and velocities of the trajectory at all simulated time steps, and s0 the positions at the initial time step. This system is non-linear, since the vector a depends on the particle positions s through \(\Im \).

Through differentiation of the equations (12) and (13) with respect to the electric field values on a grid, we can pose an adjoint system in the form of (8):

$$\begin{array}{l}{(W+{W}_{a}\nabla {\mathfrak{J}}{\bf{E}})}^{T}{\bf{v}}=\frac{\partial Q}{\partial {\bf{s}}}.\end{array}$$

Because of the non-linearity of the method, \(\nabla {\mathfrak{J}}\) is not the direct differentiation of \(\Im \). It results from the differentiation and reordering of the non-linear equations of the iterative method (equation (13)).

The inhomogeneous term in (14) can be obtained by differentiating equation (4). The focal plane is reached at a time t = tn + αdt between tn and tn+1, with position and velocity s = sn + α (sn+1 − sn). Differentiating Q for a single particle results in

$$\begin{array}{ccc}\frac{{\rm{\partial }}Q}{{\rm{\partial }}{{\bf{s}}}_{{n}_{{\rm{f}}}}} & = & 2{[\begin{array}{c}\hat{{\bf{s}}}-{{\bf{s}}}^{\ast }\end{array}]}^{{\rm{T}}}[(1-\alpha )+\frac{{\rm{\partial }}\alpha }{{\rm{\partial }}{{\bf{s}}}_{{n}_{{\rm{f}}}}}{({{\bf{s}}}_{{n}_{{\rm{f}}}+1}-{\bf{s}}}_{{n}_{{\rm{f}}}})]\\ \frac{{\rm{\partial }}Q}{{\rm{\partial }}{{\bf{s}}}_{{n}_{{\rm{f}}}+1}} & = & 2{[\begin{array}{c}\hat{{\bf{s}}}-{{\bf{s}}}^{\ast }\end{array}]}^{{\rm{T}}}[\alpha +\frac{{\rm{\partial }}\alpha }{{\rm{\partial }}{{\bf{s}}}_{{n}_{{\rm{f}}}+1}}{{\bf{s}}}_{{n}_{{\rm{f}}}+1}]\end{array}$$

with the remaining values of \(\frac{\partial Q}{\partial {\bf{s}}}\) being zero. For a beam of several particles, we apply the chain rule.

We can then calculate the adjoint system and reach the design sensitivities with

$$\begin{array}{c}\frac{{\rm{d}}Q}{{\rm{d}}{E}_{i}}={{\bf{v}}}^{T}[\,-\,{W}_{a}{\rm{\Im }}{\bf{1}}]\end{array}$$

where 1 is a vector of all ones and length of E.


  1. 1.

    Wollnik, H. Optics of Charged Particles (Academic Press, 1987).

  2. 2.

    Herzberger, M. Modern Geometrical Optics (reprint edition 1980 with corrections) (Krieger Publishing Company, 1980).

  3. 3.

    Wollnik, H. & Berz, M. Relations between elements of transfer-matrices due to the condition of sympleticity. Nucl. Instrum. Methods A 238, 127–140 (1985).

    ADS  Google Scholar 

  4. 4.

    Nadarajah, S. & Jameson, A. A comparison of the continuous and discrete adjoint approach to automatic aerodynamic optimization. In 38th Aerospace Sciences Meeting and Exhibit, 667 (2000).

  5. 5.

    Hesthaven, J. S. & Warburton, T. Nodal discontinuous Galerkin methods: algorithms, analysis, and applications, vol. 54 (Springer, 2007).

  6. 6.

    Swope, W. C., Andersen, H. C., Berens, P. H. & Wilson, K. R. A computer simulation method for the calculation of equilibrium constants for the formation of physical clusters of molecules: Application to small water clusters. The J. Chem. Phys. 76, 637–649 (1982).

    ADS  CAS  Google Scholar 

  7. 7.

    Bendsøe, M. P. Optimal shape design as a material distribution problem. Struct. Optim. 1, 193–202 (1989).

    Google Scholar 

  8. 8.

    Bendsøe, M. P. & Sigmund, O. Material interpolation schemes in topology optimization. Arch. Appl. Mech. 69, 635–654 (1999).

    ADS  MATH  Google Scholar 

  9. 9.

    Bendsoe, M. P. Topology optimization: theory, methods and applications (Springer, 2003).

  10. 10.

    Wang, M. Y., Wang, X. & Guo, D. A level set method for structural topology optimization. Comput. Methods Appl. Mech. Eng. 192, 227–246 (2003).

    ADS  MathSciNet  MATH  Google Scholar 

  11. 11.

    Giles, M. B. & Pierce, N. A. Adjoint equations in cfd: duality, boundary conditions and solution behaviour. AIAA paper 97, 1850 (1997).

    Google Scholar 

  12. 12.

    Jameson, A. Re-engineering the design process through computation. J. Aircr. 36, 36–50 (1999).

    Google Scholar 

  13. 13.

    Jameson, A. Optimum aerodynamic design using cfd and control theory. AIAA paper 1729, 124–131 (1995).

    Google Scholar 

  14. 14.

    Nikolova, N. K., Li, Y., Li, Y. & Bakr, M. H. Sensitivity analysis of scattering parameters with electromagnetic time-domain simulators. IEEE Trans. Microw. Theory Tech. 54, 1598–1610 (2006).

    ADS  Google Scholar 

  15. 15.

    Chung, Y.-S., Cheon, C., Park, I.-H. & Hahn, S.-Y. Optimal shape design of microwave device using fdtd and design sensitivity analysis. IEEE Trans. Microw. Theory Tech. 48, 2289–2296 (2000).

    ADS  Google Scholar 

  16. 16.

    Chung, Y.-S., Lee, B.-J. & Kim, S.-C. Optimal shape design of dielectric micro lens using fdtd and topology optimization. J. Opt. Soc. Korea 13, 286–293 (2009).

    Google Scholar 

  17. 17.

    Ahmed, O. S., Bakr, M. H., Li, X. & Nomura, T. A time-domain adjoint variable method for materials with dispersive constitutive parameters. IEEE Trans. Microw. Theory Tech. 60, 2959–2971 (2012).

    ADS  Google Scholar 

  18. 18.

    Zaman, M. A., Hansen, P. C., Neustock, L. T., Padhy, P. & Hesselink, L. Adjoint method for estimating jiles-atherton hysteresis model parameters. J. Appl. Phys. 120, 093903 (2016).

    ADS  Google Scholar 

  19. 19.

    Hansen, P. & Hesselink, L. Accurate adjoint design sensitivities for nano metal optics. Opt. express 23, 23899–23923 (2015).

    ADS  CAS  PubMed  Google Scholar 

  20. 20.

    Lu, J. & Vučković, J. Nanophotonic computational design. Opt. Express 21, 13351–13367 (2013).

    ADS  PubMed  Google Scholar 

  21. 21.

    Jensen, J. S. & Sigmund, O. Topology optimization of photonic crystal structures: a high-bandwidth low-loss t-junction waveguide. J. Opt. Soc. Am. B 22, 1191–1198 (2005).

    ADS  CAS  Google Scholar 

  22. 22.

    Miller, O. D., Ganapati, V. & Yablonovitch, E. Inverse design of a nano-scale surface texture for light trapping. In CLEO: Science and Innovations, CF2J–2 (Optical Society of America, 2012).

  23. 23.

    Bhargava, S., Miller, O., Ganapati, V. & Yablonovitch, E. Inverse design of optical antennas for sub-wavelength energy delivery. In CLEO: Science and Innovations, CM2F–2 (Optical Society of America, 2013).

  24. 24.

    Lalau-Keraly, C. M., Bhargava, S., Miller, O. D. & Yablonovitch, E. Adjoint shape optimization applied to electromagnetic design. Opt. Express 21, 21693–21701 (2013).

    ADS  PubMed  Google Scholar 

  25. 25.

    Zhang, Y., Ahmed, O. S. & Bakr, M. H. Adjoint sensitivity analysis of plasmonic structures using the fdtd method. Opt. letters 39, 3002–3005 (2014).

    ADS  Google Scholar 

  26. 26.

    Hansen, P., Zheng, Y., Perederey, E. & Hesselink, L. Nanophotonic device optimization with adjoint fdtd. In CLEO: Applications and Technology, JTuI61 (Optical Society of America, 2011).

  27. 27.

    Hansen, P., Zheng, Y., Perederey, E. & Hesselink, L. Adjoint fdtd for nanophotonic device optimization. In Joint International Symposium on Optical Memory and Optical Data Storage, OTuE2 (Optical Society of America, 2011).

  28. 28.

    Sigmund, O. & Jensen, J. S. Systematic design of phononic band–gap materials and structures by topology optimization. Philos. Trans. R. Soc. London, Ser. A 361, 1001–1019 (2003).

    ADS  MathSciNet  MATH  Google Scholar 

  29. 29.

    Niederberger, A. C., Fattal, D. A., Gauger, N. R., Fan, S. & Beausoleil, R. G. Sensitivity analysis and optimization of sub-wavelength optical gratings using adjoints. Opt. Express 22, 12971–12981 (2014).

    ADS  CAS  PubMed  Google Scholar 

  30. 30.

    Molesky, S. et al. Inverse design in nanophotonics. Nat. Photonics 12, 659 (2018).

    ADS  CAS  Google Scholar 

  31. 31.

    Antonsen, T. M. Jr., Chernin, D. & Petillo, J. Adjoint approach to beam optics sensitivity based on hamiltonian particle dynamics. arXiv preprint arXiv:1807.07898 (2018).

  32. 32.

    Liu, W., Ambe, T. & Pease, R. Micro-objective lens with compact secondary electron detector for miniature low voltage electron beam systems. J. Vac. Sci. & Technol. B 14, 3738–3741 (1996).

    CAS  Google Scholar 

  33. 33.

    Braun, R. M. et al. Performance characteristics of a chemical imaging time-of-flight mass spectrometer. Rapid communications mass spectrometry 12, 1246–1252 (1998).

    ADS  CAS  Google Scholar 

  34. 34.

    Szilagyi, M. Electrostatic spline lenses. J. Vac. Sci. & Technol. A: Vacuum, Surfaces, Films 5, 273–278 (1987).

    ADS  Google Scholar 

  35. 35.

    van der Steen, H., Barth, J. & Adriaanse, J. Engineering constraints and computer-aided optimization of electrostatic lens systems. Nucl. Instruments Methods Phys. Res. Sect. A 298, 377–382 (1990).

    ADS  Google Scholar 

  36. 36.

    Whitley, D. A genetic algorithm tutorial. Stat. computing 4, 65–85 (1994).

    Google Scholar 

  37. 37.

    Carpenter, S. D., Schick, C. P. & Weber, P. M. Experimental adaptive optimization of mass spectrometer ion optic voltages using a genetic algorithm. Rev. scientific instruments 70, 2262–2267 (1999).

    ADS  CAS  Google Scholar 

  38. 38.

    Dahl, D., Delmore, J. & Appelhans, A. Simion pc/ps2 electrostatic lens design program. Rev. Sci. Instruments 61, 607–609 (1990).

    ADS  CAS  Google Scholar 

  39. 39.

    Barzilai, J. & Borwein, J. M. Two-point step size gradient methods. IMA journal numerical analysis 8, 141–148 (1988).

    MathSciNet  MATH  Google Scholar 

  40. 40.

    Scherzer, O. Über einige fehler von elektronenlinsen. Zeitschrift für Physik 101, 593–603 (1936).

    ADS  MATH  Google Scholar 

  41. 41.

    Boyd, S. P. & Vandenberghe, L. Convex Optimization (Cambridge University, 2004).

  42. 42.

    Aage, N., Andreassen, E., Lazarov, B. S. & Sigmund, O. Giga-voxel computational morphogenesis for structural design. Nat. 550, 84 (2017).

    ADS  CAS  Google Scholar 

  43. 43.

    Herzog, D., Seyda, V., Wycisk, E. & Emmelmann, C. Additive manufacturing of metals. Acta Materialia 117, 371–392 (2016).

    CAS  Google Scholar 

  44. 44.

    Ingber, L. et al. Adaptive simulated annealing (asa): Lessons learned. Control. cybernetics 25, 33–54 (1996).

    MATH  Google Scholar 

  45. 45.

    Giles, M. B. & Pierce, N. A. An introduction to the adjoint approach to design. Flow Turbul. Combust. 65, 393–415 (2000).

    MATH  Google Scholar 

  46. 46.

    Estep, D. A short course on duality, adjoint operators, green’s functions, and a posteriori error analysis. Lect. Notes (2004).

  47. 47.

    Jin, J.-M. The finite element method in electromagnetics (John Wiley & Sons, 2015).

  48. 48.

    Geuzaine, C. & Remacle, J.-F. Gmsh: A 3-d finite element mesh generator with built-in pre-and post-processing facilities. Int. journal for numerical methods engineering 79, 1309–1331 (2009).

    ADS  MathSciNet  MATH  Google Scholar 

Download references


We would like to thank the Department of Homeland Security for the continued support of this research and development effort under the Science and Technology Directorate, Homeland Security Advanced Research Projects Agency Contract #HSHQDC-12-C- 00002. We also thank Stanford for partial funding.

Author information




L.T.N. wrote the code for the particle tracer. L.T.N. and P.C.H. wrote the FEM code. L.T.N. wrote the optimization programs and analyzed the results. Z.E.R. consulted on ion optics and commercial simulation methods. L.H. provided oversight and project guidance. All authors reviewed the manuscript.

Corresponding author

Correspondence to Lars Thorben Neustock.

Ethics declarations

Competing Interests

The authors declare no competing interests.

Additional information

Publisher’s note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this license, visit

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Neustock, L.T., Hansen, P.C., Russell, Z.E. et al. Inverse Design Tool for Ion Optical Devices using the Adjoint Variable Method. Sci Rep 9, 11031 (2019).

Download citation


By submitting a comment you agree to abide by our Terms and Community Guidelines. If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.


Quick links

Nature Briefing

Sign up for the Nature Briefing newsletter — what matters in science, free to your inbox daily.

Get the most important science stories of the day, free in your inbox. Sign up for Nature Briefing