## Summary

Drilling fluids are subject to substantial variations in pressure and temperature while they are circulated in a well. These changes are so great that the mass density of the drilling fluid varies significantly during circulation. Accurate estimation of the hydrostatic and hydrodynamic pressures therefore requires a reliable model of the pressure and temperature dependence of the mass density of the drilling fluid. Usually, the mass density of a drilling fluid is measured manually with a mud balance. The pressure and temperature dependence of the mass density of the fluid [i.e., its pressure, volume, and temperature (PVT) behavior] is then calculated from a PVT model of its components and their relative proportions. However, variations in the composition of the fluid mix and uncertainties in the PVT behavior of each component may lead to inaccuracies. To overcome these limitations, an apparatus has been designed to measure the PVT behavior of the drilling fluid directly and automatically. The setup measures both the mass density and the speed of sound of the fluid at specific conditions of pressure and temperature. It is possible to estimate the adiabatic compressibility from the speed of sound in the liquid mix. The device utilizes a heat exchanger from which the specific heat capacity of the drilling fluid can be derived. The isothermal compressibility can be calculated by combining the specific heat capacity and the adiabatic compressibility. While estimating the specific heat capacity using the heat exchanger, the thermal conductivity of the fluid is also estimated as a byproduct. A PVT model of the drilling fluid is obtained by combining measurements made at different conditions of pressure and temperature. The automatic and continuous provision of drilling fluid PVT behavior enhances the precision of model predictive drilling control systems and, at the same time, can simplify their configuration, therefore making them more accessible to any drilling operation.

## Introduction

Drilling fluid mass density is essential for the calculation of the hydrostatic pressure in a borehole. It is also an important parameter in viscous friction calculations because it appears in the Navier-Stokes equation and in buoyancy calculations when performing torque and drag or drillstring dynamic analysis. During drilling operations, the drilling fluid mass density is usually measured with a mud balance at regular intervals. The precision of the mud balance measurements is about ±10 kg/m^{3}. Furthermore, drilling fluids are subject to a wide range of pressures and temperatures, and therefore the drilling fluid mass density cannot be assumed to be constant for the range of depths of normal oilfield wells. Isambourg et al. (1996) found that the pressure and temperature dependence of drilling fluids can be described by a biquadratic function in the temperature range of 20–200°C and a range of pressure between 1 and 1400 bar. The biquadratic model proposed by Isambourg has since been used in a more recent study (Hermoso et al. 2017). Based on multiple published density measurements made on various fluids (Zamora et al. 2000, 2012; McMordie et al. 1982; Peters et al. 1990; Hemphill and Isambourg 2005; Demirdal and Cunha 2007, 2009; Demirdal et al. 2007; Hussein and Amin 2010), it has been found that the PVT model can be reduced to a linear function of temperature combined with a quadratic form of pressure without losing much of its accuracy and which is the model published in *API RP 13D* (2017):

where $\rho m$ is the mass density, $T$ is the temperature, $p$ is the pressure, and $Am$, $Bm$, $Cm$, $Dm$, $Em$, and $Fm$ are the parameters of the PVT model. The accuracy of the model described by Eq. 1 is about 0.35% on average with a standard deviation of 0.23% for a temperature range from 3 to 260°C and pressures from 1 to 2000 bar, based on measurements of 26 different fluids.

Calibrating Eq. 1 for a particular drilling fluid requires access to a high-pressure and -temperature densitometer, which is not routinely available at the rigsite, except, perhaps, during drilling operations in high-pressure, high-temperature conditions. The alternative is to estimate the parameters of the PVT model by combining the PVT behavior of each component of the drilling fluid. Because a drilling fluid is a mixture of solids and liquids, its mass density is simply the volumetric weighted average of all the components:

where $\rho m$ is the drilling fluid mass density, $\Omega $ is the set of indices for the different components, $fi$ is the volume fraction of the *i*th component, and $\rho i$ is its corresponding mass density.

The PVT behavior of several aqueous solutions of NaCl, NaBr, KCl, KBr, CaCl_{2}, CaBr_{2}, ZnCl_{2}, and ZnBr_{2} has been described by Kemp et al. (1989). Their model is relatively complex and does not reduce to Eq. 1. For that reason, Eq. 1 has been expanded to account for the concentration of salt by replacing the parameter $Ao$ with a cubic form of the weight of salt:

where $\rho w$ is the mass density of the brine and $wt$ is the weight fraction of the salt at the normal condition of temperature and pressure (atmospheric pressure and 297 K). $S0$, $S1$, $S2$, $S3$, $Bw$, $Cw$, $Dw$, $Ew$, and $Fw$ are the coefficients of the model as published in *API RP 13D* (2017).

The PVT behavior of base oils can also be described by Eq. 1. Zamora et al. (2013) presented parameters for several base oils and some brines. Moreover, the solid components have coefficients of thermal expansion and compressibility (Isambourg et al. 1996) which should be accounted for. Knowing the PVT characteristics of each component, it is possible to estimate the mass density of the fluid mixture with Eq. 2. However, as the various components have different compressibilities and thermal expansion characteristics, the volumetric fraction of each component changes with pressure and temperature. A method to calculate changes in volume fractions with pressure and temperature is described by Cayeux et al. (2014).

In practice, the downhole drilling fluid density will also be influenced by the presence of cuttings, dissolution of formation solids, absorption of formation fluids in the liquid phase, and barite sagging. These additional considerations are not addressed in this paper because the objective is to propose an alternative system of surface measurement to those which are, themselves, subject to the same limitations.

