In-SITU downhole fluid contamination quantative measurement system

The system uses impedance spectroscopy and machine learning to ensure contaminant-free downhole fluid sampling, improving reservoir evaluation and production efficiency by accurately identifying and quantifying fluid constituents.

WO2025226856A1PCT designated stage Publication Date: 2025-10-30BAKER HUGHES OILFIELD OPERATIONS LLC

Patent Information

Application Number
PCT/US2025/026036
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-04-24
Filing Date
2025-04-23
Publication Date
2025-10-30

AI Technical Summary

Technical Problem

Conventional downhole fluid sampling methods are prone to contamination from drilling fluids, leading to inaccurate fluid analysis and inefficient resource deployment, with uncertainties affecting reservoir evaluation and production optimization.

Method used

A system and method utilizing impedance spectroscopy with a sensor to perform chemical analysis, including Nyquist and Bode plots, and machine learning to identify and quantify fluid constituents, integrating temperature, density, and viscosity measurements to ensure contaminant-free sampling.

Benefits of technology

Provides accurate and cost-effective fluid sampling by identifying and quantifying contaminants, enhancing reservoir modeling and production optimization, reducing operational costs and uncertainties.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure US2025026036_30102025_PF_FP_ABST
    Figure US2025026036_30102025_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed herein is a method and system for analyzing wellbore fluid samples using impedance spectroscopy to identify chemical constituents and detect contaminants. The approach involves collecting fluid samples from a wellbore and performing chemical impedance spectroscopy by applying multiple discrete frequencies of alternating current, generating impedance spectra that are transformed into Nyquist and Bode plots for analysis. A data processing workflow handles raw impedance data through steps of labeling, cleaning incomplete sweeps, temperature thresholding, and temperature compensation to a reference standard. A hybrid modeling approach that integrates physics-based modeling (using a modified Randles circuit) with advanced data analytics techniques (utilizing Gaussian Process Regression) is utilized. Derived electrical properties, particularly susceptance and permittivity, are used to enhance the predictive capabilities of the model. This enables quantitative measurement of contaminants including mud filtrate and various salt types in wellbore fluids.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] IN-SITU DOWNHOLE FLUID CONTAMINATION QUANTATIVE MEASUREMENT SYSTEM

[0002] TECHNICAL FIELD

[0003] This disclosure relates generally to the field of downhole fluid sampling in oil and gas operations, and, in particular, to an improved system and method for obtaining contaminant-free fluid samples from a reservoir with enhanced cost-effectiveness.

[0004] BACKGROUND

[0005] Wellbores are drilled deep into the earth to access subterranean reservoirs for the extraction of fluids, such as oil and natural gas. The lifecycle of a well is commonly divided into two main phases, namely the exploration phase and the production phase. The exploration phase involves the initial search for hydrocarbons, including geological surveying and drilling activities to determine the presence and quantity of oil and gas. If the exploration yields positive results, operation transitions to the production phase, which focuses on the efficient extraction of these resources.

[0006] During both phases, obtaining representative samples of reservoir fluids is of interest. In the exploration phase, fluid analysis helps determine the commercial viability of the reservoir by identifying the properties of the fluids, such as chemical composition, pressure, temperature, and flow characteristics. In the production phase, ongoing analysis of these fluids can inform the optimization of extraction processes, the assessment of reservoir depletion, and the management of changes in fluid properties as extraction proceeds.

[0007] A primary objective of downhole fluid sampling is to procure samples that are free from contamination (mud filtrate, brine) and accurately represent the in-situ conditions of the reservoir. Contaminants often enter the sample from the drilling fluid, which can lead to significant deviations in the analytical results. These inaccuracies can, in turn, result in faulty reservoir evaluations and the formulation of recovery strategies that are less than ideal. To analyze fluid samples, sensors such as a tuning fork are used. A tuning fork is type of sensor that uses the principles of resonant frequency to distinguish between different types of fluids based on their viscosity and density. When these tuning forks encounter contamination, their ability to accurately identify fluid types is compromised, and replacement thereof is often then performed to provide for continued accuracy in fluid identification. A need for frequent replacement of tuning forks not only escalates operational costs but also contributes to higher uncertainties in fluid characterization. These uncertainties can introduce inaccuracies to estimates about the size and quality of the reservoir, potentially leading to inefficient or incorrect deployment of resources, which can be detrimental economically.

[0008] Additionally, it is of interest to determine the water saturation levels within reservoirs, especially in mixed salinity environments. This information is quite useful for calibrating reservoir models and optimizing production methods. Conventional systems and methodologies fall short in providing accurate data for these environments, resulting in less reliable modeling and forecasting. Consequently, further development so as to develop a new approach to downhole fluid sampling that overcomes the drawbacks of existing technologies and reduces the economic impact of uncertainties is necessary.

[0009] SUMMARY

[0010] Disclosed herein is a workflow to address the above-described challenges by providing a reliable and cost-effective solution for acquiring accurate downhole fluid samples. The workflow, in summary, includes the immersion of a sensor that would otherwise used for wellbore fluid analysis into a fluid sample, and the sensor is used to perform impedance spectroscopy to determine the chemical constituents of the fluid sample, provided there is a baseline fluid measurement to be used for comparison.

[0011] Specifically, disclosed herein is a method of sampling fluid in a wellbore that includes disposing a sampling tool into a wellbore. The method includes obtaining a sample of fluid within the wellbore and performing chemical impedance spectroscopy on the sample to thereby generate impedance spectra. The method includes generating Nyquist and Bode plots from the impedance spectra, and comparing the Nyquist and Bode plots to baseline measurements of known fluids to identify chemical constituents in the sample and chemical properties of the sample.

[0012] The method may include applying multiple discrete frequencies of alternating current to the sample and measuring a resulting impedance of the fluid at each frequency, wherein the Nyquist and Bode plots may be created based upon the measured impedances. The identification of chemical constituents in the sample may include determining an amount of contamination present in the sample based upon changes in impedance measurements and phase shifts at particular frequencies as compared to the baseline measurements of known fluids. The method may include collecting temperature, density, and viscosity measurements of the sample in conjunction with performing the chemical impedance spectroscopy, and integrating these measurements with the impedance spectroscopy data to create a dataset that reliably reflects the actual conditions of the wellbore environment.

[0013] The comparing step may include utilizing a machine learning model trained on a dataset representing a range of fluid conditions to identify the chemical constituents. The impedance spectroscopy may be performed using a sensor including a plurality of parallel disks arranged in a stacked configuration, wherein the disks may be alternately connected to positive and negative terminals. The method may include preprocessing the impedance spectra, including filtering the data and removing statistical outliers, prior to creating the Nyquist and Bode plots, wherein the preprocessing may create a dataset that reliably reflects the actual conditions of the wellbore environment. The identified chemical constituents may include water-based or oil-based mud filtrate contaminants. The method may include determining at least one of Total Acid Number (TAN) or Total Base Number (TBN) of the sample based on the identified chemical constituents.

