Linear shaped filter
BACKGROUND OF THE INVENTION 
     A major portion of the services provided by the oil field service industry relate to cementing operations, including primary cementing, that is, cementing casing into a well bore by pumping cement slurry down a centralized casing and up into the annulus between the well bore and the casing, and squeeze cementing of a particular zone or interval. Additionally, cement slurry is often pumped downhole for water control, fluid loss control, and many other purposes. 
     Another aspect of the oil field service industry is stimulation services which include, among other operations, fracturing an oil bearing formation by pumping a pressurized fluid into well bore perforations until the oil bearing formation fractures. A proppant laden slurry is then pumped down hole after the fracturing fluid. This fracture is then held open by the proppant, usually sand or bauxite, which remains embedded in the walls of the fracture after the fluid contained within the slurry migrates into the surrounding formation, or, ideally, is flowed back into the well bore out of the formation when pressure is reduced. 
     In all of the aforementioned situations it would be advantageous to have a quick-response system for determining the density of the cement slurry, or the proppant slurry. 
     In oil well cementing operations, the density of the cementing slurry is an important factor. The bore hole cementing fluid typically is a slurry of chemical constituents mixed with water and has a certain density. Should the composition of the slurry mixture change during the pumping operation, the density changes and a change in mixture can effect desired results in the cementing operation. For that reason, it is desirable to be able to sense changes in density, i.e. changes in the mixture in order to be able to provide a correction to the mixture before a large volume of incorrect mixture is introduced into the system. 
     Similarly, in fracturing of wells, monitoring of the density of the fracturing fluid, or proppant slurry, is desirable to ensure that there is not too little proppant in the slurry, which can result in fracture closure, or too much proppant, which can result in &#34;sand out&#34;, or termination of the operation due to plugging of the pump, lines or well bore with proppant. 
     It is accordingly, a feature of the present invention to obtain a relatively quick-response time to the change of density in a cementing or fracturing fluid system so that the fluid may be continuously monitored and corrected if necessary to obtain a consistent density for the fluid mixture. 
     The present invention relates to a method and apparatus for processing randomly varying data to obtain quick response control to changes in the density of a fluid. 
     The prior art has developed digitally processed data for nuclear densometers, as illustrated by U.S. Pat. No. 3,657,532, issued to Carl W. Zimmerman. As set forth in the `532 patent, digital systems allow the incorporation of reliable, inexpensive and compact integrated circuits and can be used to develop digital pulse counting techniques. However, in this prior art apparatus, there remains a substantially long time response to a change in density in the fluid sample being tested, and as a consequence, a considerable volume of incorrect density fluid may be passed through the system for use before a correction in the density can be detected or made. 
     U.S. Pat. No. 4,618,939 to Davis and assigned to the assignee of the present invention involves a method and system for sensing the density of a fluid and for providing statistical count signals which are proportional to density. This prior art system only identifies significant changes in density and then responds to these changes only after a substantial period of time. 
     Additionally, U.S. patent application Ser. No. 262,406, filed Oct. 25, 1988 and assigned to the assignee of the present invention describes a digital filter which can be used with a radioactive densometer. The digital filter uses a weighting factor including two confidence factors to determine whether or not an actual change in state has occurred. 
     SUMMARY OF THE INVENTION 
     A filter for use in a central processing unit (CPU) is provided which can quickly detect actual changes in the state of data which varies randomly about a mean. For example, a radioactive source provides emissions which vary randomly about a mean, some of which are absorbed by the fluid to be measured. The remaining emissions being counts which are a function of the density of the fluid. The present invention provides an accurate and quick means of determining whether a change in state (such as density) has actually occurred. The CPU is programmed such that the difference between the average frequency of the counts (f o ), i.e. the mean, and the frequency of the next successive sample of counts (f 1 ), divided by the number of standard deviations therebetween and a dampening factor, update a weighting factor accordingly. Thus, the further a count is from the mean, the more quickly the density reading is changed. 
     Therefore, in accordance with the previous summary, objects, features and advantages of the present invention will become apparent to one skilled in the art from the subsequent description and the appended claims taken in conjunction with the accompanying drawings. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a schematic block diagram depicting a radioactive densometer system which can utilize the present invention; 
     FIG. 2 is a graph illustrating density with respect to mean count rate; 
     FIG. 3 is a graph representing the poisson distribution function of the counts under steady state conditions and the linear approximation which is dependent upon the value of the dampening factor. 
     FIGS. 4A and 4B are flow charts for use with a microprocessor, to process the data for obtaining fast response times and indications to changes in state of signals which vary randomly about a mean. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     Referring now to FIG. 1, use of the invention in the context of cementing a well bore is described. A housing 10 is mounted on a tubular pipe with a bore 12 through which a well cementing fluid 13 is caused to flow between cementing tanks or trucks (not shown) and a well bore to be cemented (not shown). A source of radiation 14 is located on one side of a tubular pipe including bore 12 and, on an opposite side, a radiation detector 15 is located. The radiation provided by the source 14 is a constant intensity over a substantial period of time (randomly varying about a mean over a short period of time) of gamma ray emissions. A substantial period of time being a time period much less than the half life of the source of radiation. The gamma rays are transmitted through the material surrounding the bore 12, the slurry of cement 13 within the bore and to the detector 15. The detector 15 may be, for example, a crystal of sodium or cesium iodide (thallium activated) or other material capable of scintillating under irradiation and may include an electron photo multiplier tube for converting light flashes of the scintillation of the crystal into an electrical pulse. It can readily be seen that the only variable with respect to density between the source 14 and detector 15 is the cement slurry 13. A percentage of the gamma rays emitted by the source 14 are absorbed or attenuated by the cement slurry 13 and do not reach the detector 15. Thus the counting rate of the output signal from the photo multiplier tube of the detector 15 is similarly related to the density of cement slurry 13 through which the rays must pass to reach the crystal in the detector 15 and the intensity of the source 14. 
     The detector 15 is powered by a high voltage power supply 16 and the output signals from the detector 15 are supplied to a comparator circuit 17. The comparator circuit 17 eliminates extraneous noise signals below a selected amplitude level determined by a reference level set by resistor 17A, and amplifies the output signals which are passed through the circuit. The output of the comparator circuit 17 represents count pulses above the threshold level set by the resistor 17A. 
     The output signals from the comparator 17 are applied to a counter register 25 and the counter register 25 outputs to a computer 26. The computer may be a OKI Semiconductor 8085 microprocessor or other suitable CPU. The microprocessor 26 is keyed by a clock 49 to systematically and regularly process the counts in the register 25. The computer 26, upon processing of the data, may provide an output to an optional recorder 27. 
     The filter determines a &#34;best estimate&#34; for mean frequency which is based on information currently available. Initially, since no information is available, the mean frequency is arbitrarily assumed to be one (1). As information becomes available, due to a sampling of counts being taken, an estimate for the mean frequency can be made, i.e. f o (n) for any time n. Further, successive estimates can be made f o (n+1) for each successive time period during which counts are sampled. This estimated mean frequency is shown as f o  on FIG. 3, whereas the horizontal axis of FIG. 3 represents the number of standard deviations from the mean of the counts. The vertical axis of FIG. 3 represents the probability of occurrence. In other words, FIG. 3 is an illustration of a poisson distribution which closely approximates the normal distribution function. 
     The filter of the present invention uses a weighting factor which reflects the confidence which is based on the probability of statistical deviations relative to the mean. For example, the greater the distance (number of standard deviations) between the mean and the sampled data, the greater the confidence. Stated another way, the more standard deviations away from the mean value, the greater the mean, as shown on FIG. 3, is changed each time action is taken. The greater the confidence (and thus the greater the weighting factor) the more drastic is the action to be taken. For example, if a data sample is received three or more standard deviations from the mean, then the confidence is high. Thus, fairly drastic action would be taken to change the mean to correspond to the newly received data. 
     However, if the new data were less than one standard deviations from the mean, then small action would be taken (i.e. the mean would slowly approach the new data), because the confidence that a change in state has occurred is very low. 
     As the new data approaches the mean value, there is a low probability that the received data represents an actual change in state of the density. As previously noted, this probability increases as an increasing number of standard deviations away from the mean is received. 
     In the operation of the present invention, the detected counts are processed by the comparator 17 and output to the count register 25 and subsequently to the computer 26 on a periodic basis. Ten of these counts are accumulated, and the average frequency of the total is compared to a previously obtained mean. The number of standard deviations the accumulated count is from the mean is used together with a dampening factor (entered by the user of the present inventiOn, or from the filter subprogram of the present invention) to develop a weighting factor, which reflects the sensitivity of the filter system of the present invention. The weighting factor is used to determine a new mean, and this mean is used to display a new density. 
     The digital filter of the present invention is described herein with respect to a radioactive densometer, however, it should be noted that the filter is applicable to any system wherein data is randomly varied about a mean and where the standard deviation is equal to the square root of the mean, such as in many types of well logging. 
     The present invention greatly reduces response time to an actual change in state of the density by filtering out the random data from the data which indicates that an actual change has occurred and that therefore the weighting factor must be increased to quickly reflect a change in state, such as fluid density. 
     The weighting factor is determined by taking the mean, or the average frequency (f o (n)) of previously examined samples of counts. The frequency (f.sub.(n+1)), which is the average frequency of the next successive one second sample of accumulated counts, is then subtracted from the initial average frequency and the absolute value of the difference is taken. Next, the standard deviation (σ) is determined by taking the square root of the initial average frequency. ##EQU1## 
     The standard deviation (σ) is then multiplied by a dampening factor (d), a constant the value of which is dependent upon the parameters and operating characteristics of the system, such as whether a cementing, or stimulation type job is being undertaken, and the type and size of radioactive densometer utilized. It has been determined through research, development, field testing and engineering that a value of d=8 works exceedingly well with the filter of the present invention, but any positive number may be used. Finally, the weighting factor is calculated by dividing the absolute value of the difference between the initial average frequency (f o (n)), or mean and next successive average frequency (f.sub.(n+1)) by the product of the standard deviation and the dampening factor. Hence, the following equation describes the above stated relationship. ##EQU2## 
     A new frequency value, which translates into a new density value, is calculated by using a portion of the initial average frequency plus a portion of the next successive average frequency. The portion of the initial average frequency used is one minus the weighting factor. The portion of the next successive average frequency used is the weighting factor. This relationship is described by the following equation: 
     
         f.sub.o(n+1)=f.sub.o(n) (1--W)+f.sub.(n+1) W 
    
     For example, let 
     f o  =10,000 
     f 1  =10,000 
     d=8 
     Then, ##EQU3## 
     It can be seen from the above discussion and FIG. 3 that as the weighting factor approaches zero, f o .sub.(n+1) approaches f o .sub.(n). Conversely, as the weighting factor approaches one, f o (n+1) approaches f.sub.(n+1). Thus, as the weighting factor approaches zero, there is a smaller probability that an actual change in state has occurred and a greater probability that any fluctuation in the counts is due to a random variation. However, as the weighting factor approaches one, there is a greater probability that a change in state has in fact occurred and a smaller probability that the fluctuation in frequency was due to a random variation. 
     It is known from probability that the greater number of standard deviations a value is from the mean (in the present case, f o (n)), the greater likelihood that an actual change has occurred. FIG. 3 illustrates the poisson distribution of a random variable, shown as a &#34;bell&#34; shaped curve. Since f o (n) is much greater than 1, this poisson curve approximates the normal curve. Additionally, a linear approximation is depicted which extends from the vertex of the bell curve outwardly in each direction and intersects the horizontal axis at points +d and -d on either side of the line f o (n), which is also zero standard deviations. The value chosen for d will affect the speed with which the filter of the present invention operates. 
     Once it is determined that an actual change in the state (density) has occurred, i.e. f o (n+1) has been calculated, then the density output is updated and displayed on recorder 27 by using the following conversion equation. ##EQU4## where ρ=density 
     K 2  =frequency when the bore 12 is empty 
     1n=natural logarithm 
     K1=constant 
     f o (n) =mean frequency 
     It should be noted that a plot of the counting rate versus density is illustrated by the curve 18 in FIG. 2. 
     As stated above, the filter of the present invention uses a linear approximation (see FIG. 3) to determine if an actual change in state has occurred. It should be noted that poisson&#39;s distribution, or the normal distribution, or &#34;bell&#34; curve could be utilized to make this determination. However, the present invention is directed towards an embodiment wherein the microprocessor 26 does not have the capacity to determine the distribution of counts along the bell shaped curve within the time limit required by the present invention. The present invention is able to reliably determine when an actual change in state occurs using a linear approximation, without requiring existing microprocessors, already in the field, to be upgraded. Further, use of the filter system of the present invention improves the response time for large changes in density from five (5) to two (2) seconds, and improves response time for small changes in density from twenty (20) to six (6) seconds. 
     The filter subprogram of the present invention input to CPU 26 will now be described in detail with regard to FIGS. 4A and 4B. 
     At step 1, the filter subprogram of the present invention is accessed. No processing is performed in step 1. It represents only a location where other subprograms can access the filter subprogram. This subprogram is normally accessed once each time the 10 hertz clock 49 sends a signal. Step 2 increments the modulo 10 counter so that the subprogram can determine when ten, 0.1 second intervals have occurred. Next, in step 3 an accumulator adds any counts stored therein with any new counts from the count register 25. 
     Step 4 checks that ten counts have been accumulated, i.e. that the clock 49 has signaled ten times. If ten counts have not been received then the filter subprogram is exited. But, if there are ten accumulated counts, then the system proceeds to step 5, where it is determined whether the accumulator is equal to zero, i.e. if zero counts are currently stored therein. If the accumulator is equal to zero then the system proceeds to step 6 where the weighting factor, is set equal to one. Flow of control in the subprogram then proceeds to step 9. 
     If, at step 5, the accumulator is not equal to zero, then step 7 determines the weighting factor and the system continues to the next step. Step 8 determines if the weighting factor is greater than one. If not, then flow of control in the subprogram continues at step 9. Should the weighting factor be greater than one, then step 10 sets the value equal to one, thus limiting the weighting factor to one hundred percent. Step 11 and step 9 are collection nodes. That is, they show where flows of control combine. No processing occurs at collection nodes. 
     Next, the filter subprogram proceeds to step 12 where a new average frequency, or mean, is determined by multiplying the initial average frequency by, one minus the weighting factor, and adding this product to the product of the average frequency of counts in the accumulator and the weighting factor. 
     Step 13 resets the modulo 10 counter to zero, i.e. a new sample period begins, and step 14 resets the average frequency of counts in the accumulator to zero such that the average frequency for the next successive sample of counts can be determined. The filter subprogram then exits and no further filter processing is made until 0.1 seconds later when processing begins again at step 1. 
     While this system is particularly adapted to the measurement of a cement or proppant slurry where good resolution of density measurement is required along with good accuracy, fast response, and high stability, other adaptations and advantages of the invention will be readily apparent to one skilled in the art to which the invention pertains from a reading of the foregoing. It is accordingly intended that the foregoing description be illustrative only and that the scope of the invention be limited only by the language, with a full range of equivalents, of the appended claims.