May 21, 2013, Tuesday

# Noor Tell

B.S Student

Math and Biology Major

Email: ntell@wesleyan.edu

## Calculating Surface Area of Fractal Bacterial Flocs

Introduction

When considering bacterial flocs or clusters, many scientists have assumed an ideal spherical geometry. However, according to Bruce E. Logan(1999)[1]as well as student Stephen Kissler[2], bacterial flocs actually demonstrate a fractal behavior, meaning bacteria exhibit two major characteristics of fractals: a self-similar pattern and fractal dimension. Bacterial flocs are described as self-similar, meaning the pattern of the whole floc can also be seen when zooming into a portion of the cluster. In other words, if a piece of the floc were to break off, it would have the same pattern as the whole original cluster. More specifically, bacterial flocs are characterized as “statistically self-similar”, implying that when measuring the object at different scales, it is statistically the same every time (Kissler, 2012). Bacterial flocs also demonstrate a fractal dimension, a way of quantifying their complexity as a ratio of change in scale to the change in detail in pattern.

Purpose

This project aims to understand how growth relates to fractal dimension. I will specifically look at one of the driving factors of growth: surface area. The objective is to be able to accurately calculate the surface area of individual bacterial clusters and associate it to its fractal dimension in order to better understand and determine its ability to uptake nutrients, which also directly correlates to its growth rate.

Given Kissler’s results that flocs are multi-fractal deems the convex hull approximation as a poor way to compute the flocs’ surface area. If a convex hull approximation were applied to bacterial flocs, the resulting surface area would be an underestimation of the actual surface area. Convex hull approximation is accurate when the object has a lacunarity of zero and is convex in shape, which is not the case for most bacterial flocs. For example, convex hull approximation would be appropriate for a cube, but not a crescent shaped object. Therefore, a new method of calculating the surface area of bacterial flocs with the knowledge that bacterial flocs are fractal is necessary.

Methods & Data

Figure 1 - Plus Fractal (1st, 2nd, 3rd iteration)

A different approach has been taken to calculate the surface area of bacterial flocs. To begin with, an understanding of how to calculate the "surface area" of two-dimensional fractals is required. The current method is taking known, ideal fractals such as the plus fractal (see Figure 1) and hexaflake (see Figure 2) and calculating the contour length of the fractal at different iterations; for the plus fractal, first when the fractal only has 5 circles and then 25, and so on. The blue lines seen on Figure 1 illustrate the contour path taken. These specific fractals are chosen for this study because they are composed of circles, which directly relates to the spherical nature of Staphylococcus epidermidis.

Figure 2 - Hexaflake (1st, 2nd, 3rd iteration)

A general equation to calculate the contour length of the plus fractal was formulated.

(1) $L_i = c_i((\pi)/4) + r_i(2\sqrt[2]{2})) + b_i(2-\sqrt[2]{2}))$

where L is the contour length at iteration i and c, r, and b are positive integers that constantly increase with every iteration i : c increases by 8 with every iteration, r by 16, and b by 8. $c_o = 4, r_o = 4, b_o = 0$ are the initial values.

A code was then generated with the use of computer programming in the language Python to output the contour length of any iteration of the plus fractal desired. The code also graphed the radius vs. contour length and number of circles vs. contour length. The best fit line and slope of the line was also computed through the same code. Given this information and calculations, the fractal dimension was calculated. The equation used was

(2) $N(S) = C \cdot S^D$

where N(S) is the quality of the object (e.g volume, contour length, surface area), C is a constant, S is a characteristic length associated to the object, and D is the fractal dimension. The contour length was used as the quality of the object.

The same study was done with the hexaflake fractal. A general equation to calculate the contour length of any iteration of the hexaflake was created and written in a new code in the language Python. The equation is

(3) $L_i=w_i(2) + n_i( \pi/2) + s_i( \pi /4) + v_i(2.18142240792219)$

where L is the contour length at iteration i and w, n, s, and v are positive integers that constantly increase with every iteration i ; w increases by 8 with every iteration, n by 4, s by 8 and v by 4. $w_o = 6, n_o = 2, s_o = 4,$and $v_o = 0$ are the initial values.

