Model-based impurity emission front control using deuterium fueling and nitrogen seeding in TCV

This paper presents the first result using nitrogen-seeded exhaust feedback control of the NII impurity emission front in TCV. The NII emission front position is consistently located below its commonly used CIII counterpart, indicating the NII emission front is representative of a colder plasma region. We demonstrate control of the NII impurity emission front position for two cases: (a) using nitrogen seeding as the sole actuator, and (b) using deuterium fueling as an actuator while injecting a small amount of nitrogen that remains a trace impurity. For sole nitrogen actuation, peak target current density is significantly reduced when the NII emission front approaches the x-point (≈50% for the NII front at the halfway point). When actuating with deuterium, peak target current density is less affected, which is explained by changes in fueling engendering a different scrape-off-layer plasma density. Perturbative (system identification) experiments show that nitrogen actuation induces a stronger, but slower, response of the NII emission front than deuterium actuation. Moving the NII emission front back to the target after pushing it towards the x-point has proven difficult, where both the NII front position and total radiated power do not reach pre-seeding conditions within the discharge time following termination of nitrogen injection. This result highlights the need to account for impurity retention for such seeded discharges in exhaust control strategies.

. Bode plot of the transfer function modelsĤ N2NII (s) and H D2NII (s) and the FRF measurements of the full system from u (gas valve reference) to y (NII front position) in the case of D 2 and N 2 gas perturbation, indicated by M D2NII (s) and M N2NII (s) respectively. The dashed lines indicate the DC-gain used to regress the G(s) models multiplied by the DC-gain of the valve and sensor, i.e. H N2NII (0) andĤ D2NII (0).

DIFFER is part of the institutes organization of NWO.
This work was supported in part by the Swiss National Science Foundation.
This work has been carried out within the framework of the EUROfusion Consortium, funded by the European Union via the Euratom Research and Training Programme (Grant Agreement No. 101052200-EUROfusion). Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Commission. Neither the European Union nor the European Commission can be held responsible for them. This paper presents the first result using nitrogen-seeded exhaust feedback control of the NII impurity emission front in TCV. The NII emission front position is consistently located below its commonly used CIII counterpart, indicating the NII emission front is representative of a colder plasma region. We demonstrate control of the NII impurity emission front position for two cases: (a) using nitrogen seeding as the sole actuator, and (b) using deuterium fueling as an actuator while injecting a small amount of nitrogen that remains a trace impurity. For sole nitrogen actuation, peak target current density is significantly reduced when the NII emission front approaches the x-point (≈50% for the NII front at the halfway point). When actuating with deuterium, peak target current density is less affected, which is explained by changes in fueling engendering a different scrape-off-layer plasma density. Perturbative (system identification) experiments show that nitrogen actuation induces a stronger, but slower, response of the NII emission front than deuterium actuation. Moving the NII emission front back to the target after pushing it towards the x-point has proven difficult, where both the NII front position and total radiated power do not reach pre-seeding conditions within the discharge time following termination of nitrogen injection. This result highlights the need to account for impurity retention for such seeded discharges in exhaust control strategies.
Keywords: power exhaust, detachment control, system identification, impurity seeding, TCV Original Content from this work may be used under the terms of the Creative Commons Attribution 4.0 licence. Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.

