Plasma diagnostics

Quantitative LIBS assumes that the plasma is in local thermodynamic equilibrium (LTE), optically thin, and recorded within the linear range of the detector. This vignette checks these conditions on the forage spectra, measures the electron density \(N_e\) and the temperature \(T\) of the plasma, and ends with a calibration-free estimate of the composition of the samples. The intensities are not corrected for the spectral response of the instrument, which needs spectra of a calibration lamp (see response_calibration()), and the acquisition delay is not known, so the values are indicative.

library(specProc)
library(dplyr)
library(tidyr)
library(tibble)
library(ggplot2)

data("forageLIBS")
spectra_id <- forageLIBS |> select(1:2) |> names()
minerals <- forageLIBS |> select(3:14) |> names()
spectra <- forageLIBS |> select(-all_of(c(spectra_id, minerals)))
wl <- as.numeric(names(spectra))

corrected <- baseline_arpls(spectra, lambda = 1e5, max_iter = 20)$correction
mean_spectrum <- colMeans(corrected)

Detector saturation

A saturated line is clipped at the maximum count of the detector: its area is wrong and no longer grows with concentration. saturation_summary() lists the saturated channels. Each spectrum is the mean of 8 shots, so we count the channels within 1% of the 16-bit limit (65535), that is, saturated in nearly every shot:

saturated <- saturation_summary(spectra, limit = 65535, tolerance = 655)

# adjacent saturated channels belong to the same line
saturated$channels |>
  mutate(line = cumsum(c(1, diff(index) > 2))) |>
  group_by(line) |>
  summarise(wavelength = round(mean(wavelength), 2), spectra = max(n_spectra)) |>
  select(-line) |>
  arrange(desc(spectra))
#> # A tibble: 11 × 2
#>    wavelength spectra
#>         <dbl>   <dbl>
#>  1       397.     362
#>  2       393.     272
#>  3       399.     184
#>  4       280.      98
#>  5       388.      65
#>  6       280.      50
#>  7       423.      42
#>  8       589.      18
#>  9       770.       7
#> 10       590.       4
#> 11       391        1

The resonance lines of Ca II (393.37 and 396.85 nm), Mg II (279.55 and 280.27 nm), Ca I (422.67 nm), Na I (589.00 and 589.59 nm) and K I (769.90 nm), as well as the head of the CN molecular band at 388.3 nm, are saturated in part of the spectra: they are left out of every diagnostic below.

Electron density

The hydrogen line H\(\alpha\) (656.28 nm) is the standard density diagnostic: its Stark width is large and depends little on temperature (Gigosos et al., 2003). Its profile is Lorentzian in these spectra (see vignette("peak-fitting")), and electron_density() converts its full width at half maximum into \(N_e\):

halpha <- as_tibble(as.list(mean_spectrum[wl > 653.5 & wl < 659.5])) |>
  peak_fit(profile = "lorentzian")
width <- halpha$tidied[[1]] |> filter(term == "wL")
width
#> # A tibble: 1 × 5
#>   term  estimate std.error statistic  p.value
#>   <chr>    <dbl>     <dbl>     <dbl>    <dbl>
#> 1 wL        1.69    0.0403      42.0 7.68e-50
ne <- electron_density(width$estimate, method = "halpha")
ne
#>           wL 
#> 1.887979e+17

The fit also gives the standard error of the width. electron_density_uncertainty() propagates it to the density, together with the uncertainty of the width law of H\(\alpha\) itself, taken here as 10% for illustration:

ne_u <- electron_density_uncertainty(width$estimate, width$std.error, method = "halpha",
                                     reference_rsd = 0.1)
ne_u
#> # A tibble: 1 × 7
#>   width width_se electron_density      se   rsd   lower   upper
#>   <dbl>    <dbl>            <dbl>   <dbl> <dbl>   <dbl>   <dbl>
#> 1  1.69   0.0403          1.89e17 2.87e16 0.152 1.40e17 2.54e17

The width of H\(\alpha\) grows as \(N_e^{0.68}\), so a relative error of the width is amplified about 1.5 times in the density. The relative standard uncertainty of the density, 15%, comes mostly from the width law: the fit error alone is 2.4% of the width.