However, the problem remains that the composition of the drilling fluid changes continuously throughout a drilling operation, either because of the actions taken by the fluid engineer to maintain the quality of the drilling fluid or because formation fluids and solids are entrained during circulation. Even more problematically, it is often not easy to get an accurate description of the component quantities of the drilling fluid. Cayeux (2020) illustrated the impact of this lack of information on the estimated hydrostatic pressure. For instance, if the drilling fluid density is known at atmospheric pressure and 50°C (e.g., 1700 kg/m^{3}) and nothing else, the 95 percentile estimate of the hydrostatic pressure at 3500 mTVD (true vertical depth), lies between −5 and +7 bar (Fig. 1a).
However, for an oil-based fluid (OBM) with a 70/30 oil/water ratio (OWR), the 95 percentile at 3500 mTVD reduces to −2.5 and +3 bar (Fig. 1b). Knowing the fluid density for a water-based drilling fluid (WBM) at three different temperatures under atmospheric conditions will reduce the confidence interval, but only to −4 to 5.5 bar (Fig. 1c).

Having to rely on manual measurements and assumptions about the drilling fluid formulation presents difficulties when trying to automate the drilling process. Therefore, it would be a considerable advantage if the drilling fluid mass density could be measured in real time. Although such information is available on some rigs, it would be even better to obtain a full description of the drilling fluid PVT characteristics directly from inline measurements. Therefore, the goal of the present work is to establish whether it is possible to design an inline apparatus capable of measuring the PVT behavior of a drilling fluid with acceptable precision (for example, to ±5%) over a wide range of pressures and temperatures, typically 10–200°C and from 1 to 2000 bar.

## Inline PVT Measurement

Because Eq. 1 has six parameters, it is necessary to have at least six measurements made under different conditions of pressure and temperature. An obvious approach would be to measure the mass density of the fluid under six different pairs of pressure and temperature; consequently, from Eq. 1, the following set of simultaneous equations can be written:

where $\rho m1$, $\rho m2$, $\rho m3$, $\rho m4$, $\rho m5$, and $\rho m6$ are the measured mass densities at the respective conditions of pressure and temperatures $p1,T1$, $p2,T2$, $p3,T3$, $p4,T4$, $p5,T5$, and $p6,T6$. This system of equations is linear in $Am$, $Bm$, $Cm$, $Dm$, $Em$, and $Fm$ and can be easily solved using a Gauss-Jordan method, for instance (Teukolsky et al. 1992).

It is desirable to avoid operating at high pressures and temperatures to keep the design of the apparatus as simple as possible. Considering that the model of Eq. 1 has an average accuracy of about 0.35% over a range of temperatures spanning more than 250°C and a range of pressures up to 2000 bar, it is possible to calibrate the parameters with measurements made on a smaller range of pressures and temperatures. However, the accuracy of the calibrated model will depend on the accuracy of measurements and the range of pressures and temperatures over which they are taken. Fig. 2 illustrates how measurement uncertainty and the associated range of measurements influence the uncertainty of the extrapolated value when utilizing a model of known precision. In this illustration, the model is calibrated using randomly chosen values of the measurements within their accuracy range to provide a stochastic description of the envelope of model predictions outside the measurement range. The precision of the measurements limits the acceptable extrapolation range, and a narrow measurement range results in increasing uncertainties the greater the extrapolation.

Accounting for model accuracy and measurement precision and repeatability, it is useful to establish a calibration range of pressures and temperatures for the sample measurements that will permit extrapolation of the model to higher pressures and temperatures with acceptable accuracy. If the densitometer has a measurement precision of 0.05 kg/m^{3} and repeatability of 0.01 kg/m^{3}, based, for example, on an Anton Paar L-dens 7500 inline densitometer, stochastic simulations can be run to quantify the measurement error for a suitable calibration range of pressures and temperatures. Measurement precision is regarded as a source of systematic error (i.e., one randomly drawn value is applied to all measurements), while measurement repeatability is considered as a random error drawn individually for each measurement. For example, if the PVT model is to be used over a range of 1000 bar and 200°C, the root mean square (RMS) of the difference between the predicted density and the “true” value can be calculated with random variations in the systematic bias of the density measurement when the calibration samples lie within a small range of pressure and temperature. The results of 250 stochastic simulations presented in Fig. 3 show that to achieve a 5% average accuracy for the entire range of 1000 bar and 200°C, it is necessary to use a calibration range of at least 30 bar and 25°C.

A possible design for an inline apparatus could involve pumping the drilling fluid past a controllable heating element with a controllable choke downstream of a densitometer applying backpressure while measuring the mass density (Fig. 4). The set points for the heating element and the choke could be changed six times to collect the necessary mass densities to calibrate the PVT model of Eq. 1. However, in practice, the measurement sequence would take too long because changing the heating element temperature would require time to equilibrate. Gathering a complete set of calibration measurements might easily take 15–30 minutes. In practice, with a typical annular velocity of 0.8 m/s, if PVT measurements are available every 30 minutes, then the same measured values would apply for an annular fluid column of about 1400 m in length. In a typical deep well, it might mean only four or five PVT measurements in the entire annulus. This would affect the resolution of the bottomhole pressure estimate, especially if the device had measured a momentarily heavy or light sample from the mud system. Conversely, if the PVT measurements are available every 30–60 seconds, with typical annular velocities around 0.8–1 m/s, the same PVT measurement will apply for about 30 m (i.e., one stand), which is a reasonable discretization length for hydraulic calculations. So, the aim of the inline PVT measurement device should be to provide measurements at most every minute.

