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

Commit id: 6cc72809d609ddf21d69b51dbf66ecbacccdc176

deletions | additions      

       

For each temperature, we initiate an array of spins with each spin initiated to +1. At each temperature we find the average energy and average magnetization in equilibrium by "sweeping" though the array until the array reached equilibrium.  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" $"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). 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). These values are stored in the class. The functions “input_Eng” and “input_Mag” 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.