For other lines, stark_width() gives the width expected at a density from the Stark parameters of the STARK-B database (starkb_lines()), and self_absorption() compares it with the measured width.

Temperature

Atomic data

A Boltzmann plot needs, for each line, the transition probability \(A_{ki}\), the statistical weight \(g_k\) and the energy \(E_k\) of the upper level. nist_lines() retrieves them from the NIST Atomic Spectra Database, and nist_ionization_energy() the ionization energies:

ca_lines <- nist_lines(c("Ca I", "Ca II"), wavelength = c(310, 660))
nist_ionization_energy("Ca I")

So that this vignette runs offline, the calcium lines used below are included (NIST ASD, Kramida et al.). The accuracy grades of the transition probabilities (C: ≤ 25%, D: ≤ 50%) limit the precision of the temperature:

atomic <- tribble(
  ~species, ~stage, ~wavelength, ~Aki,    ~accuracy, ~Ek,       ~gk,
  "Ca I",   1,      428.301,     4.34e7,  "C+",      4.779784,  5,
  "Ca I",   1,      430.253,     1.36e8,  "C+",      4.779784,  5,
  "Ca I",   1,      431.865,     7.40e7,  "C+",      4.7690284, 3,
  "Ca I",   1,      443.496,     6.70e7,  "C",       4.680635,  5,
  "Ca I",   1,      445.478,     8.70e7,  "C",       4.681327,  7,
  "Ca I",   1,      558.876,     4.90e7,  "D",       4.7435268, 7,
  "Ca I",   1,      610.272,     9.60e6,  "C",       3.910399,  3,
  "Ca I",   1,      612.222,     2.87e7,  "C",       3.910399,  3,
  "Ca I",   1,      616.217,     4.77e7,  "C",       3.910399,  3,
  "Ca I",   1,      643.907,     5.30e7,  "D",       4.450647,  9,
  "Ca I",   1,      646.257,     4.70e7,  "D",       4.4409544, 7,
  "Ca I",   1,      649.378,     4.40e7,  "D",       4.4300117, 5,
  "Ca II",  2,      315.887,     3.10e8,  "C",       7.047169,  4,
  "Ca II",  2,      317.933,     3.60e8,  "C",       7.049551,  6,
  "Ca II",  2,      370.603,     8.80e7,  "C",       6.467875,  2,
  "Ca II",  2,      373.690,     1.70e8,  "C",       6.467875,  2
)
ionization_energy <- 6.1131549   # Ca I, eV

Line intensities

line_intensities() finds each line within 0.2 nm of its tabulated wavelength (search), which absorbs the offset of the wavelength axis, and integrates it over ±0.15 nm (half_width). It keeps the columns of the table of lines, so the result goes directly into a Boltzmann plot:

lines <- line_intensities(mean_spectrum, atomic)
lines |> select(species, wavelength, peak_wavelength, intensity, snr)
#> # A tibble: 16 × 5
#>    species wavelength peak_wavelength intensity   snr
#>    <chr>        <dbl>           <dbl>     <dbl> <dbl>
#>  1 Ca I          428.            428.      556. 194. 
#>  2 Ca I          430.            430.     1121. 391. 
#>  3 Ca I          432.            432.      692. 207. 
#>  4 Ca I          443.            443.      716. 223. 
#>  5 Ca I          445.            445.     1598. 467. 
#>  6 Ca I          559.            559.     1182. 307. 
#>  7 Ca I          610.            610.      417. 114. 
#>  8 Ca I          612.            612.     1510. 393. 
#>  9 Ca I          616.            616.     2381. 645. 
#> 10 Ca I          644.            644.     1749. 490. 
#> 11 Ca I          646.            646.     1155. 312. 
#> 12 Ca I          649.            649.      413. 125. 
#> 13 Ca II         316.            316.      764. 207. 
#> 14 Ca II         318.            318.     1629. 439. 
#> 15 Ca II         371.            371.      228.  61.4
#> 16 Ca II         374.            374.      516. 155.

Boltzmann and Saha-Boltzmann plots

neutral <- boltzmann(filter(lines, stage == 1))
neutral
#> Boltzmann plot (12 lines)
#> 
#> Temperature:  4512 +/- 501 K
#> R-squared:    0.8902

