Interface Layers Detection in Oil Field Tanks: A Critical Review

to create intelligent machines times, the of the and years of research into programming techniques, of machines is a intelligence, of seeks for human, materials and automation.


Introduction
An emulsion layer is a mixture of two or more liquids in which one of them -the dispersed phase, is present as droplets of microscopic size, distributed throughout the other, called continuous phase. The existence of such layer between oil and water is due to the crude properties, and contaminants such as asphaltenes and resins. A measurement system to determine the boundaries of this emulsion in a modern oil production field is necessary to extract the pure single phase liquids [1,2,3]. This would for instance reduce the usage of expensive two phase flow meters and avoid the installation of additional tank separators along the upstream oil pipeline. In addition, this would help collecting accurate daily oil production statistics from each oil station. One widely deployed solution consists to inject chemical substances to completely eliminate the emulsion layer and leave only a crisp oilwater interface which can then be detected relatively much more easier. However, this approach is costly, not environmental friendly, and leads to a significant increase of the retention time in the separator. This book chapter provides a survey on electronic-basedtechniques which are capable to measure the high and low boundaries of the emulsion layer in real-time. It then describes in more details a new ultrasonic-based device along with the experimental results it could provide.

State of the art techniques for emulsion layer detection in oil tanks
In recent years various types of devices have been proposed and in some cases deployed in the oil field to measure the lower and upper positions of the emulsion layers. These devices require more challenging design considerations than the ones used for level measurement because of the inhomogeneity, opacity, and multitude of phases which usually exist inside the tank. In addition, inside the crude oil tanks, there is usually abundance of H2S substance which is a harmful gas which can cause a devastating blast in case of a small ignition of the electrical parts of the device. Thus, the zone assigned to the inside area of the crude oil tanks is classified as an extremely dangerous zone, namely Zone 0 area. This requires a careful design of the device by ensuring that the voltage, current, and capacitances do not exceed a certain limit. Recently, intensive research & development works have been performed on 182 the design of such devices. They can be usually classified as radioactive or non radioactive types, in addition of featuring one or many of the followings: - The device is non intrusive and non invasive; - The device can operate continuously and require a minimum of maintenance; - The device is intrinsically safe and can operate in zone 0 areas; and - The device is a clamp-on type and externally mounted.

Differential pressure-based device
One of the commonly used devices to measure the liquid-liquid interface inside crude oil tanks is the pressure sensor-based device. The pressure, P, at a given height, h, within a liquid of density, ρ, is given by [3,4,5]: Where H is the height of the liquid. Hence, knowing H, ρ W , and ρ o one can determine the height of the interface, h 1 . Note that the temperature compensation is usually required in these devices as the density of liquids varies with temperature. The main advantages of this technique are that the pressure sensors are cheap, not cumbersome, and can be easily installed in a tank. However it is suitable only when the interface separating the two liquids is crisp. In case a relatively thick layer containing mixed liquids separates the two liquids, the above design will not be any more applicable to determine the low and high positions of this layer. A possible design alternative with this kind of sensors would be to place an array of n pressure sensors along the vertical path of the tank which are separated by a constant distance, x ( Figure 2). Hence, the lower and higher positions of the emulsion layer (h 1 and h 2 respectively in Figure 2) would correspond to the pressure sensors providing the following values: 11  Hence, for each height, h, the transmitter stores in its database the pressure values corresponding to water and oil respectively (ρ W gh) and (ρ O gh). It then proceeds to compare the actual pressure at height h, captured by the pressure sensor with these two stored values. The top height providing same (ρ W gh) and lowest height providing same (ρ W gh) corresponds to the lowest and highest interfaces respectively. Note that in this case, the knowledge of the total height of the liquid (H in Figure 2) is not any more required. Providing one single sensor is possible if it is attached to an electromechanical system to provide precise motion of the sensor in vertical positions ( Figure 3). This technique however is not recommended in oil industry as moving parts in contact with conductive materials are subject to fast corrosion which would affect then the precision of the associated devices. The other problem with both designs (Figure 2 and Figure 3) is the extremely low sensitivity required for the pressure sensors. For instance, if a resolution of the device of x = 15 cm is sought, a sensor with a sensitivity of at least 0.210 psi would be required. Another not less important limitation of this device is its inability to deal with build-up problem which can be most likely be created on the sensor in case of crude oil. These are few reasons why pressure sensors-based devices have been used for level or crisp interface measurements, rather than emulsion layer measurement.

