A scalable system for real-time analysis of electron temperature and density based on signals from the Thomson scattering diagnostic, initially developed for and installed on the NSTX-U experiment, was recently adapted for the Large Helical Device and operated for the first time during plasma discharges. During its initial operation run, it routinely recorded and processed signals for four spatial points at the laser repetition rate of 30 Hz, well within the system’s rated capability for 60 Hz. We present examples of data collected from this initial run and describe subsequent adaptations to the analysis code to improve the fidelity of the temperature calculations.

## I. INTRODUCTION

The ability to determine plasma temperature and density profiles in real time is valuable to plasma control systems seeking to optimize plasma properties or maintain device safety. The Thomson scattering diagnostic is an attractive candidate for real-time profile evaluation due to its ability to make non-invasive measurements of electron temperature *T*_{e} and electron density *n*_{e} throughout a typical fusion plasma.^{1} In addition, the localized nature of the measurement obviates the need for intermediate analysis, such as tomographic inversion or equilibrium modeling, to infer the profiles.

Systems for evaluating Thomson scattering data in real time have been developed for a number of devices over the years.^{2–6} In this work, we use a framework that was developed recently for NSTX-U^{7} but has not yet been tested during plasma discharges. Its main components are a set of fast digitizers and a multi-core server. The digitizers collect signals from the detection electronics. The server employs real-time software to calculate *T*_{e} and *n*_{e} from the signals between subsequent laser pulses, supporting repetition rates of up to 60 Hz.^{8} The server outputs *T*_{e}, *n*_{e}, and their uncertainties for each scattering volume as analog signals that may be fed into control systems.

The setup was subsequently replicated and installed on the Large Helical Device (LHD) to evaluate signals from the LHD Thomson scattering system. This system currently employs four Nd:YAG lasers that enable pulse repetition rates ranging from 10 to 100 Hz.^{9} Backscattered light is transmitted through optical fibers to a set of 144 polychromators.^{10,11} Within each polychromator, the scattered light passes through bandpass filters to six avalanche photodiodes (APDs).^{12} Signals from five of these APDs are used for *T*_{e} and *n*_{e} evaluation during plasma discharges, and the remaining signal is used for Rayleigh calibration.^{13} As the setup is similar to what is employed in NSTX-U,^{14,15} the real-time framework could be adapted for LHD with minor modifications.

During its initial operation on LHD, the real-time system collected and evaluated signals from four polychromators. For these experiments, laser pulses occurred at a 30 Hz repetition rate. In addition to performing *T*_{e} and *n*_{e} calculations for each pulse, the real-time system archived the polychromator signals at the end of each discharge, thereby enabling a postmortem assessment of the real-time calculations. In this paper, we describe this assessment, with a focus on the methods used for processing the raw polychromator signals. In Sec. II, we assess three signal-processing methods. Then, in Sec. III, we compare the values of *T*_{e} and *n*_{e} derived from each of these methods with the values calculated by the standard LHD methods performed after each discharge.

## II. SIGNAL PROCESSING METHODS

The real-time system computes *T*_{e} and *n*_{e} values in a least-squares spectral fitting technique that optimizes *T*_{e} and a scaling factor *c* to minimize *χ*^{2}, defined as follows:

Here, *N*_{c} is the number of polychromator channels (five for LHD), and *F*_{i}(*T*_{e}) is the expected relative signal strength from the *i*th channel for electron temperature *T*_{e}. The electron density *n*_{e} can then be determined from *c* along with calibration data. *s*_{i} is a measure of the signal strength from the *i*th polychromator channel. $\sigma si$ is the standard error in the *s*_{i} measurement, and $\sigma Fi$ is the (dimensionless) fractional error in *F*_{i}.

As described in Ref. 7, the values of *F*_{i} are pre-computed for a range of *T*_{e} by integrating the measured transmissivity spectrum of the *i*th polychromator channel with the Thomson scattering spectrum as predicted by the Selden model.^{16} Figure 1 shows transmissivity curves for one polychromator, along with scattering spectra for selected values of *T*_{e}. Evaluation of *F*_{i}(*T*_{e}) between laser pulses entails querying a table of the pre-computed values.

*s*_{i} in Eq. (1) must be proportional to the number of scattered photons received by the *i*th channel. In this section, we will describe three procedures for deriving *s*_{i} from polychromator signals and compare their accuracy and computational requirements. The procedures, which include peak detection, direct integration, and curve fitting, are displayed schematically in Fig. 2 with examples of two types of raw signals. The first type [Figs. 2(a)–2(c)] is a response to the firing of a single laser and will be categorized as a “single laser pulse,” whereas the second type [Figs. 2(d)–2(f)] arises from two lasers firing in rapid succession along the same beam path and will be categorized as a “double laser pulse.”