[0014] Also disclosed herein is a system for analyzing fluid in a wellbore that includes a sampling tool configured to be disposed within a wellbore and to obtain a sample of fluid. The system includes an impedance spectroscopy sensor positioned within the sampling tool, the impedance spectroscopy sensor configured to apply multiple discrete frequencies of alternating current to the fluid sample and to measure resulting impedances to thereby generate impedance spectra. The system includes processing circuitry communicatively coupled to the impedance spectroscopy sensor, the processing circuitry configured to generate Nyquist and Bode plots from the impedance spectra and compare the Nyquist and Bode plots to baseline measurements of known fluids to identify chemical constituents in the sample and chemical properties of the sample.

[0015] The impedance spectroscopy sensor may include a plurality of parallel disks arranged in a stacked configuration, wherein the disks may be alternately connected to positive and negative terminals. The processing circuitry may be further configured to preprocess the impedance spectra, including filtering the data and removing statistical outliers, prior to generating the Nyquist and Bode plots, wherein the preprocessing may create a dataset that reliably reflects the actual conditions of the wellbore environment. The system may include sensors for collecting temperature, density, and viscosity measurements of the sample in conjunction with performing the chemical impedance spectroscopy, and wherein the processing circuitry may be configured to integrate these measurements with the impedance spectroscopy data to create a dataset that reliably reflects the actual conditions of the wellbore environment.

[0016] The comparing step may include utilizing a machine learning model trained on a dataset representing a range of fluid conditions to identify the chemical constituents. The identified chemical constituents may include water-based or oil-based mud filtrate contaminants. The processing circuitry may be further configured to determine at least one of Total Acid Number (TAN) or Total Base Number (TBN) of the sample based on the identified chemical constituents. The identification of chemical constituents in the sample may include determining an amount of contamination present in the sample based upon changes in impedance measurements and phase shifts at particular frequencies as compared to the baseline measurements of known fluids.

[0017] Also disclosed herein is a downhole fluid sampling system for quantitative measurement of fluid contamination that includes a fluid sampling tool configured for deployment within a wellbore and for obtaining a fluid sample. The system includes an impedance spectroscopy sensor integrated with the fluid sampling tool, the sensor including a plurality of parallel disks arranged in a stacked configuration on a central post, the disks being alternately connected to positive and negative terminals for applying multiple discrete frequencies of alternating current to the fluid sample and measuring a corresponding impedance response to thereby generate impedance spectra. The system includes at least one additional sensor configured to obtain corresponding measurements of the fluid sample. The system includes a processing unit operatively coupled to the impedance spectroscopy sensor and the at least one additional sensor, the processing unit configured to preprocess the impedance spectra by filtering data and removing statistical outliers, integrate the corresponding measurements from the at least one additional sensor with the preprocessed impedance spectra to create a dataset that reliably reflects wellbore conditions, generate Nyquist and Bode plots from the dataset that reliably reflects wellbore conditions, compare the Nyquist and Bode plots to baseline measurements of known fluids, and identify chemical constituents in the fluid sample based on the comparison. The system includes a machine learning module coupled to the processing unit and configured to analyze the integrated impedance spectroscopy data and the additional sensor measurements to quantify water saturation and contamination levels of the identified chemical constituents in the fluid sample. The at least one additional sensor may include at least one of a temperature sensor, a density sensor, and a viscosity sensor. The identification of chemical constituents in the fluid sample may include determining an amount of contamination present in the sample based upon changes in impedance measurements and phase shifts at particular frequencies as compared to the baseline measurements of known fluids. The identified chemical constituents may include water-based or oil-based mud filtrate contaminants. The processing unit may be further configured to determine at least one of Total Acid Number (TAN) or Total Base Number (TBN) of the fluid sample based upon the identified chemical constituents. The machine learning module may be trained on a dataset representing a range of fluid conditions.

[0018] Also disclosed herein is a method for fluid contamination detection in a wellbore that includes receiving Nyquist plots derived from impedance measurements taken from a fluid sample in a wellbore. Raw impedance data associated with the Nyquist plots is labeled according to fluid parameters including mud type, salt type, salt percentage, water percentage, and pressure conditions. The labeled impedance data is cleaned by identifying and discarding incomplete sweeps from the Nyquist plots where measured current exceeds safety thresholds during impedance measurements or where non-conductive conditions trigger hardware failure protections. The cleaned impedance data is thresholded by filtering out measurements wherein temperature stability during the impedance measurements varied by greater than a threshold temperature amount across a frequency sweep. Temperature compensation is performed by adjusting the thresholded impedance values to account for thermal variations, including scaling the thresholded impedance data to a reference temperature. Mud percentage quantification is determined by using regression on the cleaned, thresholded, and temperature-compensated impedance data.

[0019] The method may include determining mud percentage quantification by applying a hybrid model that combines physics-based modeling and data analytics modeling to the cleaned, thresholded, and temperature-compensated impedance data.

[0020] The physics-based model may employ a modified Randles circuit, and the data analytics modeling may use statistical techniques and machine learning.

[0021] The method may further include deriving electrical properties from the cleaned, thresholded, and temperature-compensated impedance data, including susceptance and permittivity, and inputting the derived electrical properties as additional parameters into the regression techniques used for mud percentage quantification. The temperature compensation may normalize the thresholded impedance data to account for how conductivity changes with temperature according to the relationship r1 = rO x eA(arxT), where r1 is the resistance at temperature T, rO is the baseline resistance at a reference temperature, and ar is the temperature coefficient.

[0022] The regression may employ independent variables derived from the cleaned, thresholded, and temperature-compensated impedance data, including temperature, pressure, salt percentage, salt types, mud types, flow speed, types of crude, permittivity, and susceptance.

[0023] The regression may utilize Gaussian Process Regression to analyze the cleaned, thresholded, and temperature-compensated impedance data.

[0024] The method may further include generating a training dataset containing multiple samples of the cleaned, thresholded, and temperature-compensated impedance data from known fluid compositions with varying mud percentages. The training dataset may be divided into training and testing subsets using a StratifiedGroupKFold method that preserves complete impedance sweeps in each subset. The training and testing subsets may be used to train and validate the regression techniques prior to applying the regression techniques to determine mud percentage quantification of unknown fluid samples.

[0025] Also disclosed herein is a system for analyzing fluid in a wellbore that includes a sampling tool configured to be disposed within a wellbore and to obtain a sample of fluid. An impedance spectroscopy sensor is positioned within the sampling tool, the impedance spectroscopy sensor configured to apply multiple discrete frequencies of alternating current to the fluid sample and to measure resulting impedances to thereby generate impedance spectra. Processing circuitry is communicatively coupled to the impedance spectroscopy sensor. The processing circuitry is configured to receive Nyquist plots derived from impedance measurements taken from the sample of fluid, label raw impedance data associated with the Nyquist plots according to fluid parameters including mud type, salt type, salt percentage, water percentage, and pressure conditions, clean the labeled impedance data by identifying and discarding incomplete sweeps from the Nyquist plots where measured current exceeds safety thresholds during impedance measurements or where non-conductive conditions trigger hardware failure protections, threshold the cleaned impedance data by filtering out measurements wherein temperature stability during the impedance measurements varied by greater than a threshold temperature amount across a frequency sweep, perform temperature compensation by adjusting the thresholded impedance values to account for thermal variations, including scaling the thresholded impedance data to a reference temperature, and determine mud percentage quantification by using regression on the cleaned, thresholded, and temperature-compensated impedance data.