Capacitive sensor-based device
Radio Frequency (RF) technology uses the electrical characteristics of a capacitor in several different configurations for interface measurement. Commonly referred to as RF capacitance, the method is suited for detecting the interface which might occur between or within liquids, slurries, or granular. Basically, when two conductive plates of area, A, are separated by a distance, d, the corresponding capacitance is proportional to the dielectric constant of the process enclosed within the plates, ε r ( Figure 4) In case of interface measurement, One plate can be the vessel wall, and the other one the measurement probe or electrode ( Figure 5(a)). In another configuration, both plates are provided within the device ( Figure 5(b)). For both configurations, the second plate (reference plate) should be connected electrically to the grounded metallic tank. Hence, in case of oil-water interface measurement, the capacitance gets short by water and thus the effective area of the plates change with the level of the water inside the tank. This leads to a linear trend between the height of the tank and the value of the capacitance.  The measurement of the emulsion layer using capacitance probe is possible by deploying a vertical array of capacitance sensors along the vertical axis of the tank. In this case, the transmitter measures the dielectric constant of the liquid existing between the plates to determine the water-cut (i.e. the fraction of water in the total volume of liquid) at that height. By doing same for all sensors of the array, a vertical profile of the liquid existing in the tank can be provided. The difficulty here however is that for water-cut values greater than 40%, the capacitances tend to lose their sensitivity preventing the transmitter to determine the profile corresponding to the lower half of the emulsion layer. Another difficulty of capacitance probes in general is their inability to deal with build-up substances that might be created at the surface of their sensors.

Radar or microwave-based device
Radar or microwave-based devices generate electromagnetic waves, typically in the microwave X-band (10 GHz) range, and then proceed by analyzing the received signal to determine the liquids interface levels in the tank. The microwave generator is usually placed on the top of the tank to beam microwaves downward and then receives one or several echo signals which might be generated by the liquids interfaces, as well as by the top level of the liquid and bottom area of the tank ( Figure 6). The measurement of travel time for the signal (called the time of flight) of these echoes signals allow to determine the heights of these interfaces. For instance, in Figure 6, the height h of the oil-water interface is determined using the following equation: Where H is the distance between the transmitter and the ground (i.e. this corresponds to the height of the tank), t 1 and t 2 , the transit time of the first and second echoes respectively, and v 1 and v 2 the speed of microwaves in the air and oil respectively. Note that in the above case, no echoes are reflected by the bottom wall of the tank since the water absorbs most of the microwave energy. For this same reason, the detection of the emulsion layer which might be created between oil and water using this type of device is difficult. However, one of the advantages of this technology is that the sensors are not intrusive and non invasive and hence no build-up substances are created on its sensing part. In addition, the device is not affected by possible changes of the environmental conditions (e.g. temperature and humidity) which facilitate its deployment in the field.

Radiation-based device
Recently, radiation-based instruments have been widely used in oil field, including for the measurement of interface levels in oil separators and tanks. Radioisotopes (such as Gamma sources) used for level measurement emit energy at a fairly constant rate and in a random fashion. Different radioactive isotopes are used, based on the penetrating power needed to "see" through the process vessel. The radiation from the source penetrates through the vessel wall and process fluid. In case of interface measurement, the radiation sensors are placed on a vertical array to measure the density profile across the height of the tanks. The Tracerco Density Profiler system (based on nuclear technology) [18,19] is one the most famous devices using this technology (Figure 7). The instrument consists of a vertical array of a small, gamma ray emitting radioactive sources (Americium-241, the same radioisotope as is used in smoke detectors). The radiation is monitored by a vertical array of radiation detectors. The source and detector assemblies are secured in dip-pipes that project down into the separator. The radiation beam from each source is collimated so that only the radiation detector at the corresponding elevation detects it. The attenuation of the beam in the process material between the source and detector is related to the density of that material. Effectively, each source/detector pair functions as a density gauge. The outputs from the detectors give the density profile of the fluids inside the separator from which a precise measurement of the oil/water interface point can be obtained. The advantage of this technology is its ability to operate in harsh environments and to deal simultaneously with multitude of phases of different types (e.g. liquid and gas phases). In addition, it is extremely suitable for applications involving high temperatures and pressures or corrosive materials within the vessel [18.19]. However, there are a number of compensating factors that seem to prevent nuclear from becoming a truly universal technology. One factor is high cost which is estimated at 2-4 times that of other technologies. In addition, because of the safety risks that might occur in case of radiation lose, periodical inspections and approvals are vital.