Separate codes were also constructed that allows the generation of the image of any iteration of both fractals. All codes can be found at the end of the page.

Observations & Results

The known fractal dimension of the plus fractal was compared to the calculated fractal dimension using the contour length. The known fractal dimension calculated by Logan is 1.465. Using the calculated contour length, the fractal dimension using equation (2) was computed and a value of 1.445 was achieved.

Figure 3 - Plus fractal radius vs. contour length
Figure 4 - Plus fractal number of circles vs. contour length

Figures 3 and 4 are graphs demonstrating the relationship between the radius and contour length as well as the number of circles and contour length for the plus fractal. The red circles represent full iterations of the plus fractal. The graphs show 100 iterations. Both graphs demonstrate a linear relationship with contour length. Figure 3 also shows the best fit line of these points; the slope of this best fit line provides the fractal dimension of the edge of the fractal.

The same observations were made with the hexaflake. The fractal dimension was determined using equation (2) and a value of 1.012 was attained. When graphing the relationships between radius and contour length as well as number of circles vs contour length, a linear relationship was not expected. This is because the hexaflake exponentially increases in the number of circles with every iteration. The plus fractal adds a constant 20 number of circles with every iteration and thus a linear relationship was expected. However, Figures 5 and 6 show a linear relationship for the hexaflake.

Figure 5 - Hexaflake radius vs. contour length
Figure 6 - Hexaflake number of circles vs. contour length

Figure 5 gives a fractal dimension of the edge of the fractal to be 1.0015. Figure 6 demonstrates a linear relationship between number of circles and contour length for the hexaflake.

Discussion

Since a comparable fractal dimension was achieved for the plus fractal using the contour length to the actual fractal dimension, two things can be said. First, the method of approximation of the contour length for the plus fractal is a fairly accurate approximation. Second, the contour length of the fractal can also be used as a quality of the object (i.e N(s)) to calculate the fractal dimension in addition to volume.

Given that there is a linear relationship between number of circles and contour length (Figure 4), a linear interpolation method can be used to determine the contour length of any number of circles. In other words, the contour length for any number of circles that may not even create a full iteration of the plus fractal can be determined. Using the linear interpolation equation given two known complete iteration points $(x_0, y_0)$ and $(x_1,y_1)$ and any x number of circles

(4) $y = y_0 + (x-x_0)[(y_1-y_0) / (x_1-x_0)]$

the contour length can be calculated. Note that $(x_0, y_0)$and $(x_1,y_1)$ should be the left most and right most points of the chosen x number of circles. For example, perhaps the fractal dimension is given as 1.465 and the number of circles to be 100. The two known complete iteration points chosen are (85,239) and (105, 295). Using equation 2, y=281; for a fractal dimension of 1.645 and a 100 circles for the plus fractal, the contour length is 281.

Figure 6 shows that there also exists a linear relationship for number of circles versus contour length for the hexaflake and therefore the same linear interpolation method (4) can be used to calculate the contour length of any number of circles of the hexaflake.

Further Work

This study is still in the process and requires further work in order to achieve the goal of calculating the surface area of actual bacterial flocs. The next step is to relate this information to actual fractal bacterial flocs. A 2-dimensional approach can still be taken by only considering the data points of the bacterial flocs in the x and y plane. After plotting the x and y points, a least square approximations method can be used to determine the least squares fit line that fits the data with the smallest error possible. Given the slope m and y-intercept b from the least square approximation, it can be related to the fractal dimension equations such that the log C = b and D = m. Therefore, we can calculate the fractal dimension of the actual bacterial floc in the 2-D sense. The following step is to find the center of mass the floc simply by averaging the x and y coordinates and from the center of mass, take the Euclidian distance from the center of mass for all the coordinate points. Given the distances from the center, we can use an expanding box method such that we increase the radius of the circle to include at least a new bacterial cell or coordinate point. The radius of the circle will increase until all the points are included. This method will allow us to relate the information collected from the project to the actual data. The radius of the largest circle from the expanding box method can be determined and the related contour length from the ideal fractals can be assigned to the actual bacterial floc’s contour length. Finally, a 3-dimensional approach is the concluding step; first a study of the surface area of known, ideal 3-dimensional fractals is necessary. This information can then hopefully be applied to 3-dimensional bacterial flocs to calculate the surface area.