Introduction
One of the major outstanding challenges for reactor relevant tokamak operation is the heat and particle load on the first wall, notably the divertor [1]. Left unmitigated, the expected power fluxes impacting the divertor targets during reactorrelevant operation exceed present-day materials engineering limits [2,3]. Real-time feedback control of plasma detachment, a regime characterized by a large reduction of plasma temperature and plasma pressure at the divertor target, is required to maintain a sufficient reduction of these fluxes [4,5].
Designing such exhaust feedback controllers systematically requires a dynamic (time-dependent) model of the to-becontrolled physical system. This model includes the plasma, actuator, and sensor, and allows to design for model-based guarantees on stability and performance of the controlled system [6]. Predictive dynamic models are therefore paramount to confidently apply controllers to a new reactor from the first discharge. This should start with a robust design in the robustness-performance trade-off, and move to performance design once more experimental data is available to improve the modeled dynamics. Experimental identification of the heat exhaust dynamics is therefore the logical approach to design controllers for present-day devices. This ensures a discharge efficient control development and adds dynamic data to the experimental database necessary for validating first-principle time-dependent models.
In [7], dedicated system identification experiments were performed to obtain a parametric dynamic model of the CIII (465 nm triplet) emission front position response to deuterium (D 2 ) fueling in the carbon machine Tokamakà configuration vriable (TCV). This model was used to systematically design a controller off-line. This approach resulted in a successful real-time feedback control of the CIII emission front, where the intrinsic Carbon of the TCV wall allowed for enhanced radiation. In future reactors, i.e. metal walls, intrinsic impurity radiation from carbon will not be present. Therefore, exhaust control will require the direct injection of impurities into the divertor region to augment power losses, as is envisioned for ITER and DEMO [8,9].
In this paper, we adhere to this approach, performing real-time plasma exhaust control with the direct injection of nitrogen (N 2 ) in TCV. N 2 is injected through a piezoelectric gas valve into the divertor to further cool the exhaust plasma. We employ the resulting NII (399.5 nm) emission front to diagnose the plasma detachment progression. Similarly to carbon, nitrogen has a high radiative potential for the temperature range typical of the TCV divertor. We use the transfer function structure derived in [10] for emission front control in TCV, which is based on a 1D diffusion equation. This model is regressed against system identification measurements, because the simple gain and delay model used in [7] was unable to reproduce the measured dynamic response of the CIII emission front to D 2 gas injection [10].
Note that, the corresponding nitrogen seeded detachment physics in TCV L-mode plasmas was probed experimentally in [11] and compared with SOLPS-ITER in [12]. In this paper we focus specifically on using the NII emission front position as a control parameter for the divertor plasma and designing corresponding controllers. Furthermore, we compare the dynamic response of the exhaust plasma to N 2 and D 2 injection to gain further insight in the dynamic modeling for heat exhaust control.
In this paper, we report on three key results. (a) Successful real-time control of the NII emission front position actuated by both N 2 and D 2 , which includes using N 2 as a tracer. A single discharge per actuator was sufficient to identify the transfer function model parameters and design a controller for each of these: N 2 and D 2 . This is the first demonstration of real-time control of the plasma exhaust using N 2 in TCV. This is also the first demonstration of using the transfer function structure of [10] to design a gas injection actuated emission front controller. (b) The controlled NII front position was consistently located 2-3 cm below the CIII emission front position. Hence, we conclude that the NII emission is indicative of a colder region than the CIII emission. This is qualitatively in line with the SOLPS-ITER analysis of [12], where the CIII and NII impurity emission fronts were found to correspond to local electron temperatures of 11-12 and 6.5 eV, respectively. Note that the experimental temperatures (from spectroscopy and Thomson Scattering when available) are generally considerably lower for both (see e.g. [13] and references therein). (c) The CIII and NII emission front positions respond identically to D 2 or N 2 injection perturbations in the system identification experiments. This indicates they cannot be controlled independently by the used actuators, at least up to the highest excited frequency of 37 Hz. Both fronts do, however, respond differently to actuation using D 2 than to actuation using N 2 , with the latter inducing a stronger, but slower response of both fronts. This paper is organized as follows. In section 2, the experimental set-up and the control goal, including the used actuators and sensor in the control loop are introduced. In section 3, the system identification experiments are discussed and their results presented. The system identification results are then used to regress the diffusion-based transfer function structure on which we base the controller design. We show the emission front control results in section 4, and analyze the impact of NII emission front position on target saturation current density and radiated power fraction. We also compare actuation of the NII emission front using D 2 and N 2 as actuators to track the same desired reference position. The conclusions and a discussion follows in section 5.

Experimental setup
The experiments for this work were performed on the TCV [14]. Results are obtained in a lower single-null 340 kA Ohmically heated diverted L-mode scenario in reversed field (unfavorable to H-mode access), B tor = 1.4 T, and a line-averaged electron density ofn e ≈ 9 × 10 19 m −3 ( f GW = 0.4). The scenario is similar to the high-density scenario used in [11] to analyze nitrogen seeded divertor detachment in TCV Lmode plasmas and was chosen as it operates close to detachment. Additionally, it was observed in [11] that the higher line-averaged density case resulted in better core screening to N 2 penetration, increasing the discharge's operational range with respect to the quantity of N 2 injected.