The Ca I lines come from upper levels between 3.9 and 4.8 eV. Over such a narrow range, the slope is sensitive to the errors of a few intensities or transition probabilities. The Saha equation places the lines of the ion on the same plot, using the electron density, and extends the range of energies to about 13 eV:

saha <- saha_boltzmann(lines, ionization_energy = ionization_energy, electron_density = ne)
saha
#> Saha-Boltzmann plot (16 lines)
#> 
#> Temperature:  8263 +/- 188 K
#> R-squared:    0.9928
#> Ne:           1.89e+17 cm-3
plot_boltzmann(saha)

The Saha-Boltzmann temperature, 8300 K, is far better determined than the Boltzmann temperature of the neutral lines alone (4500 ± 500 K). Its standard error, 190 K, reflects the scatter of the points.

tidy() lists the estimates of a fit, here with their 95% confidence intervals (that of the temperature is the interval of the slope, transformed), and glance() summarizes the fit in one row, to compare plots or bind the results of several spectra:

tidy(saha, conf.int = TRUE)
#> # A tibble: 2 × 5
#>   term        estimate std.error conf.low conf.high
#>   <chr>          <dbl>     <dbl>    <dbl>     <dbl>
#> 1 temperature 8263.      188.    7877.     8688.   
#> 2 intercept      0.165     0.241   -0.350     0.681
glance(saha)
#> # A tibble: 1 × 9
#>   r.squared sigma  nobs df.residual energy.range electron.density iterations
#>       <dbl> <dbl> <int>       <int>        <dbl>            <dbl>      <int>
#> 1     0.993 0.469    16          14         9.25          1.89e17         10
#> # ℹ 2 more variables: method <chr>, units <chr>

The lines of a Boltzmann plot can also be chosen interactively: line_finder() measures the lines picked on a spectrum, fits their Boltzmann plot as they are added, and leaves out the points clicked on the plot.

Uncertainty of the temperature

The points scatter because of the errors of the intensities and of the transition probabilities. The accuracy grades of the NIST database (column accuracy) bound the standard uncertainties of the transition probabilities: 18% for grade C+, 25% for C and 50% for D (see aki_uncertainty()). line_intensities() gives the standard error of each intensity due to the noise of the spectrum (intensity_se). plasma_uncertainty() propagates these uncertainties, and that of the electron density, to the temperature: it repeats the fit with inputs perturbed within their uncertainties (Monte Carlo simulation):

set.seed(1)
saha_u <- plasma_uncertainty(saha, electron_density_se = ne_u$se)
saha_u
#> Monte Carlo uncertainty of a Saha-Boltzmann plot
#> 1000 draws, 95% intervals
#> 
#> Intensities:              0.12% to 1.3%
#> Transition probabilities: 18% to 50%
#> Electron density:         15%
#> Reduced chi-squared:      3.81
#> 
#>  quantity    estimate se  lower upper
#>  temperature 8263     137 8006  8561 
#> 
#> Standard error of the fit (scatter of the points): 188 K

The intensities of the mean spectrum are measured to about 1%, so the transition probabilities and the electron density, which contribute about equally, make up the interval, 8010 to 8560 K. The reduced chi-squared compares the scatter of the points with their stated uncertainties. At 3.8, the scatter of the points is about 2.0 times what these uncertainties explain: other errors are at work, such as the spectral response of the instrument, which is not corrected here, or self-absorption. The interval does not include them, so it is a lower bound of the uncertainty.

Is the plasma in LTE?

The McWhirter criterion gives the minimum electron density for collisions to dominate the population of the levels. The largest energy gap here is the first excited level of Ca II, 3.15 eV above the ground state:

lte <- mcwhirter_criterion(temperature = saha$temperature, delta_e = 3.15, electron_density = ne)
lte
#> # A tibble: 1 × 5
#>   temperature delta_e minimum_density electron_density satisfied
#>         <dbl>   <dbl>           <dbl>            <dbl> <lgl>    
#> 1       8263.    3.15         4.55e15          1.89e17 TRUE

