# Open Source Pendant Drop

This page is based on a report written (with 2 others who ran the validation experiments) as a project for Prof. Kavehpour at UCLA wherein I attempted to build an open-source alternative to the expensive pendant drop analyzer in his lab. To moderate success.

# Introduction

Current Pendant drop hardware and software is relatively expensive. This project aims at developing a cheaper (free) alternative of measuring surface tension using the pendant drop method. Open-source computer vision software is used as it is a free library of programming functions, which focuses mainly on real-time image processing. The accuracy of our work will be validated using current cutting edge technology made specifically to measure surface tension using a pendant drop, specifically the DSA100, Drop Shape Analyzer made by Kruss. Subsequent to developing our code, which measures surface using a pendant drop, we investigate the potential of extending the code into a working cell phone application.

# Background and Theory

The work, which has to be expended in order to increase the size of the surface of a phase, is referred to as the surface tension. As a measure of work per unit area or force per wetted length, surface tension has the unit mN/m and is designated by the symbol $$\sigma$$. If the phase is solid, the equivalent term that is normally used is surface free energy. If the adjacent phase is a liquid or a solid, reference is made to interfacial tension.

Many methods exist for the measurement of surface and interfacial tension, and each have an advantages for particular applications. Some are dynamic, and are ideally suited to following the changes occurring in a surface during the first fractions of a second after its formation. However, most commonly measurements are made in a static manner, and are intended to indicate the properties of the surface in its equilibrium condition. In Prof. Kavehpour's lab at UCLA, he has industrial hardware which uses the so-called Pendant Drop Method, which we will discuss next.

## Pendant Drop Method

The shape of a drop suspended from a needle is determined from the surface tension and the weight of the drop. The surface tension can be obtained from the image of the drop. An increased pressure is produced inside the drop as a result of the interfacial tension between the inner and outer phase. The correlation between the pressure difference, the radii of curvature of both surfaces at a point and the interfacial tension is described by the Young-Laplace equation,

$$\Delta p = \sigma (1/r_1 +1/r_2 )$$

The pendant drop is deformed under the effect of gravity, as a hydrostatic pressure, which affects both main radii of curvatures inside the drop due to its weight.

When dealing with liquids with a relatively high viscosity, such as colloidal solutions, and by containing material of high molecular weight the result is a low speed of diffusion. The pendent drop method is ideal, as it does not depend on the extension of a liquid surface. The extension of high viscosity liquids surface is inefficient because under such conditions not only would the slow diffusion prevent attainment of equilibrium, but also the high viscosity would invalidate any calibration with free flowing liquids [2].

Taking the origin to be the bottom of the drop, the equation for the profile of a liquid surface of revolution is

$$1/\rho+\sin\phi/x=2+\beta z$$

where $$\rho$$ is the density of the liquid, $$\phi$$ is the slope at the same point and

$$\beta=-(g\rho b^2)/\sigma$$

where $$\sigma$$ is the surface tension, $$\rho$$ is the density, and $$b$$ is the radius of curvature at the origin. $$\beta$$ Determines the shape of a drop and $$b$$ determines its size.

Figure 5: Pendant Drop Schematic (From [2])

If the maximum diameter $$d_e$$ is measured, a diameter $$d_s$$ at a horizontal plane of height $$d_e$$ drom the bottom of the drop is also found. Their ratio, noted as $$S$$, is a function of $$\beta$$, which for a given $$S$$ and $$d_e$$ is proportional to $$b$$

$$S=\frac{d_s}{d_e}$$
$$\sigma = \frac{g\rho d_e^2}{H}$$

where

$$\frac{1}{H}=\frac{1}{\beta(d_e/b)^2}=\frac{1}{4\beta x_e^2}$$

is a function of $$S$$. The function connecting $$1/H$$ and $$S$$ was originally obtained by experiments with water, the surface tension of which is known from capillary measurements [2]. The plot below shows the available data from literature for this experiment. The data was fit to a power law as shown in the figure. The curve fit equation is used later in our software for the sake of simplicity in programing.

Figure 6: Experimental Value of 1/H Versus S

Using the theoretical equation for the profile of a liquid drop shown previously, a similar plot is obtained and shown in the figure below. The data available from literature was also curve fit for the sake of comparison to the experimental plot shown above.

Figure 7: Theoretical Plot of 1/H Versus S

# Validation Experiments