Control goal
The TCV divertor plasma can be spectroscopically diagnosed from either intrinsic (e.g. carbon, helium, hydrogen) or extrinsic (e.g. nitrogen, argon) line emission [15,16]. Their emission spectra are strongly temperature-dependent in the divertor plasma temperature range, providing direct information on the divertor plasma state [17].
In this work, we aim to control the NII emission front position, diagnosing the exhaust plasma by using the emission of an injected impurity instead of the intrinsic carbon always present in TCV. We aim to control the NII front with two actuators: (a) Using N 2 gas injection as an actuator, directly changing the impurity radiated power intensity whilst having a relatively small effect upon the core plasma density; (b) Using D 2 gas injection as an actuator, increasing the divertor plasma density which changes the intrinsic carbon source. These affect hydrogenic and carbon radiated power respectively. In case 2, we also inject a small amount of N 2 , to probe the use of extrinsic impurities as diagnostic tracers. For this work we define the tracer impurity as a relatively small amount of N 2 injection, not used as an actuator for control. The chosen amount resulted in a relatively constant measurement of integrated NII emission showing only minor impurity content buildup. We note that changes in integrated NII emission may be an incomplete measure of changes in nitrogen concentration in the divertor plasma, but use it as an estimate.
The receding of CIII emission from the target is often taken as an indication of the onset of divertor detachment in TCV [11,13,18,19] and was used as a control parameter cast as an emission front position in [7]. The NII impurity emission front has not yet been used for control purposes, and may have different characteristics as a control parameter.
From SOLPS-ITER analysis of [12] and experimental results from [11] the NII emission front position is expected at a lower plasma temperature and therefore positioned between the divertor target and the CIII emission front position. Its receding from the target is thus an indication of lower divertor temperatures than the receding of CIII emission. It may be reasonable to expect that the dynamic response of the NII emission front position to N 2 is considerably different than that of the CIII emission front, as in the first case the emitting impurity is directly used for actuation while in the second case it is related to the intrinsic carbon source. However, we will show that both the NII emission front and CIII emission front respond identically to perturbations of a single gas species, be it N 2 or D 2 . Figure 1 shows the process control loop. The dynamics of the full system H are defined from requested gas input u to measured NII front position y, that includes the actuator A, the plant G and sensor S. These need to be included to design a feedback controller off-line and predict performance and robustness margins [20]. Next, we elaborate on the used sensor and actuator and their individual dynamics. Identification of Figure 1. The process control loop. A control reference position r is compared with a measured front position y. The control error e is fed to a controller C, which computes voltage request u, send to the gas valve actuator A. The internal gas valve controller follows this request, resulting in a (measured) injected gas flow um. The gas enters the plant G, which is the TCV. The divertor plasma response, in terms of an emission front position, is measured using the sensor S, i.e. MANTIS. the local (linearized) dynamics of the plant G, together with the full system from u to y, is performed through system identification experiments shown in section 3.

Sensors
The NII and CIII emission front locations are measured using a real-time detection algorithm [21] applied to spectrally filtered images originating from the multi-spectral imaging diagnostic MANTIS [22]. The MANTIS cameras run at a frame rate of 800 Hz, where the shutter opening time stamp plus half the exposure time (≈0.5 ms) for each image is taken as the representative time for when each image, and thus the front position, is measured. We define the corresponding front position as x NII , which is the total distance from the outer divertor target to the front location, along the outer leg. Conversely, the front position as received by the real-time control system, after the image has traversed the real-time detection and written the result to memory, is defined as y NII . The value for y NII is delayed by 4 ms with respect to x NII . These sensor dynamics S are, thus, well captured by y(t + 0.004) = x(t). We will transform these sensor dynamics to the Laplace domain, since the total system then becomes a straightforward multiplication of the terms: G(s) = S(s)H(s)A(s), assuming local linearity. This was elaborated in previous work [10] and references therein. The sensor dynamics y(t + 0.004) = x(t) then become the transfer function with s the Laplace variable.
We investigate the effect of the NII emission front position on the divertor plasma from the ion saturation current density at the inner-and outer strike points using wall-embedded Langmuir probes, and from the radiated power measured by gold-foil bolometers [23]. The Langmuir probes provide a measurement of the ion saturation current density from current-voltage curve fits over a 5 ms period average (further details on the analysis are described in [24]). The bolometers estimate the total radiated power fraction f tot rad and radiated power fraction in the scrape-off-layer f SOL rad . Radiated power from the core P core rad is estimated from a tomographic reconstruction of the bolometer camera array. We define the total and SOL radiated power fractions as Left: magnetic geometry used for this work is shown in the poloidal plane of TCV in blue. Langmuir probe locations which were used to measure ion saturation current density are shown by red dots. Lines of sight of 64 gold-foil bolometers which were used to estimate radiated power are shown in pink. Gas injection locations of D 2 and N 2 are located at the machine bottom shown in dark green. Right: NII emission image from MANTIS at t = 1 s during this discharge, including the detected NII emission front location indicated by the cyan cross. The detected position is mapped to the poloidal plane on the left using the algorithm of [21], resulting in y NII = 0.12 m, which is the total distance from the outer divertor target to the front position along the outer leg.
respectively, where P ohm is the ohmic heating power. Figure 2 shows the positions of the LPs, bolometer lines of sight, and an example of the detected NII emission front position a discharge.

