Patent Publication Number: US-7595876-B2

Title: Method and apparatus for estimating a property of a fluid downhole

Description:
CROSS REFERENCE TO RELATED APPLICATIONS 
   This application is a continuation-in-part of co-pending U.S. application Ser. No. 11/330,283 filed Jan. 11, 2006, the full disclosure of which is hereby incorporated by reference herein. U.S. application Ser. No. 11/330,283 claims priority from U.S. patent application Ser. No. 10/985,715 filed on Nov. 10, 2004 entitled “Method and Apparatus for A Downhole Spectrometer based on Electronically Tunable Optical Filters,” which claims priority from U.S. Provisional patent application Ser. No. 60/518,965 filed on Nov. 10, 2003, both of which are hereby incorporated by reference in their entirety. 

   BACKGROUND OF THE INVENTION 
   1. Field of the Invention 
   The present invention relates to the field of downhole fluid analysis in hydrocarbon producing wells for determining fluid density, viscosity, and other parameters for a fluid downhole in a borehole during production, monitoring while drilling or wire line operations. 
   2. Background Information 
   Oil and gas companies spend large sums of money to find hydrocarbon deposits. Oil companies drill exploration wells in their most promising prospects and use these exploration wells, not only to determine whether hydrocarbons are present but also to determine the properties of those hydrocarbons, which are present. 
   To determine hydrocarbon properties, oil and gas companies often withdraw some hydrocarbons from the well. Wireline formation testers can be lowered into the well for this purpose. Initially, fluids that are withdrawn may be highly contaminated by filtrates of the fluids (“muds”) that were used during drilling. To obtain samples that are sufficiently clean (usually &lt;10% contamination) so that the sample will provide meaningful lab data concerning the formation, formation fluids are generally pumped from the wellbore for 30-90 minutes, while clean up is being monitored in real time. Then, these withdrawn fluids can be collected downhole in tanks for subsequent analysis in a laboratory at the surface. 
   Alternatively, for some properties, samples can be analyzed downhole in real time. The present invention relates both to monitoring sample clean up and to performing downhole analysis of samples at reservoir conditions of temperature and pressure. A downhole environment is a difficult one in which to operate a sensor. Measuring instruments in the downhole environment must operate under extreme conditions and limited space within a tool&#39;s pressure housing, including elevated temperatures, extreme vibration, and shock. 
   SUMMARY 
   A method for estimating a property of a fluid downhole is disclosed, the method including but not limited to exposing the fluid to light downhole; directing different wavelengths of light that have interacted with the fluid light toward a first optical grating; measuring light at different wavelengths reflected from the first optical grating; and estimating a property of the fluid from the measured light. An apparatus for estimating a property of a fluid downhole is disclosed, the apparatus including but not limited to a downhole tool for estimating a property of a fluid downhole, including but not limited to a light source that illuminates the fluid downhole; a first optical grating having a plurality of elements that selectively light that have interacted with the fluid; and a sensor that measures the light reflected from the first optical grating elements. 
   Examples of certain features of the invention have been summarized here rather broadly in order that the detailed description thereof that follows may be better understood and in order that the contributions they represent to the art may be appreciated. There are, of course, additional features of the invention that will be described hereinafter. 

   
     BRIEF DESCRIPTION OF THE FIGURES 
     For a detailed understanding of the present invention, references should be made to the following detailed description of the exemplary embodiment, taken in conjunction with the accompanying drawings, in which like elements have been given like numerals, wherein: 
       FIG. 1  is a schematic diagram of an illustrative embodiment of the present invention deployed on a wireline in a downhole environment; 
       FIG. 2  is a schematic diagram of an illustrative embodiment of the present invention deployed on a drill string in a monitoring while drilling environment; 
       FIG. 3  is a schematic diagram of an illustrative embodiment of the present invention deployed on a flexible tubing in a downhole environment; 
       FIG. 4  is a schematic diagram of an illustrative embodiment of the present invention as deployed in a wireline downhole environment showing a cross section of a formation tester tool; 
       FIG. 5  is a schematic diagram of an illustrative embodiment showing a micro electromechanical system (MEMS) tunable optical grating (TOG) spectrometer; 
       FIG. 6  is a schematic diagram of mirrored members in a TOG in an illustrative embodiment; 
       FIG. 7  is a flow chart illustrating collection and analysis of spectra for an unknown fluid in an illustrative embodiment; 
       FIG. 8  is a flow chart illustrating sweeping a wavelength range to find spectral peaks in an illustrative embodiment; 
       FIG. 9  is a depiction of an apparatus for performing Hadamard spectroscopy in a particular illustrative embodiment; and 
       FIG. 10  is a flow chart illustrating fluids exposed to light in a downhole. 
   

   DETAILED DESCRIPTION OF THE INVENTION 
   Due to the uncertainties and enormous expenditures associated with producing hydrocarbons for a formation, down hole sampling of formations are critical to the planning oil companies undergo prior to undertaking production. Thus, oil companies consider down hole indications of formation fluid properties indispensable because these downhole indication of formation fluid properties are extremely helpful in accurately indicating the feasibility of producing oil and gas from a hydrocarbon bearing formation. Thus there is great public benefit provided by the illustrative embodiment as it aids in the efficient planning and production of energy. For these reasons, oil companies are willing to pay significant amounts of money for the estimations of fluid properties down hole, as provided by a illustrative embodiment. 
   In a particular illustrative embodiment, a method is disclosed for estimating a property of a fluid downhole, the method including but not limited to exposing the fluid to light downhole; reflecting different wavelengths of light that have interacted with the fluid from a first optical grating; measuring light at different wavelengths reflected from the first optical grating; and estimating a property of the fluid from the measured light. In another particular illustrative embodiment of the method, the light interacting with the fluid further comprises light selected from the group consisting of light reflecting off of the fluid and light passing through the fluid. 
   In another particular illustrative embodiment of the method the first optical grating further includes but is not limited to a plurality of elements, the method further including but not limited to activating a portion of the plurality of elements on the first optical grating to select a band of wavelengths of light reflected by the activated portion. In another particular illustrative embodiment of the method, the method further includes but is not limited to, reflecting different wavelengths of light that have interacted with the fluid from a second optical grating that reflects a different wavelength of light onto each of the elements of the first optical grating. In another particular illustrative embodiment of the method further includes but is not limited to exposing a secondary fluid to light; estimating a property of the secondary fluid; comparing the property of the fluid to the property of the secondary fluid; and determining whether the fluid derives from the same formation compartment as the secondary fluid. 
   In another particular illustrative embodiment of the method the plurality of elements further comprises an upper row of the plurality of elements aligned above a lower row of the plurality of elements. In another particular illustrative embodiment of the method the lower row of elements does not reflect light from the first optical grating. In another particular embodiment, the lower row of elements reflects light that is not measured by the optical sensor that measures the light reflected from the upper row of elements. 
   In another particular illustrative embodiment of the method, the method further includes but is not limited to performing Hadamard spectroscopy on the light measured from the activated portion of the first optical grating. In another particular illustrative embodiment of the method, the method further includes but is not limited to optically multiplexing the light reflected from each element of the first optical grating. In another particular illustrative embodiment of the method, the first optical grating further comprises a tunable optical filter and the elements further comprise mirrored members. In another particular illustrative embodiment of the method, the method further includes but is not limited to filtering the light reflected from the TOG before the reflected light is measured. 
   In another particular illustrative embodiment a downhole tool is disclosed for estimating a property of a fluid downhole. In a particular illustrative embodiment, the downhole tool includes but is not limited to a light source that illuminates the fluid downhole; a first optical grating having a plurality of elements that selectively reflect light that have interacted with the fluid; and a sensor that measures the light reflected from the first optical grating elements. In another particular illustrative embodiment, the downhole tool further includes, but is not limited to a grating that reflects a different wavelength of light onto each of the plurality of elements of the first optical grating, wherein when each of the plurality of elements is activated, each of the plurality of elements reflects the different wavelength of light which impinges upon the activated element. 
   In another particular illustrative embodiment of the downhole tool, the downhole tool further includes, but is not limited to, a circuit that selectively actuates each of the plurality of elements of the first optical grating to vary a wavelength of light reflected by the first optical grating. In another particular embodiment, the downhole tool further includes but is not limited to an optical filter positioned between the optical detector and the first optical grating, wherein the optical filter reduces a spectra of light reflected from the first optical grating. In another particular embodiment, the downhole tool further includes but is not limited to a filter positioned between the fluid and the first optical grating that reduces the spectra of light reflected from the fluid. In another particular embodiment, the downhole tool further includes but is not limited to a processor in data communication with the photodetector that estimates a property of the fluid downhole from data from the photodetector, wherein the processor is configured to use the data from the photodetector and a soft modeling technique to estimate the property of the fluid. In another particular embodiment, the downhole tool further includes but is not limited to a reference fluid in optical communication with the light source and the first optical grating, wherein the processor is configured to estimate the property of the fluid based on a comparison to the reference fluid. 
   In another particular embodiment of the downhole tool, the elements can be, but are not limited to a multiplicity of mirrored members or elements, wherein the elements are individually selectable to reflect the light. In a particular embodiment the elements of an upper row are selectable to reflect light to an optical sensor and the elements of a lower row do not reflect light to the optical sensor. In one aspect of the invention a method is provided for estimating a property of a fluid downhole. The method provides for exposing the fluid to light, reflecting light that have interacted with the fluid off of a micro electromechanical system (MEMS) tunable optical grating (TOG) having a first mirrored member and a second mirrored member. In an illustrative embodiment, for purposes of this disclosure, reflection (or reflecting) is meant to encompass reflection, diffraction, and interference of light. The method further provides measuring the light reflected from the TOG and estimating a property of the formation fluid from the measured light. For higher overall wavelength resolution, light that have interacted with the fluid can first be filtered using an optical band pass filter or other means to select only those wavelengths in a narrow range of wavelengths before projecting that pre-filtered light onto the tunable grating. 
   In another particular embodiment the method provides for varying a distance between the first mirrored member and the second mirrored member to sweep a wavelength of light reflected by the TOG over a range of wavelengths. In another aspect of the invention the method provides for exposing a second system to light. The second system further provides a second TOG having a third mirrored member and a fourth mirrored member, wherein the third mirrored member and the fourth mirrored member are substantially parallel to each other and not directly in contact with one another. The second system further provides a secondary formation fluid, estimating a property of the secondary formation fluid, comparing the property of the formation fluid to the property of the secondary formation fluid, and determining whether the formation fluid derives from the same formation compartment as the secondary formation fluid. 
   In another aspect of the invention the method provides for modulating the distance between the mirrored members by controlling a piezoelectric element. In another aspect of the invention modulating the distance between the mirrored members by controlling a micro-electromechanical device. In another aspect of the invention the range of wavelengths includes but is not limited to a hydrocarbon band of wavelengths. The method further provides locating at least one peak in the range of wavelengths and performing wavelength modulation spectroscopy around a center wavelength for the at least one peak. 
   In another aspect of the invention the method of uses the measured light and a soft modeling technique to estimate the property of the formation fluid. In another aspect of the invention the method provides for estimating at least one of the set consisting of a carbon number distribution and percentage of drilling mud contamination. In another aspect of the invention a downhole tool is provided for estimating a property of a fluid downhole that provides a light source that illuminates the fluid downhole, a TOG having two separated mirrored members that reflect a wavelength of light based on a control input, a photodetector that measures light that have interacted with the fluid downhole and been reflected by the TOG, and a processor in data communication with the photodetector that estimates a property of the fluid downhole from the data from the photodetector. 
   In another aspect of the invention the downhole further provides a circuit that adjusts the TOG for a wavelength of light and includes a modulator that modulates the wavelength. In another aspect of the invention a control input varies a distance between the two parallel members. In another aspect of the invention the optical filter further provides a piezoelectric element or a micro-electromechanical device that adjusts the distance between the two parallel members. In another aspect of the invention the processor uses the data from the photodetector and a soft modeling technique to estimate the property of the initial formation fluid. 
   In another aspect of the invention the downhole further provides a secondary formation fluid in optical communication with the light source and the TOG, wherein the processor estimates the property of the formation fluid based on a comparison to the secondary formation fluid. Previously, commercial downhole optical spectrometers could be described as near-infrared filter photometers. That is, commercial downhole optical spectrometers have used fairly broadband individual optical filters that were centered at a handful of different discrete wavelengths. The bandwidth of each optical filter was typically 20-30 nm although a few filters may have provided a narrower bandwidth of only 11 nm, which is near the limit for interference filters that can be manufactured for downhole applications using today&#39;s technology. Also, there was often a substantial gap in wavelength coverage between the wavelength region covered by one optical filter and the wavelength region covered by the next optical filter so one did not obtain continuous spectra at nanometer resolution. 
   An illustrative embodiment of the system, apparatus and method disclosed herein provides a tunable optical grating (TOG) for estimating a property of a fluid downhole. The TOG can be selected from electronically tunable optical Micro Electromechanical System (MEMS) gratings to collect spectra of downhole fluids with wavelength resolution on the order of a nanometer. The nanometer-resolution spectra can be used to, but not limited to, estimate or determine physical properties and composition (synthetic chromatogram), oil-based mud filtrate contamination, H 2 S, and CO 2  concentrations for downhole fluids. The TOG reflects light at a wavelength selected by the spacing between mirrored members in the TOG. In an illustrative embodiment, the tunable wavelength range of TOG is continuous. 
   The TOG provides high wavelength resolution on the order of 1-2 nm downhole, thereby providing continuous nanometer-resolution spectroscopy (NRS) downhole. Most, if not all, of the currently available MEMS TOGs are not are rated by their manufacturer for the high temperatures (up to 175° C. or more) encountered downhole. Thus, the present invention provides, when desired, sorption cooling or another type cooling system to overcome temperature limitations to enable operation of the TOG at downhole temperatures up to and exceeding 175° C. 
   There are numerous advantages to using continuously tunable TOGs. One advantage is that the present invention uses only a single photodetector to perform continuous NRS downhole. Using a single photodetector to collect data for all wavelengths greatly improves the quality of the spectra obtained because it eliminates the need to calibrate and normalize the spectral response and sensitivity between members of an array of photodetectors. A single detector also offers many practical design advantages. With a non-tunable grating the reflected light spectrum is spread out over a defined angle. If the angle between the grating and the detector is fixed, then an array of detectors such as a photodiode or CCD array can be used to collect the reflected light spectrum. An illustrative embodiment provides a multiplexer for low level signals that can operate at the high-temperatures encountered downhole. 
   The present invention provides continuous NRS for estimating concentration of one gas in a mixture of gases such as concentration of H 2 S in a natural gas mixture. The term continuous as used herein means that there are no gaps in wavelength coverage of the reflected light spectrum. That is, the difference in center wavelengths between any two neighboring wavelength channels does not exceed twice the full-width at half maximum wavelength response for either channel. The present example of the invention provides a single photo detector, rather than trying to synchronize or calibrate the response of two photo detectors at downhole conditions. Furthermore, because the present invention can rapidly and continuously change the wavelength of light reflected by the TOG, the present invention can also perform wavelength modulation spectroscopy (WMS) about a center wavelength (or frequency) of light. WMS is discussed in a number of papers and texts. In one embodiment of the invention, a hydrocarbon band (1650 nm-1850 nm) is continuously scanned and spectral peaks or other spectral features located within the band. WMS is then performed for each peak located in the band. 
   In a particular illustrative embodiment, a tool and method provide WMS, to obtain the first derivative of an absorption spectrum about one or more center wavelengths by modulating the TOG&#39;s wavelength about a selected center wavelength. To calculate the change in absorbance for a fluid sample (rather than absorbance, itself) using WMS, it is not necessary to determine how much transmitted light entered a sample but only how much the transmitted light changed from its average value after passing through the sample. WMS can also be performed to determine reflectance. Thus, by applying WMS, an illustrative embodiment collects spectra using a “single beam” instrument with as much or better accuracy than a “dual beam” instrument for which errors can be introduced by differences between the two photodetectors (reference and sample) that are commonly used in dual beam instruments. WMS is performed by modulating the distance between two mirrored members in the TOG. 
   By definition, the absorbance A at wavelength
 
