12.07.2015 Views

Chapter 13 - Davidson Physics

Chapter 13 - Davidson Physics

Chapter 13 - Davidson Physics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 14. FRACTALS AND KINETIC GROWTH MODELS 535Then we divide this half into half again and so on until the correct position is found. The linear andbinary search methods are compared in Problem 14.7d. The binary search is the default methodused in class Invasion.The main quantities of interest are the fraction of sites occupied by the invader, and theprobability P (r)∆r that a site with a random number between r and r + ∆r is occupied. Theproperties of invasion percolation are explored in Problem 14.7.Listing 14.4: Class for simulating invasion percolation.package org . o p e n s o u r c e p h y s i c s . s i p . ch<strong>13</strong> . i n v a s i o n ;import java . awt . Color ;import org . o p e n s o u r c e p h y s i c s . frames . * ;public class I n v a s i o n {public int Lx , Ly ;public double s i t e [ ] [ ] ;public int perimeterListX [ ] , perimeterListY [ ] ;public int numberOfPerimeterSites ;public boolean ok = true ;public LatticeFrame l a t t i c e ;public I n v a s i o n ( LatticeFrame l a t t i c e F r a m e ) {l a t t i c e = l a t t i c e F r a m e ;l a t t i c e . setIndexedColor ( 0 , Color . blue ) ;l a t t i c e . setIndexedColor ( 1 , Color . black ) ;}public void i n i t i a l i z e ( ) {Lx = 2*Ly ;s i t e = new double [ Lx ] [ Ly ] ;perimeterListX = new int [ Lx*Ly ] ;perimeterListY = new int [ Lx*Ly ] ;for ( int y = 0 ; y

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!