employing least squares and piecewise cubic hermite ...courses.washington.edu › mengr535 ›...
TRANSCRIPT
1
Employing Least Squares and Piecewise Cubic
Hermite Interpolating Polynomial Fitting to
Analyze In-Situ Raman Spectroscopy Data
ME 535 - Final Project Paper
Elizabeth Rasmussen, [email protected]
DEPT. OF MECHANICAL ENGINEERING UNIVERSITY OF WASHINGTON - SEATTLE
JUNE 3, 2018
2
Table of Contents Table of Contents .......................................................................................................................................... 2
Abstract ......................................................................................................................................................... 3
Introduction ................................................................................................................................................... 3
Literature Review .......................................................................................................................................... 4
Governing Equations .................................................................................................................................... 6
Hermite Interpolation ................................................................................................................................ 6
Linear Least Squares Method ................................................................................................................... 7
Methods and Materials - MATLAB Code .................................................................................................... 7
Data Parsing .............................................................................................................................................. 7
Baseline Creation and Background Spectra Subtraction .......................................................................... 7
Concentration Finder ................................................................................................................................ 8
Methods and Materials - Experimental Set Up to Validate Code ................................................................. 8
Results ......................................................................................................................................................... 10
Future Work ................................................................................................................................................ 12
Conclusions ................................................................................................................................................. 12
Acknowledgements ..................................................................................................................................... 13
References ................................................................................................................................................... 14
3
Abstract The ability to instantaneously collect and analyze a substance’s composition is of great value
in defensive military applications such as verifying the neutralization of chemical warfare agents.
A method currently under development to complete this task includes a continuous supercritical
water hydrolysis (CScWH) reactor with an in-situ Raman spectrometer and optical cell. A
bottleneck in the process of obtaining conclusive results on the products exiting the system is in
the tedious background subtraction processing of the raw data output by the Raman spectrometer.
To correct this problem a Matlab program was created that processes the output file and after
correcting for laser power and integration time it subtracts fluorescent background signal using
least squares curve fitting. The remaining signal is then obtained and plotted to clearly identify
signal intensity of various compounds, and thus the concentration of products exiting the system.
The presented method was verified using multiple sets of formic acid decomposition data.
Keywords: supercritical reactor, Raman spectroscopy, in-situ, data processing, numerical
methods
Introduction Raman spectroscopy uses a sample’s unique, sometimes referred to as their ‘fingerprint’,
inelastic scattering upon light radiation to detect rotational, vibrational, and low- frequency modes
in a system [1]. The non-invasive technique can be used to study solid, liquid, and gaseous samples
and its high chemical sensitivity allows for in-situ analysis [2].
A research project currently funded by the US Defense Threat Reduction Agency (DTRA) in
the mechanical engineering department is focusing developing a new means of neutralizing
chemical warfare agents (CWA) using a single-step, continuous supercritical water hydrolysis
(CScWH) reactor platform. In-situ Raman spectroscopy significantly reduces experimental
uncertainty and experimentation time, while allowing for the accurate identification of
decomposition products. For example, in the decomposition of formic acid the products are namely
H2, CO2, and trace amounts of CO. Collected spectra can be used for the quantification of
decomposition kinetics if the spectra are processed correctly with fluorescent background signal
properly subtracted. Previous to this project all fluorescent background signal was subtracted
manually using Origin 2018 software. This process was recorded to take 15 - 20 minutes to analyze
a single sample’s data. With experiments running daily this lead to a backlog of analyzed data and
frustration on the part of the researchers. Additionally, in a study consisting of 16 volunteers
Jirasek et al. found that manual baseline determination can not only be influenced by the user’s
experience with Raman spectroscopy data, but also the accuracy of baseline determination was
negatively effected with a highly sloping baselines, such as one would see in the project being
studied here[3]. Figure 2 shows the Raman spectra of the decomposition products formed from
gasifying formic acid at 374°C. The corresponding wavenumbers of significant peaks are noted
on the plot. This temperature is chosen because it clearly contains all Raman peaks observed in
the experiments.
4
Given both the time demanding process, and the possible inaccuracies caused by manual
baseline subtraction of the florescent background signal a numerical model using Piecewise Cubic
Hermite Interpolating Polynomial and then defining the concentrations of the resulting reagents
using least squares fitting of the non - linear signals was created.
Literature Review Previous studies relating to automated methods for subtracting the fluorescence focus on the
application to analyzing biological samples. For example, Lieber et al. reported a process to
automatically subtract the background fluorescence from biological spectra in 2003 [4]. The study
focused on updating past methods of simply fitting a polynomial curve to the raw spectrum because
the fit is based on minimizing the differences between the fit and measured spectrum (including
the fluorescence). This leads to error in the resulting baseline to be subtracted which can be seen
below in Figure 1.
Figure 2. Raman spectra of decomposition products of formic acid at 374°C, with significant Raman spikes
identified by correlated chemical species.
5
To address these limitations a least-squares-based polynomial curve fitting function was used
but it identified all data point sin the curve that had an intensity value higher then the pixel value
in the input spectrum to be reassigned to the original intensity. The process of curve fitting and
subsequent reassigning iterated between 25 and 200 times to gradually result in a desired output
of eliminating the higher frequency Raman peaks from the underlying baseline fluorescence.
A more recent investigation by Beier and Berger reported in 2009 outlined a method for
baseline subtraction when the Raman spectra contains known contaminants [5]. This method was
useful to investigate because it was found empirically that when concentration levels of the reagent
being input into the reactor the baseline for the spectra changed in a way that usually shifted
vertically. Knowing though the location of peaks for a substance like Carbon Dioxide or Hydrogen
can help with the alignment of the baseline subtraction between sets of data.
Table 2 lists compounds present in the Raman spectra and associated wavenumbers of
significant peaks. These peaks may be slightly shifted from the reference data provided by several
Raman libraries due to differences in operating temperature or pressure. Figure 2 shows the Raman
spectra of the decomposition products formed from gasifying formic acid at 374°C. The
corresponding wavenumbers of significant peaks are noted on the plot. This temperature is chosen
because it clearly contains all Raman peaks observed in the experiments.
6
Table 2. Compounds present in Raman spectra of the product stream, with locations of
Raman peaks noted
Compound Wavenumbers of Significant Raman Peaks (cm-1)
Sapphire (Al2O3) 379, 418, 751
Water (H2O) 1640, 3185
Formic Acid (HCOOH) 712, 1219, 1400, 1714, 2943
Hydrogen (H2) 355, 587, 814, 1034
Carbon Dioxide (CO2) 1272, 1383
Carbon Monoxide (CO) 2138
Both of the reviewed methods were referenced and considered when creating the final
resulting code for analyzing formic acid in-situ Raman spectra data.
Governing Equations
Hermite Interpolation
For the background Raman spectra data subtraction Hermite interpolation was used.
Background of Hermite interpolation is as follows and was defined from De Boor et al. [6].
If the first derivatives of the function are known as well as the function value at each
of the node points , i.e., we have available a set
of values , then the
function can be interpolated by a polynomial of degree :
In principle, the coefficients could be obtained
by solving a linear equation system of the same number of equations:
As the solution of this equation system, the coefficients are unique.
7
Linear Least Squares Method
To determine the concentration data of the formic acid given different resonance times while
staying at the same temperature of 400 degrees Celsius a numerical analysis of the Raman
spectroscopy data was done using linear least squares method. The principles of least squares curve
fitting are described as follows [7]:
Methods and Materials - MATLAB Code
Data Parsing
The first step to analyze the raw Raman spectra data was to have Matlab parse information
from the Raman probe’s output file which was in .txt format. Using the function, ‘textscan’ the
integration time, number of averages, laser power, wavelength and raw counts data was extracted
and defined suitable variable names. A note output to the user that the “Text files processed”. Then
the signal was scaled to equivalent laser power and integration time, choosing the strongest signal
as the reference. The signal was determined by the product of the laser power and integration time.
Baseline Creation and Background Spectra Subtraction
The baseline was created by using predefined anchor points that indicated where the
beginning of known substances for Formic Acid would be as shown earlier in Table 1 in the
Introduction section of this report. A for loop was used to scan through the data and using the built
in function ‘interp1’ and ‘pchip’ which is used for Piecewise Cubic Hermite Interpolating
Polynomial. More on the background of this function is:
pchip interpolates using a piecewise cubic polynomial P(x) with these properties:
8
• On each subinterval xk≤x≤xk+1, the polynomial P(x) is a cubic Hermite interpolating
polynomial for the given data points with specified derivatives (slopes) at the
interpolation points.
• P(x) interpolates y, that is, P(xj)=yj, and the first derivative dP/dx is continuous. The
second derivative dP2 / dx2 is probably not continuous so jumps at the xj are possible.
• The cubic interpolant P(x) is shape preserving. The slopes at the xj are chosen in such
a way that P(x) preserves the shape of the data and respects monotonicity. Therefore,
on intervals where the data is monotonic, so is P(x), and at points where the data has a
local extremum, so does P(x).
Then once the baseline is created it is subtracted from the raw Raman data to filter out the
background spectra and a new variable is defined for the processed data and the output is plotted
on a graph along with the baseline and original raw data.
Concentration Finder
To find the concentration of formic acid in the products after going through the ScWG reactor
a second code was written that interacted with the automatic baseline Matlab script. The
concentration data is determined using a line of best fit for concentration versus signal intensity.
The signal used is the ratio of characteristic peak or set of peaks in the reagent to the magnitude of
the low-wavenumber sapphire spike that occurs at 418 cm-1.
Methods and Materials - Experimental Set Up to Validate Code
The author worked as a part of a research team to design and fabricate a continuous
supercritical water reactor with high-resolution in-situ Raman spectroscopy enabling real-time
process monitoring and reducing measurement uncertainty. This reactor was used to study
gasification of formic acid at temperatures between 300 and 400°C, at a constant pressure of 25
MPa, at residence times between 8.7 and 39 s, and at a constant feedstock concentration of 5.06
wt%. A Raman immersion ball probe from MarqMetrix was installed immediately after the heat
exchanger and prior to the back pressure regulator, to allow for in-situ monitoring of product
species concentrations. A system schematic is shown in Figure 1.
9
The reactor is housed in an extruded aluminum enclosure; Plexiglas shields are used as a
primary safety enclosure and to allow for ventilation of the reactor space in case of a leak.
The fiber-optic Raman laser has an excitation wavelength of 785 nm and was operated at 300
mW. A sapphire ball lens is used to focus the excitation light 0.6 mm in front of the lens. The ball
lens protrudes 0.5 mm into the flow. Spectra were collected in the backscatter configuration where
the exciting laser and the collected spectra enter and exit the measurement volume through the
same optical window, and along the same axis. To achieve consistent signals and to reduce
Figure 1. Schematic of the UW reactor system. The system can operate at pressures up to 35 MPa and
temperatures up to 650°C, with residence times of 0.7 – 70 s. The maximum throughput of the system is 41 g of
H2O per minute.
10
measurement uncertainty, 20 to 40 averages of the signal were collected, with a signal integration
time of 0.5 to 1 s. This reduced signal noise and ensured that minor signal constituents were
collected accurately. Variations in integration time leads to a linear difference in signal magnitude;
the data were corrected in post-processing to account for different integration times for each
experiment.
With the data collected it was now ready to be processed using the Matlab script.
Results First a single data Raman signal consisting of five percent Formic Acid reagent at 400 degrees
Celsius with a resonance time of five seconds was used to test the algorithm. The resulting plot
showing the original spectra, the determined baseline, and then the final resulting spectra can be
seen below. As can be seen the method used resulted in a clean result of the baseline subtraction
from the background spectra. With other research reporting on the number of iterations or the time
it took to obtain results it is hard to compare methods without creating a unique code for situations
studied by researchers like Wang and Dai [8].
Once it was seen that the baseline subtraction method worked the concentration script was
run for three different resonance times to see the amounts of formic acid that were left in the
system. At a resonance time of zero seconds there is no decomposition of the formic acid so there
will be 100% seen by the Ramen cell. At 12.5 seconds it was noticed that there was no formic acid
11
left in the system, it had all fully decomposed. The amount of five percent formic acid left in the
system that didn’t decompose compared to resonance time at 400 degrees Celsius can be seen
below in Table 2.
Resonance Time
(seconds)
Formic Acid in System
0 100 %
2.5 88%
5 42%
10 6%
12.5 0%
A plot of the samples with a pure water signal can be seen below.
Key components of this graph can be seen in the subsequent figure below:
12
The ‘tic’ and ‘toc’ functions were used within this code to compute the elapsed time it took
to remove the background signal. It was found that it took 0.016852 seconds to analyze a single
sample of data that consisted of 1,941 spectral points. This is a huge improvement over the manual
method previously used that took 20-25 minutes to process a single sample.
Future Work Future experiments will monitor decomposition at a range of residence times for each reaction
temperature, to allow for the calculation of kinetic rates and Arrhenius parameters of the
decomposition reactions. Concentration measurements are required for these calculations; a robust
method for translating Raman spectra into concentration data is currently being developed.
To generalize the process of monitoring decomposition and identifying intermediate products
with Raman spectroscopy, it is necessary to develop a library of potential reaction intermediates
and products. From this study, the Raman spectra of formic acid, H2, CO2, CO, sapphire, and
water are known, but future studies involving more complex decomposition pathways will require
the methodical identification of Raman spectra of intermediate species. This will be accomplished
by sequentially gasifying increasingly complex molecules.
Conclusions Raman data clearly demonstrates decomposition of formic acid and allows for identification
and separation of product compound spectra. Formic acid was selected as an ideal compound to
test the in-situ spectroscopic system with, as it is a common intermediate compound in gasification
reactions, and it is the simplest organic acid. Gasification products of formic acid are known to be
13
CO, H2 and CO2. Post processing for the clear identification of products and kinetic rates is under
development and will allow for rapid product identification.
In this study, formic acid gasification in a continuous supercritical water reactor was studied
at temperatures between 300 and 400°C, a pressure of 25 MPa, residence times between 8.7 and
39 s, and a feedstock concentration of 5.06 wt%. The feasibility of monitoring the gasification
process with high-resolution Raman spectroscopy was demonstrated. Reaction products were
identified as H2, CO2, CO, and residual formic acid from known Raman peaks observed in
collected spectra. At temperatures below 300°C formic acid does not show any significant
decomposition.
Supercritical water gasification is a promising technology for the destruction of waste
products and the production of useful compounds and fuels. Temperature, residence time, and
feedstock concentrations are the most relevant parameters in determining decomposition routes
and rates. Additional work is required to determine the decomposition pathways and intermediate
products for a broader set of operating conditions and for more complex organic model
compounds. In future studies kinetic rates and Arrhenius parameters of observed decomposition
reactions will be calculated; concentration data will be extracted from Raman spectra.
Acknowledgements The author would like to thank the course instructor, Prof. Ashley Emery for guidance and
stimulating lectures that invited me to apply the course teachings to my research. The author would
also like to thank the course Teacher’s Assistant (T.A.) David Schipf for promptly answering
questions via email and Skype so consistently and clearly throughout the course and for this
project. Additionally, the author would like to acknowledge the fellow lab members David
Gorman, Vedant Maheshwari and Brian Pinkard who helped run experiments to collect data that
this work was based on as well as provide strong direction into the analysis for the Raman spectra.
Finally, the author would like to recognize the funding provided by the DOD Defense Threats
Reduction Agency – Grant HDTRA1-17-1-0001, as well as the resources provided by the
University of Washington which made this work possible.
14
References
[1] D. J. Gardiner, "Introduction to Raman scattering," in Practical Raman Spectroscopy:
Springer, 1989, pp. 1-12.
[2] J. Lakowicz, "Principles of Fluorescent Spectroscopy. Springer," New York, 2006.
[3] A. Jirasek, G. Schulze, M. Yu, M. Blades, and R. Turner, "Accuracy and precision of
manual baseline determination," Applied spectroscopy, vol. 58, no. 12, pp. 1488-1499,
2004.
[4] C. A. Lieber and A. Mahadevan-Jansen, "Automated method for subtraction of
fluorescence from biological Raman spectra," Applied spectroscopy, vol. 57, no. 11, pp.
1363-1367, 2003.
[5] B. D. Beier and A. J. Berger, "Method for automated background subtraction from
Raman spectra containing known contaminants," Analyst, vol. 134, no. 6, pp. 1198-1202,
2009.
[6] C. De Boor, K. Höllig, and M. Sabin, "High accuracy geometric Hermite interpolation,"
Computer Aided Geometric Design, vol. 4, no. 4, pp. 269-278, 1987.
[7] A. Emory, "Lecture 13 - Least Squares Curve Fitting," Lecture Notes vol. 13, no. 1, p. 1,
06/01/2018 2018.
[8] T. Wang and L. Dai, "Background Subtraction of Raman Spectra Based on Iterative
Polynomial Smoothing," Applied spectroscopy, vol. 71, no. 6, pp. 1169-1179, 2017.