λ is  A (λ)=log 10    [I   0 (λ)/ I (λ)]  (1)
 
where I 0  is the intensity of light entering the sample and I is the intensity of light exiting the sample. If one modulates the wavelength of light from λ 1  to some nearby wavelength, λ 2 , then the change in absorbance, ΔA, is given by,
 
Δ A=A (λ 2 )− A (λ 1 )=log 10    [I   0 (λ 2 )/ I (λ 2 )]−log 10    [I   0 (λ i )/ I (λ 1 )]  (2)
 
Δ A =log 10    [I   0 (λ 2 )/ I   0 (λ 1 )]−log 10    [I (λ 2 )/ I (λ 1 )]  (3)
 
   One defines,
 
Δ I=I (λ 2 )− I (λ i )  (4)
 
   By modulating over a spectral region where the sample&#39;s absorbance is changing rapidly with wavelength (near an absorbance peak), one can assume that the fractional change in incident (source) intensity with wavelength is small compared to the fractional change in transmitted intensity with wavelength. That is, we assume that I 0 (λ 2 )/I 0 (λ1)=1 so that the first logarithmic term of (3) vanishes. Then, substituting (4) into the remaining term of (3) to obtain,
 
Δ A =−log 10  [( I (λ 1 )+Δ I ))/ I (λ 1 )]=−log 10  [1 +ΔI/I (λ 1 )]  (5)
 
   Note that ΔA now has no dependence on source intensity so it is not necessary to provide a second photodetector to obtain neither the source intensity nor an optical multiplexer to shuttle between source and transmitted light impinging on a single detector. This eliminates the need for a second detector (which can be difficult to precisely calibrate against the first detector, especially at extreme downhole temperatures) and reduces or eliminates the need for a multiplexer to switch between the two intensities. 
   Because Δλ=Δλ 2 −λ 1 , is very small, it can be assumed that ΔI&lt;&lt;I(λ 1 ). Then, defining ε,
 
