{'fraction_non_alphanumeric': 0.02408826749768382, 'fraction_numerical': 0.007074875768550493, 'mean_word_length': 4.8263002944062805, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Two-dimensional shaping of Solov'ev equilibrium with vacuum using external coils

In this work, we demonstrate a method for constructing the Solov'ev equilibrium with any given 2D shape surrounded by a vacuum region using external poloidal field coils. The computational domain consists of two parts: the plasma region, where the solution is the same as the Solov'ev solution, and the vacuum region, where the magnetic field generated by external coils as well as plasma current is determined using the Green function method through a matching condition near the separatrix. However, the method is not limited to the Solov'ev equilibrium in particular. The accuracy, efficiency, and robustness of such a scheme suggest that this method may be applied to the 2D shaping of tokamak plasma with vacuum region using external coils in general.

For a tokamak plasma, its stability and transport can be significantly affected by the twodimensional (2D) shaping of equilibrium poloidal cross-section [1][2][3][4] . Thus it is often desirable to construct the tokamak equilibrium with any prescribed poloidal shape for its plasma-vacuum interface using external coils in both theory and experiments.
2D shaping of tokamak equilibrium has been a subject of extensive studies. For certain pressure and current profiles, several analytical solutions of the Grad-Shafranov (G-S) equation allowing arbitrary plasma shape have been derived, where the shaping parameters, including elongation and triangularity, are determined using the expansion coefficients of the homogeneous solutions [5][6][7][8] . In simulation and experiments, 2D shaping studies have been often carried out in the design and optimization of equilibrium configuration feedback control schemes, which have been implemented in most tokamak devices (e.g. EAST 9 and DIII-D 10 ). one common such scheme usually involves the measurement and calculation of poloidal flux at specific control points [11][12][13] . For the given plasma current and pressure profiles, any deviation of the poloidal shaping from its target at a certain control surface can be corrected by adjusting the external coil current, and the exact adjustment can be determined by the matching condition at the control points. Such a method has been found successful in practice 9,10 . However, the direct relation between the 2D plasma shape and external coil configurations, which would allow the identification of their overall geometric and physical connections, has yet to be explicitly established. This paper presents a method for finding the direct and explicit relation between the tokamak shaping and the external poloidal field coil configuration, taking the well-known Solov'ev equilibrium as an example. As one of the analytical solutions of the G-S equation, Solov'ev equilibrium is often used in the benchmark of the numerical G-S equation solver and the analysis of tokamak equilibrium, such as the study on 2D plasma shaping 6,8 . The conventional Solov'ev solution, however, is derived with toroidal current filling all space, which is in contrast to the tokamak experiment where there is virtually a vacuum out of separatrix. Even though many studies have been done on the relationship between Solov'ev solutions and plasma shape 6,8 , most of these studies are based on the conventional Solov'ev solution without vacuum region. Xu and Fitzpatrick find an overall equilibrium solution with the Solov'ev solution in plasma along with a vacuum region 14 using the Green function and multiple expansion method, which may fail when the external coils are close to the plasma boundary as in realistic experiments. Instead, we directly use the Green function method for both plasma current and external poloidal field coils, which allows us to not only find the matching vacuum solution to a given Solov'ev equilibrium inside the separatrix but also establish the direct and explicit relation between the plasma shape and the external coil configuration. In general, this method can be directly applied to obtain tokamak equilibrium with desired 2D plasma shape in both simulation and experiment.
The rest of this paper is organized as follows: first, the numerical method is presented for finding the relation between plasma shaping and external poloidal field coil configuration. Then, we demonstrate the usage of the method and evaluate the associated numerical error using an example case of Solov'ev equilibrium. Finally, we apply the method to discuss the explicit relations between several typical plasma shaping and their corresponding external poloidal field coil configurations.
Numerical method: For the MHD equilibrium with toroidal axisymmetry, the poloidal magnetic flux function ψ is governed by the G-S equation Here, (R, φ , Z) corresponds to the right-hand cylindrical coordinate system. The above equation is written in the dimensionless form, where the magnetic field, poloidal magnetic flux, plasma pressure p, toroidal current density J φ , and poloidal current are normalized by the constants , and R 0 B 0 respectively, with R 0 , B 0 being the major radius and magnetic field strength at the magnetic axis.
The solutions to the G-S equation consist of the special and homogeneous contributions: where ψ 0 is the special solution specified by the pressure and the current profiles, and ψ i is a set ψ in the closed field line region: In this region, we first determined the special solution given by the pressure and current profiles. In the case of Solov'ev equilibrium, the pressure and current profiles are as follows: For any given special solution, the 2D plasma shaping is further determined by the homoge- where Ω represents the plasma region inside the separatrix, J φ is the toroidal current density, N c is the total number of the external coils, and I i is the current in each of the external coils, the Green function G (R, Z; R , z ) is given by 19 where K (k) and E (k) are the complete elliptic integrals of the first and second kind, and the argument is defined by which can be derived through calculating the vector potential generated by an axisymmetric current ring with unit current 20 . And ε is a small quantity added to avoid the singularity at the control surface caused by the complete elliptic integral of the first kind K.
Matching on last closed field surface: To guarantee the continuity of poloidal magnetic flux ψ between the open and the closed field line regions, the values of ψ from both regions could be matched on a surface close to the LCFS at chosen matching points j where ψ X is the poloidal magnetic flux at the X point on separatrix, ψ = (1 − η) ψ X is the flux on the matching surface, η is a small number chosen to avoid singularities caused by discontinuities in the tangential slopes of the magnetic field lines at the X points 14  In this way, we obtain the complete equilibrium solution to the G-S equation in Eq. (1) where the corresponding configuration of the external poloidal field coils can maintain the prescribed plasma profiles and 2D shape at the separatrix are also determined.
An example case and error evaluation: An up-down symmetric tokamak equilibrium with separatrix, which can be minimally specified with the first four items expansion terms of the homogeneous solutions along with a special solution of the G-S equation (1), is shown here as an example of the solution method described in the previous section: In this case, the four unknown coefficients c 1 − c 4 in Eq. (3) can be determined by the locations of the X points (R X , ±Z X ) and the magnetic axis (R 0 , 0) together with the assumption that the poloidal flux function ψ = 0 at the magnetic axis. This yields the corresponding constraints: The constraint that the derivative of ψ on Z at the magnetic axis equals zero is naturally satisfied, owing to the symmetry of ψ in Z. The constraints in Eq. (12) 6), the two-dimensional trapezoidal rule is adopted on a 100 × 100 uniform rectangular grid.
Using the method outlined in previous sections, we obtain the Solov'ev equilibrium with a vacuum region outside the separatrix (Fig. 1) and the corresponding external coil configuration.
In comparison to the conventional Solov'ev equilibrium without a vacuum region, the contours of ψ are the same in the closed field line region, and the shape of the separatrix is nearly identical subject to the numerical error. The relative error of the vacuum solution on the separatrix can be where ψ X is the Solov'ev solution on the separatrix and ψ vac X (θ ) is the numerical vacuum solution along the separatrix and dependent on the poloidal angle θ at the given ψ X on the separatrix. As shown in the upper figure of Fig. 2, the maximum difference is at the X points, which is caused by the discontinuity of the tangential slope of the magnetic field line at the X points. Nonetheless, as seen in the lower figure of Fig. 2, ψ is continuous at separatrix.
Outside the separatrix, the contour of ψ differs from the Solov'ev solution, as also indicated by the different external angles of field lines at the X points. The error Λ depends on the matching parameter η and the grid size. Keeping the grid size fixed, the relative error increases with η, as shown in Fig. 3. For several fixed given η, the numerical convergence in terms of Λ with grid size is also confirmed.
2D shaping by external coils: In the above method, only a set of linear equations for the coil currents need to be solved for a set of prescribed coil locations, which suggests that the method may be used as an efficient 2D shaping control scheme using external coils. To demonstrate this, we solve for example the external coil settings for several Solov'ev equilibria with vacuum regions and the designed features of 2D shape, such as varying degrees of up-down asymmetry, elongation, and triangularity.
Up-down asymmetry: For an up-down asymmetric equilibrium, the positions of the magnetic axis and two different X points can be chosen to determine the plasma shape. As a result of the choice, we will need to select at least three additional expansions terms of the homogeneous solutions of Eq. (1).
Now, seven constraints are required to solve the seven unknown coefficients c i .
The constraint on the derivative of ψ on Z at the magnetic axis is required now because it is Two corresponding constraints are required to determine these two unknown coefficients, such as the requirement that ψ at the inner and outer points of LCFS be the same as ψ at the X point The Solov'ev equilibrium thus solved is shown in Fig. 6 along with the conventional Solov'ev equilibrium with the same plasma current, pressure profiles, and plasma shape.
In summary, a general method for constructing an equilibrium with any specified 2D shape surrounded by a vacuum region using external poloidal field coils is presented, which allows the determination of the direct relation between the plasma shaping and the corresponding external poloidal field coil setting. And this method is demonstrated to be effective for specifying the elongation, triangularity, and up-down symmetry of Solov'ev equilibrium with a vacuum region by adjusting the current of a set of external coils at fixed locations, for example. However, this method is not limited to the Solov'ev equilibrium. We plan on implementing the method into 2D equilibrium solvers, such as NIMEQ 21,22 and CHEASE 23 , to obtain a desirable equilibrium with designed plasma shape using external coils and extending this method to the calculation of external coil setting for more general and realistic tokamak equilibrium with any prescribed 2D shape, which may be eventually developed into a practical 2D shaping control scheme.

DATA AVAILABILITY STATEMENT
The data that support the findings of this study are available from the corresponding author upon reasonable request.