The measured density is 42 times the minimum. The criterion is necessary but not sufficient: in a transient, inhomogeneous plasma, LTE also requires the equilibration to be faster than the changes of the plasma (Cristoforetti et al., 2010). lte_criteria() computes the time the plasma takes to relax to equilibrium, through the resonance transition of Ca II (393.37 nm, oscillator strength 0.68), and the distance an atom diffuses meanwhile, here compared with 1 mm, the order of the size of the plasma:

criteria <- lte_criteria(temperature = saha$temperature, electron_density = ne,
                         delta_e = 3.15, oscillator_strength = 0.68, mass = "Ca",
                         length_scale = 1)
criteria |>
  select(mcwhirter, relaxation_time, diffusion_length, length_ratio, spatial)
#> # A tibble: 1 × 5
#>   mcwhirter relaxation_time diffusion_length length_ratio spatial
#>   <lgl>               <dbl>            <dbl>        <dbl> <lgl>  
#> 1 TRUE             5.44e-10         0.000399     0.000399 TRUE

The relaxation time, 0.54 ns, is far shorter than the microseconds over which a LIBS plasma cools, and the diffusion length, 0.4 µm, far shorter than the plasma: the spatial criterion is satisfied. The temporal criterion needs the temperature and density at several delays (time), which these spectra, recorded at one delay, do not have.

Self-absorption

Resonance lines end on the ground state, which is heavily populated, so the plasma reabsorbs part of their light. correct_self_absorption() compares each line with a reference line of the same species that is little absorbed, by default the one of smallest optical depth (Sun and Yu, 2009). The potassium lines:

k_lines <- tribble(
  ~species, ~wavelength, ~Aki,      ~Ei,      ~Ek,      ~gk,
  "K I",    404.414,     1.150e+06, 0,        3.064907, 4,
  "K I",    404.721,     1.070e+06, 0,        3.062581, 2,
  "K I",    691.108,     2.500e+06, 1.609958, 3.403454, 2,
  "K I",    693.877,     4.956e+06, 1.617113, 3.403454, 2,
  "K I",    766.490,     3.779e+07, 0,        1.617113, 4,
  "K I",    769.896,     3.734e+07, 0,        1.609958, 2
)
line_intensities(mean_spectrum, k_lines) |>
  correct_self_absorption(temperature = saha$temperature) |>
  select(wavelength, measured_intensity, SA, reference)
#> Warning: 1 line(s) have SA > 1: check the reference lines, the atomic data or
#> the intensities.
#> # A tibble: 6 × 4
#>   wavelength measured_intensity    SA reference
#>        <dbl>              <dbl> <dbl> <lgl>    
#> 1       404.               191. 0.660 FALSE    
#> 2       405.               135. 1     TRUE     
#> 3       691.               123. 1.07  FALSE    
#> 4       694.               138. 0.612 FALSE    
#> 5       766.              5172. 0.135 FALSE    
#> 6       770.              6899. 0.362 FALSE

The self-absorption coefficient SA is the fraction of the intensity that escapes the plasma. The resonance doublet at 766.49 and 769.90 nm keeps only a small fraction: the 766.49 nm line has twice the \(g_k A_{ki}\) of the 769.90 nm line, so it should be twice as intense, yet it is weaker. These lines curve the calibration of vignette("calibration") and are unsuitable for the calibration-free analysis below. The coefficients of the weaker lines, between about 0.6 and 1.07 (hence the warning), show the precision of the method: it inherits the noise of the reference line and the errors of the transition probabilities.

curve_of_growth() needs no reference line. It fits the curve of growth of a homogeneous plasma in LTE to the lines of one or several species at once, the model of the C-sigma graphs of Aragón and Aguilera (2014): the intensity of a line grows as its optical depth while the plasma is thin, then more slowly as its center saturates. With one column density per species, the fit gives the optical depth of every line, its self-absorption coefficient and its optically thin intensity, ready for boltzmann() or cf_libs(). It needs the Stark widths of the lines, which set how fast they saturate: stark_width() gives them from the STARK-B database (starkb_lines()) at the electron density measured above, and plot_curve_of_growth() draws the fit.

Calibration-free composition