To speed up measurements, an alternative would be to perform six measurements simultaneously. Fig. 5 shows a configuration where the densitometers are mounted in series. The configuration would consist of six parallel branches or any combination of series and parallel branches. Fig. 6 depicts two parallel branches where, in one branch, the temperature of the fluid remains constant, while in the second, it is changed. For each of the branches, backpressure is applied at two intermediate positions. This configuration has the advantage of fewer chokes and pressure sensors, four instead of five.

With simultaneous measurements of mass density, it is possible to provide in real time a complete, calibrated, PVT model. Yet, the circuitry is complex, involving four or five chokes. Therefore, it would be worthwhile to investigate whether the hydraulic circuit could be further simplified.

## Reducing the Number of Pressure and Temperature Conditions

The pressure and temperature dependence of drilling fluid densities is related to the fluid compressibility and its thermal dilatation. Therefore, if it is possible to directly measure the fluid compressibility, it would be possible to simplify the setup and reduce the number of pressure and temperature conditions required for the solution. The isothermal compressibility ($\kappa T$) of a fluid is defined as follows (Landau and Lifshitz 1980):

where $V$ is the volume that is related to the mass density through

where $m$ is the mass of matter contained in the volume $V$. It is possible to express the isothermal compressibility of the fluid in terms of the PVT model described in Eq. 1:

Let us now consider the definition of the speed of sound ($c$) in matter:

where $S$ is the entropy. Then, the isentropic compressibility is defined as follows:

and it is possible to express a relation between the isentropic compressibility to the speed of sound in the medium:

Finally, the isentropic compressibility is related to the isothermal compressibility through the following relation (Landau and Lifshitz 1980):

where $\alpha =1V(\u2202V\u2202T)p$ is the volumetric coefficient of thermal expansion and $Cp$ is the isobaric specific heat capacity. It is possible to express the volumetric coefficient of thermal expansion in terms of the PVT model described in Eq. 1:

Thus, if the mass density and the speed of sound are measured at the same time, six equations can be obtained with only three combinations of pressure and temperature:

where $c1$, $c2$, and $c3$ are the respective speeds of sound for the conditions of pressure and temperature $p1,T1$, $p2,T2$, and $p3,T3$, $\kappa p1,T1$, $\kappa p2,T2$, and $\kappa p3,T3$ are the estimated isothermal compressibility coefficients at the respective conditions of pressure and temperature $p1,T1$, $p2,T2$, and $p3,T3$, and $\alpha p1,T1$, $\alpha p2,T2$, and $\alpha p3,T3$ are the estimated volumetric coefficients of thermal expansion at the respective conditions of pressure and temperature $p1,T1$, $p2,T2$, $p3,T3$.

The resulting system of equations is nonlinear. To solve that system of equations, Eq. 13 is reformulated:

where $x=(AmBmCmDmEmFm)$ , $Xj=(0000000Xm0000000000000Xm0000000000000Xm)$ with $j=1$, $Xm=Bm$, $j=2$, $Xm=Dm$, $j=3$, $Xm=Fm$. The $6\xd76$ matrix $A$ is as follows:

the matrix $B$ is

the matrix $C$ is

the matrix $D$ is

and $Et=(1c121c221c32\rho m1\rho m2\rho m3).$

Eq. 14 can then be rearranged as follows:

Noting that $X1$, $X2$, and $X3$ are expressed as a function of $x$, Eq. 19 has the form $x=fx$, which can be solved efficiently by a fixed-point iteration method:

where $j$ denotes the iteration level. The algorithm stops when $xj+1-xj\u2264\epsilon $, $\epsilon $ being a small real value.

Because the term $\alpha 2T\rho Cp$ in Eq. 11 is much smaller than $\kappa T$, it is therefore possible to use

as an initial value for the fixed-point iteration method. In practice, the solution of Eq. 13 with the fixed-point iteration method does not require more than a half dozen iterations to achieve a stopping condition of $\epsilon =10-6$.

Suppose the speed of sound can be measured with an uncertainty of 0.1 m/s and repeatability of 0.01 m/s, based, for example, on the characteristics of an inline combined densitometer and speed-of-sound sensor model L-Com 5500 from Anton Paar, then it is possible to proceed as before and estimate the range of pressures and temperatures required to obtain a predictability of the mass density over a range of 1000 bar and 200°C. The results in Fig. 7 show that it is possible to achieve a precision better than 5% on average over the whole range of pressure and temperature of 1000 bar and 200°C, with three calibration measurements over a range of 60 bar and 5°C.

This result shows that it is possible to reduce the number of pressure and temperature conditions to three by measuring the speed of sound in the drilling fluid in addition to the mass density. However, this reduction in the number of pressure and temperature conditions depends on knowing the specific heat of the drilling fluid, which is often not the case. In the next section, the influence of the fluid specific heat capacity on the heat transfer along an insulated pipe will be analyzed.

## Heat Transfer along an Insulated Pipe after Passing a Heat Source

The definition of specific heat is (Landau and Lifshitz 1980) as follows:

where $Q$ is the amount of heat (i.e., it characterizes the amount of energy necessary to change the temperature of a given mass of matter).

The specific heat capacity of the drilling fluid can be obtained using a hydraulic circuit consisting of a pump, a volumetric flow-rate measurement, and an insulated pipe in which a drilling fluid is circulated with a heating element upstream of the pipe (Fig. 8).

Consider the energy conservation of a system under isobaric conditions (Corre et al. 1984):

where $H$ is the enthalpy per unit mass, $Q\u2192f=\rho mHv\u2192$ is the forced-convective heat flow, $Q\u2192c$ is the conductive and natural convective heat flow, and $qs$ is a heat source per unit time and per unit length.

