README.TXT

The project uses the C files: percolation.h percolation.c perc.c

One wants to use it may set the parameters for the length and the probability (L,p respectively) in the header file

percolation.h
Change the lines:
                #define L 10
                #define pr 32 (it should be a probablity*100)

Then compile the C project (perc.c).

In percolation.c there are some functions which process the Hoshen-Kopelman algorithm in the following way:

init_system() and randomized_system() set the crystal initialization randomly due to the parameters

defined at the header file.

printing(char *filename) gets the filename and prints the requested coordinates.

(One wants to see the whole crystal should execute "crystal.exe Proper_labels.txt").
I.e. printing("Initial_crystal.txt") - prints the Initial crystal configuration to file "Initial_crystal.txt".

 labeling_function()

There are 3 loops for the 3 dimensions. The function calculates and sets the initial label for each site in the crystal. Each site gets the minimum label of the neighbors and their np(label)`s as known from the Hoshen-Kopelman Algorithm. Sub-function mini(int number,int c_label) returns the minimum number which is not zero between the 2 numbers it gets.

np_calculation(int x,int y,int z,int l)

{At the end of each site labeling there is a calculation of the np's. This function calls function np_set(int minus,int xyz,int l) it gets the neighbor's label, the current site label and the max label. It takes the minimum among labels and set this np to all the nps belong to linked sites.}

The steps taken before give us the crystal initial labels and a vector of proper np's.

The next step is printing the labels - printing("Labeled_clusters.txt");

 set_the_proper_labels() - Sets proper labels to the sites. Each site has np!=0 gets the np as its label.

The function also counts the number of each sites in every cluster and prints the results into file "Clusers_size.txt".

 percolation_data_print("X-direction.txt",percolation_check('X'))

Sub-function percolation_check(char perc_choose) gets the direction and check if there is a percolation in that direction. It returns the_percolation_cluster_label/FALSE respectively.
Function percolation_data_print(char *filename,int perc_label) gets an output filename and the cluster percolation label. If there was no percolation the function prints proper message to the output file. Else it prints the percolation cluster label and coordinates of the sites with the same label. It will be used to show the cluster with the OpenGL program.

 

Executing the OpenGl program with the X-direction we want will show us the percolation cluster (if there is one!).

 

© Nir niry@poetic.com