Calibration-free LIBS (CF-LIBS; Ciucci et al., 1999) derives the composition of a sample from its line intensities alone. In LTE, the Boltzmann plots of all species share the same slope, \(-1/k_B T\), and the intercept of each plot gives the density of its species. cf_libs() fits the plots together, adds the ionization stages that are not observed with the Saha equation, and normalizes the densities of the elements to fractions that sum to one.

The lines must be unsaturated and optically thin, which rules out the resonance lines. cf_libs() also needs the partition functions of the species, which it computes from the energy levels of nist_levels(), and the ionization energies:

species <- c("Ca I", "Ca II", "Mg I", "Mg II", "K I", "K II", "Na I", "Na II")
levels <- nist_levels(species)
ionization <- nist_ionization_energy(c("Ca I", "Mg I", "K I", "Na I"))

To run offline, the atomic data and the partition functions (from partition_function(), tabulated from 6000 to 12000 K) are included here:

cf_atomic <- tribble(
  ~species, ~wavelength, ~Aki,      ~accuracy, ~Ek,      ~gk,
  "Ca I",   428.301,     4.340e+07, "C+",      4.779784, 5,
  "Ca I",   430.253,     1.360e+08, "C+",      4.779784, 5,
  "Ca I",   431.865,     7.400e+07, "C+",      4.769028, 3,
  "Ca I",   443.496,     6.700e+07, "C",       4.680635, 5,
  "Ca I",   445.478,     8.700e+07, "C",       4.681327, 7,
  "Ca I",   616.217,     4.770e+07, "C",       3.910399, 3,
  "Ca II",  315.887,     3.100e+08, "C",       7.047169, 4,
  "Ca II",  317.933,     3.600e+08, "C",       7.049551, 6,
  "Ca II",  370.603,     8.800e+07, "C",       6.467875, 2,
  "Ca II",  373.690,     1.700e+08, "C",       6.467875, 2,
  "Mg I",   383.829,     1.610e+08, "B+",      5.945916, 7,
  "Mg I",   516.732,     1.130e+07, "B+",      5.107827, 3,
  "Mg I",   517.268,     3.370e+07, "B+",      5.107827, 3,
  "Mg I",   518.360,     5.610e+07, "A",       5.107827, 3,
  "Mg II",  279.078,     4.010e+08, "A",       8.863762, 4,
  "Mg II",  279.800,     4.790e+08, "A",       8.863654, 6,
  "Mg II",  292.863,     1.150e+08, "A",       8.654711, 2,
  "Mg II",  293.651,     2.300e+08, "A",       8.654711, 2,
  "K I",    404.414,     1.150e+06, "A",       3.064907, 4,
  "K I",    404.721,     1.070e+06, "B+",      3.062581, 2,
  "K I",    691.108,     2.500e+06, "AA",      3.403454, 2,
  "K I",    693.877,     4.956e+06, "AA",      3.403454, 2,
  "Na I",   818.326,     4.290e+07, "A+",      3.616977, 4,
  "Na I",   819.482,     5.140e+07, "A+",      3.616971, 6
)
cf_ionization <- c(Ca = 6.113155, Mg = 7.646236, K = 4.340664, Na = 5.139077)

partition_table <- tribble(
  ~species, ~`6000`, ~`7000`, ~`8000`, ~`9000`, ~`10000`, ~`11000`, ~`12000`,
  "Ca I",   1.407,   1.798,   2.401,   3.281,   4.499,    6.184,    8.356,
  "Ca II",  2.389,   2.633,   2.917,   3.229,   3.560,    3.905,    4.262,
  "Mg I",   1.049,   1.109,   1.207,   1.362,   1.597,    1.959,    2.463,
  "Mg II",  2.001,   2.004,   2.010,   2.020,   2.036,    2.058,    2.087,
  "K I",    2.488,   3.000,   3.858,   5.078,   6.743,    8.938,    11.503,
  "K II",   1,       1,       1,       1,       1,        1,        1,
  "Na I",   2.166,   2.401,   2.868,   3.635,   4.779,    6.548,    8.724,
  "Na II",  1,       1,       1,       1,       1,        1,        1
)
# log-linear interpolation of the table, in the form cf_libs() accepts
partition <- function(species, temperature) {
  grid <- as.numeric(names(partition_table)[-1])
  vapply(species, function(s) {
    u <- unlist(partition_table[partition_table$species == s, -1])
    exp(stats::approx(grid, log(u), xout = temperature)$y)
  }, numeric(1))
}