Displacer-based device
Displacers or floats are some of the most commonly used interface measuring mechanisms for ages. They rely on the Archimedes principle which states that when a body is floated or immersed in a fluid, it loses weight equal to the weight of the liquid displaced [20] [21]. Hence, when two liquids have densities ρ 1 and ρ 2 (ρ 1 < ρ 2 ), a floater with density ρ would float on the interface separating the two liquids if the following condition is satisfied: In case of emulsion layer measurement, a vertical array of several floats can be deployed in such a way that adjacent floats have densities which match the ones of liquids to be detected. For instance in Figure 8, the middle float would have a weight just larger than the oil and just lower than the highest level of emulsion to be measured. These devices have the advantages to be simple, accurate and can be adapted to measure wide variations in fluid densities. However, once the sensor is set up and adjusted for specific density of the liquid, the fluids measured must maintain their density, which is not always the case in oil field tanks where the wide variation range of temperature leads to a change in the density of the liquid. Another possible source of errors in displacer/floats measurements is caused by sticky fluids such as heavy crude oil which can deposit on it and effectively change the displacement and causes a calibration shift.

Vibrating switches-based device
Vibrating level switches detect the dampening that occurs when a vibrating probe submerged in the target fluid moves at a resonance frequency which can range from 85 to 400 Hz. This dampening is function of the density of the fluid surrounding it. Figure 9 shows the basic principle of the device. It comprises mainly a paddle, control and processing unit, a magnet, and reed switch. The control and processing unit uses a driver coil to induce a 85-400 Hz vibration in the paddle that is damped out when the paddle gets covered by a process material. Hence, the magnet which is screwed inside the paddle moves vertically up and down and the reed switch gets actuated whenever the magnet is located in front of the switch. By this way, the sensor can detect both rising and falling levels of the paddle whose speed depends on the process. Hence, by deploying a vertical array of these switches inside the oil tank, the liquid profile inside the tank can be obtained. These devices can detect liquid/liquid, liquid/vapor, and solid/vapor interfaces, and can also signal density or viscosity variations. In addition, they are able to operate at pressures reaching up to 3,000 psig and at temperatures ranging from -100 to 150°C (-150 to 300°F). Also, the low operational frequency of these sensors makes the hardware-software design of the system easy and cheap. In addition, its fast response time, which is about 1 second, make real-time measurements possible. However, one major disadvantage of these sensors is the huge power required to drive the sensors up and down in the oil tank. Such motions may create some turbulences on the fluid which may induce some measurement errors. Another disadvantage of this device is the necessity to watch its sensing part immediately after each immersion in a sludge or slurry as they are extremely sensitive to material build-up or coating. In addition they are invasive and intrusive. These are few reasons why these sensors have been rarely deployed in the field.

Optical fiber-based device
In recent years, optical fiber sensors have been used in some oil field tanks as they have the capability to measure the pressure and temperature at different vertical positions of the tank and along one single optical fiber [3,4,5,6,7]. The basic concept is that the power propagating along the optical fiber is attenuated if part of its cladding is removed and if the external surrounding medium has a refractive index greater than that of the core. This is known as Fiber Brag Grating ( Figure 10). Consequently the sensing element consists of a fiber that extends over the whole depth of the tank and whose cladding has been removed in equally spaced zones. Every time the liquid reaches or leaves one of these zones, the output power increases or decreases depending on the direction of the change of the liquid level. The liquid measurement is then carried by a discrete component analog signal conditioning circuit, which sums the up and down output power variations, each of which is counted separately. This prototype showed itself to have a good accuracy and an acceptable dynamic performance. The transducer resolution can be extremely low (less than 1 mm).

Transducer Claddings
Optical fiber In practice, increasing the number of unclad zones per meter would decrease the output power changes when the liquid level nears the full-scale. Hence, if the resolution has to be improved, the sensitivity of the signal conditioning hardware must be increased, to allow useful output power variations to be distinguished from noise. One of the major advantages of this type of sensors is that the readings are not affected by the electrical interfaces that might be generated by the surrounding electrical cables or motors. In addition they are intrinsically safe and the signal cable can be deployed inside the tank without the need of any kind of certification. However, one of their main disadvantages is their incapacity to overcome the build-up problem.