The pendant drop is a drop suspended from a needle in a bulk liquid or gaseous phase. The shape of the drop results from the relationship between the surface tension or interfacial tension and gravity. In the pendant drop method, the surface tension or interfacial tension is calculated from the shadow image of a pendant drop using the drop shape analysis. The drop shape analysis (DSA) is an image analysis method for determining the contact angle from the shadow image of a sessile drop and the surface tension or interfacial tension from the shadow image of a pendant drop.

A drop is metered onto a sample or is located at the tip of a needle (pendant drop). an image of the drop is recorded with the help of a camera and transferred to the drop shape analysis software. A contour recognition is initially carried out based on a grey-scale analysis of the image. In the second step, a geometrical model describing the drop shape is fitted to the contour. The surface tension is always calculated with the help of a Young Laplace fit to the contour of a pendant drop determined by the image analysis. The image scale and the difference in density between drop phase and bulk phase must be known.

## DSA Method

If a drop of liquid is hanging from a syringe needle then it will assume a characteristic shape from which the surface tension can be determined. The force of gravity acting on the drop and depending on the particular height compensates the Laplace pressure, which is given by the curvature of the drop contour at this point. The Laplace pressure results from the radii of curvature standing vertically upon one another in the following way

$$\Delta p = \sigma (1/r_1 +1/r_2 )$$

This equation describes the difference between the pressure below and above a curved section of the surface of a drop with the principle radii of curvature $$r_1$$ and $$r_2$$. The pressure difference is the difference in pressure between the outside and inside of the drop.

## Basic Drop Contour Equation

For a pendant drop, which is rotationally symmetrical in the z direction then, based on the Laplace equation it is possible to give an analytically accurate geometric description of the principle radii of curvature. The tangent at the intersection of the z-axis with the apex of the drop forms the x-axis. The following figure is a schematic illustrating geometrical variables used

Figure 8: DSA Pendant Drop Schematic (from [4])

In hydro-mechanical equilibrium the following relationship applies

$$\Delta p_{apex} - \Delta p_{p} = z\Delta\rho g$$

where the first term on the left is the pressure difference at the apex, the second term from the left is the pressure difference at point p and the second term from the right is the difference in density between the drop liquid and its surroundings.

With the principle curvatures, k, and the young Laplace equation we obtain

$$\Delta p = \sigma(k_1 + k_2)$$

From differential geometry the analytical expressions for the curvatures of the principle sections at point P are known by the following two equations.

$$k_{p,1} = \frac{d\phi}{ds}$$
$$k_{p,2} = \frac{\sin\phi}{x}$$

Substituting the above two curvature expressions back into the equilibrium equation we obtain the following equation below, noting that the principle curvatures at the apex are the same due to the axial symmetry of the drop [3]

$$\frac{d\phi}{ds} = 2k_{apex} - \frac{z\Delta\rho g}{\sigma} - \frac{\sin\phi}{x}$$

where s is the arc length of the drop profile. The definitions below are used next to convert the above equations into a dimensionless form to solve it.

$$X=x/a$$
$$Z=z/a$$
$$B=\frac{1}{ak_{apex}}$$

with

$$a = \sqrt{\sigma/(\Delta\rho g)}$$

Where $$B$$ is the dimensionless form parameter of the pendant drop, and $$a$$ is the capillary constant. With these definitions the final equilibrium equation can be written in the following way

$$\frac{d\phi}{dS} = \frac{2}{B} - Z - \frac{\sin\phi}{X}$$
$$\frac{dX}{dS} = \cos\phi$$
$$\frac{dZ}{dS} = \sin\phi$$

The equation above is known as the fundamental equations for a pendant drop. The parameter $$B$$ describes the shape of the drop profile and is therefore called the shape parameter. In addition, it can be seen that the surface tension can be calculated for a known difference in density if the relative size ratio a of a measured drop can be determined for the corresponding theoretical drop profile. By varying the form parameter $$B$$ it is possible to calculate the theoretical drop profiles after carrying out a numerical integration method. If the theoretical drop profile corresponds to the measured drop profile then the surface tension can be calculated.

## DSA Results

The Drop Shape Analyzer (DSA100) was used to measure the surface tension of both water and hexadecane using the built in pendant drop method in the DSA. We chose to measure these two liquids because the surface tension of hexadecane is around half the surface tension of water. This gives us a good range to determine the feasibility of measuring surface tension using our own open source computer vision code.

For each measurement run, the drop shape analyzer takes a video of the pendant drop and calculates the surface tension a number of times, as defined by the frames per second, which is determined by the user. A typical graph illustrating the captured surface tension values is shown in the plot below

Figure 9: DSA Surface Tension Results for Water