Programs

#calculating the contour length of the plus fractal
import math
c=4.0
r=4.0
b=0
i=0

myList=[]
f=open('YES.txt','w')
for i in range (0,1000):
p=c*((math.pi)/4) + r*(2*(2**0.5)) + b*(2-(2**0.5))
c=c+8
r=r+16
b=b+8
if i%1==0:
print 'The new perimeter value is', p
pStr=str(p)
myList += [pStr]
myString = ",".join(myList)+'\n'
f.write(myString)
print 'The program has finished running.'
f.close()

import matplotlib.pyplot as plt
from numpy import *
from pylab import *
import pylab

preX=range(3,603,6)
x=[] #characteristic length associated with the object (radius)
y=[] #quality of the object (contour length)
for index in range(len(myList)):
x.append(log(float(preX[index])))
y.append(log(float(myList[index])))

#finding the best fit line
(m,b) = polyfit(x,y,1)
yp=polyval([m,b],x)
plt.plot(x,yp)
grid(True)
print 'The slope is of the best fit line is', m
print 'The y-intercept of the best fit line is', b

plt.plot(x,y,'ro')

#labeling/details of graph
plt.title('Change in Radius of Fractal vs.Contour length ')
plt.ylabel('Log(Contour Length)')
plt.show()
#growing any number of iterations of the plus sign fractal
from numpy import *
from pylab import *
import pylab
from matplotlib.contour import ContourSet
import matplotlib.cm as cm

#iterations of circles
# REMEMBER to change the iterations depending on the size of the fractal/number of iterations
plt.xlim(-100,100)
plt.ylim(-100,100)

#circles for first iteration of fractal
circle1=plt.Circle((0,0),1,color='black')
circle2=plt.Circle((0,2),1,color='black')
circle3=plt.Circle((2,0),1,color='black')
circle4=plt.Circle((-2,0),1,color='black')
circle5=plt.Circle((0,-2),1,color='black')
fig = plt.gcf()

a=2
c=0
f=-2

# REMEMBER to change the range number depending on number of iterations desired
for i in range(0,3):
#right side of the plus fractal
circlea=plt.Circle((a+2,0),1,color='black')
circleb=plt.Circle((a+4,0),1,color='black')
circlec=plt.Circle((a+6,0),1,color='black')
circled=plt.Circle((a+4,c+2),1,color='black')
circlef=plt.Circle((a+4,c-2),1,color='black')

#let side of the fractal
circleg=plt.Circle((f-2,0),1,color='black')
circleh=plt.Circle((f-4,0),1,color='black')
circlej=plt.Circle((f-6,0),1,color='black')
circlek=plt.Circle((f-4,c+2),1,color='black')
circlem=plt.Circle((f-4,c-2),1,color='black')

#top of the fractal
circlen=plt.Circle((0,a+2),1,color='black')
circleo=plt.Circle((0,a+4),1,color='black')
circlep=plt.Circle((0,a+6,0),1,color='black')
circleq=plt.Circle((c+2,a+4),1,color='black')
circler=plt.Circle((c-2,a+4),1,color='black')

#bottom of fractal
circles=plt.Circle((0,f-2),1,color='black')
circlet=plt.Circle((0,f-4),1,color='black')
circleu=plt.Circle((0,f-6),1,color='black')
circlev=plt.Circle((c+2,f-4),1,color='black')
circlew=plt.Circle((c-2,f-4),1,color='black')
a=a+6
f=f-6
if i%1==0:
fig = plt.gcf()

pylab.show()
#calculating the contour length of the hexagonal fractal
w=6.0
o=2.0
b=4.0
r=0

import math

myList=[]
f=open('contour length - hexagonal fractal.txt','w')
for i in range (0,100):
contourlength=w*(2) + o*(math.pi/2) + b*(math.pi/4) + r*(2.18142240792219)
w=w+8
o=o+4
b=b+8
r=r+4
if i%1==0:
print 'The new contour length is', contourlength
CStr=str(contourlength)
myList += [CStr]
myString = ",".join(myList)+'\n'
f.write(myString)
print 'The program has finished running.'
f.close()