Actuators
The NII emission front position is controlled by the injection of N 2 or D 2 molecules in the divertor through piezo-electric gas valves [25]. A pressure transducer at the output of the valve is absolutely calibrated to estimate the mass flow entering the vacuum vessel. Both the actuator voltage request u to the valve, and the pressure at the valve output (directly related to gas flow) u m are measured. The piezo-electric valves have a dynamic response from a requested gas flow to an actual gas flow indicated by the block A in figure 1. Separate identification of the dynamics of each valve was obtained by step that can be described by the transfer function  (3) is where δ is the applied step input on u. The model parameters K, τ and τ d are determined by regressing the FOPDT model on 15 step response measurements in the time-domain, using a root-mean-squared error minimization of the modeled stepresponse with respect to the measured response. Table 1 shows the average of the obtained model parameters for each valve over the 15 measurements. We shall refer to the corresponding models as A D2 (s) and A N2 (s) for the deuterium valve and the nitrogen valve, respectively. Figure 2 shows the gas injection locations of both these valves in TCV.

System identification experiments
Efficient and systematic controller design requires a dynamic model of the to-be-controlled system [6], herein the total dynamics from input u to output y as shown in figure 1. In reality, most systems have non-linear input/output characteristics, however, a local linear description is often sufficient to describe the dynamics within a useful operating range [26], where the feedback controller will deal with residual non-linearities. These local system dynamics are identified experimentally using dedicated system identification experiments, similar to [7,27]. By exciting the system with carefully designed perturbations to the input u while measuring the output y, assuming small perturbations, a local linear approximation of the system is identified. This local description is only valid for an operating range around the perturbed equilibrium, whose size depends on the strength of present non-linearities. In [7] no clear non-linear contributions were identified from dedicated system identification experiments using D 2 gas perturbations to perturb the CIII emission front position, providing confidence that a local linear description is adequate for emission front controller design.
As described in section 2, we can measure the mass flow of gas entering the vessel, and also the shutter aperture time of MANTIS and corresponding front position measurement x. We can therefore identify the local dynamics of the plant, G(s), individually as well as the local dynamics of the total systemĤ(s) = A(s)Ĝ(s)S(s). We will use this to compare the local response of the divertor plasma to D 2 and N 2 gas injection without including any spurious effects from the actuator or sensor dynamics, i.e. comparing the plant physics only. With the actuator and sensor dynamics A(s) and S(s) taken as global descriptions to be valid for the full operational space. For the gas valves known to be untrue when operating near its closure, as its response becomes nonlinear, but we shall assume this contribution to be negligible.
In the following section, the perturbation design for the system identification experiments is briefly discussed, and the experimental results are presented.