Each procedure was implemented as a C++11 function that could be called by the real-time software. The functions each took a digitized raw signal as input and returned values for *s*_{i} and $\sigma si$. The computational expense of each procedure was determined by recording the time required for its respective function to process archived experimental signals. These tests were performed on the same type of processing hardware employed in the experimental setup, i.e., a SuperMicro real-time server with 32 GB RAM and 20 cores clocked at 2.1 GHz.^{7,8}

We will use function evaluation times to determine how much each procedure will add to the system's end-to-end processing time. This duration, which includes digitization, signal evaluation, plasma parameter calculation, and output signal generation, was previously determined in offline tests to be less than 16.7 ms with the peak-detection procedure. While the calculations for each scattering volume are performed in parallel threads, the values of *s*_{i} and $\sigma si$ for each polychromator channel are determined in series. Hence, we will estimate the additional end-to-end-time required for a given procedure as the time by which the evaluation of the five signals from a polychromator with the procedure exceeds that of peak detection. To accommodate the 30 Hz laser repetition rate used during the LHD experiments, the total time should not exceed 33.3 ms.

### A. Peak detection

As originally designed, the software worked on the assumption that the photon flux to each polychromator channel would scale directly with the peak amplitude of its signal. Hence, it would suffice to define *s*_{i} simply as the peak amplitude in order to determine *T*_{e}. Provided that the signals from absolute calibrations are evaluated in the same way, a consistent scaling factor may be determined for extracting *n*_{e} from *c*.

The real-time code determines the amplitude of the scattered-light signal during each laser pulse by subtracting the peak value of the signal from the average of the background signal recorded prior to the laser pulse. The procedure is illustrated in Fig. 2(a) for the case of a single laser pulse and in Fig. 2(d) for a double pulse. The background level, illustrated by the horizontal dashed line, is obtained as the average of a group of sample points separated from the peak by at least 80 ns. To correct for stray laser light due to reflections within the plasma vessel, this amplitude would be adjusted by subtracting the average signal amplitude recorded during laser pulses prior to the beginning of the discharge from the corresponding scattering volume and polychromator channel.

This approach has the advantage of simplicity and speed. However, the amplification circuitry, which in this setup includes a high-pass filter, may exhibit a dispersive or nonlinear response that would give rise to distortions of the signal that can vary from one channel to another. Evidence of this response can be seen in the overshoot of the signal above the background level following the peak in the examples shown in Fig. 2.