For an isotropic solid, like steel or an insulating material, the pure conductive heat flow is expressed as follows:

where $\lambda $ is the thermal conductivity.

The Nusselt number in the heat flow direction ($NuL$) is introduced to estimate the natural convective heat flow in a drilling fluid:

where $hL=q\Delta T$ is the convective heat transfer coefficient in the heat flow direction, $L$ is the characteristic length, $q$ is the heat flux (i.e., thermal power per unit area), and $\Delta T$ is the temperature difference. For laminar flow, Corre et al. (1984) use the following expression of the Nusselt number (Corre et al. 1984):

where $n1=\pi \lambda mL4Qv\rho mCpm$, $Qv$ is the volumetric flow rate, $Cpm$ is the specific heat capacity of the drilling fluid, $\lambda m$ is the thermal conductivity of the drilling fluid, and $\psi $ is defined as follows:

Furthermore, the convective wall heat flux in laminar flow conditions ($qw$) is then (Barletta 1996)

where $Ri$ is the internal pipe radius, $Tw$ is the wall temperature, and $Tm$ is the drilling fluid temperature.

The enthalpy of a thermodynamic system is the sum of its internal energy $U$ and the work required to achieve its pressure and volume:

In differential form, Eq. 29 can then be expressed as [see Landau and Lifshitz (1980) for a demonstration]:

Assuming that the pressure drop along the pipe length of Fig. 8 is negligible, then $dH\u2248CpdT$, so the energy balance of the drilling fluid contained in the pipe can be expressed as:

where $Tm$ is the drilling fluid temperature, *s* is the curvilinear abscissa, and $Ti$ is the temperature of the wall inside the pipe. The characteristic length $L$ of the Nusselt number is the internal pipe diameter (i.e., $L=2Ri$). The hydraulic work arising from viscous pressure losses is

The energy balance for the pipe and the insulation material is defined in a cylindrical coordinate system as

where $\rho s$, $Cps$, and $\lambda s$ are, respectively, the mass density, specific heat capacity, and thermal conductivity of the solid material of either the pipe or the insulation material, and $qsh$ is the generated heat per unit time and unit length of the heating element. Considering the axial symmetry of the system, the term $\u22022Ts\u2202r2$ is necessarily equal to zero.

In steady-state conditions, without heat generation and in pure axial conduction, Eq. 33 can be written as follows:

After integration over a cylindrical area between $R1$ and $R2$, the axial heat flux per unit length ($qa$) is derived:

The axial heat flux over an axial distance $l$ can be estimated:

where $\u2206Ta$ is the axial difference of temperature.

Similarly, in steady-state conditions without heat generation and in pure radial conduction, Eq. 33 can be written as follows:

After integration over a shell of radius $r$ and length $l$, the radial heat flux per unit radial distance ($qr$) is as follows:

And therefore, the radial heat flux between $R1$ and $R2$ is

where $\u2206Tr$ is the radial temperature difference.

Analysis of the heat transfer along an insulated pipe after the fluid has passed a heat source shows that the temperature along the pipe depends not only on the specific heat capacity but also the thermal conductivity of the fluid.

## Experimental Setup for Determining $Cp$ and $\lambda $

Attaching temperature sensors to the outside of the pipe in Fig. 8 enables the radial heat flux to be measured while circulating fluid in the system. This proposition was verified by constructing a flow loop similar to that shown in Fig. 8. Fig. 9 shows a schematic view of the experimental setup. A 10-L tank is equipped with an agitator and copper coil through which tap water is circulated. The flow rate is controlled so that the temperature in the tank remains constant.

A progressive cavity pump injects the fluid into the insulated instrumented pipe section. The pump is equipped with an encoder to measure the pump speed, and because there is very little pressure loss in the flow loop, the flow rate is directly proportional to the pump speed. The conversion factor from pump speed to volumetric flow rate has been calibrated by measuring the time to pump a known volume of fluid. The insulated pipe section comprises a 2-m length of 20-mm-diameter stainless-steel tube. Close to the inlet is a cylindrical aluminum block 200 mm in length and 100 mm in diameter heated by four resistors. A temperature sensor (TT1) is placed inside the aluminum block, and a controller regulates the electrical current to the heating resistor to regulate the temperature of the aluminum to a given set point. The remaining temperature sensors are placed 250 mm apart, and the insulation material is 30 mm thick.

Fig. 10 shows what happens when the heating element is turned on at 550 seconds, and then just after 3,100 seconds, when the flow rate is decreased from 0.451 to 0.096 L/min. The first temperature sensor downstream of the heating element (TT2 in Fig. 10) is positioned 100 mm above the top of the heating element and therefore is dominated by the heat conducted through the pipe with minimal influence from the circulating fluid. Because the mass density is known, temperature measurements at two different fluid velocities allow the specific heat capacity and the thermal conductivity of the drilling fluid (Fig. 11) to be derived from the heat transfer model described by Eqs. 31 and 33.

## Overall Experimental Design

The measurement of radial heat flux along a pipe under varying flow conditions, shown in Fig. 12**,** with three stages of pressure and temperature permits the determination of the PVT properties of the fluid, as follows:

Ambient pressure and temperature conditions at the inlet

Increasing the temperature by 5–10°C at a pressure in the region of 50–60 bar

Increasing the temperature by a further 5–10°C with a pressure in the region of 25–30 bar