An alternative: ultrasonic-based device
Detection of changes of composition in a medium with the aid of ultrasound waves has been disclosed in [9]. The probe comprises two ultrasonic sensors (one emitting and another receiving sensor) mounted into two vertical stands to detect the upper and lower levels of the emulsion layer inside a laboratory-scale tank of 1 meter height. Both sensors move up and down at the same horizontal level to provide information on the liquid within that level. However the system is not suitable to operate in relatively higher tanks (i.e. more than 3 meters tanks, which is the minimum height of storage or separation tanks in oil fields). One reason is that the electrical millivolt echo signal generated by the receiver ultrasound sensor can barely reach the electronics located at the top of the tank if their separating distance exceeds few meters. In addition, the system suffers from using relatively low ultrasonic frequencies (i.e. less than 180 kHz) which affects the accuracy of the measurement and prevents the device to detect relatively thin layers of sludge buildup commonly found at the surface of the sensors after few operating days.
In this book chapter, a new industrial prototype ultrasonic-based device, which overcomes the above drawbacks, is presented. It does not contain any moving part and has been demonstrated to effectively measure the emulsion levels, in addition to the amount of water-cut (i.e. percentage of water in oil) within the emulsion layer. The probe operates in a real oil field tank (e.g. a tank with a height equal to 4.35 m) by transmitting ultrasonic waves at its different heights in a time multiplexer manner. An embedded expert system algorithm is implemented in the transmitter situated at the top of the tank to find out if the fluid at the height of the ultrasound transducer which is being activated corresponds to oil, water, emulsion, or air. It uses as input features for the pattern recognition algorithm both the delay and number of echoes whose amplitude exceeds a predefined threshold. The determination of the water-cut within the emulsion layer is performed by an embedded feed forward neural network algorithm. Experimental results in various conditions of temperature showed a good accuracy for the detection of the emulsion layer and +/-3 relative error for the computation of the water-cut within the emulsion layer.

Measurement principal and preliminary experimental setup
The measuring principle for measuring the position of the emulsion layer in the oil tank consists to use a one dimensional array of high frequency ultrasonic sensors (i.e. 3 MHz sensors have been used in this book). Each sensor of the array operates in transmit-receive mode to emit horizontally burst of ultrasonic waves through the medium (i.e. oil, water, emulsion, or foam) and then collects the received waves and convert them into electronic signals for further processing. This latter task is performed by the transmitter, which is fixed on the top of the tank, to measure the type of medium surrounding the actual sensor. By similarly driving all the sensors of the array, a vertical profile of the oil tank can be deduced. The usage of high frequency sensors, instead of low frequency is motivated by the fact that usually the crude oil leaves a thin layer of undesirable sludge buildup on the surfaces. Thus, a high resolution ultrasound imaging system is required to scale down to that small thickness. This book chapter treats this common practical problem, which, to our knowledge, has not been sufficiently tackled in the literature. Figure 11 shows the overall hardware bloc diagram of the system. The array of ultrasonic sensors are hold in cuboid boxes (two sensors per box) which are fixed to a vertical stainless steel bar though screws to occupy the complete height of the tank (i.e. 4.35 m). A second vertical stainless steel bar which is parallel to the first one by a separating distance of 5 cm is used as a reflector for the ultrasonic sensors. The usage of stainless steel material is motivated by the need to avoid the corrosion of the metallic bars which may lead to false measurements. One of the advantages of the proposed system is that it is modular, since adjacent sensors are connected to each other though a removable flexible stainless steel pipes which carry few electrical wires (i.e. for carrying power supply and sensor signals: See Section 3). In addition, the system is not invasive since the sensors are not in direct contact with the process liquid but protected with circular glass. Prior to a detailed design of the electronic system and its pattern recognition algorithm, a preliminary experimental setup was built to carry out the analog signals of each sensor of the array under various conditions of temperature, sensor depth, and flow rate of the mixed two phases liquid injected into the tank. The repetitiveness of the measurements and matching the collected database with theoretical concepts were sought out of this preliminary step of the design. In addition, the tightness of the sensor against any penetration of the liquid into the electronics had to be investigated for different depths. This is because the amount of acidity existing in the crude oil can easily attack the gaskets which protect the electronics, especially under high temperature and pressure. Following extensive experiments, it came out that the strongest epoxy can't sustain crude oil, whereas viton, which has been selected, could resist up to 5 bars pressure and 75 0 C in contact with crude oil. The designed device is inserted inside a thermostat regulated and pressurized column of 4.7 meters height. This would allow testing the instrument at even deeper depth (e.g. up to 45 meters for some oil field separator tanks) since this latest, h, is proportional to the pressure, p (e.g. ). Two pumps are used to inject either water or oil, from two outdoor storage oil and water tanks of 1 m 3 each respectively, towards the column creating an emulsion layer inside it. The liquid formed in the column may also be carried out into a separate storage tank under different flow rate, leading to a continuous testing with similar conditions than in the oil field. The operational cycle can be described in the following way: A pulse generator feeds each transmit transducer of the array under test with a sinusoidal burst of a predetermined number of periods through a connection network. This process continues for a predetermined number of times, where the acquisition is performed in a coherent fashion by a high bandwidth oscilloscope (i.e. 500 Msamples/ sec) which was placed on the top of the tank (i.e. same connection points than the transmitter). The measured data were presented to the remote PC over the RS485 serial interface. Figure 12 shows the reflection signals generated by one of the ultrasonic sensors of the array and collected by the oscilloscope. Hence, several echo signals (more than seven in this case) could be observed. The first high-amplitude signal which follows the transmitted pulse however is not an echo signal but a reflection signal from the sensor's stainless-steel casing. Hence, a software delay of few µs is performed by the transmitter in order to discriminate this pulse from the real echoes. The removal of these latest is not required since it does not belong to the region of interest (i.e. before the actual echoes start to appear).