[0026] The system may determine mud percentage quantification by applying a hybrid model that combines physics-based modeling and data analytics modeling to the cleaned, thresholded, and temperature-compensated impedance data.

[0027] The physics-based model may employ a modified Randles circuit, and the data analytics modeling may use statistical techniques and machine learning.

[0028] The processing circuitry may further be configured to derive electrical properties from the cleaned, thresholded, and temperature-compensated impedance data, including susceptance and permittivity, and input the derived electrical properties as additional parameters into the regression techniques used for mud percentage quantification.

[0029] The temperature compensation may normalize the thresholded impedance data to account for how conductivity changes with temperature according to the relationship r! = rO x eA(arxT), where r! is the resistance at temperature T, rO is the baseline resistance at a reference temperature, and ar is the temperature coefficient.

[0030] The regression may employ independent variables derived from the cleaned, thresholded, and temperature-compensated impedance data, including temperature, pressure, salt percentage, salt types, mud types, flow speed, types of crude, permittivity, and susceptance.

[0031] The regression may utilize Gaussian Process Regression to analyze the cleaned, thresholded, and temperature-compensated impedance data.

[0032] The processing circuitry may further be configured to generate a training dataset containing multiple samples of the cleaned, thresholded, and temperature-compensated impedance data from known fluid compositions with varying mud percentages, divide the training dataset into training and testing subsets using a StratifiedGroupKFold method that preserves complete impedance sweeps in each subset, and use the training and testing subsets to train and validate the regression techniques prior to applying the regression techniques to determine mud percentage quantification of unknown fluid samples.

[0033] BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a flowchart of workflow described herein for performing impedance spectroscope on a fluid sample in order to determine the chemical constituents of the fluid sample.

[0034] FIGS. 2-4 are Nyquist plots generated from collected chemical impedance spectra.

[0035] FIG. 5 is a sample first Bode plot.

[0036] FIG. 6 is a sample second Bode plot.

[0037] FIG. 7 is a graph used for calibration and comparison with collected chemical impedance spectra to determine components and constituents of fluid in the wellbore.

[0038] FIG. 8 is a second Bode plot showing identified contamination with carbonaceous materials.

[0039] FIGS. 9-13 are second Bode plots showing the effect of different contamination amounts on different drilling fluids.

[0040] FIG. 14 is a flowchart showing specifics of the quantitative analysis of the identified contaminants.

[0041] FIG. 15 is a cross sectional view of the impedance spectroscopy sensor used in making the measurements described hereinbelow.

[0042] FIG. 16 is a cross sectional view of the impedance spectroscopy sensor as collocated in a tool with density and viscosity sensors.

[0043] FIG. 17 is a flowchart of the fluid contamination detection workflow described herein.

[0044] FIG. 18 is a diagram of the Randles circuit equivalent model employed for analyzing electrochemical impedance spectroscopy data as per the workflow of FIG. 17.

[0045] FIG. 1 is a Nyquist plot showing crude oil impedance measurements at different temperatures taken using the impedance spectroscopy sensor described herein.

[0046] FIG. 20 is a Nyquist plot showing the same measurements as FIG. 22 after temperature correction to a standardized reference temperature, pursuant to the workflow of FIG. 17.

[0047] FIG. 21 is a Nyquist plot comparing different impedance curves for Carbo CaCI 20% salt calibration data.

[0048] FIG. 22 is an illustration of the Gaussian process regression model used in the workflow of FIG. 17, showing observed data points, confidence intervals, and the mean function estimated by the model for predicting wellbore fluid properties. FIG. 23 is a graph showing an example of the Gaussian Process Regression model's performance for imaginary impedance for Carbo and MgCI mud, displaying the mean prediction, sampled functions, and confidence bands.

[0049] FIG. 24 is a table illustrating variables considered in the analysis of wellbore fluid samples performed as per the workflow of FIG. 17.

[0050] FIG. 25 is a chart showing the distribution of Carbo samples by salt type used in model development and validation, such model being used in the workflow of FIG. 17.

[0051] FIG. 26 is a representation of the StratifiedGroupKFold method used for dividing datasets into training and testing subsets to be used in the workflow of FIG. 17.

[0052] FIG. 27 is a graph of prediction versus actual values for Carbo NaCI showing mud percentage predictions across different salt concentrations, demonstrating the accuracy of the analysis provided by the workflow of FIG. 17.

[0053] FIG. 28 is a graph of prediction versus actual values for Carbo CaCI showing mud percentage predictions across different salt concentrations, demonstrating the accuracy of the analysis provided by the workflow of FIG. 17.

[0054] DETAILED DESCRIPTION

[0055] The following disclosure enables a person skilled in the art to make and use the subject matter described herein. The general principles outlined in this disclosure can be applied to embodiments and applications other than those detailed above without departing from the spirit and scope of this disclosure. It is not intended to limit this disclosure to the embodiments shown, but to accord it the widest scope consistent with the principles and features disclosed or suggested herein.

[0056] In the context of a wellbore tool used for lubricant fluid analysis, commonly determined parameters of the lubricant include Total Acid Number (TAN), Total Base Number (TBN), Moisture, and Viscosity. While the definitions of moisture and viscosity are self-evident, Total Acid Number (TAN) measures the acidic constituents in a lubricant, and Total Base Number (TBN) is the counterpart to TAN and measures the alkaline constituents of the lubricant.

[0057] It has been found that the analysis performed by such wellbore tools on lubricants may also be performed on wellbore fluid samples, as the principles behind the measurements are applicable to a range of fluid types. In the context of wellbore fluid sampling, the measurement of contaminant like oil based or water-based mud filtrate and different types salt like Mg, Na, K is critical to ensure clean sample collection in the tank for further analysis. TAN would help in assessing the corrosiveness of the formation fluids, which would be of use in understanding the potential for corrosion-related issues within the wellbore. TBN could potentially indicate the buffering capacity of the fluids against acidic components, which may be relevant in certain scenarios, such as when dealing with the injection of treatment fluids. Naturally, water content analysis is of interest because water can significantly affect the properties of the formation fluids.. Finally, density and viscosity measurements are of interest for understanding the flow characteristics of the formation fluids, which impact the design of the completion strategy and the prediction of production rates.

[0058] The workflow is now described with reference to the flowchart 10 of FIG. 1 and begins with running of lowering of a sampling tool into the wellbore (11 ) add the collection of a fluid sample (12). The sensor is immersed inthe fluid sample, and then applies multiple (e.g., 28) discrete or continuous frequencies of alternating current to the fluid, and the resulting impedance at each frequency is measured, otherwise known as the performing of impedance spectroscopy (13). Nyquist and Bode plots are then generated from the impedance spectra (14), either using processing circuitry within the sampling tool or using processing circuitry located uphole.