The volumetric flow rate and mass density at the inlet are measured with a Coriolis flowmeter. A speed-of-sound sensor is installed upstream of the inlet of the progressive cavity pump. In the second stage, a heating element downstream of the pump increases the fluid temperature by 5–10°C. A stainless-steel pipe is mounted on a thermal insulator downstream from the heating element. A differential pressure sensor measures the pressure losses along the pipe. The temperature distribution along a pipe is measured by at least four temperature sensors after which the mass density and speed of sound are again measured with a Coriolis flowmeter. The pressure in this second stage is controlled by a choke downstream of the flowmeter. The third stage consists of a pipe of a different diameter from the first, designed to create flow conditions that differ from those in the previous stage. A similar heating element further increases the temperature. The pipe is thermally insulated from the heating element and, again, at least four temperature sensors are placed along the pipe to measure the temperature distribution as well as a differential pressure transducer. Another combined sensor measures the mass density and the speed of sound under the third set of conditions. The pressure in this third stage is controlled by a choke at the outlet.

The heat transfer (Eq. 31) depends on $\rho m,$$Cpm$, $\lambda m$, and the Nusselt number $NuL$, which in turn depends on $\rho m,$$Cpm$, $\lambda m$. The solution of Eq. 31 gives the temperature evolution of the system. Because the fluid’s mass density is measured, it remains to determine $Cpm$ and $\lambda m$. These parameters are obtained by solving the minimization problem:

where $Ti$ and $T~l$ are, respectively, the measured and estimated temperatures at $nT$ different positions along the pipe. If Eq. 31 is divided by $Cpm$, then the equation depends on a term proportional to $\lambda mNuLCpm$ and $qs\Delta pCpm$. Because the second term is small compared with the first, the temperature along the pipe is mostly influenced by the ratio of $\lambda m$ and $Cpm$. Because it is desired to explicitly determine the specific heat capacity of the fluid, it is necessary to create conditions that yield both the specific heat capacity and the thermal conductivity. Two dissimilar pipe sizes will result in different fluid velocities, allowing the term $qs\Delta pCpm$ to elicit this difference.

## Theoretical Model of Experimental Setup for Determining *C*_{p} and $\lambda $

To extract values of *C _{p}* and

*λ*from the setup shown in Fig. 12, the system is discretized as shown in Fig. 13 in $na$ axial elements of length $\u2206s$ (indexed by $i$) and in radial elements of radial distance $\u2206r$ (indexed by $j$). Similarly, time may be discretized in time steps of duration $\u2206t$ (indexed by $k$).

Eq. 31 governs the heat transfer in the drilling fluid and in the air (outside of the system). For air, there are no heat sources, and there is no forced circulation; therefore, the energy balance at the external wall of the setup reduces to

where $\rho air$ is the mass density of air, $Cpair$ is the specific heat capacity of air, $Rnr$ is the external radius, $hair$ is the air convective heat transfer coefficient, and $Tair$ is the air temperature.

For the drilling fluid, heat generation arises from viscous pressure drops. Eq. 32 is used to estimate the heat generation caused by the passage of the fluid through the chokes. The energy balance at the internal wall of the pipe is

where $R1$ is the internal radius of the pipe, $Tmi$ is the temperature of the fluid at axial position *i,* and $\u2206pi$ is the viscous pressure drop at axial position *i*. Note that $Qv$ and $NuL$ also depend on the axial position.

For any other values of $j$, the energy conservation is based on Eq. 33:

where $Rj+12$ means the average radius between $j$ and $j+1$ and $qshi$ is the heat generation at axial position *i*, if any.

After regrouping all the terms indexed $k+1$ on one side and the terms indexd $k$ on the other, a system of linear equations is obtained. It can be solved for all $Ti,j,k+1$, for example, using a Gauss-Jordan method:

where $P$ is a pentagonal matrix in which coefficients depend on the current boundary conditions and values estimated at the previous timestep $k$, $Tk+1$ is a vector of unknown temperature at timestep $k+1$, and $R$ is a vector of coefficients that depend only on the current boundary conditions and values estimated at the previous timestep $k$. The boundary conditions are the air temperature, the temperature of the pipe and the drilling fluid at the inlet, the volumetric flow rate at the inlet, the drilling fluid mass density in in-situ conditions, the specific heat capacity and the thermal conductivity of the drilling fluid, and the heat generated by the heating elements. In practice, a Crank-Nicolson scheme is used to improve the stability of the numerical resolution (Crank and Nicolson 1947). It is then possible to calculate, as a function of time, the temperature anywhere in the system and on the external side of the pipe.

Initial values of $Cpm$ and $\lambda m$ are unknown and therefore must be estimated. Because $nT$ temperatures are measured along the pipes, $Cpm$ and $\lambda m$ can be estimated by solving Eq. 40.

Setting $F=\u2211l=1nTTl-T~l2=\u2211l=1nTrl2$, the sum of squared temperature differences, and defining $\beta t=[Cpm\lambda m]$, the vector of model parameters. $F$ is a minimum when

Linearizing the solution vector from one iteration to another:

where $\xi $ is the iteration number. Then the first order approximation of $T~l\beta $ is

where $Jls=\u2202rl\u2202\beta s$ are the members of the Jacobian matrix $J$. Then, a first-order approximation of $rl$ is

where $\u2206Tl,\xi =Tl-T~l\beta \xi $ is the temperature difference for sensor $l$ at iteration $\xi $. Substituting in Eq. 45, here is the resulting equation:

which can be rewritten as follows:

