Computational Physics project

Niv Ierushalmi, under the supervision of Prof. Joan Adler.

Bootstrap percolation of a damaged diamond and measurement of the smoothness of the diamond surface

computational physics course - winter 2012-2013

The aim of this project is to write a program that applies the bootstrap percolation algorithm to a model of a damaged diamond to clean it, and analyse the resulting membrane's smoothness. The bootstrap program was written in the c language, and the final analysis was done using MATLAB. Visualization is done with AViz and possibly MATLAB.

The Model

The model used for this project is of a diamond crystal damaged by irradiation. The damaged area contains atoms in a graphitic state (sp2 hybridization) and in a diamond state (sp3), the models were prepared in simulation by carbon ion implantation which breaks many of the bonds in the diamond, followed annealing to convert the damaged regions to graphite. The models were prepared in two different schedules. The aim of this process is to produce smooth diamond membranes for photonic devices. The samples were prepared by Amihai Silverman, Joan Adler and Rafi Kalish [1]. The samples come in xyz files that can be viewd in AViz ,the diamond atoms in the files are marked with the letter 'C', and the graphite atoms with 'H'.

fig1: Diamond lattice damaged by irradiation, graphite (sp2) and diamond (sp3) atoms.

Bootstrap Percolation

Bootstrap percolation is the process of repeatedly removing sites acording to the occupation of their neighbors, until the system is stable - nothing more to remove.

When applied to our model of a diamond crystal, every diamond (sp3) atom is a site, and it is removed if it has less than 2 neighboring diamond atoms within a distance of a 1.55 angstom - the bond length of carbon in diamond.

fig2: After the bootstrap process, only connected diamond (sp3) atoms.

Animation of the bootstrap process

Fractal Dimension

Fractal dimension is a measure of the complexity of a set, in this case a surface in space, measuring how its details change with a change of scale.

The smoothness of the diamond surface was measured by its fractal dimension - the lower the dimension the smoother the surface. To accomplish, this the bulk of the crystal was first removed, leaving only the diamond-vaccum surface, then the surface's fractal dimension was measured using the box counting algorithem in MATLAB. this algorithem was first checked on a flat surface to verify that it gives the predicted resault of d=2.

fig3: Top vaccum-diamond surface, seperated from the bulk.

Box counting is a practical way to compute a surface's fractal dimension, by counting how many boxes of size epsilon^3 it takes to cover the entire surface for smaller and smaller epsilons, and calculating: .for a smooth surface the fractal dimension equals the topological dimension of d=2, but for a complex surface the fractal dimension is between 2 and 3.

The Program

The bootstrap program reads a list of atom coordinates and types from an .xyz file, and stores only the C type in a linked list. By measuring the distances between any two atoms in the list it compiles a neighbors list for every atom, and then repeatedly remove every atom who has less than 1 neighbor. The program outpus an .xyz file for every step in the process. Once the bootstrap process is done - no additional atoms are removed - the program moves to final stage of stripping the membrane from the bulk, by sorting and splitting the list according to different coordinates it find the surface atoms and puts them into two .xyz files - Bottom_Surface and Top_surface.

The MATLAB boxcount program reads the surface files and interpolate the atoms' coordinates to form a surface function, it then applies the box count algorithm to the surface to measure its fractal dimension.

fig4: Interpolated surface function, MATLAB.

Using the program

The bootstrap program is non interactive, it takes names of xyz files to process as command line parameters. Any number of files can be provided. The program generates output xyz files for every step of the bootstrap process, and a list file, which can be used to visualize the process with AViz. additionally the program outputs two surface xyz files for each input file.

The boxcount MATLAB function works similarly by taking the input surface files as parameters, it outputs a visualization of the surface interpolation and the measured fractal dimension of each input file.

Compiling and running the program

Get the source from here.

The samples can be downloaded here

On linux or a compatible system, untar and compile the program with the commands:

tar -xf diamond_bootstrap.tar
cd diamond_bootstrap
gcc -lm main.c bootstrap.c file_operations.c -o bootstrap

This command will generate an executable called 'bootstrap'. it can then be moved or added to the path, or called by its path.

In the directory where the samples.tar file is, untar the samples with:

tar -xf samples.tar

Than the program can be run by:

path/to/program/bootstrap samples/*.xyz

Or more generally:

path/to/program/bootstrap [-no_anim] [ ...]

(square brackets [ ] denotes an optional parameter). All output files are created in the current working directory. The optional flag -no_anim can be provided before all input file names to suppress the creation of xyz files for the bootstrap process, the program will create the surface files anyway. running the program without parameters outputs a short usage explanation.

The bootstrap program created surface files called and, use the matlab function from the sources, called boxcount, with the surface files, by calling it within MATLAB from the directory where the boxcout.m file is:

boxcount (, );


boxcount (-no_graphic,, );

Or from the command line from within the directory where the boxcount.m file is (provided MATLAB is installed on the computer) by:

matlab -nodesktop -nosplash -r "boxcount [-no-graphic] [ ...]"

The optional flag -no_graphic provided before all input file names, prevents plotting the surface function.

The bootstrap program was checked to compile and run on linux systems, it might also work on windows and on windows/cygwin.


Four samples were used in the project, prepared in two schedules:

  1. samples 1 and 2 were irradiated at a temperature of 0K and annealed at 2000k.
  2. samples 3 and 4 were irradiated and annealed at 2000k.

Runing the bootstrap program on the sample files and then the box count function, gives the results:

surface fractal dimension
Sample 1 top surface 2.2800 +- 0.0086
Sample 1 bottom surface 2.2619 +- 0.0057
Sample 2 top surface 2.2624 +- 0.0067
Sample 2 bottom surface 2.2412 +- 0.0057
Sample 3 top surface 2.3019 +- 0.010
Sample 3 bottom surface 2.2723 +- 0.0078
Sample 4 top surface 2.2433 +- 0.0064
Sample 4 bottom surface 2.2606 +- 0.0056
On average, schedule 1 gives a dimension of d1avg=2.2614 +- 0.0034, and schedule 2 gives d2avg=2.2695 +- 0.0038

It seems that irradiating at cold temperatures gives a smoother result (lower fractal dimension) as was observed by Silverman, Adler and Kalish [1].