ε=Δ I/I (λ 1 ).  (6)
 
   Note that ΔI can be considered as an “AC” signal which is modulated by modulating λ 2  about a fixed λ 1 . Similarly, I(λ 1 ) can be considered as a “DC” signal at a fixed λ 1 . The ratio, ε, of “AC” to “DC” is used to calculate ΔA. In this way, absorbance spectroscopy can be performed without having to determine baseline light transmission through an empty sample cell. 
   Then, one can employ the expansion for the natural logarithm about unity,
 
ln(1+ε)=ε−ε 2 /2+ε 3 /3−ε 4 /4+ . . . for −1&lt;ε&lt;1  (7)
 
and the identity, log a (N)=log b (N)/log b (a) to write,
 
Δ A=−[ε−ε   2 /2+ε 3 /3−ε 4 /4−+ . . . ]/2.303  (8)
 
   Finally, one estimates the first derivative of spectrum about λ 1  as
 
Δ A/Δλ=−[ε−ε   2 /+ε 3 /−ε 4 /4+ . . . ]/(2.303Δλ)  (9)
 
   The present invention provides a nanometer-resolution spectrometer using a TOG to enable nanometer-resolution spectral measurements to determine or estimate physical and chemical properties of a gas or fluid, including the percent of oil-based mud filtrate contamination in crude oil samples. The present invention also enables spectral measurements to determine or estimate the mole fraction or percent of chemical groups (aromatics, olefins, saturates) in a fluid such as a crude oil or gas sample. The present invention also enables analysis of nanometer-resolution spectral measurements to determine or estimate or directly measure gas oil ratio (GOR) for a fluid. 
   The illustrative embodiment provides a nanometer-resolution spectrometer incorporating a TOG to enable nanometer-resolution spectral measurement to determine or estimate the composition of a fluid. The illustrative embodiment can determine or estimate other parameters of interest of a fluid, such as to estimate whether crude oil contains wet gas (high methane) or dry gas (low methane), which is determined by the relative concentrations of C 1 , C 2 , C 3 , C 4 . The illustrative embodiment provides a nanometer-resolution spectrometer using a TOG to enable nanometer-resolution spectral measurements to determine or estimate CO 2  in methane gas or CO 2  dissolved in a fluid, for example, crude oil. 
   The illustrative embodiment provides a nanometer-resolution spectrometer using a TOG to enable nanometer-resolution spectral measurement to provide improved correlation of spectral measurements to physical properties (API Gravity, cloud point, bubble point, asphaltene precipitation pressure, etc.) or chemical properties (acid number, nickel, vanadium, sulfur, mercury, etc.) of crude oil. The illustrative embodiment provides a nanometer-resolution spectrometer using a TOG to provide nanometer-resolution spectral measurement to determine or estimate fluid properties, for example, the phytane/pristane ratios of crude oil. 
   The illustrative embodiment provides a nanometer-resolution spectrometer using a TOG to enable nanometer-resolution spectral measurement to determine or estimate the fluid properties such as the amount of H 2 S that is dissolved in crude oil, which is commercially important because the value of a barrel of crude oil drops with increasing H 2 S concentration due to extra costs of handling and removal of the H 2 S. 
   The illustrative embodiment provides a nanometer-resolution TOG for spectral measurements from which a correlative equation derived from soft modeling (chemometrics such as multiple linear regression, principal components regression, partial least squares, or a neural network) can be used to infer physical and chemical properties of sample formation fluids or other fluids. The illustrative embodiment takes advantage of the TOG&#39;s rapid and continuous wavelength switching capability to perform derivative spectroscopy or WMS to find spectral peaks on a shoulder of another larger spectral peak or to greatly improve signal to noise ratios and makes it possible to observe subtle changes. 
   The illustrative embodiment enables quantification of aromatics, olefins (unlikely in crude oil but common in OBM filtrate so it can be used to quantify the percentage of filtrate), saturates, methane, ethane, propane, and butane. The illustrative embodiment determines or estimates the percentage of oil based mud filtrate contamination downhole, particularly if the base oil is aromatic-free (unlike crude oil) but olefin-rich (also unlike crude oil). In another embodiment, by changing the wavelength (or frequency) of light reflected by the TOG by tuning the TOG, the present invention also performs Raman spectroscopy in combination with a single wavelength detector for the light that is Raman scattered by the sample. 
   One difficulty with implementing a TOG spectrometer downhole is temperature. Typically, manufacturers rate tunable optical filters to temperatures of 80° C. or less. The illustrative embodiment of the invention combines a TOG with a downhole sorption cooling system, when desired. The sorption cooling system cools the TOG spectrometer to assist operating the TOG spectrometer at high ambient temperatures downhole. The TOG and associated TOG spectrometer components can be placed in thermal contact with a source of water (either as a liquid or as a hydrate). The TOG is cooled as water is evaporated from liquid or released by hydrate. The resulting water vapor which carries heat away from the TOG and is sorbed by a sorbent, which becomes hotter in the process. The sorbent transfers its excess heat to the well bore fluid with which it is in thermal contact. It would also be useful to determine the change in response of the TOG with temperature so that one could correct for its temperature response if the TOG&#39;s temperature changed substantially during the downhole job as might occur if one ran out of water coolant before the job was completed. 
   In an illustrative embodiment, a TOG is used to perform nanometer-resolution spectroscopy sweeps of the section of the hydrocarbon band which spans from about 1650-1850 nm. Other wavelength bands can be swept as well depending on what elements or measurements are desired in measuring spectral transmissivity, reflectivity, and absorbance or fluorescence luminance response. From these TOG transmissivity, reflectivity, fluorescence luminance or absorbance spectral measurements, the present invention quantifies aromatics, olefins (unlikely in crude oil but common in OBM filtrate, which therefore provides one way to estimate filtrate contamination percentage based on olefin measurements), saturates, methane and possibly ethane, propane, and butane. With TOG nanometer-resolution spectroscopy, the illustrative embodiment determines or estimates the percentage of oil based mud (OBM) filtrate contamination downhole in a formation fluid sample, particularly if the OBM contaminants are aromatic-free but olefin-rich. The illustrative embodiment can estimate the degree of formation fluid clean up or removal of contamination by monitoring a property of OBM present in a formation fluid. 
   Furthermore, with nanometer-resolution spectroscopy provided by a particular illustrative embodiment, the particular illustrative embodiment can determine or estimate subtle chemical compositional differences between two formation fluids taken at different depths in a well bore. Such differences can be used to assess the compartmentalization of a reservoir, which means to determine whether different sections of a reservoir are separate compartments (across which fluids do not flow) or whether they are connected to each other. Separate compartments must be drained separately (separate wells) and may need different types of processing for their fluids. 
   Multi-billion dollar decisions on how to develop a reservoir (well locations, types of production facilities, etc.) are based on whether or not a reservoir is compartmentalized. One way to assess compartmentalization is based on phytane/pristane ratios of liquid crude oil or by using any other distinguishing features such as any unexpected subtle differences in the fluid spectra that are capable of being resolved using a TOG. Gravity segregation will cause some expected spectral differences in fluids from different depths even when there is no compartmentalization. For example, one expects the top of a column of crude oil to be more gas rich than the bottom. For a 2 mm path length, the dominant liquid (C6+) hydrocarbon optical absorption peaks are near 1725 nm, while the corresponding absorbance peaks of hydrocarbon gases such as methane, ethane, propane, butane, lie between 1677 nm and 1725 nm. Subtle differences in spectra outside the regions where these hydrocarbon gases absorb are unexpected and therefore provide evidence of compartmentalization. 
   In one aspect of the invention, MEMS or piezoelectric devices are disposed in between a first and second mirrored member for operatively applying forces to vary a distance between the first and second mirrored members. MEMS and piezoelectric technology are well known to those skilled in the art. MEMS is a process whereby micron-sized mechanical devices are fabricated on silicon wafers by photolithography and etching techniques. These mechanical devices are formed on integrated circuit chips so that devices, which incorporate MEMS technology, essentially become miniature electromechanical systems. MEMS devices are activated by analog voltages which create an electric field that will cause the MEMS devices to physically deflect since they are made of silicon and therefore respond to the electric field. 
   Accordingly, in one particular embodiment a DC power supply controlled by a processor is connected to MEMS or piezoelectric devices through leads to bias MEMS devices and variation in the distance between the first and second mirrored members. In another particular embodiment, the distance between the first and second rows of mirrored members does not vary, and individual members or elements of the rows of mirrored members are turned off and on for optical multiplexing, which is discussed below. One of the advantages of using MEMS devices on a silicon integrated circuit chip is that MEMS devices are low mass, low power, and low voltage devices. 
   The low mass means that the MEMS device has low sensitivity to shock and vibration, which is important in wireline applications and even more important in logging while drilling applications, where shock and vibration is even worse. The low voltage and low power means that one can use ordinary printed circuit board designs and use battery power in conjunction with the MEMS devices if desired. Preferably, voltages of between about 0 and 10 volts are provided to control the desired deflection of MEMS or piezoelectric devices. These low voltages help to ensure low attenuation of the cavity signals and low insertion losses. Applied voltages of between about 0 and 10 volts also reduce the polarization dependent loss for high signal attenuation. Moreover, while power supply source has been described as a DC power supply, it will be recognized by those with skill in the art that power supply could alternately be an AC source with appropriate rectifying circuitry, or an AC source that directly applies power to MEMS devices where MEMS devices are configured for actuation by AC power. 
   MEMS devices can be any kind of micro electro mechanical system actuator operable to uniformly and easily move mirrored members of a tunable optical grating. For example, cantilevered arms, pivot points, spring-like or other resilient mechanisms, levers, moment arms, torque generating devices, and other devices and equivalents thereof that can apply the correct amount of force to the mirrored members are all configurable in silicon MEMS devices and are within the scope of the present invention. In the illustrative embodiment, MEMS devices are implemented by a pair of pistons that are extendable to uniformly push against mirrored mirrors to separate mirrored members. The MEMS device is physically connected to leads to receive power from the power supply. 
   The illustrative embodiment provides a downhole instrument that can measure real-time, nanometer-resolution, continuous optical spectra of fluids, particularly over the hydrocarbon band region of the spectrum. Nanometer-resolution spectra (that is, resolution in the 1-2 nanometer range) over the near-infrared hydrocarbon band (1650-1850 nm) contain detailed information about hydrocarbons. Such information is of high commercial value to the oil industry. For example, from the hydrocarbon band region, one can obtain information about the ratio of methyl (—CH 3 ) to methylene (—CH 2 ), which is indicative of the average hydrocarbon chain length and information on the relative concentrations of methane, ethane, propane, butane, and so on. 
   This spectral region also contains information on the concentrations of aromatics, olefins, and paraffins, which could be used for quantifying the percentage of oil-based mud (OBM) filtrate in a crude oil mixture. For example, for environmental friendliness, synthetic base oils for OBMs are designed to be free of aromatics, whereas crude oils always have some aromatics. Conversely, many synthetic muds contain olefins or esters, which are not present in crude oils. These distinctions provide a means to quantify percentages of OBM filtrate in mixtures of filtrate with crude oil. Of course, to reliably glean such subtle information from the spectra it is useful to have high spectral resolution (both in wavelength and absorbance) as provided in an illustrative of a particular illustrative embodiment. 
   It is possible to assess hydrocarbon chain length from the ratio methyl to methylene by applying Fourier transform infrared (FTIR) spectroscopy to individual fluid inclusions greater than 15 microns in rock using an A-590 Bruker microscope linked to an FTIR Bruker IFS 88 spectrometer (J M Dereppe, J. Pironon, C. Moreaux,  American Mineralogist , v. 79, p. 712-718, 1994). An infrared beam, and an MCT detector, cooled with liquid N2, allowed the IR detection between 600 and 5000 cm−1 (Barres et al., 1987). The spectra, presented in absorbance units and wave numbers (cm−1), were recorded in the transmission mode with a spectral resolution of 4 cm−1 after 400 accumulations. A chain-length coefficient can be calculated by comparing CH3-CH2 ratio of the sample to the same ratios measured on a standard n-alkane series. 
   In an illustrative embodiment, the present invention provides a TOG to reflect a band of wavelengths of broad band or white light. White light that has interacted with a fluid sample is reflected off of the TOG to an optical sensor. The optical sensor can include, but is not limited to a single photodetector and amplifier which can sense the light reflected off of the TOG. A continuously variable wavelength control is provided to the TOG to enable creation of nanometer-resolution spectra for performing chemometric correlations for estimation of percentage of oil based mud filtrate to gas oil ratio and spectrally-inferred synthetic chromatograms. 
   In an illustrative embodiment white light is transmitted through a first window, though a formation fluid or down hole fluid, through a second window and onto the TOG. The TOG acts as a diffraction element. Light is detected as it is reflected off of the TOG. The individual elements of the TOG can be grouped together into groups or sections. Control system electronics continuously adjust the voltages applied to various sections of the TOG elements to change the wavelength or wavelengths of light reflected by the TOG elements within the selection wavelength range. In a particular illustrative embodiment, a photodetector is provided to detect the light that has interacted with a down hole fluid and reflected off of the TOG. When desired, a transform, such as a Hadamard transform can be used to recover a spectrum for the reflected light. The application of the Hadamard transform is discussed below in connection with  FIG. 9 . 
   Spectral peaks can be identified in the reflected light collected from the optical spectra of the swept wavelength band. The TOG can oscillate around a single wavelength coincident with a center wavelength for one or each of the spectral peaks for derivative spectroscopy. Derivative spectroscopy reduces the effects of baseline offset and artifacts. Reduction of offsets and artifacts facilitates maintenance of robust chemometric predictions of fluid properties based on spectra for the fluid. WMS can also be performed using optical multiplexing or selective activation of the TOG or optical grating elements to selectively reflect different bandwidths of light from the activate TOG elements or element sections, as discussed below with  FIG. 9 , by optically multiplexing between two near by frequencies reflected by two adjacent or nearby elements on the TOG which are alternately turned on and off to alternately reflect different nearby wavelengths of light from the fluid. 
   One particular illustrative embodiment provides a piezoelectric or MEMS controlled TOG that is suitable for downhole use in part because the TOG is small, light weight and temperature resistant. In a particular illustrative embodiment, the TOG is resistant to vibration and shock downhole because it can be a low mass device manufactured on an electronic semiconductor device or piezoelectric material. In another illustrative embodiment, the TOG is also physically small so that it can be easily retrofitted into an existing downhole tool with minimal reengineering for physical space, power, light or control. In another illustrative embodiment, the TOG can potentially withstand temperatures up to 175° C. or more, which makes it suitable to withstand high temperatures for downhole use. In another illustrative embodiment, sorption can be added to bolster the TOG&#39;s ability to withstand downhole temperatures. 
   In another illustrative embodiment, the TOG also has no macroscopically moving parts. The wavelength of light reflected by the TOG is controlled by microscopic movement varying a distance between two mirrored members. Thus in an illustrative embodiment, the TOG is durable and robust, thus suitable for downhole use. 
   In another particular illustrative embodiment, white light is alternately directed through an unknown fluid sample and a reference chamber containing a reference compound having a known optical spectrum. White light can also be reflected off of the unknown fluid sample for the collection of reflectance spectra for the fluid sample. Spectra are collected for the unknown fluid and for the reference fluid. The spectrum of the reference fluid is compared and correlated to the spectrum of the unknown fluid sample. Thus, through comparing and correlating the unknown fluid spectrum with the reference fluid spectrum over wavelength regions where the unknown fluid&#39;s matrix spectrum does not interfere with the reference compound&#39;s spectrum, the concentration of reference compound in the unknown fluid matrix can be estimated. 
   For example, if the reference fluid contains one hundred parts per million (PPM) of a particular component (for example, H 2 S) and the unknown fluid has a spectrum which looks the same but which has twice the absorbance at each non-interfering wavelength, then the unknown fluid can be estimated to contain two hundred PPM H 2 S. 
   Turning now to  FIG. 1 ,  FIG. 1  is a schematic diagram of an illustrative embodiment of the tool deployed in a borehole  18  on a wire line in a downhole environment. As shown in  FIG. 1 , a downhole tool  10  containing a downhole MEMS nanometer-resolution spectrometer  410  is deployed in a borehole  14 . The borehole  18  is formed in formation  16 . Tool  10  is deployed via a wireline  12 . Data from the tool  10  can be transmitted to the surface to a computer processor  20  with memory inside of an intelligent completion system  30 . 
     FIG. 2  is a schematic diagram of another illustrative embodiment of the tool having a MEMS nanometer-resolution spectrometer deployed on a drill string  15  in a monitoring while drilling environment.  FIG. 3  is a schematic diagram of another illustrative embodiment having a MEMS nanometer-resolution spectrometer deployed on a flexible tubing  13  in a downhole environment. Sampling and analysis by MEMS nanometer resolution spectrometer  410  can be performed at variable depths whether deployed from a wire line  12 , drill string  15 , or flexible tubing  13 . 
     FIG. 4  is a schematic diagram of an illustrative embodiment of the present invention as deployed in a borehole  18  in a wire line downhole environment showing a cross section of a wireline formation tester tool  10 . As shown in  FIG. 4 , the tool  10  is deployed in a borehole  14  filled with borehole fluid  434 . The tool  10  is positioned in the borehole  18  by backup support arms  416 . A snorkel  418  with packer contacts the borehole wall  432  for extracting formation fluid from the formation  414 . In an illustrative embodiment, tool  10  contains downhole MEMS nanometer-resolution spectrometer  410  containing the TOG disposed in or near flow line  426 . The control and acquisition electronics ( 350  as shown in  FIG. 5 ) which include a processor, memory and data bases shown in  FIG. 6  are housed in the tool  10 . Pump  412  pumps formation fluid from formation  414  into flow line  426 . In the illustrative embodiment formation fluid travels through flow line  426  and into valve  420  which directs the formation fluid to line  422  to save the fluid in a sample tank or to line  428  where the formation fluid exits to the borehole. 
   Turning now to  FIG. 5 , another illustrative embodiment of the tool is illustrated. As shown in  FIG. 5 , a light source  201  provides light  202  to collimating lens  203 . Collimated white light  204  is transmitted through a first window  303 , though a formation fluid or down hole fluid  341 , through a second window  302  and onto the TOG  250 . The tunable grating acts as a diffraction element. Reflected light  233  is detected by optical detector  230  as it is reflected off of the TOG  250 . Mirror spacing control electronics  350  sweep the wavelength of the TOG  250  over a selected band of frequencies and wavelengths. A photodetector  230  and an order-sorting blocking filter  232  are used to detect the light reflected off of the TOG  250 . A transform, for example, a Hadamard type transform can be used to recover a spectrum or spectra for the fluid from the detected light. Electrical power is provided by power supply  351  which can be a battery. 
   To collect a spectrum more quickly, the entire MEMS tunable optical grating, consisting of a multiplicity of mirrored members, can be subdivided into a hundred or more regions or sets of mirrored members or elements, each of which is then operated as if it was a separate grating dedicated to a single wavelength. Then, each separate grating element set can either project or not project its dedicated wavelength of light onto the spectrometer&#39;s photodetector. Each separate grating can then be thought of as an “on-off” filter for its dedicated wavelength. 
   This configuration acts as an optical multiplexer which allows projection of more than one wavelength (e.g. 50 wavelengths) or more than one band of wavelengths, simultaneously onto a single optical sensor, such as a photodetector and then sequentially cycle through various predetermined patterns of projected wavelengths. A mathematical (Hadamard) transform can then be used to process the data of photodetector response for each pattern to determine the amount of light that would have detected at each individual wavelength. This approach is the basis of Hadamard spectroscopy. This configuration also allows one to mimic absorption spectra of a reference sample (e.g. H2S) by projecting all wavelengths but those wavelengths at which the sample would absorb light. 
   In another particular embodiment, a set of light diverters, for example, mirrors  343 ,  344 ,  345 , and  347 , can be used to redirect light  204  through reference sample  342 . Light diverter  347  can be rotated so that in the position shown, mirror  347  reflects light  204  from light diverter  345  and intercepts light from sample  341 . Light  204  reflects off of mirror  343  to mirror  344  through reference sample  342  to mirror  345  where it is reflected off of mirror  347  into light path  204  to impinge on TOG  250 . 
   The back side  346  of mirror  347  intercepts light passing through sample  341 . when in the position shown in  FIG. 5  and reflects light passing through the reference sample. When mirror  347  is rotated from the position shown to the position shown by dashed line  348 , light from the sample  341  is not intercepted and passes to strike TOG  250  and light from reference sample  342  is not reflected to TOG  250 . 
   Rotating mirror  347  is positionally controlled by a motor controlled by electronics  350 . Thus, the illustrative embodiment enables comparison of spectra for reference sample  342  to spectra for reference sample  341 . Spectra for reference sample  342  can be obtained at the surface and compared to spectra for the reference sample obtained downhole to recalibrate the TOG spectrometer for downhole temperature measurements. 
   Turning now to  FIG. 6 , in another particular illustrative embodiment, the TOG  250  comprises a multiplicity of mirrored members or elements aligned along rows  254  and  256 , which may include a lower row or set of grating elements or mirrors  254  and an upper row or set of grating elements or mirrors  256  on a MEMS semiconductor chip  258 . The two rows or sets of elements or mirrored members  254 ,  256  can each be divided into smaller subsets or regions. The smallest subset of a row of elements would be an individual element or member of a row. Each smaller element, sub set or region can be independently controlled to reflect or not reflect light. A piezoelectric device may be incorporated into the MEMS chip. A feed back loop  266  may be provided between the optical detector  230  and mirror spacing and region control electronics  350 . 
   The mirror spacing control electronics  350  can include a processor  630 , memory  632  and database  634  for storing a computer program for execution by the processor. The computer program can contain instructions to find peaks within a hydrocarbon band and perform derivative spectroscopy around a center wavelength for each of the peaks. The spacing  255  or distance between the upper  256  and lower  254  mirrored members determines the wavelength of light reflected off of the TOG  250  to the optical detector  230  through the order-sorting blocking filter  232 . 
   Turning now to  FIG. 7 , a flow chart  700  is shown wherein in an illustrative embodiment of a method and apparatus, spectra are collected for an unknown fluid downhole at block  702 . Spectra are then collected for a reference fluid sample downhole at block  704 . The collected reference fluid spectra and unknown fluid spectra are collected and compared at block  706 . Composition for the unknown fluid is estimated at block  708  and the process ends. 
   Turning now to  FIG. 8 , a flow chart  800  is shown wherein in another illustrative embodiment a wavelength range is continuously. (that is without an interruption in spectral coverage) swept over a hydrocarbon band at block  802  for an unknown fluid. In an illustrative embodiment the process finds spectral peaks and subpeaks (on the shoulders of larger peaks) in the hydrocarbon range at block  804 . Wavelength modulation spectroscopy is performed for each peak and subpeak and derivative spectra estimated at block  806 . Composition of the unknown fluid is estimated from spectra at block  808  and the process ends. 
   Spectral peaks can be identified in the hydrocarbon band of wavelengths swept by mirrored member spacing control and data acquisition electronics  350 . Derivative spectrometry can be performed centered about a single wavelength coincident with a single center wavelength for one or each of the spectral peaks. Derivative spectroscopy reduces the effects of baseline offset and artifacts. Reduction of offsets and artifacts facilitates maintenance of robust chemometric predictions of fluid properties based on spectra for the fluid. 
   Turning now to  FIG. 9 , in a particular illustrative embodiment, a grating such as TOG  250  comprises a multiplicity of mirrored members or elements aligned along an upper row  256  and a lower row  254 . In another particular illustrative embodiment the grating is not tunable but has selectable elements for reflecting and not reflecting light from the upper row of mirrored members. Thus, the grating can be used for optical multiplexing, however, the distance between the upper row of elements and the lower row of elements for the grating is not adjustable (i.e., tunable), thus the optical grating is referred to as a selectable optical grating (SOG) rather than as a TOG. TOG mirrored members which may include but are not limited to a lower set or row of elements or member such as grating mirrors  254  and an upper set of grating mirrors  256  on a MEMS semiconductor chip  258 . Each mirrored member or element  251 ,  253 ,  257 ,  259 ,  261  and  263  of the upper set or row of mirrored members  256  can each be turned on an off independently. Each mirrored member reflects incident light impinging upon the mirrored member when the mirrored member is turned on and does not reflect incident light when the mirrored member is turned off. 
   In another illustrative embodiment, each independent element of the lower and upper row of mirrored members  254 ,  256  can be individually turned on and off. The selectable on and off state for each mirrored element or member of the SOG or TOG is controlled by member control electronics  350 . A piezoelectric device may be incorporated into the MEMS semiconductor chip  258 . A feed back loop  266  may be provided between the optical detector  230  and mirror spacing and member control electronics  350 . The member control electronics  350  can include a processor  630 , memory  632  and database  634  for storing a computer program for execution by the processor. The computer program can contain instructions to find peaks within a hydrocarbon band and perform derivative spectroscopy around a center wavelength for each of the peaks. Each of the mirrored members or elements can be turned on or off to determine the wavelength or band of frequencies or wavelengths of light reflected off of the TOG  250  to the optical detector  230 . The elements can also be separated into groups for control at the group level for reflecting and not reflecting as a selectable group of elements. In another particular illustrative embodiment the light reflected from the TOG passes through the order-sorting blocking filter  232 . 
   In another particular illustrative embodiment, a white light source supplies white light  202  that passes through sample  341 . The light passing through the sample is directed onto a fixed grating  206  which divides the light  204  that has passed through the sample into multiple frequencies or band of frequencies (or bands of wavelengths) f 1 -f n    281 ,  283 ,  285  and  287 . The fixed grating directs a different frequency or different band of frequencies of light onto each of the mirrored members or elements in rows  254  and  256 . Similarly, light that has been reflected off of the sample can be divided into multiple frequencies or multiple bands of frequencies (or bands of wavelengths) f 1 -f n    281 ,  283 ,  285  and  287 . 
   Thus a single frequency or single band of frequencies can be selected for reflection of incident light impinging upon a particular mirrored member or element by turning on the mirrored member upon which the single frequency of incident light impinges. In one particular embodiment, the angle of the incident light  204  upon the two rows of mirrored members or elements is such that light is reflected only from the upper row  256  and not from the lower row  254 . Thus each one of the mirrored members in row  256  can be individually turned on one frequency or band of frequencies reflected by each of the mirrored members or elements in row  256  one at a time to collect light from reflected from the single element that is turned on. Thus, by directing a single frequency of band of frequencies onto individual mirrored members and turning the mirrored members on one at a time, light from the sample can be optically multiplexed in this manner to perform Hadamard spectroscopy to find spectral peaks for performing analysis of the sample  202 . 
   In another illustrative embodiment, the spacing  255  or distance between the upper  256  and lower  254  mirrored members can be controlled by member control electronics which changes the frequency of light reflected by the upper row  256  and lower row  254  of mirrored members. 
   Turning now to  FIG. 10 , a flow chart  1000  is shown wherein in another illustrative embodiment a fluid is exposed to light downhole at block  1002 . Different wavelengths of light that have interacted with a fluid light is directed toward a first optical grating at block  1004 . Light measured at different wavelengths is reflected from a first optical grating at block  1006 . Property of the fluid is estimated from the measured light at block  1008 . Light is selected from a group consisting of light reflecting off of the fluid and light passing through the fluid at block  1010 . A portion of the plurality of elements is activated on the first optical grating to select a band of wavelengths of light reflected by the activated portion at block  1012 . Different wavelengths of light are reflected that have interacted with fluid from a second optical grating that reflects a different wavelength of light onto each of the elements of the first optical grating at block  1012 . In another illustrative embodiment a secondary fluid is exposed to light at block  1014 . The property of the secondary fluid is estimated at block  1016 . The property of fluid is compared to the property of the second fluid at block  1018 . It is determined whether fluid derives from the same formation compartment as the secondary fluid at block  1020 . In another illustrative embodiment plurality of elements includes an upper row of elements alignment above a lower row of elements at block  1022 . A lower row of elements does not reflect light from the first optical grating at block  1024 . In another illustrative embodiment a Hadamard spectroscopy is performed on light measured from activated portion of first optical grating at block  1026 . Light reflected from each element of first optical grating is optically multiplexed at block  1028 . First optical grating includes tunable optical filter and elements include mirrored members at block  1030 . Light reflected from TOG filtered before reflected light is measured at block  1032 . 
   While the foregoing disclosure is directed to the exemplary embodiments of the invention various modifications will be apparent to those skilled in the art. It is intended that all variations within the scope of the appended claims be embraced by the foregoing disclosure. Examples of the more important features of the invention have been summarized rather broadly in order that the detailed description thereof that follows may be better understood, and in order that the contributions to the art may be appreciated.