`powdR`

is an R implementation of the full pattern summation approach to quantitative mineralogy from X-ray powder diffraction (XRPD) data. Whilst this is available in Excel spreadsheets such as FULLPAT (Chipera and Bish 2002) and ROCKJOCK (Eberl 2003), implementation in R allows for faster computation than is currently available, and provides a user-friendly `shiny`

application to help with the often iterative process of mineral quantification.

A powerful property of XRPD data is that it can provide quantitative estimates of phase concentrations (mineral and amorphous). Though several methods are available for quantitative mineralogy, full pattern summation is particularly suitable for mineral mixtures containing disordered and amorphous phases. A prime example of such mixtures is soil, where clay minerals represent disordered phases, and organic matter is present as a common X-ray amorphous constituent.

The full pattern summation implemented in `powdR`

is based on the principle that an observed pattern is comprised of the sum of signals from pure individual components. A key component of this approach is a library of measured or calculated patterns of pure phases. The pure patterns should be sufficient to cover all of the phases that may be encountered in your samples, and would ideally be measured on the same instrument as the sample (but this is not always possible). To quantify a given sample, phases from the library are selected, and their relative contributions optimised until an appropriate fit of the observed pattern is achieved (Chipera and Bish 2002). The fit is usually refined using least squares optimisation of an objective parameter, but non-negative least squares can also be used. The scaled intensities of the optimised patterns are then converted to weight % using reference intensity ratios, which are a measure of diffracting power relative to a standard mineral (usually corundum).

Version 0.2.0 of `powdR`

currently implements full pattern summation via a standardless approach. The prerequisite of this approach is that all mineral and amorphous phases can be identified within the sample, and that these must sum to 100 weight % (Chipera and Bish 2013; Omotoso et al. 2006).

`fps()`

Full pattern summation in `powdR`

is provided in the `fps()`

function. In the following example the full pattern summation process using `fps()`

will start with a reference library containing a single quartz phase, and subsequent phases will be added by examining the residuals of the fit. If running this vignette yourself, all plots can be made interactive by:

`plot(fit, interactive = TRUE)`

Making them interactive aids visual interpretation of the fitted patterns, which can otherwise be difficult when using static plots.

```
library(powdR)
data(minerals)
data(soils)
#Apply summation to the sandstone sample, with quartz as the only mineral
fit <- fps(lib = minerals,
smpl = soils$sandstone,
refs = "QUA.1",
std = "QUA.1",
align = 0.2)
#>
#> -Using maximum tth range
#> -Using default solver of BFGS
#> -Using default objective function of Rwp
#> -Aligning sample to the internal standard
#> -Interpolating library to same 2theta scale as aligned sample
#> -Optimising...
#> -Computing phase concentrations
#> -Full pattern summation complete
#plot the data to interpret the fit
plot(fit)
```

In this case, the fitted pattern consistently overestimates the quartz peak intensities compared to the measured pattern, but underestimates the background contribution. This can occur when X-ray amorphous phases are present within the sample. To Account for this, an organic matter phase from the reference library will be added, and the fit recomputed.

```
#Apply fps to the sandstone sample with quartz (crystalline) and organic matter (amorphous)
fit <- fps(lib = minerals,
smpl = soils$sandstone,
refs = c("QUA.1", "ORG"),
std = "QUA.1",
align = 0.2)
#>
#> -Using maximum tth range
#> -Using default solver of BFGS
#> -Using default objective function of Rwp
#> -Aligning sample to the internal standard
#> -Interpolating library to same 2theta scale as aligned sample
#> -Optimising...
#> -Computing phase concentrations
#> -Full pattern summation complete
#plot the data to interpret the fit
plot(fit)
```

Now the fit is much improved, highlighting how organic matter is an important component of this pattern. Based on the current residuals, there is a notable peak at 12.3 degrees 2theta, which is often associated with kaolinite. There are also numerous peaks either side of the main quartz peak at 26.6 degrees 2theta, which are often coincident with feldspar minerals. The next fit will therefore add kaolinite, plagioclase and potassium feldspar to the process.

```
#Apply fps to the sandstone sample, adding kaolinite, feldspar and oligoclase to the process
fit <- fps(lib = minerals,
smpl = soils$sandstone,
refs = c("QUA.1",
"QUA.2",
"KAO",
"FEL",
"OLI"),
std = "QUA.1",
align = 0.2)
#>
#> -Using maximum tth range
#> -Using default solver of BFGS
#> -Using default objective function of Rwp
#> -Aligning sample to the internal standard
#> -Interpolating library to same 2theta scale as aligned sample
#> -Optimising...
#> -Computing phase concentrations
#> -Full pattern summation complete
#plot the data to interpret the fit
plot(fit)
```

When including all these phases, pretty much all peaks are accounted for. Once the user is satisfied that an appropriate fit has been achieved, the mineral concentrations can be extracted and interpreted by looking at two elements of the output from `fps()`

