Bitwise Implementation of a Two-Dimensional Cellular Automata Biofilm Model Gonzalo E. Pizarro 1 ; João Teixeira 2 ; Marcos Sepúlveda 3 ; and Daniel R. Noguera 4 Abstract: Mathematical modeling using the cellular automata CAapproach is an attractive alternative to models based on partial differential equations when the domains to be simulated have complex boundary conditions. The computational efficiency of CA models is readily observed when using parallel processors, but implementations in personal computers are, although feasible, not quite efficient. In an effort to improve the computational efficiency of CA implementations in personal computers, we introduce in this paper a bitwise implementation based on the use of each bit as a different CA cell. Thus, in a 32-bit processor, each computer word stores information about 32 different CA cells. We illustrate the bitwise implementation with a biofilm model that simulates substrate diffusion and microbial growth of a single-species, single-substrate, structurally heterogeneous biofilm. The efficiency of the bitwise implementation was evalu- ated by comparing the computational time of equivalent CA biofilm models that used more common low-level implementations, namely, if-then operators and look-up tables. The processing speed of the bitwise implementation was over an order of magnitude higher than the processing speed of the other two implementations. Regarding the biofilm simulations, the CA model exhibited self-organization of the biofilm morphology as a function of kinetic and physical parameters. DOI: 10.1061/ASCE0887-3801200519:3258 CE Database subject headings: Biofilm; Distributed processing; Dynamic models; Mathematical models; Simulation. Introduction Cellular automata CAare fully discrete models of physical sys- tems Rothmann and Zaleski 1997. They are often described as counterparts to models based on partial differential equations. CA have found practical applications in communications, computa- tion, construction, and for modeling growth, reproduction, com- petition, and evolution in biological systems Ermentrout and Edelstein-Keshet 1993; Hogeweg 1988; Toffoli and Margolus 1987. Because of their mathematical simplicity, CA have re- cently been used as alternatives to differential equation models to simulate physical phenomena such as heat transfer, diffusion, and flow dynamics Chopard and Droz 1991; D’Souza and Margolus 1999; Rothmann and Zaleski 1997; Toffoli 1984b, or a combi- nation of physical and biological processes, such as the diffusion- reaction equations describing the growth and activity of biofilms, especially when the biofilms are not flat and uniform structures, but have structurally heterogeneous characteristics that influence the diffusion of substrates Eberl et al. 2004; Noguera et al. 2004; Picioreanu et al. 1998. CA models have been used for a long time in physics as the- oretical models for studying physical phenomena when complex boundary conditions are encountered Olson and Rothman 1997; Rothmann and Zaleski 1997. Because the states of the variables of CA models are discrete, they can be implemented entirely using logical operations; thus, CA models have the potential to eliminate any numerical artifacts that can appear in the computa- tion due to rounding or truncation of real numbers Creutz 1997; D’Souza et al. 2002. A classic example of the use of CA in physics is the microscopic modeling of diffusion. Because diffu- sion is a macroscopic manifestation of Brownian motion, it is possible to simulate it as a random walk of particles in a lattice Chopard and Droz 1999; Toffoli and Margolus 1987. The char- acteristics of locality, uniformity, and spatial regularity of CA algorithms make them ideal for simulations on parallel computers or specially designed cellular automata machines D’Souza et al. 2002; Toffoli and Margolus 1987. However, many researchers do not have access to dedicated parallel hardware and, when imple- mented in desktop single processorcomputers, the efficiency of these algorithms decreases considerably. In this paper, we introduce a new concept for the implemen- tation of CA models on single-processor computers. We propose a bitwise implementation of the CA model so as to reduce the memory required and to improve the efficiency of the single- processor computer. In this implementation, the variables are the bits of a computer word e.g., 32, 64, or 128 bits per wordand the computations are made only with low-level logical operations, native operations to the processor. With this method and object- oriented programming, the efficiency of these algorithms is dramatically increased while simplicity of the programming is 1 Assistant Professor, Dept. of Hydraulics and Environmental Engineering, Pontificia Universidad Católica de Chile, Casilla 306, Correo 22, Santiago, Chile corresponding author. E-mail: gpizarro@ing.puc.cl 2 Assistant Professor, Dept. of Mathematics, Universidade Técnica de Lisboa, Av. Rovisco Pais, 1049-001 Lisboa, Portugal. 3 Assistant Professor, Dept. of Computer Science, Pontificia Universidad Católica de Chile, Casilla 306, Correo 22, Santiago, Chile. 4 Associate Professor, Dept. of Civil and Environmental Engineering, Univ. of Wisconsin-Madison, 3216 Engineering Hall, 1415 Engineering Dr., Madison, WI 53706. Note. Discussion open until December 1, 2005. Separate discussions must be submitted for individual papers. To extend the closing date by one month, a written request must be filed with the ASCE Managing Editor. The manuscript for this paper was submitted for review and pos- sible publication on January 20, 2004; approved on December 20, 2004. This paper is part of the Journal of Computing in Civil Engineering, Vol. 19, No. 3, July 1, 2005. ©ASCE, ISSN 0887-3801/2005/3-258–268/ $25.00. 258 / JOURNAL OF COMPUTING IN CIVIL ENGINEERING © ASCE / JULY 2005