[0059] In impedance spectroscopy, a Nyquist plot represents the complex impedance as a coordinate in the complex plane. The x-axis (e.g., real axis) shows the real part of the impedance (e.g., resistance), and the y-axis (e.g., imaginary axis) shows the imaginary part of the impedance (e.g., reactance). Each point on the plot corresponds to one of the discrete frequencies applied by the sensor. These points can reveal details about the fluid's electrochemical properties that vary with frequency. Example of a Nyquist plots formed using the workflow described herein may be observed at FIGS. 2-4.

[0060] A first Bode Plot graphs the magnitude (or modulus) of the impedance (e.g., in decibels) versus the frequency (logarithmic scale). It shows how the total impedance changes with frequency. An example first Bode plot formed using the workflow described herein may be observed at FIG. 5.

[0061] A second Bode plot shows the phase angle (e.g., the phase difference between the voltage and current) versus the frequency (logarithmic scale). It illustrates the frequencydependent phase shift caused by the fluid's capacitive and inductive elements. An example second Bode plot may be observed at FIG. 6. In impedance spectroscopy, a Bode plot is used to graphically represent the response of a fluid sample when subjected to an alternating current (AC) at various frequencies. This Bode plot includes two separate graphs, namely, a magnitude plot (first Bode plot) and a phase plot (second Bode plot).

[0062] The first Bode plot illustrates the magnitude of the impedance, expressed in decibels (dB), against the frequency. This plot shows how the overall impedance, which is the fluid's resistance to the flow of the AC, changes as the frequency of the AC voltage changes. The magnitude captures both the resistive (real) and reactive (imaginary) components of impedance.

[0063] The second Bode plot displays the phase angle, which is the phase difference between the applied voltage and the resulting current, against the frequency. The phase angle indicates whether the current leads or lags the voltage and by how much (the voltage referred to here is the AC voltage applied across the fluid, with the current being the result of this applied voltage). This phase shift occurs because the fluid's properties cause it to store and release energy differently at various frequencies, typically due to its capacitive and inductive elements. Capacitive elements can cause the current to lead the voltage, while inductive elements cause the current to lag.

[0064] The plots are analyzed in comparison to baseline measurements of known fluids to identify deviations indicative of the chemical constituents present in the sample (1 5), using the processing circuitry - a sample dataset used as these baseline measurements may be seen in FIG. 7, showing the effect of mud contamination on the impedance measurement. For example of identified chemical constituents, water or water / oil based mud filtrate has distinct dielectric properties as compared to hydrocarbons, and the presence of water therefore changes the impedance of the fluid mixture, particularly at specific frequencies where water or water / oil based mud filtrate molecules respond more strongly to an electric field. Also, water or water / oil based mud filtrate in a fluid mixture can increase the capacitive behavior of the fluid due to its polar nature. This will be evident in the Bode plot as a phase shift at particular frequencies and will be evident in the Nyquist plot as a larger semicircle at high frequencies, as this is associated with the polarization of water molecules.

[0065] Upon identifying the constituents, the information is utilized to make informed decisions regarding the composition and quality of the wellbore fluids, allowing for contaminant free sample collection in downhole. For example, shown in FIG. 8 is a second Bode plot showing identified contamination with carbonaceous materials and that way in which that contamination affects the identification of different inorganic salts in the wellbore. Shown in FIGS. 9-13 is a second Bode plot showing the effect of different contamination amounts on a variety of different drilling fluids.

[0066] As can be appreciated from the above, this disclosure is directed to the use of impedance spectroscopy (EIS) to delineate and differentiate different contributions within the electrochemical processes occurring in wellbore fluids. As explained above, EIS operates by imposing a small perturbation signal at varying frequencies to the fluid and measuring the resulting impedance, allowing the characterization of electrochemical kinetics and mass transport phenomena.

[0067] Variations in the time constants associated with these processes enable EIS to distinguish between different electrochemical phenomena. The collected EIS data contain a large amount of electrochemical information regarding the fluid's properties and can be interpreted through the construction of an equivalent circuit model. Such a model replicates the impedance behavior of the actual electrochemical system using a combination of model resistors, capacitors, and inductors to represent the various processes at play. In addition to circuit modeling, data processing techniques, including multivariate data analysis and distribution-based analyses may be performed to manage the complexity of the impedance data. Machine learning-based approaches can also be applied to identify and determine patterns / trends within the data, providing for assistance with the identification and quantification of contaminants in the wellbore fluid. The combination of these analytical techniques allows for a fairly complete understanding of the wellbore fluid's composition and reactivity, facilitating the detection of contaminant species with overlapping electrochemical signatures.

[0068] Despite this, the interpretation of EIS data remains challenging due to the aforementioned concurrent occurrence of multiple physical processes that contribute to the overall measured impedance yet exhibit significantly overlapping responses within the frequency domain.

[0069] This disclosure proposes a systematic approach to processing the inherently noisy impedance spectra obtained from downhole fluids across various domains including frequency, temperature, density, and viscosity. This is achieved by capturing data from a multiplicity of sensing modalities. A combination of physics-based and machine learning (ML) data analysis techniques is employed to not only deconvolute the complex impedance responses but also to derive and extract meaningful parameters that can be directly correlated with the inherent properties of the wellbore fluid and the presence of specific contaminants therein.

[0070] To assist, a machine learning model may be trained on a diverse dataset representing a range of mixed salinity conditions, and such a model can accurately quantify water saturation within the reservoir by recognizing patterns in the impedance data that are indicative of water in various states of mixture with hydrocarbons. By correlating certain frequencies with specific fluid characteristics, the model can isolate the signals attributable to water content from those related to other constituents such as contaminants, even in mixed salinity conditions.

[0071] This determination of presence of contaminants and the quantitative analysis thereof by the processing circuitry is now described with reference to FIG. 14. First, EIS, temperature, density, and viscosity measurements are taken through the use of appropriate tools in conjunction with the EIS tool (21).

[0072] Incoming impedance spectra is preprocessed in the frequency domain (22). This involves filtering techniques to purify the data stream, the removal of statistical outliers, the verification of data completeness, and the integration of sensor data across different measurement modalities. This preprocessing is designed to create a dataset that reliably reflects the actual conditions of the wellbore environment.

[0073] Next, the preprocessed data is subject to a fitting process where related electrical parameters are extracted (23). Employing equivalent circuit modeling and distributionbased analysis, the electrochemical properties of the wellbore fluid are inferred from the impedance data, creating a mathematical representation that mirrors the physical phenomena within the fluid.

[0074] Further analysis of relevant features derived from the electrical parameters then follows (24). Matrix factorization methods are applied to deconstruct the dataset, reducing its dimension and distilling the essence of the information. Statistical modeling is then utilized to discern structures and patterns within the data, which may correlate with specific chemical constituents.

[0075] With these features identified, the chemical properties of the wellbore fluid are quantified and its contaminants are estimated (25). This is achieved through multivariate data analysis and regression techniques, alongside the use of the above described machine learning model that has been trained to recognize and interpret patterns indicative of water saturation and contaminant presence within mixed salinity conditions. Finally, utilizing the refined and analyzed data, Nyquist and Bode plots are generated (26), from which both the presence and the concentration of various contaminants can be determined.