The average surface tension for this particular measurement was 71.5 mN/m. the literature value is around 72 mN/m, which is definitely in the vicinity. The surface tension value of liquids is very sensitive to any contaminants contained in the liquid. This is why we chose to compare our own software results with actual experimental results using the Drop Shape Analyzer. Note that the variation of measured surface tension values for this run is around ±2 mN/m. this is rather large fluctuation error. It was observed during the measurement that the drop was very sensitive to any movement, although the DSA is placed on an optical table. This caused the drop to continuously vibrate during the experiment. This was a major source of error. Later it will be shown that the hexadecane results have a much smaller standard deviation. This is most likely due to the high surface tension of water as compared to hexadecane, which allows the water droplet to have a much smaller throat diameter as compared to hexadecane and thus allowing for more instability during the measurement.

A typical snap shot of a water droplet during this experiment is shown below

Figure 10: DSA Pendant Drop Captured Image of Water

The bottom blue horizontal line is a user-defined line, which indicates the maximum height, which will be used to for the fitting of the drop profile. This is to illuminate the distorted region caused by the needle. The top two blue lines are placed on the needle to calibrate the image from pixels to millimeters. In this case the needle size used was 0.51mm. The green line is the profile fit for the pendant droplet. Finally, the red lines define the computation region, as indicated by the user, and should be made as small as possible to reduce the computation time.

Next, the results for the hexadecane will be shown. Again for each measurement run, the drop shape analyzer takes a video of the pendant drop and calculates the surface tension a number of times, as defined by the frames per second, which is determined by the user. A typical graph illustrating the captured surface tension values for hexadecane is shown in the plot below

Figure 11: DSA Surface Tension Results for Hexadecane

The average surface tension for this particular measurement was 27.45 mN/m. the literature value is around 27.47mN/m, which is very close. Again, the surface tension value of liquids is very sensitive to any contaminants contained in the liquid. This is why we chose to compare our own software results with actual experimental results using the Drop Shape Analyzer. Note that the variation of measured surface tension values for this run is around ±.3 mN/m. this is a rather small fluctuation as compared to the experiment done with water, For same reason mention earlier.

A typical snap shot of a hexadecane droplet during this experiment is shown below.

Figure 12: DSA Pendant Drop Captured Image for Hexadecane

As previously stated, the bottom blue horizontal line is a user-defined line, which indicates the maximum height, which will be used to for the fitting of the drop profile. This is to illuminate the distorted region caused by the needle. The top two blue lines are placed on the needle to calibrate the image from pixels to millimeters. In this case the needle size used was 1.81mm. The green line is the profile fit for the pendant droplet. Finally, the red lines define the computation region, as indicated by the user, and should be made as small as possible to reduce the computation time.

# Image Processing with ucla-pendant-drop

The image processing of droplets to extract surface tension has been designed with the idea of avoiding ad hoc processing of each droplet being analyzed. Based on our skill level of image processing, automatically extracting edges from images was difficult and slow when there was any ‘noise’ in the image. We’ll call ‘noise’ anything like reflections or visible background colors. Our solution was to present on-screen to the user a reticle for centering and sizing the droplet. The software was built with and calibrated with the water droplet first.

## Droplet locating with on-screen reticle

An example of using the reticle is shown in the series of images of Fig. 13.a-f. The process involves the user interacting with the camera image via an on-screen cross-hairs. The main advantage of this approach is having a known general location of the droplet for the sake of processing.

a) original droplet image

b) on-screen reticle for user interaction to center the droplet

c) droplet now centered in the reticle

d) with centered droplet, automatic processing of the image can proceed, first the image far outside the reticle is deleted.

e) a threshold is applied within the reticle area to binarize the image into ‘black’ or ‘white’ pixels

f) from the binary image, edges can be efficiently and cleanly extracted (shown in white).

Figure 13:Demonstration workflow of the ucla-pendant-drop software centering, cleaning, thresholding and extracting edges for radius calculations

With the droplet located, a threshold and edge-detection technique are applied to the image. The details of these processes are described next.

## Canny edge detection

Before detecting edges in the image, we assist the calculation by applying a binary threshold to pixel color value in the droplet image. Mathematically speaking, the threshold can be thought of to be performing the following calculation

if img_source(x,y) > threshold_value:
img_target(x,y) = val
else:
img_target(x,y) = 0