import matplotlib.pyplot as plt
from numpy import *
from pylab import *
import pylab

preX=range(3,6003,6)
x=[] #characteristic length associated with the object (radius)
y=[] #quality of the object (contour length)
for index in range(len(myList)):
x.append(log(float(preX[index])))
y.append(log(float(myList[index])))

#finding the best fit line
(m,b) = polyfit(x,y,1)
yp=polyval([m,b],x)
plt.plot(x,yp)
grid(True)
print 'The slope is of the best fit line is', m
print 'The y-intercept of the best fit line is', b

plt.plot(x,y,'ro')

#labeling/details of graph
plt.title('Change in Radius of Hexagonal Fractal vs.Contour length ')
plt.ylabel('Log(Contour Length)')
plt.show()

import math

#graphing number of circles vs. contour length for the plus fractal
c=4.0
r=4.0
b=0
i=0

myList=[]
f=open('YES.txt','w')
for i in range (0,100):
p=c*((math.pi)/4) + r*(2*(2**0.5)) + b*(2-(2**0.5))
c=c+8
r=r+16
b=b+8
if i%1==0:
print 'The new perimeter value is', p
pStr=str(p)
myList += [pStr]
myString = ",".join(myList)+'\n'
f.write(myString)
print 'The program has finished running.'
f.close()

import matplotlib.pyplot as plt
from numpy import *
from pylab import *
import pylab

preX=range(5,2005,20)
x=[] #characteristic length associated with the object (radius)
y=[] #quality of the object (contour length)
for index in range(len(myList)):
x.append(float(preX[index]))
y.append(float(myList[index]))

#finding the best fit line
(m,b) = polyfit(x,y,1)
yp=polyval([m,b],x)
plt.plot(x,yp)
grid(True)
print 'The slope is of the best fit line is', m
print 'The y-intercept of the best fit line is', b

plt.plot(x,y,'ro')

#labeling/details of graph
plt.title('Number of circles vs. Contour Length',fontsize=24)
plt.xlabel('Number of Circles',fontsize=20)
plt.ylabel('Contour Length',fontsize=20)
plt.tick_params(labelsize=20)
plt.show()



import math
#graphing number of circles vs. contour length for hexaflake
circles=7
n=0
myList=[]
for i in range (0,50):
n=n+1
circles=circles+(6*n)*7
if i%1==0:
print circles
CircleStr= str(circles)
CircleStr = CircleStr.split(',')
myList += CircleStr

#calculating the contour length of the plus fractal
w=6.0
o=2.0
b=4.0
r=0

myList=[]
f=open('contour length - hexagonal fractal.txt','w')
for i in range (0,50):
contourlength=w*(2) + o*(math.pi/2) + b*(math.pi/4) + r*(2.18142240792219)
w=w+8
o=o+4
b=b+8
r=r+4
if i%1==0:
print 'The new contour length is', contourlength
CStr=str(contourlength)
myList += [CStr]
myString = ",".join(myList)+'\n'
f.write(myString)
print 'The program has finished running.'
f.close()

import matplotlib.pyplot as plt
from numpy import *
from pylab import *
import pylab

#plotting number of circles vs contour length
preX=myList
x=[] #characteristic length associated with the object (radius)
y=[] #quality of the object (contour length)
for index in range(len(myList)):
x.append(float(preX[index]))
y.append(float(myList[index]))

#finding the best fit line
(m,b) = polyfit(x,y,1)
yp=polyval([m,b],x)
plt.plot(x,yp)
grid(True)
print 'The slope is of the best fit line is', m
print 'The y-intercept of the best fit line is', b

plt.plot(x,y,'ro')

#labeling/details of graph
plt.title('Number of Circles vs.Contour length',fontsize=20)
plt.xlabel('Number of Circles',fontsize=18)
plt.ylabel('Contour Length',fontsize=18)
plt.show()



References

[1] Logan, B. E. (1999). Environmental transport processes. University Park: John Wiley & Sons, Inc.

[2] Kissler, S. (2012). Fractal dimension and lacunarity of bacterial flocs: Research review. Unpublished manuscript, Applied Mathematics, University of Colorado, Boulder, Boulder, CO.