[0076] FIG. 15 illustrates the construction of the impedance spectroscopy sensor (30) employed in the workflow described herein. The sensor includes eight parallel disks (31), each affixed to a central post, forming the core sensing element. These disks (31) are configured in a stacked arrangement along the post, providing for a compact and efficient design for impedance measurements under the high-pressure high-temperature (HPHT) conditions often present in wellbores.

[0077] Electrical connections to the sensor are facilitated by high-quality HPHT feedthroughs (32), which provide robust electrical paths from an external signal generator to each disk. The disks (31 ) are alternately connected to the positive and negative terminals of the signal generator: disks positioned at even intervals along the post are connected to the positive terminal, while those at odd intervals are connected to the negative terminal. This alternating connection scheme provides for the functionality of the sensor, as it allows for the generation and propagation of electrical signals through the sensor.

[0078] The sensor's (30) disks (31 ) may be excited using a variety of waveforms, including sine and sawtooth waves, used for performing the impedance spectroscopy described herein. Indeed, the application of these waveforms stimulates the disks to produce an electrical field that permeates the surrounding fluid, with the impedance of the fluid modulating the response detected by the sensor.

[0079] FIG. 16 is a cross-sectional view of the impedance spectroscopy sensor (30) as it is integrated within a downhole tool that also houses density (33) and viscosity (34) sensors. This collocation combines the measurement capabilities of each sensor type within a single tool, ensuring that the impedance measurements are conducted in close spatial relation to the density and viscosity measurements, allowing for the correlation of data from these different sensing modalities. By harmonizing the sensor outputs in this fashion, a more detailed and precise characterization of the wellbore fluid properties may be achieved.

[0080] The workflow described above with reference to FIG. 14 provides a general overview of data collection and the analysis of contaminants in wellbore fluids. Now described with reference to FIGS. 17-26 is continuation or expansion of the workflow (for example, using the data obtained at step 26 in FIG. 14), which illustrates data analysis and predictive modeling approaches utilized for fluid contamination detection. This workflow utilizes a hybrid modeling approach that combines two complementary methodologies: physics-based modeling employing a modified Randles circuit to simulate the electrical properties of the mud system, and data analytics modeling built entirely from collected measurements using statistical techniques and machine learning. These two approaches are integrated to create a unified hybrid model. This hybrid modeling strategy provides for the identification and quantification of contaminants in the wellbore fluid (particularly mud percentage and type), as well as determination of ion concentrations (potassium, sodium, calcium). Note that in the description of the workflow below, the various steps are performed either using processing circuitry within the sampling tool or using processing circuitry located uphole.

[0081] The workflow begins with input Nyquist plots (41 ) derived from the impedance measurements taken using the sensor (30) described herein above with reference to in FIG. 15, which is immersed in the fluid sample as per step 13 of FIG. 1. These Nyquist plots represent the complex impedance data obtained from the 28 discrete frequencies applied to the fluid sample during the impedance spectroscopy measurements.

[0082] The workflow then continued with labeling (42), which involves categorizing the raw impedance data according to various parameters. This labeling is not merely an analysis of the Nyquist plots themselves, but rather a process of associating the impedance data with known fluid parameters to create a structured dataset for model development. The parameters included in this labeling are mud type (such as Delta, Carbo, or Maxbridge), salt type (KCI, CaCI, MgCI, NaCI), salt percentage, water percentage, and pressure conditions. This labeling establishes the connections between impedance signatures and fluid compositions across many permutations of these parameters.

[0083] The workflow continues with cleaning incomplete sweeps (43), a quality control step that provides for data integrity. This addresses two specific scenarios where impedance measurements may be compromised. In the first scenario, when highly conductive fluids (such as those with high salt content) are encountered, the current during measurement can exceed safety thresholds, triggering over-current protections in the sensor hardware and causing the sweep to terminate prematurely. In the second scenario, non-conductive oils may result in an open circuit condition, triggering hardware failure protections. In both cases, the incomplete sweep data cannot be used for analysis and is therefore discarded during the cleaning (43) to prevent the introduction of noise in the subsequent processing steps. Following this, thresholding temperatures (44) is performed, which further filters the data based on temperature stability during measurements. This step is of particular concern because electrochemical impedance spectroscopy is highly sensitive to temperature variations. The displacement current and conductive current of the liquid can change drastically with temperature, significantly affecting the impedance readings. To maintain data quality, any frequency sweep during which the temperature changes by more than a defined threshold determined by experimentation is discarded. This ensures that only measurements taken under stable thermal conditions (with temperature variation less than a threshold across all 28 frequencies in a sweep, with it being understood there may be any number of frequencies used in a sweep depending on specific application and the specific hardware used) are included in the analysis, minimizing the impact of temperature- induced variations on the impedance spectra.

[0084] Shown in FIG. 18 is the equivalent circuit model used in this workflow for analyzing the electrochemical impedance spectroscopy data. This model is a modified form of the Randles circuit, tailored to capture the electrochemical behavior of wellbore fluids interacting with the sensor.

[0085] The circuit diagram shows four components, namely:

[0086] Zresistor: This corresponds to the ohmic series resistance of the fluid solution, representing how easily ions can move through the fluid. This component is primarily affected by the ionic concentration and temperature of the fluid;

[0087] ZCPE: The Constant Phase Element, which models the non-ideal capacitive behavior at the electrode-fluid interface. Unlike an ideal capacitor, a CPE accounts for surface roughness and non-uniform current distributions;

[0088] ZW: The Warburg impedance, which represents diffusion-limited electrochemical processes in the fluid. This component models how charged species diffuse through the solution; and

[0089] ZC: The capacitive element, which represents the displacement current in the system, accounting for the ability of the fluid to store electrical charge.

[0090] In the mathematical representation of this circuit, the components are arranged where Z1 represents one branch of the circuit and Z2 represents another. Specifically:

[0091] Z1 = Zresistor + ZCPE + ZW and Z2 = ZC

[0092] The total impedance (Z_total) is calculated using the parallel combination of these branches:

[0093] Ztotal = (Z1 x Z2) / (Z1 + Z2) = Zreal + jZimag Where Zreal represents the real (resistive) component of the impedance and Zimag represents the imaginary (reactive) component.

[0094] The temperature dependence of the model is primarily observed in the resistive component Zresistor, which follows the following relationship: r1 = rO x eA(arxT)

[0095] In this equation r1 is the resistance at temperature T, rO is the baseline resistance (at a reference temperature), ar is the temperature coefficient (a negative value), and T is the temperature.

[0096] This relationship shows how the fluid's conductivity increases (and thus resistance decreases) as temperature rises. When temperature increases, ions move more freely through the fluid, reducing the resistive component.