which is a system of linear equations that can be solved for $\Delta \beta $ resulting in a new value of $\beta $ for the next iteration. The procedure stops when $\Vert \beta ^\Vert \u2264\epsilon $, where $\epsilon $ is small and $\beta ^t=[CpmCp0\lambda m\lambda 0]$, which is a normalized version of the solution vector with $Cp0$ and $\lambda 0$ being chosen such that $CpmCp0$ and $\lambda m\lambda 0$ are of the same order of magnitude for normal expected values of $Cpm$ and $\lambda m$. When convergence is achieved, acceptable estimates of $Cpm$ and $\lambda m$ have been found. The Jacobian terms are estimated using a central difference approximation:

The initial values for $\beta \xi =0$ are chosen from standard values for water/brines and base oils mixed with a quantity of barite that is necessary to obtain the current fluid mass density. Equations for determining the necessary amount of barite for a given mass density can be found in Cayeux (2020), and equations for estimating the specific heat capacity and thermal conductivity of a mix with solids can be found in Cayeux et al. (2014).

Having obtained values of *C _{p}* and

*λ*, the parameters A, B, C, D, E, and F of the API PVT model can be calculated from Eq. 14.

Originally, only the specific heat capacity of the fluid ($Cpm$) had to be determined to enable conversion of the isentropic to isothermal compressibility (Eq. 11). However, by designing a setup based on temperature measurements at different positions along a pipe downstream of a heat source, it was found that these temperatures depended not only on $Cpm$ but also on the fluid thermal conductivity ($\lambda m$). While the determination of $\lambda m$ is a necessary step in establishing the value of $Cpm$ as a byproduct, it is a valuable input to additional downhole heat transfer calculations.

## Discussion

An inline PVT measurement sensor for drilling fluids has been described. It reduces the number of pressure and temperature conditions required to predict the fluid densities by measuring the speed of sound in the medium. However, to obtain the isothermal compressibility of a drilling fluid, it is also necessary to measure its specific heat. Therefore, the initial design of the apparatus was modified to incorporate the measurement of temperatures along a pipe after applying a step change in temperature to the fluid. However, it has been found that the specific heat could not be determined without also finding another thermo-physical property of the fluid, namely, its thermal conductivity. An experimental setup was constructed to obtain these values, but, so far, the experiments have only been conducted with aqueous solutions of sodium chloride, potassium chloride brines, and methanol. After the initial experiments, it was found the design had to be modified based on the lessons learned from the first series of tests. It remains to be seen whether the new design based on constant flow rates with two pipe diameters provides the necessary measurement precision to calibrate the specific heat and thermal conductivity of the drilling fluid. In addition, the setup must be tested with both WBM and OBM. The precision of the apparatus over the wide range of pressures and temperatures depends on the availability of high-precision process industry densitometers and speed-of-sound sensors. Drilling fluids are notoriously difficult to analyze because of their high solids content. There is a risk of a deterioration in the accuracy of the sensors because of surface erosion of their internal pipes. This possibility will have to be tested in an experimental setup over extended periods to determine changes in accuracy against independent laboratory PVT measurements.

## Future Work

The proposed design can provide the complete PVT behavior of the drilling fluid as well as its specific heat capacity and thermal conductivity continuously, in real time and without delay. The next step is to build a laboratory prototype of the proposed design to verify the working principle. The measured values will be compared with laboratory measurements of mass density made over a wide range of pressures and temperatures, as well as laboratory measurements of specific heat capacity and thermal conductivity. If the results are satisfactory then, after further refinement of the design, consideration will be given to the development of a system that can be used for field trials at the rigsite.

## Conclusions

Knowledge of the PVT behavior of a drilling fluid is important for estimating downhole pressures during drilling operations. As the drilling fluid composition changes, it is difficult to define PVT behavior accurately based on sporadic mass density measurements made under ambient conditions at the surface.

A PVT model for a drilling fluid can be calibrated using a set of six pressure and temperature measurements. Calibration measurements made at low values of pressure and temperature can be reliably extrapolated to those to which the fluid is exposed when being circulated in the borehole, so long as the precision of the mass density measurement is in the order of 0.05 kg/m^{3}. However, a setup capable of measuring mass density under six different pressure and temperature conditions either would produce the PVT model parameters with substantial time delay if only one set of sensors is used or would require a relatively complex hydraulic setup to acquire the six sets of measurements simultaneously.

It has been shown that the number of pressure and temperature conditions can be reduced to three if the speed of sound in the drilling fluid is measured at the same time as the mass density. However, this method requires knowledge of the specific heat capacity of the drilling fluid. A method involving the addition of extra temperature sensors to the apparatus has been described. The additional temperature measurements are used to estimate the specific heat capacity of the fluid. The thermal conductivity of the fluid is also obtained as a valuable byproduct of the analytic procedure.

The outcome of this work is an inline setup that provides the PVT behavior of the drilling fluid as well as its specific heat capacity and thermal conductivity continuously and without delay. The latter two parameters are, of themselves, very important for heat transfer calculations in real-time model-predictive-control drilling automation applications.

## Nomenclature

*A*6×6 matrix

- $Am$
parameter of the drilling fluid PVT model, ML

^{−3}, kg/m^{3} - $Ao$
parameter of the oil-phase PVT model, ML

^{−3}, kg/m^{3} *B*6×6 matrix

- $Bm$
parameter of the drilling fluid PVT model, ML