The effect of such distortions in the fitting of the polychromator output spectra is visible in Fig. 3(a), which compares fitted data *s*_{i}/*c* with the predicted signals *F*_{i}(*T*_{e}) acquired from one scattering volume during an example plasma discharge. These fits contain substantial systematic errors. In particular, the fitted signal amplitudes are mostly lower than the model prediction for polychromator channels 3 and 5, whereas they are mostly higher than the model prediction for channel 4.

### B. Numerical integration

In the presence of distorted polychromator signals, the integrals of the signals may provide a more accurate representation of the detected scattered light than the amplitudes alone. To test this, we implemented a modified version of the signal processing function that performs trapezoidal integration on an interval of the signal of pre-determined length centered around the peak value. This procedure is illustrated schematically in Figs. 2(b) and 2(e). Analogously to the case of pulse amplitude determination, the integrals of signals recorded during the plasma discharge were corrected by subtracting the average integral value of a set of stray laser light signals obtained prior to the plasma discharge.

The switch to numerical integration has minimal impact on computation time, with each integration taking ≤1 *µ*s longer than a corresponding amplitude determination. Hence, to evaluate the five polychromator outputs necessary for a spectral fit, the added time would not exceed 5 *µ*s. This is negligible compared to the laser firing period of 16.7 ms for which the system was designed.

As shown in Fig. 3(b), the use of integrated signals improved the quality of the spectral fits. In particular, the systematic offsets between the data and the fitted spectra that arose from the use of pulse amplitudes [Fig. 3(a)] are no longer visible.

While the use of numerical integration removed the systematic offsets, the fits did exhibit increased scatter, particularly for the weaker signals from channel 5. This may arise from background noise, which can make spurious contributions to the integral in the case of a low signal-to-noise ratio (SNR) as seen in Figs. 2(b) and 2(e). As the background fluctuations in the raw signal exhibit time scales similar to the laser pulse width, their contributions to the integral will not necessarily cancel out.

### C. Curve fitting

One way to avoid contributions from background fluctuations is to integrate a waveform fitted to the signal rather than the raw signal itself.^{17,18} To this end, we implemented an additional function that fits Gaussian curves to the signal and outputs the integrals computed analytically from the fitting parameters. Specifically, signals were fit to functions of the form

with free parameters *p*_{1,…,7}. For single laser pulses, *p*_{5} = 0, and *p*_{6} and *p*_{7} were ignored. The true signal waveform is not exactly Gaussian due to the effects of the amplifier circuitry. However, a more precise model would be more computationally expensive, and we expect that the Gaussian fits will be accurate enough for the purposes of real-time analysis.

The parameters *p*_{i} are determined in a Levenberg–Marquardt least-squares fitting procedure. The integrals of the fitted curves follow as $2\pi p2p3$ for single pulses and $2\pi (p2p3+p5p6)$ for double pulses. The choice of whether to fit to a single or double pulse can be made based on laser energy signals: if two lasers fire, a double pulse is fitted; otherwise, a single pulse is fitted.

The curve-fitting approach requires substantially more complex computations than the previous approaches. Each least-squares iteration requires at least two evaluations of the exponential function for each time point within the integration window, as well as the inversion of an *n* × *n* matrix, where *n* is the number of free para-meters. We employed the Armadillo C++ linear algebra library^{19,20} to ensure efficient matrix inversion.

Evaluation times for curve fitting during a survey of five example shots are shown in Fig. 4. Each sample corresponds to the total time to evaluate fitting parameters for signals from each of five polychromator channels from a single scattering volume for a particular laser pulse during a given discharge. Values near zero correspond to samples in which all the signals from a polychromator were less than their respective SNR (occurring, e.g., at the beginnings and ends of discharges), in which case the procedure would not attempt any fits. Overall, the computation time to process five polychromator signals was less than 110 *µ*s in 95% of cases for single laser pulses. For double pulses, the total time was less than 550 *µ*s in 95% of cases, although a number of outliers required more than 800 *µ*s.

As stated previously, the real-time system with its original software had an end-to-end processing time of 16.7 ms or less. Hence, in a worst-case performance scenario in which the system requires a full 16.7 ms to complete its operations for a laser pulse, replacing the peak-detection procedure with curve-fitting could extend the required processing time by 0.5–1 ms. Under these conditions, the system could not accommodate laser pulses at the 60 Hz repetition rate for which it was originally designed. However, it could still accommodate rates of up to 50 Hz, which would have cycle deadlines of ≥20 ms. In particular, the incorporation of curve fitting would still work on LHD when a 30 Hz rate is employed.

## III. TEMPERATURE AND DENSITY CALCULATIONS

Figure 5 compares example *T*_{e} and *n*_{e} estimates using the three different procedures described in Sec. II. The reference values *T*_{e,ref} and *n*_{e,ref} were obtained from the standard LHD post-processing routines. The real-time functions calculated *n*_{e} using the values of *c* [Eq. (1)] scaled and offset by calibration factors determined through fitting to *n*_{e,ref} obtained from a separate set of discharges, independently for single and double laser pulses. Points with *n*_{e} < 0.5 × 10^{−19} m^{−3} and *T*_{e} > 4 keV generally had high uncertainty for this example and were omitted from the plot.

Overall, the values of *T*_{e} and *n*_{e} as computed by all three methods track well with the reference values, almost always agreeing to within 0.5 keV and 0.5 × 10^{19} m^{−3}. In general, the real-time software tends to slightly overestimate *T*_{e} relative to the reference values. Note that the overestimation of *T*_{e} is most severe for the peak-detection method [Fig. 5(a)], an effect that we believe is related to the systematic errors in the spectral fitting for this method. The values of *T*_{e} determined from numerical integration exhibit greater scatter than the other two methods due to the impact of noise on the integration: the standard deviation of *T*_{e} − *T*_{e,ref} was 190 eV for the numerical integration approach, whereas it was 160 eV for the pulse amplitude approach and 130 eV for curve fitting. The tendency of curve-fitting methods to produce *T*_{e} values with less scatter than direct integration has also been observed, for example, in the Thomson scattering system at KSTAR.^{21}

## IV. CONCLUSIONS

In summary, we have adapted and commissioned a real-time evaluation system for Thomson scattering on the LHD experiment, representing the first *in situ* operation of the system. We have implemented and compared three different approaches to evaluating the polychromator signals, each of which offers advantages and disadvantages. The curve-fitting approach generally provides the greatest accuracy and precision, but at the expense of extra computation time. Nevertheless, initial comparisons of *T*_{e} and *n*_{e} output by all three methods mostly exhibit good agreement with values calculated by the standard post-processing software.

## ACKNOWLEDGMENTS

The authors would like to thank B. P. LeBlanc for helpful discussions. This work was supported by the U.S. Department of Energy (Contract Nos. DE-AC02-09CH11466 and DE-SC0015480) and the NIFS LHD Project (Grant No. ULHH040). The work was conducted within the framework of the NIFS/PPPL International Collaboration. The U.S. Government retains a non-exclusive, paid-up, irrevocable, world-wide license to publish or reproduce the published form of this manuscript, or allow others to do so, for U.S. Government purposes.

## DATA AVAILABILITY

The data that support the findings of this study are available at http://arks.princeton.edu/ark:/88435/dsp014t64gr25v.