[0097] The data next undergoes temperature compensation (45), which adjusts the impedance values to account for the effects of thermal variations. This step is particularly important because the models developed in laboratory conditions typically cover a limited temperature range (up to approximately 100°C), while wellbore conditions can reach temperatures up to 200°C or higher. The temperature compensation algorithm allows models trained at one temperature (e.g., 50°C) to be applied at different temperatures. This is accomplished by scaling the impedance data to a reference temperature (typically 50°C), enabling consistent comparison across samples collected at different thermal conditions. The temperature compensation normalizes the data to account for how conductivity changes with temperature, as higher temperatures generally result in increased conductivity and consequently lower resistance values.

[0098] FIGS. 19 and 20 show Nyquist plots for crude oil samples at different temperatures. FIG. 1 in particular displays the plots for crude oil between 75°C and 18°C, visualizing how temperature affects the impedance measurements. The differences between the curves at different temperatures highlight the necessity of temperature compensation in the workflow. FIG. 20 shows these same plots after temperature correction to a standardized 50°C reference temperature, demonstrating the effectiveness of the temperature compensation algorithm in normalizing the data.

[0099] Shown in FIG. 21 is a Nyquist plot showing the comparison between two different impedance curves, illustrating an example of the Carbo CaCI 20% salt calibration data, demonstrating how different compositions or conditions create distinguishable impedance patterns that can be analyzed to identify specific fluid characteristics.

[0100] In an example, the impedance analyzer sensor captures sweeps ranging from 0.08 Hz to 100 kHz, measuring both real impedance (Zr), phase and imaginary impedance (Zi) components. From these measurements, additional parameters are derived to enhance the model's predictive capabilities. Specifically, two electrical properties are calculated: susceptance and permittivity. Susceptance is the imaginary component of admittance (the inverse of impedance) and represents how easily alternating current flows through the capacitive or inductive components of the fluid; it is computed as yi = -Zi / (Zr2+Zi2) and yr = Zr / (Zr2+Zi2). Permittivity, which characterizes how the fluid stores and transmits electrical charge in response to an electric field, is calculated as ereal = yi / 2ncoeO and eimag = yr / ncosO, where sO is the permittivity of free space and co is the angular frequency 2nf. These electrical properties are particularly sensitive to the presence of polar molecules like water and various ions, making them valuable indicators of fluid composition.

[0101] For the next stage of the workflow (46), a Gaussian Process Regression technique or a neural network may be utilized as the data analytics component of the hybrid model. This technique, when integrated with the physics-based Randles circuit model described earlier, achieves high accuracy in predicting contaminant levels.

[0102] Shown in FIG. 22 is an illustration of the Gaussian process regression model. Gaussian process regression is a non-parametric model that approximates a probability distribution over possible functions that fit the training set of data (observed points). As illustrated in FIG. 23, the mean function obtained from the posterior distribution of the possible functions is used to make predictions. The prior function gets updated with new observations in the data, and since the model maintains a probability distribution over all functions, it provides an indicator of prediction confidence as shown by the gray shaded area in the figure.

[0103] The regression function modeled by a multivariate Gaussian is given by:

[0104] P(f IX) = N(f|p,K) where X=[x1,..., xn] represents the observed data points, f = ^(x,),...,^^] represents the function values, p = [m(x1),...,m(xn)] is the mean function, and Kij = k(xj,Xj) is the kernel function.

[0105] FIG. 23 provides an example of the Gaussian Process Regression model's performance for a specific feature input, in this case showing the imaginary impedance (Zi) at 10Okhz as an input variable for predictions involving Carbo and MgCI mud. The figure illustrates how the mean function (solid line) is approximated given the training set of observations (gray dots), along with five sampled functions and the standard deviation confidence band. This visualization demonstrates how the model captures uncertainty in its predictions, which is particularly valuable when dealing with the inherently complex and noisy measurements obtained in wellbore environments.

[0106] The inputs used for the GPR model include multiple electrical parameters derived from the impedance measurements, including real and imaginary impedance components at each frequency, susceptance and permittivity values calculated as described above, solubility per temperature range, salt percentage, and mud type.

[0107] The selection of an appropriate kernel function impacts how smoothly the model fits the training data and represents a critical hyperparameter that was carefully tuned during model development. This tuning process ensures that the model strikes an optimal balance between fitting the training data accurately and maintaining generalization capabilities when presented with new, previously unseen wellbore fluid samples.

[0108] The GPR modeling approach provides several advantages in this application, including built-in uncertainty quantification, the ability to work effectively with limited training data, and flexibility in modeling complex, non-linear relationships between impedance measurements and fluid properties. These characteristics make it particularly well-suited for quantifying contaminants in wellbore fluids, where measurement conditions can vary significantly and the relationships between electrical properties and fluid composition are inherently complex.

[0109] Having established the mathematical foundation of the GPR model, the following figures illustrate the variables used and the validation results obtained using this approach. Finally, mud percentage quantification (47) is performed using regression techniques. This step is where the cleaned, thresholded, and temperature-compensated impedance data is analyzed to determine the precise levels of contaminants present in the wellbore fluid. The regression analysis employs various independent variables, including but not limited to: temperature, pressure, salt percentage, salt types, mud types (OBM, WBM), flow speed, types of the crude (API), permittivity, and susceptance.

[0110] FIG. 24 is a table illustrating the variables considered in the analysis. The table displays the input variables and the output variable, specifically: salt types including KCI, CaCI, MgCI, and NaCI; salt concentration percentages ranging from 1 -40%; mud types including Delta, Carbo, and Maxbridge; water content percentages of 20% for KCI, 35% for CaCI, and other values; temperature values of 25°C, 50°C, and 75°C; and contamination percentages of 2%, 5%, 10%, and 20% respectively. This sample data illustrates the range of conditions under which the impedance measurements may be collected and analyzed, and represents the pernnutation combinations used to create the comprehensive dataset for model training.

[0111] FIG. 25 is a chart visualizing the number of samples for each salt type used in the development and validation of the predictive models. This graph displays the relative frequency of different salt types within collected samples, showing CaCI with 105 samples, KOI with 60 samples, MgCI with only 4 samples, and NaCI with 107 samples. The distribution indicates different salt compositions in the dataset, with a particular emphasis on calcium chloride and sodium chloride, which are common in wellbore environments.

[0112] Shown in FIG. 26 is a representation of the StratifiedGroupKFold method used for dividing the dataset into training and testing subsets. This cross-validation technique follows the standard 80 / 20 rule, where 80% of the data is used for training and 20% for testing. To avoid biasing the model, the data is shuffled and divided into random groups while ensuring that complete impedance sweeps are preserved in each subset. The method implements a K-fold approach (with K=4 in this case, representing iterations 0 through 3), where different portions of the dataset are selected for testing across multiple iterations. As shown in the figure, certain sections represent the training set and certain other sections represent the testing set. This approach ensures that samples from the beginning, middle, and end of the experimental data collection are included in both training and testing sets, thereby minimizing potential temporal bias in the data.

[0113] Shown in FIG. 27 is a graph of prediction versus actual values for Carbo NaCI, showing mud percentage predictions across different salt concentrations (1 %, 10%, 20%) with a consistent water content of 20%. The diagonal line represents perfect prediction, and the proximity of the data points to this line demonstrates the model's accuracy in predicting mud contamination levels. An RMSE value less than 1 .0 indicates approximately 99% accuracy in the predictions, confirming the high precision of the model in quantifying contamination levels.