Perturbation design
We identifyĤ(s) andĜ(s) in the form of frequency response function (FRF) data, obtained using sinusoidal perturbations superimposed on a pre-programmed feedforward trace. An FRF datapoint is obtained for each frequency ω [rad s −1 ] excited in the perturbation waveform, consisting of the relative amplitude and relative phase of the measured output response to the input perturbation. The FRF datapoints are the evaluation of the system its transfer function in the Fourier domain using s = jω, which may be interpreted as its response to constant amplitude oscillations. The perturbation we apply to the gas input is a multisine waveform, consisting of a sum of sinusoids, each with a distinct frequency, phase and amplitude. Such a multisine waveform is chosen as all perturbation energy is then concentrated on the chosen set of frequencies, maximizing signal to noise ratio. Additionally, a key benefit of identifying the system with an FRF is that no pre-chosen model structure is required, i.e. no assumption on the underlying physics is made.
More information on the specific design of this approach with multisine perturbations in TCV experiments is described in [7], with more information on the general theory available in [27,28].
The discharge scenario allows for a perturbation time τ ex p of approximately 0.8 s, placing a lower bound on the identifiable frequency range, or fundamental frequency f 0 , at 3.75 Hz as a minimum of three periods is required to obtain a meaningful variance computation [28]. We choose to perturb the system using a multisine with f 0 = 1/0.19 Hz and harmonics on lines 1, 3, 5, 7 (5.26, 15.79, 26.32, 36.84 Hz), applied to the N 2 valve and D 2 valve in discharges #68861 and #69147, respectively. A slightly higher frequency than 3.75 Hz is chosen such that earlier than expected plasma discharge termination would include at least three periods of perturbation, ensuring more discharges were effective. Figure 3 shows the time traces of the two system identification discharges. The perturbations are superimposed on a designed feedforward trace that provides approximately constant line-averaged density. We observe a clear response of both the NII and CIII emission front to perturbations applied to the N 2 and D 2 valves, including a slow drift of the front position upward along the divertor leg towards the x-point. This drift is a transient response, likely caused by nitrogen content build-up in the plasma and/or changing wall sources and sinks, for which we compensate in the frequency domain analysis using the local polynomial method (LPM) [27,29]. The LPM separates the measured transient response from the response originating from the excitation frequencies in the multisine perturbation. This exploits the property of transients to be smooth over frequency, unlike the response of the multisine excitation.

Experimental results
We find the CIII emission front position is consistently located 2-3 cm above the NII emission front position throughout the discharge, demonstrating the NII front is indicative of a colder region than for CIII assuming a negative temperature gradient from upstream to target.
We analyze the frequency response measurements by plotting the FRF datapoints in a Bode plot, that shows the relative amplitude and phase between input perturbation and output response. Figure 4 shows the measured FRF data points from both actuators (actual N 2 and D 2 gas flow) to the CIII and NII emission front positions compensated for the 4 ms measurement delay, i.e. these results are corrected for actuator and sensor dynamics (cf G(s) only in figure 1).
The FRF data shows that both the CIII and NII emission fronts respond equally to the perturbations on a single actuator, . The 2σ errorbars are computed using the propagation of uncertainty for magnitude and phase as in [30], assuming a noiseless input case. Bottom: discrete Fourier transform (DFT) of the NII emission front response to both gas species, the signal has been compensated for the slow drift (using linear detrending) for clarity. The grey vertical lines indicate the excited frequencies in the perturbation.
i.e. they move together when a single gas species is perturbed. Until the highest probed excitation frequency of 36.84 Hz, no clear separation of these fronts is seen, implying emission equilibration time-scales in the scrape-off layer are significantly faster.
With N 2 perturbations, we observe a stronger phase drop and an amplitude response of almost a factor four higher, per molecule, than with D 2 . Thus, N 2 injection results in a stronger, although for higher (>10 Hz) frequencies slower, response of the NII and CIII emission front positions than D 2 . Generally, a smaller phase delay results in higher possible performance of the closed-loop system. The results indicate a higher performance may be possible with D 2 actuation of impurity emission front position, assuming there is no issue with the required larger gas injection amplitude. Figure 4 also shows the discrete Fourier transform (DFT) of the NII emission front response amplitude over frequency. The perturbed frequency amplitudes are clearly well above the noise level, with a strong peak observed around ∼150 Hz. This periodic external disturbance (not resulting from the applied perturbations) is concentrated around the sawteeth crash frequency for this scenario, determined from soft x-ray emission measurements. Sawteeth perturb the core plasma, and are some time later observed in the divertor plasma. They do not effect the system identification results, as it is significantly removed from the probed excitation frequencies. However, this observation will be retained in controller design, to ensure it does not act on these high frequency disturbances.
In the next section we obtain a model of the full system H, by coupling the estimated actuator and sensor dynamics A(s) and S(s) to our local plant dynamicsĜ(s). The resulting modelĤ(s) = S(s)Ĝ(s)A(s) is then verified experimentally using FRF measurements.