The influence of the threshold value chosen will be discussed later. After the application of the threshold command we are left with an image such as Fig.13.e, where the ‘val’ is 225 for grey in the threshold (an arbitrarily chosen number) and 0 for the black of the droplet. The threshold chosen for this study was 10. In other words, if the pixel was ‘less white’ than 10/255ths white, it was considered black. With a crisp demarcation between black and white pixels, it was then simple to apply a canny edge detector filter. The edge detector simply scans for the gradient of pixel intensity and finds locations of gradients greater than a specified tolerance level. Details of the edge detector can be found in the OpenCV documentation.

Assuming we have calculated the gradient strength, G, at every pixel, the mathematic representation of the filtering heuristics can be summarized similarly,

if G(x,y) > edge_threshold_value:
edge(x,y) = 1
else:
edge(x,y) = 0


For the calculation of the droplet curvature, it is not necessary (and in fact harmful) to consider the entire droplet edge. We again make use of the reticle locating of the droplet to extract only the bottom portion of the droplet, as seen in Fig. 14

Figure 14: an Example edge of the water droplet. The white line is data of (x,y) arrays to be used in a least-square circle-fitting

## Diameter calculations

Once edges are detected, the data can be loaded into a standard scatter array and a least-squares fit applied to find a circle with matching radius. This was performed numerically with the following (relatively) self-explanatory Python script. In it a Jacobian is numerically calculated to accelerate the least-square computation. It is assumed there exists an array of (x,y) housing the data points to be fit

# coordinates of the barycenter
x_m = mean(x)
y_m = mean(y)
method_2b  = "leastsq with jacobian"

def calc_R(xc, yc):
""" calculate the distance of each 2D points from the center c=(xc, yc) """
return sqrt((x-xc)**2 + (y-yc)**2)

def f_2b(c):
""" calculate the algebraic distance between the 2D points and the mean circle centered at c=(xc, yc) """
Ri = calc_R(*c)
return Ri - Ri.mean()

def Df_2b(c):
""" Jacobian of f_2b
The axis corresponding to derivatives must be coherent with the col_deriv option of leastsq"""
xc, yc     = c
df2b_dc    = empty((len(c), x.size))

Ri = calc_R(xc, yc)
df2b_dc[ 0] = (xc - x)/Ri                   # dR/dxc
df2b_dc[ 1] = (yc - y)/Ri                   # dR/dyc
df2b_dc       = df2b_dc - df2b_dc.mean(axis=1)[:, newaxis]

return df2b_dc

center_estimate = x_m, y_m
center_2b, ier = optimize.leastsq(f_2b, center_estimate, Dfun=Df_2b, col_deriv=True)

xc_2b, yc_2b = center_2b
Ri_2b        = calc_R(xc_2b, yc_2b)
R_2b         = Ri_2b.mean()

# diameter of the droplet!
de           = R_2b*2


Code snippet 1: demonstration of the least-squares curve fitting for finding the radius of curvature of the droplet.

The least-squares fit is applied first to the water droplet (see Fig. 14). The result is graphically represented in Fig. 15, from which a droplet diameter of 203 pixels is computed.

Figure 15: Extracting edge data plotted with the least-square fit circle of radius 203 pixels to show excellent fit of the circle.

With the droplet diameter only found in pixels, we must use a conversion value from the needle (of known physical width) to translate pixels into millimeters. The detected edges of the entire droplet (Fig. 13.f) are used for this purpose. Furthermore, the other unknown diameter, $$d_s$$, is also calculated at this point in time. The results are all shown together in Fig. 16 along with the calculated value locations.

Figure 16: The needle width is calculated in pixels and used, with the known physical parameter, as a conversion ratio from pixels --> mm

The data of $$d_s$$, $$d_e$$, and needle diameter are summarized in pixel and physical widths in Table 1. The conversion factor is relatively sensitive to the measured physical diameter of the needle so care must be taken in the future when one is attempting to calculate surface tension.

Table 1: Summary of droplet diameters for water

Needle ds de
px (mm) px (mm) px (mm)
80 (0.51) 254 (1.62) 407 (2.60)

## Water results

With droplet diameters, we can directly calculate the surface tension of the water droplet from the equations given in the Theory section. We compute a surface tension of $$\gamma$$=71.5 mN/m for this droplet. This value compares extremely well with the measurement from DSA and the value reported in literature. A summary of important values calculated/used in the computation are given in Table 2.

Table 2: The surface tension value calculated by ucla-pendant-drop match extraordinarily closely to the reported values from DSA and literature for water.

| | | UCLA | DSA | Literature s | H | ρ | γ | γ | γ | | kg/m3 | mN/m | mN/m | mN/m --- | --- | --- | --- | --- | ---
0.630 | 0.936 | 998.7 | 71.5 | 71.5 | 72