^{−3}ϑ^{−1}, kg/(m^{3}K) - $Bm`$
parameter of the drilling fluid PVT model, ML

^{−3}ϑ^{−2}, kg/(m^{3}K^{2}) - $Bo$
parameter of the oil-phase PVT model, ML

^{−3}ϑ^{−1}, kg/(m^{3}K) - $Bw$
parameter of the brine-phase PVT model, ML

^{−3}ϑ^{−1}, kg/(m^{3}K) - $c$
speed of sound, LT

^{−1}, m/s - $c1$
speed of sound at conditions of pressure and temperature $p1,T1$, LT

^{−1}, m/s - $c2$
speed of sound at conditions of pressure and temperature $p2,T2$, LT

^{−1}, m/s - $c3$
speed of sound at conditions of pressure and temperature $p3,T3$, LT

^{−1}, m/s *C*6×6 matrix

- $Cm$
parameter of the drilling fluid PVT model, L

^{−2}T^{−2}, kg/(m^{3}Pa) - $Co$
parameter of the oil-phase PVT model, L

^{−2}T^{−2}, kg/(m^{3}Pa) - $Cp$
isobaric specific heat capacity, L

^{2}T^{−2}$\u03d1$^{−1}, J/(kg·K) - $Cpair$
specific heat capacity of air, L

^{2}T^{−2}$\u03d1$^{−1}, J/(kg·K) - $Cpm$
specific heat capacity of the drilling fluid, L

^{2}T^{−2}$\u03d1$^{−1}, J/(kg·K) - $Cps$
specific heat capacity of a solid material, L

^{2}T^{−2}$\u03d1$^{−1}, J/(kg·K) - $Cw$
parameter of the brine-phase PVT model, L

^{−2}T^{−2}, kg/(m^{3}Pa) *D*6×6 matrix

- $Dm$
parameter of the drilling fluid PVT model, L

^{−2}T^{−2}ϑ^{−1}, kg/(m^{3}PaK) - $Dm`$
parameter of the drilling fluid PVT model, L

^{−2}T^{−2}ϑ^{−2}, kg/(m^{3}PaK^{2}) - $Do$
parameter of the oil-phase PVT model, L

^{−2}T^{−2}ϑ^{−1}, kg/(m^{3}PaK) - $Dw$
parameter of the brine-phase PVT model, L

^{−2}T^{−2}ϑ^{−1}, kg/(m^{3}PaK) *E*6×1 matrix

- $Em$
parameter of the drilling fluid PVT model, L

^{−1}M^{−1}T^{−4}, kg/(m^{3}Pa^{2}) - $Eo$
parameter of the oil-phase PVT model, L

^{−1}M^{−1}T^{−4}, kg/(m^{3}Pa^{2}) - $Ew$
parameter of the brine-phase PVT model, L

^{−1}M^{−1}T^{−4}, kg/(m^{3}Pa^{2}) - $fi$
volume fraction of the $i$th component of the drilling fluid, dimensionless

- $F$
sum of the square temperature differences, ϑ

^{2}, K^{2} - $Fm$
parameter of the drilling fluid PVT model, L