[0114] Shown in FIG. 28 is a similar graph of prediction versus actual values but for Carbo CaCI, displaying results for salt concentrations of 1 %, 10%, 20%, and 30% with a water content of 20%. The consistent performance across different salt types and concentrations demonstrates the robustness of the model in handling various fluid compositions.

[0115] Through this workflow, the impedance spectroscopy-based workflow provides a solution for precisely quantifying contaminants and ion concentrations in complex wellbore environments, enabling enables more informed decision-making in both the exploration and production phases, ultimately leading to optimized resource utilization and improved operational efficiency.

[0116] Finally, practical applications of the above workflows of FIGS. 14 and 17 and their influence on operator decision making should be appreciated. The downhole fluid characterization capabilities enable operators to make immediate, data-driven decisions about sample quality while still at the wellsite. When contamination is detected above acceptable thresholds, operators can continue pumping until cleaner formation fluid is obtained, saving costs by preventing the collection of compromised samples that would require redeployment of sampling tools. Improved drilling operations safety is achieved as operators can respond to the detection of corrosive elements by adjusting mud chemistry and selecting appropriate equipment materials, preventing failures and reducing downtime. The optimized reservoir development planning facilitated by precise fluid characterization allows production engineers to select suitable equipment and treatment programs based on the specific fluid properties identified, while reservoir engineers can create more accurate simulation models leading to better well placement decisions and optimized production strategies that maximize recovery while minimizing formation damage.

[0117] It is evident that modifications and variations can be made to what has been described and illustrated herein without departing from the scope of this disclosure.

[0118] Although this disclosure has been described with a limited number of embodiments, those skilled in the art, having the benefit of this disclosure, can envision other embodiments that do not deviate from the disclosed scope. Furthermore, skilled persons can envision embodiments that represent various combinations of the embodiments disclosed herein made in various ways.

Claims

CLAIMS1 . A method of sampling fluid in a wellbore, comprising: disposing a sampling tool into a wellbore; obtaining a sample of fluid within the wellbore; performing chemical impedance spectroscopy on the sample to thereby generate impedance spectra; generating Nyquist and Bode plots from the impedance spectra; and comparing the Nyquist and Bode plots to baseline measurements of known fluids to identify chemical constituents in the sample and chemical properties of the sample.

2. The method of claim 1, wherein performing the impedance spectroscope on the sample comprises applying multiple discrete frequencies of alternating current to the sample and measuring a resulting impedance of the fluid at each frequency; and wherein the Nyquist and Bode plots are created based upon the measured impedances.

3. The method of claim 2, wherein the identification of chemical constituents in the sample includes determining an amount of contamination present in the sample based upon changes in impedance measurements and phase shifts at particular frequencies as compared to the baseline measurements of known fluids.

4. The method of claim 1, further comprising collecting temperature, density, and viscosity measurements of the sample in conjunction with performing the chemical impedance spectroscopy, and integrating these measurements with the impedance spectroscopy data to create a dataset that reliably reflects the actual conditions of the wellbore environment.

5. The method of claim 1, wherein the comparing step includes utilizing a machine learning model trained on a dataset representing a range of fluid conditions to identify the chemical constituents.

6. The method of claim 1, wherein the impedance spectroscopy is performed using a sensor comprising a plurality of parallel disks arranged in a stacked configuration, wherein the disks are alternately connected to positive and negative terminals.

7. The method of claim 1, further comprising preprocessing the impedance spectra, including filtering the data and removing statistical outliers, prior to creating the Nyquist and Bodeplots, wherein the preprocessing creates a dataset that reliably reflects the actual conditions of the wellbore environment.

8. The method of claim 1 , wherein the identified chemical constituents include waterbased or oil-based mud filtrate contaminants.

9. The method of claim 1, further comprising determining at least one of Total Acid Number (TAN) or Total Base Number (TBN) of the sample based on the identified chemical constituents.

10. A system for analyzing fluid in a wellbore, comprising: a sampling tool configured to be disposed within a wellbore and to obtain a sample of fluid; an impedance spectroscopy sensor positioned within the sampling tool, the impedance spectroscopy sensor configured to apply multiple discrete frequencies of alternating current to the fluid sample and to measure resulting impedances to thereby generate impedance spectra; and processing circuitry communicatively coupled to the impedance spectroscopy sensor, the processing circuitry configured to: generating Nyquist and Bode plots from the impedance spectra; and comparing the Nyquist and Bode plots to baseline measurements of known fluids to identify chemical constituents in the sample and chemical properties of the sample.11 . The system of claim 10, wherein the impedance spectroscopy sensor comprises a plurality of parallel disks arranged in a stacked configuration, wherein the disks are alternately connected to positive and negative terminals.

12. The system of claim 10, wherein the processing circuitry is further configured to preprocess the impedance spectra, including filtering the data and removing statistical outliers, prior to generating the Nyquist and Bode plots, wherein the preprocessing creates a dataset that reliably reflects the actual conditions of the wellbore environment.

13. The system of claim 10, further comprising sensors for collecting temperature, density, and viscosity measurements of the sample in conjunction with performing the chemical impedance spectroscopy, and wherein the processing circuitry is configured to integrate these measurements with the impedance spectroscopy data to create a dataset that reliably reflects the actual conditions of the wellbore environment.

14. The system of claim 10, wherein the comparing step includes utilizing a machine learning model trained on a dataset representing a range of fluid conditions to identify the chemical constituents.

15. The system of claim 10, wherein the identified chemical constituents include waterbased or oil-based mud filtrate contaminants.

16. The system of claim 10, wherein the processing circuitry is further configured to determine at least one of Total Acid Number (TAN) or Total Base Number (TBN) of the sample based on the identified chemical constituents.

17. The system of claim 10, wherein the identification of chemical constituents in the sample includes determining an amount of contamination present in the sample based upon changes in impedance measurements and phase shifts at particular frequencies as compared to the baseline measurements of known fluids.

18. A downhole fluid sampling system for quantitative measurement of fluid contamination, comprising: a fluid sampling tool configured for deployment within a wellbore and for obtaining a fluid sample; an impedance spectroscopy sensor integrated with the fluid sampling tool, the sensor comprising: a plurality of parallel disks arranged in a stacked configuration on a central post, the disks being alternately connected to positive and negative terminals for applying multiple discrete frequencies of alternating current to the fluid sample and measuring a corresponding impedance response to thereby generate impedance spectra; at least one additional sensor configured to obtain corresponding measurements of the fluid sample; a processing unit operatively coupled to the impedance spectroscopy sensor and the at least one additional sensor, the processing unit configured to preprocess the impedance spectra by filtering data and removing statistical outliers, integrate the corresponding measurements from the at least one additional sensor with the preprocessed impedance spectra to create a dataset that reliably reflects wellbore conditions, generate Nyquist and Bode plots from the dataset that reliably reflects wellbore conditions, compare the Nyquist and Bode plots to baseline measurements of known fluids, and identify chemical constituents in the fluid sample based on the comparison; and a machine learning module coupled to the processing unit and configured to analyze the integrated impedance spectroscopy data and the additional sensor measurements to quantify water saturation and contamination levels of the identified chemical constituents in the fluid sample.