It was desired that the code be fairly robust and universal for all droplets to be analyzed. For this reason, once the code settings had been calibrated for water, the droplet image of hexadecane was processed with no changes. The only requirement was that the droplet be centered in the reticle.

The hexadecane droplet was much less bulbous in relation to the needle diameter, as compared to the water droplet. The on-screen curved cross-hairs are still able to aid in left-right centering of the droplet but the up-down centering is slightly less concrete. The only major impact that has is on how high up on the droplet the ‘bottom half’ is for measuring the droplet bottom radius of curvature.

Figure 17: Hexadecane centered in the reticle is more ambiguous as to where, vertically, it should be placed.

The diameters calculated by ucla-pendant-drop code are given in Table 3, it is evident that the magnitude of pixel sizes for diameters are much closer to the needle width. This makes the physical measurement even more important for an accurate conversion factor.

Table 3: Summary of droplet diameters for hexadecane.

Needle ds de
px (mm) px (mm) px (mm)
197 (1.85) 234 (2.20) 265 (2.49)

The results of hexadecane surface tension are given in Table 4, the value calculated by ucla-pendant-drop is about 84% of the values calculated by DSA and given in literature. Considering the code had been calibrated for a separate droplet and used straight-away on the hexadecane, the value is promisingly close but not excellent.

Table 4: The surface tension value calculated by ucla-pendant-drop for hexadecane are much less in fitting with DSA or literature but is within the ballpark.

| | | UCLA | DSA | Literature s | H | ρ | γ | γ | γ | | kg/m3 | mN/m | mN/m | mN/m --- | --- | --- | --- | --- | ---
0.881 | 2.19 | 768.8 | 23.1 | 27.45 | 27.47

We considered the influence of the threshold values from the binary threshold and edge detection as possible sources of inaccuracies in the calculations. A short summary of the threshold summary is given next.

## Threshold study

Different values of threshold used in the binary threshold operation resulted in different average locations of the outer limits of the droplet. The droplet seems to have a crisp edge outline, but when viewing the pixels there is a color gradient from black to white that is fuzzy near the edge. When various levels of minimum threshold are used, different surface tension values are calculated. The example images from varying thresholds are given in Fig. 18.

Figure 18: The threshold value (val) used in the image processing resulted in different outer limits of the droplet pixels, less restrictive (val=30) considered more and more 'grey ' pixels to be actually 'black'

Table 5: The surface tension drops as the diameter of the droplet increases due to the less tolerant threshold value.

Minimum Threshold | Surface Tension | mN/m --- | --- 5 | 81.8 10 | 71.5 15 | 70.9 20 | 70.6 25 | 70.7 30 | 68.0

Table 5 shows the variance of surface tension calculation for different threshold tolerances. A value very restrictive value, val = 5 produces the highest surface tension. The value of val = 10 was used for water and leads to a surface tension computation that is very close to values from literature. The same value of val = 10 was used in the hexadecane droplet.

# Conclusion

Using the open-source libraries in OpenCV, as accessible in Pyhon scripts, we successfully took images of droplets, converted them into usable data, and found surface tension values for the liquids. When the code was calibrated for water droplets, the value of surface tension is extremely close to data reported in both our DSA calibration and from literature. The code was extended directly to other materials and gave surface tensions but with less accuracy.

The code has been developed in such a way as being relatively easily ported onto other architecture, such as mobile platforms. The OpenCV libraries are also available in the Android SDK. Though we have not studied that possibility here.

We showed also the sensitivity, aside from any physical features, of the results to numerical values in the image processing tools. We considered only the binary threshold but perhaps a full phase-space of edge-trimming and greyscale thresholding should be done to determine the complete sensitivity of results to image-processing parameters.

Lastly, the code has been made available for public access and forking on github repository to encourage future development. The repository is located here: https://github.com/jtvanlew/ucla-pendant-drop

# References

1. KRUSS GmbH, Drop Shape Analyzer, http://www.kruss.de/products/contact-angle/dsa100/drop-shape-analyzer-dsa100/
2. S. Fordham, The Royal Society, on the calculation of surface tension from measurements of pendant drops, Vol. 194, No. 1036, July 1948.
3. Arthur W. Adamson, Alice P. Gast, Physical Chemisrty of Surfaces, sisxth edition, 1997
4. Clyde E. Stauffer, Measurement of Surface Tension by the Pendant Drop Technique, Vol. 69, No. 6, December 1964
5. Roger P. Woodward, Surface Tension Measurements using the Drop Shape Method