^{−1}M^{−1}T^{−4}ϑ^{−1}, kg/(m^{3}Pa^{2}K) - $Fm`$
parameter of the drilling fluid PVT model, L

^{−1}M^{−1}T^{−4}ϑ^{−2}, kg/(m^{3}Pa^{2}K^{2}) - $Fo$
parameter of the oil-phase PVT model, L

^{−1}M^{−1}T^{−4}ϑ^{−1}, kg/(m^{3}Pa^{2}K) - $Fw$
parameter of the brine-phase PVT model, L

^{−1}M^{−1}T^{−4}ϑ^{−1}, kg/(m^{3}Pa^{2}K) - $hair$
convective heat transfer coefficient, MT

^{−3}ϑ^{−1}, W/(m^{2}K) - $hL$
convective heat transfer coefficient, MT

^{−3}ϑ^{−1}, W/(m^{2}K) - $H$
enthalpy per unit mass, L

^{2}T^{−2}, J/kg *J**n*×2 Jacobian matrix_{T}- $l$
length [L](m)

- $L$
characteristic length, L, m

- $m$
mass of drilling fluid contained in volume $V$, M, kg

- $na$
number of axial elements

- $NuL$
Nusselt number, dimensionless

- $p$
absolute pressure, ML

^{−1}T^{−2}, Pa *P**n*·_{a}*n*×_{r}*n*·_{a}*n*_{r}matrix, ML^{2}T^{–3}ϑ^{–1},W/K- $q$
heat flux, MT

^{−3}, W/m^{2} - $qa$
axial heat flux per unit length, MLT

^{−3}, W/m - $qr$
radial heat flux per unit radial length, MLT

^{–3}, W/m - $qs$
heat source per unit time and per unit length, MLT

^{−3}, W/m - $qsh$
heat source per unit time and per unit length generated by the heating element, MLT

^{−3}, W/m - $qs\Delta p$
heat source per unit time and per unit length generated by pressure loss, MLT

^{−3}, W/m - $qw$
convective wall heat flux in laminar conditions, MT

^{−3}, W/m^{2} - $Q$
amount of heat, ML

^{2}T^{−2}, J - $Qa|l$
axial heat flux over a length $l$, ML

^{2}T^{−3}, W - $Q\u2192c$
conductive and natural convective heat flow, ML

^{2}T^{−3}, W - $Q\u2192f$
forced convective heat flow, ML

^{2}T^{−3}, W - $Qr|R1R2$
radial heat flux between $R1$ and $R2$, ML

^{2}T^{−3}, W - $Qv$
volumetric flow rate, L

^{3}T^{−1}, m^{3}/s - $r$
radial distance, L, m

- $rl$
difference of measured and estimated temperature at position $l$, $\u03d1$, K

*R**n*·_{a}*n*vector, ML_{r}^{2}T^{–3}, W- $R1$
radial distance in a solid, L, m

- $R2$
radial distance in a solid, L, m

- $Ri$
internal pipe radius, L, m

- $s$
curvilinear abscissa, L, m

- $S$
entropy, ML

^{2}T^{−2}ϑ^{−1}, J/K - $S0$
parameter of the brine density model, ML

^{−3}, kg/m^{3} - $S1$
parameter of the brine density model, ML

^{−3}, kg/m^{3} - $S2$
parameter of the brine density model, ML

^{−3}, kg/m^{3} - $S3$
parameter of the brine density model, ML

^{−3}, kg/m^{3} - $T$
temperature, $\u03d1$, K

- $Tair$
air temperature, $\u03d1$, K

- $Ti$
temperature at the internal wall of the pipe, $\u03d1$, K

- $Tl$
measured temperature, $\u03d1$, K

- $T~l$
estimated temperature, $\u03d1$, K

- $Tm$
temperature of the drilling fluid, $\u03d1$, K

- $Tmi$
drilling fluid temperature at axial position $i$, $\u03d1$, K

- $Tw$
internal pipe wall temperature, $\u03d1$, K

- $v\u2192$
fluid velocity, LT

^{−1}, m/s - $wt$
weight fraction of a salt, dimensionless

*x*6×1 matrix

*X*_{1}6×6 matrix

*X*_{2}6×6 matrix

*X*_{3}6×6 matrix

- $\alpha $
volumetric coefficient of thermal expansion, ϑ

^{−1}, K^{−1} - $\alpha p1,T1$
volumetric coefficient of thermal expansion at conditions of pressure and temperature $p1,T1$, ϑ

^{−1}, K^{−1} - $\alpha p2,T2$
volumetric coefficient of thermal expansion at conditions of pressure and temperature $p2,T2$, ϑ

^{−1}, K^{−1} - $\alpha p3,T3$
volumetric coefficient of thermal expansion at conditions of pressure and temperature $p3,T3$, ϑ

^{−1}, K^{−1} - $\beta $
vector of the calibration parameters $Cpm$ and $\lambda m$

- $\beta ^$
vector of the normalized calibration parameters $CpmCp0$ and $\lambda m\lambda 0$

- $\u2206pi$
viscous pressure drop at axial position $i$, ML

^{−1}T^{−2}, Pa - $\u2206r$
length of a radial element, L, m

- $\u2206s$
length of an axial element, L, m

- $\u2206t$
duration of a timestep, T, seconds

- $\u2206Ta$
axial temperature difference, ϑ, K

- $\u2206Tl,\xi $
difference between the $l$-temperature measurement and its corresponding estimated value at iteration $\xi $, ϑ, K

- $\u2206Tr$
radial temperature difference, ϑ, K

- $\epsilon $
small number, dimensionless

- $\kappa p1,T1$
isothermal compressibility coefficient at conditions of pressure and temperature $p1,T1$, M

^{−1}LT^{2}, Pa^{−1} - $\kappa p2,T2$
isothermal compressibility coefficient at conditions of pressure and temperature $p2,T2$, M

^{−1}LT^{2}, Pa^{−1} - $\kappa p3,T3$
isothermal compressibility coefficient at conditions of pressure and temperature $p3,T3$, M

^{−1}LT^{2}, Pa^{−1} - $\kappa S$
isentropic compressibility, M

^{−1}LT^{2}, Pa^{−1} - $\kappa T$
isothermal compressibility coefficient, M

^{−1}LT^{2}, Pa^{−1} - $\lambda $
thermal conductivity, MLT

^{−3}ϑ^{−1}, W/(m·K) - $\lambda m$
thermal conductivity of the drilling fluid, MLT

^{−3}ϑ^{−1}, W/(m·K) - $\lambda s$
thermal conductivity of a solid material, MLT

^{−3}ϑ^{−1}, W/(m·K) - $\xi $
iteration number in the calibration procedure for $Cpm$ and $\lambda m$

- $\rho air$
mass density of air, ML

^{−3}, kg/m^{3} - $\rho i$
mass density of the $i$ component of the drilling fluid, ML

^{−3}, kg/m^{3} - $\rho m$
mass density of a drilling fluid, ML

^{−3}, kg/m^{3} - $\rho m1$
mass density measurement at conditions of pressure and temperature $p1,T1$, ML

^{−3}, kg/m^{3} - $\rho m2$
mass density measurement at conditions of pressure and temperature $p2,T2$, ML

^{−3}, kg/m^{3} - $\rho m3$
mass density measurement at conditions of pressure and temperature $p3,T3$, ML

^{−3}, kg/m^{3} - $\rho m4$
mass density measurement at conditions of pressure and temperature $p4,T4$, ML

^{−3}, kg/m^{3} - $\rho m5$
mass density measurement at conditions of pressure and temperature $p5,T5$, ML

^{−3}, kg/m^{3} - $\rho m6$
mass density measurement at conditions of pressure and temperature $p6,T6$, ML

^{−3}, kg/m^{3} - $\rho s$
mass density of a solid material, ML

^{−3}, kg/m^{3} - $\rho w$
mass density of a brine, ML

^{−3}, kg/m^{3} - $\Omega $
a set of indices for the components of the drilling fluid

## Acknowledgments

Finally, I would like to extend a special thanks to John Thorogood for very fruitful discussions and valuable inputs during the preparation of this manuscript.

## Article History

This paper (SPE 204084) was accepted for presentation at the SPE/IADC International Drilling Conference and Exhibition, Virtual, 8–12 March 2021, and revised for publication. Original manuscript received for review 25 April 2022. Revised manuscript received for review 20 June 2022. Paper peer approved 13 July 2022.

## References

*API RP 13D*