:

`fit$phases`

`fit$phases_summary`

```
#returns individual contributions from each reference pattern
fit$phases
#> phase_id phase_name rir phase_percent
#> 1 FEL K-feldspar 0.75 11.2386
#> 2 KAO Kaolinite 0.91 11.0615
#> 3 OLI Plagioclase 1.06 7.2093
#> 4 QUA.1 Quartz 4.62 32.9080
#> 5 QUA.2 Quartz 4.34 37.5826
#returns summed contributions from each mineral
fit$phases_summary
#> phase_name phase_percent
#> 1 K-feldspar 11.2386
#> 2 Kaolinite 11.0615
#> 3 Plagioclase 7.2093
#> 4 Quartz 70.4906
```

All of the above and subsequent examples can be further tested using the two other XRPD measurements available in the `soils`

list (`soils$limestone`

and `soils$granite`

), each representing soils with different mineralogies.

`fps()`

with non-negative least squaresAs mentioned previously, an alternative to minimisation of an objective function (the default for `fps()`

) is non-negative least squares (NNLS). This is implemented in `powdR`

version 0.2.0, and provides very fast computation. Whilst NNLS can struggle with X-ray amorphous phases, its speed makes it particularly useful for fast quantitative estimates of a sample using a whole reference library at once. All phases with a coefficient equal to zero are excluded.

```
#Apply fps to the sandstone sample using NNLS. Note that when NNLS is selected as the solver argument, there is no need to define the refs because all phases in the library are used by default
fit <- fps(lib = minerals,
smpl = soils$sandstone,
solver = "NNLS",
std = "QUA.1",
align = 0.2)
#>
#> -Using maximum tth range
#> -Aligning sample to the internal standard
#> -Interpolating library to same 2theta scale as aligned sample
#> -Applying non-negative least squares
#> -Computing phase concentrations
#> -Full pattern summation complete
#plot the data to interpret the fit
plot(fit)
```

`afps()`

Since NNLS is fast and can be used to exclude phases from large libraries (based on coefficients equal to zero), it has been used in combination with a method for estimating limits of detection (S. Hillier 2003) to create an algorithm for automated full pattern summation, `afps()`

. The rationale behind this algorithm relates to the challenge of accurately quantifying high-throughput soil XRPD datasets, which show substantial variation in mineralogy. Large reference libraries are needed to handle such datasets, thus an algorithm was needed that both selected appropriate phases from a large library, and then excluded phases estimated to be below the detection limit.

```
#Apply afps to the sandstone sample using afps. Note that amorphous phases need to be specified because they are treated differently to crystalline phases in this algorithm
fit <- afps(lib = minerals,
smpl = soils$sandstone,
std = "QUA.1",
amorphous = "ORG",
align = 0.2)
#>
#> -Using maximum tth range
#> -Using default shift of 0.05
#> -Using default solver of 'BFGS'
#> -Using default objective function of 'Rwp'
#> -Using default lod of 0.3
#> -Using default amorphous_lod of 0
#> -Aligning sample to the internal standard
#> -Interpolating library to same 2theta scale as aligned sample
#> -Applying non-negative least squares
#> -Optimising...
#> -Shifting patterns
#> -Reoptimising after shifting data/adding amorphous phases
#> -Removing negative coefficients and reoptimising...
#> -Calculating detection limits
#> -Removing phases below detection limit
#> -Reoptimising
#> -Computing phase concentrations
#> -Automated full pattern summation complete
#plot the data to interpret the fit
plot(fit)
```

Chipera, Steve J., and David L. Bish. 2002. “FULLPAT: A full-pattern quantitative analysis program for X-ray powder diffraction using measured and calculated patterns.” *Journal of Applied Crystallography* 35 (6): 744–49. doi:10.1107/S0021889802017405.

———. 2013. “Fitting Full X-Ray Diffraction Patterns for Quantitative Analysis: A Method for Readily Quantifying Crystalline and Disordered Phases.” *Advances in Materials Physics and Chemistry* 03 (01): 47–53. doi:10.4236/ampc.2013.31A007.

Eberl, D. D. 2003. “User’s guide to ROCKJOCK - A program for determining quantitative mineralogy from powder X-ray diffraction data.” Boulder, CA: USGS.

Hillier, S. 2003. “Quantitative Analysis of Clay and Other Minerals in Sandstones by X-Ray Powder Diffraction (XRPD).” *Clay Mineral Cements in Sandstones* 34. International Association of Sedimentologists, Special Publication: 213–51.

Omotoso, Oladipo, Douglas K. McCarty, Stephen Hillier, and Reinhard Kleeberg. 2006. “Some successful approaches to quantitative mineral analysis as revealed by the 3rd reynolds cup contest.” *Clays and Clay Minerals* 54 (6): 748–60. doi:10.1346/CCMN.2006.0540609.