Modeling Coral Growth Biology of Corals Modeling Assumptions Main modeling simplification: a polyp buds when it encounters a nutrient in the water. Simplified Coral Biology corals are sessile, filter-feeding a coral is made up of genetically identical polyps a few millimeters in diameter Model Assumption passive filtering of diffusing nutrients every node of a coral is an identical ‘polyp’ unit every edge node of a coral can grow into a neighboring node corals grows asexually by polyp budding polyps bud when they reach maturity coral nodes grow in response to a threshold level of local nutrient corals are a very simple organism/colony no communication or interaction assumed between polyps Canonical Model: Diffusion Limited Aggregation Eden model, 1961: seed with random budding Witten and Sander DLA model, 1981: seed with diffusion limited budding Kaandorp, Lowe, Frenkel and Sloot, 1996: nutrient diffuses and flows Discrete Agent-Based Modeling Components Nutrient Source point source from one direction or homogeneous source from all directions? do nutrients spontaneously decay or disappear off-lattice? will the equilibrium density of nutrient be small or large? Nutrient Diffusion (and diffusion boundary conditions) random walk rate of diffusion? do nutrients spontaneously decay or disappear off-lattice? Nutrient Flow (and flow boundary conditions) do nutrients flow as an ensemble? (current-like) do nutrients flow independently in a biased direction? (biased random walk) Coral Growth nodes of potential growth need to be identified Nutrient and coral need to be initialized, and the rules for nutrient source, flow and diffusion need to be integrated and coupled with rules for coral growth. Developing the Octave Code (This worksheet can be downloaded electronically from the course web page so that code sections can be cut and paste into Octave.) Compose the Function In a Text Editor The function coral_growth(INITIALIZE, T) will model coral growth. If you type > coral_growth(1,5) into the command line, the algorithm will initialize and proceed for 5 time steps. If you type > coral_growth(0,5) into the command line, the algorithm will continue from where it left off and proceed for 5 time steps. function [CORAL,polyps,radius]=coral_growth(INITIALIZE, T); global CORAL % global makes these matrices … global NUTRIENT % … available outside the function N = 25; % size of the lattice f = 0; % flow rate of nutrient source=1; %number of particles added per time step Save the file as coral_growth.m . Initial Conditions We will model the ‘sea’ as an NN matrix. We will need to keep track of the amount of nutrient in each node of the sea and which nodes are occupied by coral as it grows. %%% INITIAL CONDITIONS %%% if INITIALIZE == 1 'initialize algorithm' NUTRIENT = zeros(N,N); CORAL = zeros(N,N); CORAL(fix(N/2),fix(N/2)) = 5; %one ‘seed’ node imagesc(CORAL+NUTRIENT) polyps=sum(sum(CORAL>0)) radius=1 colorbar end Type > coral_growth(1,5) and check the output. Try moving the initial seed position to different locations on the lattice. Try replacing ‘zeros’ with ‘rand’ in the line defining the nutrient. Main Algorithm During each time step, several things need to happen. They will happen independently, each once per time step. Cut and paste the following and we’ll address each component one at a time. %%% MAIN BODY ALGORITHM %%% if T>0 for timesteps=1:T %NUTRIENT SOURCE %NUTRIENT DIFFUSION %NUTRIENT FLOW %IDENTIFY POTENTIAL CORAL GROWTH potential_growth=zeros(N,N); %CORAL GROWTH end %%% OUTPUT %%% imagesc(CORAL+NUTRIENT + 5*potential_growth) polyps=sum(sum(CORAL>0)) [I,J]=find(CORAL>0); radius=max(max(abs(J-fix(N/2)),abs(I-fix(N/2))))+1 end Nutrient Source %NUTRIENT SOURCE %courtesy of Michael %adding nutrient at edge nodes in N by N lattice edges=ones(N,N); edges(2:N-1,2:N-1)=0; edge_nodes=find(edges==1); %determine the size of the list s=size(edge_nodes,1); %pick 5 of the edge nodes at random as a nutrient source nutrient_source=fix(rand(source,1)*s)+1; %node occupied as nutrient source added_nutrient=zeros(N,N); added_nutrient(edge_nodes(nutrient_source))=1; NUTRIENT = NUTRIENT + added_nutrient; Nutrient Diffusion (and diffusion boundary conditions) %NUTRIENT DIFFUSION new_nutrient=zeros(N,N); for i=1:N for j=1:N number_particles=NUTRIENT(i,j); for b=1:number_particles direction=fix(rand(1)*4)+1; %add particle if new location is on lattice, %otherwise, the particle disappears if direction==1 if (i+1)<(N+1) %moves up new_nutrient(i+1,j)=new_nutrient(i+1,j)+1; end end if direction==2 if (j+1)<(N+1) %moves right new_nutrient(i,j+1)=new_nutrient(i,j+1)+1; end end if direction==3 if (i-1)>0 %moves down new_nutrient(i-1,j)=new_nutrient(i-1,j)+1; end end if direction==4 if (j-1)>0 %moves left new_nutrient(i,j-1)=new_nutrient(i,j-1)+1; end end end end end NUTRIENT=new_nutrient; %save nutrient positions after diffusion algorithm Nutrient Flow (and flow boundary conditions) %NUTRIENT FLOW %nutrient has a small probability f of flowing to the right new_nutrient=zeros(N,N); for i=1:N for j=1:N number_particles=NUTRIENT(i,j); for b=1:number_particles %with probability f, each particle moves right if rand(1)<f %add particle if new location is on lattice, %otherwise, the particle disappears if (j+1)<(N+1) %moves right new_nutrient(i,j+1)=new_nutrient(i,j+1)+1; end else new_nutrient(i,j)=new_nutrient(i,j)+1; end end end end NUTRIENT=new_nutrient; %save nutrient positions after diffusion algorithm Identify Potential Coral Growth %IDENTIFY POTENTIAL CORAL GROWTH %every node in contact with coral is a potential growth node potential_growth=zeros(N,N); for i=2:(N-1) for j=2:(N-1) neighborhood=CORAL(i-1:i+1,j-1:j+1); if sum(sum(neighborhood))>0 potential_growth(i,j)=1; end end end Coral Growth %CORAL GROWTH new_growth=(potential_growth==1).*(NUTRIENT>0).*(CORAL==0); NUTRIENT=NUTRIENT-new_growth; CORAL=CORAL+5*new_growth; Using the Octave Code To Study Diffusion Limited Aggregation Generally, a more branching structure will result if the lattice is large, the source is small and the flow is small. Also, the coral will grow more slowly. (1) Set the flow rate equal to 0, the source equal to 1 and the lattice size to 25. What does the coral look like after 500 time steps? (Run one time and we’ll compare for different students in the class.) polyps = radius = (2) Set the flow rate equal to 1. What does the coral look like after 500 time steps? (Run one time and we’ll compare for different students in the class.) polyps = radius = (3) Set the flow rate equal to 1 and increase the nutrient source to 2 particles per time step. What does the coral look like after 500 time steps? (Run one time and we’ll compare for different students in the class.) polyps = radius =