With partition = NULL (the default), cf_libs() downloads the levels and computes the partition functions itself. On the mean spectrum:

cf_mean <- line_intensities(mean_spectrum, cf_atomic) |>
  cf_libs(electron_density = ne, partition = partition, ionization_energy = cf_ionization)
cf_mean
#> Calibration-free LIBS (24 lines, 6 species; Saha-Boltzmann plots)
#> 
#> Temperature:  9016 +/- 218 K
#> Ne:           1.89e+17 cm-3
#> Normalization: closure
#> 
#>  element atomic_fraction mass_fraction stages      
#>  Ca      0.1012          0.1095        I, II       
#>  Mg      0.0871          0.0571        I, II       
#>  K       0.7587          0.8005        I, II (Saha)
#>  Na      0.0531          0.0329        I, II (Saha)
plot_boltzmann(cf_mean)

The four Saha-Boltzmann plots are parallel within the scatter of their points. The forage is mostly C, H, O and N, whose lines are not used here, so the fractions describe the relative composition of Ca, Mg, K and Na, which we compare with the laboratory values on the same basis:

laboratory <- forageLIBS |>
  summarise(across(c(Ca, Mg, K, Na), \(v) mean(v, na.rm = TRUE))) |>
  unlist()
cf_mean$composition |>
  select(element, cf_libs = mass_fraction) |>
  mutate(laboratory = laboratory[element] / sum(laboratory),
         ratio = cf_libs / laboratory)
#> # A tibble: 4 × 4
#>   element cf_libs laboratory ratio
#>   <chr>     <dbl>      <dbl> <dbl>
#> 1 Ca       0.109      0.222  0.494
#> 2 Mg       0.0571     0.0702 0.813
#> 3 K        0.801      0.698  1.15 
#> 4 Na       0.0329     0.0101 3.25

Without any calibration, the composition is of the right order: the ratios to the laboratory values are 0.5 for Ca, 0.8 for Mg, 1.1 for K and 3.3 for Na. The main sources of bias are the spectral response of the instrument, which weights the lines of each element differently, the uncertain transition probabilities of the Ca lines, and the weak Na lines. With one standard of known composition, the remaining bias can be measured and removed for each element.

plasma_uncertainty() also repeats the calibration-free analysis with perturbed inputs:

set.seed(1)
cf_u <- plasma_uncertainty(cf_mean, n = 500, electron_density_se = ne_u$se)
cf_u
#> Monte Carlo uncertainty of a CF-LIBS fit (Saha-Boltzmann plots)
#> 500 draws, 95% intervals
#> 
#> Intensities:              0.12% to 6.6%
#> Transition probabilities: 1% to 25%
#> Electron density:         15%
#> Reduced chi-squared:      296
#> 
#>  quantity        element estimate se     lower  upper 
#>  temperature             9016     104    8835   9233  
#>  atomic_fraction Ca      0.1012   0.0070 0.0882 0.1148
#>  atomic_fraction Mg      0.0871   0.0049 0.0780 0.0973
#>  atomic_fraction K       0.7587   0.0091 0.7396 0.7763
#>  atomic_fraction Na      0.0531   0.0014 0.0503 0.0557
#>  mass_fraction   Ca      0.1095   0.0076 0.0954 0.1243
#>  mass_fraction   Mg      0.0571   0.0034 0.0510 0.0641
#>  mass_fraction   K       0.8005   0.0088 0.7830 0.8171
#>  mass_fraction   Na      0.0329   0.0009 0.0312 0.0346
#> 
#> Standard error of the fit (scatter of the points): 218 K

The intervals are narrow, a few percent of each fraction. The reduced chi-squared, 296, shows why they are misleading: the K, Mg and Na lines have accurate transition probabilities (grades AA to B+) and intensities measured to a few percent, so their scatter about the parallel plots comes from other errors, such as the spectral response, self-absorption or departures from LTE. These systematic errors, not the random ones, limit the accuracy of the composition, as the comparison with the laboratory values shows.

Summary

References