Transfer function model
In section 2, the sensor and actuator dynamics of our control loop were introduced as the transfer functions S(s) for the MANTIS real-time front detection and A D2 , A N2 for the deuterium and nitrogen gas valve dynamics respectively. The NII emission front response is found to be different for each actuator, so a separate transfer function models of the local plant approximationĜ D2 (s) andĜ N2 (s) is taken to describe the response to deuterium and nitrogen. A control-oriented transfer function model structure for emission front control in TCV was presented in [10]. This model is based on the observation of typical Warburg-domain phase and magnitude behavior of FRF measurements from D 2 gas injection to CIII front position response, indicating a (quasi) diffusive process can describe the plant dynamics.
The measured phase response to N 2 gas injection does not directly show a typical Warburg-domain behavior of roughly −45 • over a large frequency range. However, its magnitude response does show an equivalent slope with respect to frequency as the response to D 2 . Therefore, we do reuse the (quasi) diffusive model structure here, assuming it is appropriate to describe the dynamic response to N 2 gas injection. We note, however, this choice might be overstretching the use of this model structure, but have not identified a better substantiated alternative at present.
As in [10] we take a direct relation between the change in local neutral density and front position, but allow the evaluation location of this neutral density to vary. The transfer function structure forĜ(s) then becomes δy = cosh(xλ) tanh(Lλ) − sinh(xλ) Dλ δu (6) wherex, L and D represent the evaluation location, domain size and diffusion coefficient respectively, and λ = s/D with s the Laplace variable. Note that, we use here δu and δy as the model is a local (linearized) approximation of the dynamics. As the valve reference u is in units of volts, the other parameter magnitudes are no longer physical parameters, but just the structure of the function is used. One of the problems  [10] with identifying such parameters with system identification data is the limited range of frequencies that can be identified. Specifically, a lower limit is induced by the experimental time duration as discussed at the start of this section. Additional data is required to obtain a unique parameter fit, which was obtained in [10] using SOLPS-ITER simulations to obtain an additional FRF data point at the zerofrequency that represents the DC-gain. We re-use this data point, together with the conversion factor for molecules per second to volts which is different for each gas valve. The DCgain forĜ D2 (s) then becomes 0.15 mV −1 corresponding to 4.22 × 10 −22 m/D 2 s −1 ] in our operating space. ForĜ N2 (s), such analysis with SOLPS-ITER has yet to be performed. We, therefore, analyze the change in NII emission front position to step-wise increases from N 2 injection in a preceeding discharge. The change in NII emission front position was 0.042 mV −1 for N 2 injection, which we use as the DC-gain for G N2 (s). The resulting model parameters, after regression to the measurements, are shown in table 2. Figure 4 shows the used DC-gains by dashed lines. Now that the individual models of the sensor, actuator and plant dynamics in the process loop in figure 1 are known from equations (1), (4) and (6), we can take their product (assuming local linearity) to obtain models for the full system as These should coincide with our FRF measurement of the full systemĤ(s) for both cases. Figure 5 shows that this is indeed the case, as our derived transfer function models of the full system reproduces the FRF measurements, confirming that the transfer function models of (7) adequately capture the system dynamics. The transfer functionsĤ N2NII (s) andĤ D2NII (s) may thus be used to design a controller for both actuators to control the NII emission front position in real-time. Evidently, we could have fitted a model directly from the FRF measurements ofĤ(s), equally useful for controller design. However, separating the control loop into several sub-models provides more insight into the performance of each system component. This allows, for example, a simple replacement of the gas valve actuator model. Then, the effect of this change in actuator on control performance can be directly observed, and used to design a new controller. Furthermore, it allows the direct comparison of the measured plasma response to machines and experiments where different actuators or sensors are used.

Control experiments
In this section, we present the NII emission front control results. We start with details on the controller design, present the experimental result for two discharges, and finally compare D 2 and N 2 actuation from two discharges with identical NII emission front position control references.