Feature extraction and pattern recognition algorithm
The discrimination between oil, water, and emulsion relies on a number of feature descriptors, some of them being meaningful and the rest being redundant, if not properly handled. The aim of this section is to highlight effects of some parameters on the ultrasound waves and how they can complement each other to achieve accurate results with low hardware complexity.
Where T, S, and Z are temperature in degrees Celsius, salinity in parts per thousand and depth in meters, respectively. Where a 1 to a 9 are positive constants. However, in case of oil, the speed of the ultrasonic waves decreases with the increase of temperature [11]. Therefore, the detection of the emulsion layer in case of high temperature is easier since the delay tends to be larger. A mixture of oil and water would 3provide a speed between the speed of pure oil and speed of pure water. Consequently, knowing the actual temperature and salinity of the liquid, together with the speed of the ultrasonic waves in the liquid, it is possible to deduce the density of liquid using some well adopted pattern recognition algorithms. Figure  13 shows the effect of the temperature (from 20 to 85 ºC) on the delay for one of the ultrasonic sensor of the array (i.e. sensor # 12). The delay here corresponds to the time it takes for echo to cross 100 mV for the first time. From Figure 13, it can be deduced that the delay can be used as one of the features for classification since it provides a clear discrimination between pure oil and pure water at a given temperature. However, as it will

Time [x100 µs]
www.intechopen.com be highlighted in the next section, the computation of the water-cut may require the consideration of more additional parameters since various combinations of oil-water mixtures may lead to a same delay.

b. Effects of oil used
The type of oil used in our experiments is crude oil which is continuously injected into the oil tank creating a significant emulsion layer of undefined water-cut. The effect of the watercut and the flow rate of the fluid carried out from the tank on the ultrasonic waves were sought out of this phase of experiments. As shown in Figure 14, in case of bubbles of oil (fluid2 in Figure 14) in water (fluid1 in Figure 14), the average delay of ultrasound waves (in seconds) are expected to vary according to the equation: Where d 1 and d 2 are the path lengths traversed by the ultrasonic wave in Fluid 1 and Fluid 2 respectively and v(Fluid1) and v(Fluid2) the sound speed in Fluid 1 and Fluid 2 respectively. In addition, the reflected wave, Pr in Figure 14, may be damped by the mixed fluid proportionally to its absorption coefficient, α, which has the following expression [12]: Where f is the frequency of the sound wave, µ the viscosity of the medium, ρ the density of the medium, and c the velocity of the sound in the medium.  Figure 15 shows the water-cut function of the delay for two sensors of the array (i.e. sensors #4 and 12) at 32 0 C. Hence, overall the delay follows a non linear increasing trend for both sensors. Similar trend was observed for the peak to peak voltage of the ultrasound wave. The usage of neural network technique for each sensor seems then to be a possible alternative for the pattern recognition algorithm to determine the water-cut surrounding the sensor. However, in some regions (points A and B in Figure 15), the delay is similar for two different values of water-cut. The reason is due to the output flow of the liquid inside the tank, which tends to move the ultrasonic wave in its direction, causing an extra delay. This is the reason why additional information regarding the flow velocity, v, of the liquid carried out from the column needs to be considered. This latest is function of the differential pressure, ΔP, between two sensors fixed along the array as follows [14]: Where h is the distance separating the two pressure sensors, ρ the density of the liquid along the column, f is the friction factor (e.g. a Moody friction factor calculated using known roughness of an inner surface of the pipe), and d is the inner diameter of the pipe. The solution adopted in this book chapter consists then to add two pressure sensors in the array (i.e. in transducers 1 and 28 respectively), within which, the average density of the liquid is also estimated. Figure 16 shows the plot of the velocity function of the differential pressure for different fluid densities (ρ = 820, 910, and 950 kg.m -3 ). Hence, overall the flow velocity follows the trend of equation 10. In practice, by using the pressure as additional input to treat the regions which are similar to A and B, a compensation of the delay function of the fluid velocity could be achieved.

c. Effects of liquid bubbles in the continuous phase
In addition to the liquid viscosity, the loose of energy of the transmitted ultrasonic wave may also be caused by the liquid bubbles which generate reflections according to the following equation [12]: Where R is the ratio of reflected to the incident ultrasound waves' pressure, Z 1 the acoustic impedance of the liquid bubble, and Z 2 the acoustic impedance of the continuous phase. In [13] the impedance and interaction processes for a wide range of materials of interest is provided. Hence, the level of decrease of the voltage amplitude of the received echo from the stainless steel reflector, and consequently the number of echoes, is function of the number of bubbles in the continuous phase. Consequently, as shown in Figure 17 (where the x-axis, "sensor level", corresponds to a given sensor numbered from bottom to top in the tank), the number of received echoes would provide an indication on the type of liquid surrounding the sensor (i.e. water, oil, or emulsion). In the Figure, sensor 9, 10, and 11 provided only 3 echoes, whereas sensors 12 to 16 provided more than 6 echoes. Sensors 1 to 8 could not provide any echo, since the corresponding liquid was foam. Figure 18 shows the number of echoes, function of the water-cut. Overall, this number is higher for pure liquid than in case of emulsion. However, it does not provide information on the water cut. Accordingly, knowing the delay, peak to peak amplitude of the echo signals and their numbers, an estimation of the actual water-cut within the emulsion layer can be achieved.

d. Compensation of the sludge buildup
Besides the three aforementioned effects, the intrinsic properties of the crude oil may lead to the creation of a sludge buildup on the surfaces of the sensor and reflector (Figure 19), the thickness of which may vary from few mms to several cm. The challenge then is how to compensate for such layer during the measurements.   The goal here is to consider only echoes generated either by the stainless steel reflector or the surface of the sensor and mask out other echoes caused by the sludge build-up. Thus, the pattern recognition algorithm has to deal with a liquid of variable thickness, thliquid in Figure 19. One solution to compute this variable is to consider a time window of duration [0, tmax], where tmax is the maximal delay throughout the liquid (i.e. delay in case the path is 100% crude oil in this case) and then count the number of echoes, Nechos, within this window. The value of thliquid could be then determined using one the following three equations: Where d is the actual distance between the sensor and reflector ( Figure 19) and voil the speed of the ultrasonic wave in the crude oil. Hence, in case of two echoes, selecting one of the two possible values of thliquid would require to check the phase of the first echo received by the sensor. According to Equation 11, the phase corresponding to the transition sensor-sludge build-up-liquid-reflector is the inverse of the phase corresponding to the transition liquid-sludge build-up-reflector. Consequently, a proper exploration of the ultrasonic signals would overcome the errors of measurements introduced by the sludge built-up, which is impossible to achieve with other types of sensors such as the capacitance and conductance sensors. For a thickness, thliquid, the delay and peak to peak voltage to be considered for the ultrasonic waves can be scaled up for the pattern recognition algorithm to the following expressions:

Pattern recognition algorithms
Following the above experimental setup, a pattern recognition algorithm has been designed and implemented (Figure 21). It is modular and consists of a loop of several sequential time domain processes which use as input patterns the echo signal's amplitude a(t), delay d(t), number of echoes, Necho(t), Temperature, T(t), and differential pressure, ΔP(t). The estimation of the build-up thickness and the determination of the liquid flow-rate were already addressed in Section 2. The next two sections would present the algorithms to determine the type of liquid and compute the water-cut respectively.
www.intechopen.com a. An expert system-based algorithm to determine the type of liquid Figure 22 shows the flow chart of the algorithm. It consists of an expert system which uses the delay and number of echoes caused by the reflector as input parameters. The algorithm starts by activating the lowest sensor in the tank (i.e. n =1), from which it acquires the corresponding time delays and number of echoes. These two parameters are then processed by the expert system according to the elements of the database.  Hence, for a time delay less than a threshold twater*(th liquid /d) (where d is the distance between the sensor and reflector) the type of liquid being sensed by the actual sensor corresponds to water. Otherwise, in case the time delay is greater than oil*(t hliquid /d), then the liquid is either emulsion or oil depending on the number of pulses being collected (i.e. emulsion for less than 3 pulses, oil otherwise). Finally, in case no echo is detected, then the corresponding phase corresponds to foam or gas. Note that the thresholds, t water *(th liquid /d) and t oil *(th liquid /d) (e.g. according to Section 2.1(a) and Figure for an operation temperature ranging from 20 0 C to 70 0 C setting twater and toil to 140 μs and toil, = 150 μs, respectively is reasonable for thliquid = d) were selected in such a way that the classification is independent of the temperature. The same procedure is done for all sensors of the device to provide the water-cut profile of the column. This algorithm, which has been coded in assembly and implemented into the transmitter, has the advantage of being simple and does not require complicated hardware. However it is not capable to provide the water-cut value.

b. A neural network-based algorithm for water-cut computation
The second algorithm dedicated for water-cut computation is based on a feed forward neural network with backpropagation training. The motivation of using neural network is due to the fact that the elements of the database as shown in Figures 3,5, and 6 are not linear and depend on several variables (i.e. temperature and flow rate). The topology that gave satisfactory results was: input layer of dimension 6, one hidden layer with 6 neurons and the output layer with 1 neuron for the water-cut value ( Figure 23). This network demonstrated to be robust enough to determine the water-cut value within relatively low computation time. The first layer contains the six input variables (peak to peak voltage, delay, number of pulses within the time window [0, tmax], phase of the ultrasonic wave, temperature, and ΔP). The training set had 94 exemplars, and also validation and test sets each with 47 exemplars, were employed. All sets were mutually exclusive, and contained exemplars spanning the considered water-cut range. The nodes in the hidden layer are connected to all nodes in adjacent layers. Each connection carries a weight, w ij . Hence, the output of a node (j) in the hidden layer can be expressed as follows: Where g j is the activation function which is usually selected as non linear to enable the network to model to some extent some nonlinearities present in the problem. Following extensive experiments, the Logsig function was found to be the most appropriate in our case. Thus, for a particular input vector, the output vector of the network is determined by feedforward calculation. We progress sequentially through the network layers, from inputs to outputs, calculating the activation of each node using Eq. (7), until we calculate the activation of the output nodes.

Electronic design
The overall system is modular and consists of a 1-D array of tens of ultrasonic transducers which are connected to each other in a daisy chain manner via stainless-steel shielded wires and an embedded transmitter based on Reduced Instruction Set Computer (RISC) processor to perform control, data acquisition and real-time pattern recognition tasks. In addition it delivers the output results (i.e. low and high position of the emulsion layer) either as current loop 4-20 mA or RS-485 protocol to the remote control room. The temperature of the tanks which can reach up to 700C in summer season. Furthermore, and following the results obtained from the experimental setup, each transducer has been equipped with a temperature sensor. In addition, two pressure sensors were added to sensors 1 and 26 respectively.

Ultrasonic transducer
Each transducer comprises the sensor and its corresponding electronics (housed in stainless steel enclosures with IP-68 norm) and is provided with a periodical pulse repetition rate of approximately 10 Hz for the received echoes to die completely out before an excitation of 200 V peak to peak of the next burst cycle. Thus, the whole column which consists of 28 sensors can be scanned within 2.8 s. This is fast enough for oil field tanks, since they are filled with a maximal flow rate of 500 l/min (e.g. 22.8l/2.8 sec,), which corresponds to a negligible increase of the liquid height in the tank since the tank diameter usually exceeds 5 m. The returned echoes are pre-amplified and amplified with an accumulative gain of up to 30 dB using a variable gain amplifier which also provides pass-band filtering with a bandwidth of 3 MHz + 200 KHz. The role of the filter is to reduce low frequency noises induced by the vibrations of the pipes which are connected to the tank. Thus, using this filter, the signal to Noise Ratio (SNR) of the signal in Figure 12 was improved from 9.4 dB to 16.4 dB which is high enough to perform pattern recognition tasks. The next step is then to emit similar echo signals to the transmitter for further processing. Figure 24 shows the electrical connections between the sensors and the transmitter. A set of only twelve (12) electrical wires (2 for DC power supply, 2 for signals and 8 for control) only connect adjacent enclosures in a daisy chain manner. Thus an analog switch is associated to each ultrasound sensor to enable/disable the high voltage (e.g. 200 Volts) pulse voltage generated by the transmitter based on the value carried out by the input address bus. The echo signal from the sensor is then amplified and carried out via a single shared wire to the transmitter. This design has the advantage to reduce the number of wires between the transducers to a constant value (12 wires), independently from the height of the tank or the target resolution. All the electronics parts were implemented in PCBs. In addition, the instrument is not invasive since the ultrasonic sensors are not directly in contact with the process fluid but protected with glass proving an EEx-m protection. The transmitter also comprises a main processing unit that implements the pattern recognition algorithm and provides an Input/Output interface to/from the remote computer (RS485 or 4-20 mA standards which generates three levels corresponding to the bottom and top levels of the emulsion layer and the top level of the oil, as well as the tank profile), an amplifier module to amplify the signal to an acceptable level, and a pulser/selector circuit to activate each of the sensors in a time multiplexed manner with a short burst signal. The analog signal sent by the ultrasonic sensor is converted into digital by a high speed comparator for further processing.

Experimental results and discussions
The ultrasonic system has been immersed into the column and extensively assessed under different scenarios as follows: The oil tank and water tank continuously feed the column with various water-cut values by remotely adjusting the control valves placed after the oil pump and water pump respectively using a host computer. The fluid inside the tank is then simultaneously carried out into a storage tank, allowing a continuous supply of the mixed fluid into the column until both oil and water tanks become empty. Figure 25 shows the www.intechopen.com Expert Systems for Human, Materials and Automation 204 principle of the experiment. The assessment of the device is done by comparing the amount of water-cut measured at a specific height in the column (e.g. height corresponding to sensor #16) with the output of the water-cut meter which measures the amount of water in oil of the two phase outflow carried out from the column at the same height than sensor # 16. Figure 26 shows the results obtained from the two devices, where the "reference" signal is provided by the water-cut meter and "instrument" signal is provided by our acoustic system. It can be clearly observed the capability of our device to track fast water-cut variations, even within the critical range of 40-60% which would not be possible with the capacitance or conductance probes. Note that in some situations, the water-cut meter indicates brief 0% water-cut, which is different from the output of the acoustic system. This might be due to the flow regime of the fluid crossing the water-cut meter where because the fluid is discharged from the column into the storage tank by gravity, no liquid is present at those time slots (which corresponds to 0% water-cut). Figure 27 shows another experiment covering higher water-cuts. Hence, it can be clearly observed the capability of the device to determine the profile of oil tanks for various values of water-cut. Overall, the averaged relative error for oil and water was always less than +/-3%. It is defined respectively as:  Regarding the emulsion layer detection, Figures 18(a) and (b) shows the dynamic behavior of the emulsion for one of the sensors of the device (sensor #16) in case of water dominated (e.g. water fraction more than 90%) or oil dominated mixture (e.g. oil fraction more than 90%) respectively. It could be seen that in case of water dominant emulsion, the delay keeps decreasing since the bubbles of oil tend to disappear. However, in oil dominant emulsion, the delay keeps increasing since the bubbles of water tend to disappear. Figure 29 shows the results of tracking the emulsion layer in the column. Initially, the column was filled with water (of height 285 cm) and oil (of height 75 cm). By filling the column with water (of height 30 cm), an emulsion layer has been created on the top of the column. As the water tends to move downward, the thickness of the emulsion layer tends to increases and reaches its maximum value at time t = 20 s. Next, pure oil starts to appear at the top of the tank and its thickness tends to increase until it reaches its maximal value at time = 78 s. Hence, the water thickness increases by 30 cm from its initial value. Figure 30 shows the graphical user interface in the computer of the control room showing a snapshot of the above experiment in which an emulsion layer was formed between the water and www.intechopen.com Expert Systems for Human, Materials and Automation 206 kerosene. The emulsion layer is represented by two windows: In window 1 the plot of the emulsion layer is represented, whereas in Window 3, the profile of the whole tank is represented by assigning each sensor with a specific color (e.g. Blue for water, pink for emulsion, yellow for gas, and brown for crude oil).

Conclusion
In this book chapter, a critical review on the most recent devices for emulsion layer detection was presented. At present, the radioactive-based device seems to be the most successfully commercially available devices from the accuracy point of view. However, because of the continuous danger it presents to the operator, oil companies are reluctant to use this technology in their field. This book chapter also presents an alternative safe solution which uses ultrasonic sensors. This device was designed, implemented and tested for realtime and accurate detection of the emulsion layer in a 4.35 m height tank. In addition, it was The ability to create intelligent machines has intrigued humans since ancient times, and today with the advent of the computer and 50 years of research into AI programming techniques, the dream of smart machines is becoming a reality. The concept of human-computer interfaces has been undergoing changes over the years. In carrying out the most important tasks is the lack of formalized application methods, mathematical models and advanced computer support. The evolution of biological systems to adapt to their environment has fascinated and challenged scientists to increase their level of understanding of the functional characteristics of such systems. This book has 19 chapters and explain that the expert systems are products of the artificial intelligence, branch of computer science that seeks to develop intelligent programs for human, materials and automation.