19. The downhole fluid sampling system of claim 18, wherein the at least one additional sensor comprises at least one of a temperature sensor, a density sensor, and a viscosity sensor.

20. The downhole fluid sampling system of claim 18, wherein the identification of chemical constituents in the fluid sample includes determining an amount of contamination present in the sample based upon changes in impedance measurements and phase shifts at particular frequencies as compared to the baseline measurements of known fluids.21 . The system of claim 10, wherein the identified chemical constituents include waterbased or oil-based mud filtrate contaminants.

22. The downhole fluid sampling system of claim 18, wherein the processing unit is further configured to determine at least one of Total Acid Number (TAN) or Total Base Number (TBN) of the fluid sample based upon the identified chemical constituents.

23. The downhole fluid sampling system of claim 18, wherein the machine learning module is trained on a dataset representing a range of fluid conditions.

24. A method for fluid contamination detection in a wellbore, comprising: receiving Nyquist plots derived from impedance measurements taken from a fluid sample in a wellbore; labeling raw impedance data associated with the Nyquist plots according to fluid parameters including mud type, salt type, salt percentage, water percentage, and pressure conditions; cleaning the labeled impedance data by identifying and discarding incomplete sweeps from the Nyquist plots where measured current exceeds safety thresholds during impedance measurements or where non-conductive conditions trigger hardware failure protections; thresholding the cleaned impedance data by filtering out measurements wherein temperature stability during the impedance measurements varied by greater than a threshold temperature amount across a frequency sweep; performing temperature compensation by adjusting the thresholded impedance values to account for thermal variations, including scaling the thresholded impedance data to a reference temperature; and determining mud percentage quantification by using regression on the cleaned, thresholded, and temperature-compensated impedance data.

25. The method of claim 24, wherein determining mud percentage quantification includes applying a hybrid model that combines physics-based modeling and data analytics modeling to the cleaned, thresholded, and temperature-compensated impedance data.

26. The method of claim 25, wherein the physics-based model employs a modified Randles circuit; and wherein the data analytics modeling uses statistical techniques and machine learning.

27. The method of claim 24, further comprising: deriving electrical properties from the cleaned, thresholded, and temperature-compensated impedance data, including susceptance and permittivity; and inputting the derived electrical properties as additional parameters into the regression techniques used for mud percentage quantification28. The method of claim 24, wherein the temperature compensation normalizes the thresholded impedance data to account for how conductivity changes with temperature according to the relationship r1 = rO x eA(arxT), where r1 is the resistance at temperature T, rO is the baseline resistance at a reference temperature, and ar is the temperature coefficient.

29. The method of claim 24, wherein the regression employs independent variables derived from the cleaned, thresholded, and temperature-compensated impedance data, including temperature, pressure, salt percentage, salt types, mud types, flow speed, types of crude, permittivity, and susceptance.

30. The method of claim 24, wherein the regression utilizes Gaussian Process Regression to analyze the cleaned, thresholded, and temperature-compensated impedance data.31 . The method of claim 24, further comprising: generating a training dataset comprising multiple samples of the cleaned, thresholded, and temperature-compensated impedance data from known fluid compositions with varying mud percentages; dividing the training dataset into training and testing subsets using a StratifiedGroupKFold method that preserves complete impedance sweeps in each subset; and using the training and testing subsets to train and validate the regression techniques prior to applying the regression techniques to determine mud percentage quantification of unknown fluid samples.

32. A system for analyzing fluid in a wellbore, comprising: a sampling tool configured to be disposed within a wellbore and to obtain a sample of fluid; an impedance spectroscopy sensor positioned within the sampling tool, the impedance spectroscopy sensor configured to apply multiple discrete frequencies of alternating current to the fluid sample and to measure resulting impedances to thereby generate impedance spectra; and processing circuitry communicatively coupled to the impedance spectroscopy sensor, the processing circuitry configured to: receive Nyquist plots derived from impedance measurements taken from the sample of fluid; label raw impedance data associated with the Nyquist plots according to fluid parameters including mud type, salt type, salt percentage, water percentage, and pressure conditions; clean the labeled impedance data by identifying and discarding incomplete sweeps from the Nyquist plots where measured current exceeds safety thresholds during impedance measurements or where non-conductive conditions trigger hardware failure protections; threshold the cleaned impedance data by filtering out measurements wherein temperature stability during the impedance measurements varied by greater than a threshold temperature amount across a frequency sweep; perform temperature compensation by adjusting the thresholded impedance values to account for thermal variations, including scaling the thresholded impedance data to a reference temperature; and determine mud percentage quantification by using regression on the cleaned, thresholded, and temperature-compensated impedance data.

33. The system of claim 32, wherein determining mud percentage quantification includes applying a hybrid model that combines physics-based modeling and data analytics modeling to the cleaned, thresholded, and temperature-compensated impedance data.

34. The system of claim 33, wherein the physics-based model employs a modified Randles circuit; and wherein the data analytics modeling uses statistical techniques and machine learning.

35. The system of claim 32, wherein the processing circuitry is further configured to: derive electrical properties from the cleaned, thresholded, and temperature-compensated impedance data, including susceptance and permittivity; and input the derived electrical properties as additional parameters into the regression techniques used for mud percentage quantification.

36. The system of claim 32, wherein the temperature compensation normalizes the thresholded impedance data to account for how conductivity changes with temperature according to the relationship rl = rO x eA(arxT), where rl is the resistance at temperature T, rO is the baseline resistance at a reference temperature, and ar is the temperature coefficient.

37. The system of claim 32, wherein the regression employs independent variables derived from the cleaned, thresholded, and temperature-compensated impedance data, including temperature, pressure, salt percentage, salt types, mud types, flow speed, types of crude, permittivity, and susceptance.

38. The system of claim 32, wherein the regression utilizes Gaussian Process Regression to analyze the cleaned, thresholded, and temperature-compensated impedance data.

39. The system of claim 32, wherein the processing circuitry is further configured to: generate a training dataset comprising multiple samples of the cleaned, thresholded, and temperature-compensated impedance data from known fluid compositions with varying mud percentages; divide the training dataset into training and testing subsets using a StratifiedGroupKFold method that preserves complete impedance sweeps in each subset; and use the training and testing subsets to train and validate the regression techniques prior to applying the regression techniques to determine mud percentage quantification of unknown fluid samples.

Citation Information

Patent Citations

  • Application of electrochemical impedance spectroscopy in drilling fluid composition measurements

    CA3028979A1

  • Determining surface wetting of metal with changing well fluids

    US20160047221A1

  • System and method of sensing hydrocarbons in a subterranean rock formation

    US20190345820A1

Cited By

  • Ultrapure water treatment and dynamic wastewater recycling integrated system for new energy

    CN122102413A