Controller design
The controllers are designed using the Loop Shaping method [20]. With this method, the loop transfer function L(s) = H(s)C(s) is shaped towards certain stability margins and performance based on the modelĤ(s) derived in section 3. The resulting phase margin and bandwidth of a chosen controller C(s) can be interpreted as a measure for stability margin and performance respectively. For reference, a phase margin of 30 • is considered the minimum stability margin, while 90 • is considered the most conservative. A large stability margin means the closed-loop remains stable for a large uncertainty of the modelĤ(s), but comes at the cost of a low bandwidth and thus performance. The interested reader is referred to [6,31] for the corresponding control theory and to [32] for a more detailed example in fusion where loop shaping was used.
As the system is gas transport driven, we do not expect any resonances and should obtain adequate performance from a PI controller. A PI controller of the form is chosen for both actuators, where the controller gain K p and integrator cut-off frequency K i are chosen such that a bandwidth of 7 Hz is obtained with a phase margin of 50 • or higher to maintain sufficient robustness margin for modeling errors.
A bandwidth of 7 Hz has proven sufficient to provide reasonable performance for emission front control as shown in [7]. The controller is extended using an Infinite Impulse Response (IIR) low pass filter with a passband edge frequency at 40 Hz, to reduce the influence of high-frequency measurement noise like the measured ∼150 Hz peak originating from sawtooth crashes (see figure 4) on the tracking error. We choose an IIR low-pass filter as this meets the filter specifications with a lower filter order than Finite Impulse Response filters, leading to lower computation and storage costs in the control system [33]. The filter must be accounted for during loop shaping, by taking the product of the transfer function of the low-pass filter and the PI controller. Table 3 shows the resulting controller gains, bandwidth and phase margin.
In order to prevent integral windup, the controllers are implemented using the clamping anti-windup method. This method saturates the integral action build-up when it reaches a pre-defined threshold. This prevents overshoot caused by the rise time of a system response during which the integral action builds-up, see [34]. Figure 6 shows two discharges where the NII emission front position was controlled using N 2 seeding. In discharge #69144 a step-wise increase in the control reference was applied, we find the controller is able to track the desired reference well with little overshoot after the step transitions. The resulting peak target current density J peak sat follows an inverse response, showing a clear reduction when the NII front is at a higher position in the divertor leg. Additionally, both the total radiated power fraction P rad total /P ohm and the radiated power fraction in the SOL P rad SOL /P SOL show a correlated increase with NII front position height.

