Henry Daniels-Koch edited section_Implementation_of_Code_label__.tex  over 8 years ago

Commit id: 18a9396bcf154c12d4cfd9b7d4c842b54ae2f641

deletions | additions      

       

For each sweep of the array, we call the function “sweep”. “sweep” generates N randomly selected \textit{x} and \textit{y} coordinates of the array and determines whether to flip the spin by calling the function "determine\_Flip". In order for "determine\_Flip" to decide whether or not flip the spin, it must learn what spins its neighbors have. Using periodic boundary conditions, we initialize the right, left, top, and bottom neighbors of the spin. We calculate what the change in energy would be if we decided to switch the sign of the spin \textit{dE}. We then compare a randomly generated number to \beta where $\beta=1/\textit{k}T$ . In actuality \textit{k} is the Boltzman constant, but this would cause the random number to be altered accordingly and thus we simplify the problem by setting \textit{m} equal to 1. If the random number is less than difference between the two energy states $e^{-\beta\textit{dE}}$, we flip the sign. Otherwise, the sign stays the same.   Next we find the magnetization and energy after each sweep of the array with the function “find\_Mag\_Energy”. To determine the magnetization of the array the function sums the values of each spin the array and divides by the number of spins (\textit{m}^{2}) using equation (1). the following expression $$\sum s_ij.  To determine the energy of array the function uses periodic boundary conditions to sum of the energies of pair to pair interactions from nearest neighbors and divide by the number of spins (\textit{m}^{2}) using equation (2). (\textit{m}^{2}).  These values are stored in the class. The functions “input\_Mag” and “input\_Eng” store the magnetism and energy of the spins into two arrays. Both the number of sweeps and the magnetism are written to a file while the number of sweeps and energy is written to a separate file. After all sweeps are complete, the average equilibria magnetism and energy are calculated (Eq 3 and 4). To find the equilibrium value for each T, we compare each M or E in each sweep with the average value of previous 100 Ms or Es. If the M or E is smaller than our acceptable error (0.01), the M or E has reached equilibrium for this temperature. Thus, the average M or E is the equilibrium value of M or E. If the method does not return a value for the temperature, there are not enough sweeps to reach equilibrium. To calculate standard deviations we use the functions "mag\_Std” and “eng\_Std”. These functions sum up the squares of the values of (magnetism/energy) - (the avg magnetism/energy) for each of the 100 values before equilibrium. The standard deviations are the square roots of these two sums. Lastly, we write the average magnetism and average energy for each temperature to a file. For each temperature we print out the average magnetism/energy and standard deviation in magnetism/energy.