Introduction to Modeling and Simulation, Spring 2005, MIT Problem Set 5 Due April 24,2006 Monte Carlo Study qualitative behavior of the two-dimensional Ising model. Write a computer program to simulate L × L two-dimensional Ising in the absence of an external field. The energy of the system is given by E = −J � si sj {i,j } where the sum is over all nearest neighbors on the square lattice. Set J = 1, kB = 1. The total magnetization M of the system is M = L � si i=1 Use Metropolis Monte Carlo algorithm to simulate dynamics of the system. Use periodic boundary conditions. With periodic boundary conditions, the top spin in a column is next to the bottom spin in the same column, and the far left spin in a row is next to the spin on the far right in the same row. 1 For L = 16 and T = 2 determine the number of Monte Carlo steps neq needed to equilibrate the system. Start your simulations from configurations where the direction of each spin is chosen at random. Plot the values of E and M after each Monte Carlo step per spin.(The number of spins is 16 × 16 = 256, so how many Monte Carlo steps is one per spin?) 2 Visualize the states of the spins at equilibrium and a few transitional time points. You can either use an external graphics program (MATLAB, Mathematica, etc) or just print out L × L table of spins. (If you are using MATLAB, you might find the functions fill, area, or patch useful.) Is the system “ordered” or “disordered” at T = 2 after the equilibration is established? 3 Repeat 1 and 2 with all spins initially up. Does the equilibration time increase or decrease? Do you see qualitative changes in the final configuration? Watch for domains of spins in the same state. 4 Repeat 1–3 for T = 0.5 and T = 2.5. 5 Starting your runs from all spins up, compute equilibrium average energy per spin e = hEi/L2 and average equilibrium magnetization per spin m = hMi/L2 at different temperatures T . Use at least 1000 Monte Carlo steps per spin. Plot e vs T , m vs T for 1.5 ≤ T ≤ 3.5. 6 Study how e and m depend on the temperature T . In other words, describe the qualitative relationship between e and m. Optimization by genetic algorithm Extra Credit. This problem is extra credit. Only fairly good solutions are worth extra credit, though we will accept solutions to each portion (a numbered item below) separately. Do what you can with it if you have time. The deadline for extra credit is one week after the problem set is due. Have fun with this one! Here your goal is to study “evolution” of organisms in complex environment. The genome of each organism is encoded by a string of L genes si=1...L = −1 or 1. Genes interact with themselves (Ji )and with the environment Hi , such that the total fitness of the organism is given by F (s) = L−1 � i=1 Ji si si+1 + L � H i si i=1 (You might think of Hi as a magnetic field.) Consider evolution in the population of N organisms sj=1..N . Set values of J and H and start with random genomes s. At each generation make mutations in the genomes by flipping randomly picked genes and compute the fitness of each individual. Next select individuals according to their fitness such that a probability of leaving an offspring for next generation is given by exp(F (sj )/T ) P (sj ) = �N k k=1 exp(F (s )/T ) Make N rounds of selection to obtain N offspring for the new generation. Go back to the mutation step. 1 Try ferromagnetic interactions between genes, i.e. Ji = 1, L = 6, N = 100, T = 1, introducing N mutations in each round of mutations. Start with no interactions with environment: Hi = 0. How long does it take to find the ground state energy (i.e. highest fitness)? What’s the role of T ? Can changing T make your evolution find the ground state faster? 2 Repeat each run at least 10 times. Do you always get the ground state when you start with random genomes? Try longer L = 10, 20 and smaller population sizes N = 25, 50. How does efficiency of evolution (i.e. fraction of runs that end at the ground state and number of generations required) depend on the population size and L? 3 Repeat parts 1 and 2 using the values for environment, Hi , randomly drawn from the uniform distribution [−1, 1]. In this case you do not always know the ground state configuration, but you can check whether repeated runs (with the same values of Hi but different starting configurations) generate similar high-fitness genomes. Optional: for short L = 6, 10 you can obtain optimal genomes by complete enumeration. Can you find optimal genomes for larger L with another method? 4 Optional: Repeat 1 and 2 using no interactions with the environment (Hi = 0) while having random interactions between the genes Ji (drawn from normal distribution with mean=0 and variance=1). In this case there are several local maxima of fitness and individuals can “climb” these local maxima and compete. Do you observe this? Remember to try different values of T . Good luck! What do these simulations teach us about natural evolution? Can a complicated genome/organism/solution be found by incremental improvements in large populations? Is it likely that such solution can be found“by chance” in one generation?