Experimental results
In discharge #69185 a step-wise increase in NII front reference position is requested first, followed by a step decrease. The controller is again well able to track the desired reference for the step increase, but the front remains too high after the step decrease, even though the controller ceases N 2 injection completely. Like the NII front position, the radiated power fractions does not decay further after 1.4 s, although, again, N 2 seeding has ceased completely. Interestingly, the peak target current density continuous to increase after this time, possibly Experimental results for two reference tracking experiments of the NII emission front using first N 2 seeding. Row 1: injected N 2 and D 2 gas and line-averaged electron densityne. Row 2: requested front position reference r NII and both raw and low-pass filtered measured front position y NII . Row 3: peak target current density J peak sat on the inner strike point (ISP) and outer strike point (OSP). Row 4: Ratio of J peak sat tone · 10 19 . Row 5: total radiated power fraction P rad total /P ohm and SOL radiated power fraction P rad SOL /P SOL .
caused by the observed increase in line-averaged density after seeding has ceased. In attached conditions of TCV L-mode plasmas, the target ion flux scales linearly with line-averaged density [13,15]. To disentangle the effect of density changes to J peak sat , we analyze traces of J peak sat /n e · 10 19 , that show a smaller, but still clear, increase after N 2 seeding ceases.  Figure 7 compares two discharges where the NII emission front position was controlled towards an identical reference trajectory, using N 2 seeding (#69145) or using D 2 fueling (#69148) as an actuator. With D 2 fueling a small constant influx of N 2 is maintained as a trace impurity, to ensure the NII impurity emission front can remain detectable.

Comparison of deuterium and nitrogen actuation
The controller tracks the step-wise increase of the desired front position well for both cases. However, here again the step decrease has difficulties. For N 2 actuation the NII front position remains higher than desired, even though the N 2 valve is closed and the line-averaged electron density is no longer increasing. For D 2 actuation the NII front position again remains higher than desired, with the D 2 valve closed. Here, however, this is accompanied by a clear decrease in emission front position, in line with the decay in line-averaged density and radiated power fractions that accompany the reduced gas injection. The peak target current density J peak sat shows a considerably different behavior. A clear reduction is obtained with a higher NII front position for N 2 actuation alone, which is attributed to a reduction in ionization efficiency from the SOLPS-ITER analysis in [12]. In contrast, D 2 actuation does not show this reduction. We note that moving the NII front position with D 2 actuation is coherent with the change in lineaveraged density, leading to relative constant J peak sat , likely resulting from operating around a line-averaged density close to pre-detachment roll-over for this scenario [11]. This is confirmed by accounting for changes in line-averaged density by comparing the traces of J peak sat /n e , showing fairly similar changes for both D 2 and N 2 actuation.

Conclusion and discussion
In this work, we have shown the first results of real-time control of the NII (399.5 nm) emission front position using N 2 seeding in TCV, diagnosing the exhaust plasma by using light emission of an injected impurity gas. We used a novel controloriented transfer function structure for emission front control in TCV [10], regressed onto system identification measurements to obtain a (locally valid) dynamic model of the NII front response to both D 2 and N 2 gas injection. This model was combined with an identified model for the gas valve actuators, and for the MANTIS sensor, to construct a model description of the complete system dynamics, subsequently used to design controllers off-line, providing successful control of the following discharge.
We have demonstrated real-time control of the NII emission front position actuated by N 2 gas injection, or actuated by D 2 gas injection while injecting a small amount of N 2 as a trace impurity. For both cases, the NII emission front was controlled towards higher positions, but moving the front position back towards the target proved difficult, likely affected by nitrogen retention in the machine. This retention was observed to affect subsequent discharges, showing the importance of tracking impurity retention and efficiently removing impurities from the machine. If impurity injection is used to mitigate radiative fluctuations in the plasma exhaust this accumulation would become a limiting factor in control performance, strategies where impurity injection is kept to a minimum would be required. This is in line with the strategic operation of exhaust control, that must simultaneously encompass a soft limit of reattachment (which can still be temporarily endured by using, for example, strike-point sweeping [35][36][37]), and a hard limit resulting from radiative instability induced disruptions.
We found the NII front position is consistently located between the CIII emission front and the divertor target, showing the NII front position is indicative of a colder plasma region than its CIII counterpart. This is qualitatively in line with the SOLPS-ITER analysis of [12], where the CIII and NII impurity emission front was found to correspond to a local electron temperature of 11-12 and 6.5 eV respectively, where it should be recalled that experimental measurements of the CIII emission front temperature are considerably lower (see e.g. [13]). We have shown the CIII and NII emission front positions respond simultaneously to the injection of D 2 or N 2 perturbations in the described system identification experiments, indicating these front positions cannot be controlled independently by the used actuators, at least up to the highest probed excited frequency of 37 Hz. Additionally, this result highlights the robustness of using these emission fronts as an indication of local electron temperature, where the amount of emitting impurities, injected or sputtered, seems to not significantly affect the location of their emission.
However, both emission fronts do respond differently to D 2 actuation than to N 2 actuation, where the latter induces a stronger, but slower response of both front positions. We note that N 2 is injected in the private flux region, while D 2 is injected in the open flux region, possibly partly explaining the difference in response. However, the frequency response measurements in [7] using D 2 injection in the private flux region show similar results as the results of D 2 injection presented here. This leads us to conjecture that differences in transport and thermal velocity due to mass difference may be a more reasonable candidate to explain this difference in response, but further investigation is necessary.
We note that, even after completely ceasing N 2 or D 2 injection, pre-seeding/fueling conditions were not obtained before the end of the discharge, likely caused by insufficient N 2 impurity removal and/or decay-time of divertor plasma density, respectively. However, [7] demonstrated the displacement of the CIII emission front from the target and back twice using D 2 in an unseeded TCV discharge with a similar controller, showing faster movement of an impurity emission front back to the target than observed in this work. Leaving one of the actuators (N 2 or D 2 ) uncontrolled may be the cause of this discrepancy, unintentionally increasing impurity enrichment in the case of D 2 actuation instead of merely having a trace impurity. A combination of real-time D 2 and N 2 actuation to control the divertor state more appropriately may be required, complemented by an additional measurement next to an impurity emission front position, for example tracking impurity retention. As both D 2 injection and N 2 injection affect the impurity emission front position in different ways, this will require a controller that specifically handles this interaction. Such a multi-input multi-output controller is presently under development at TCV.