Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can I get the python programs for each of these computational physics problems? Textbooks for reference: ? Computational Physics by Mark Newman (guide to Python

Can I get the python programs for each of these computational physics problems?

Textbooks for reference:

? "Computational Physics" by Mark Newman (guide to Python in computational physics)

? "Numerical Recipes" by W. H. Press et al. (covers very comprehensibly a vast range of numerical topics; 3rd edition is in C++; older editions, e.g. in C, are freely available online)

? "Clean Code" by Robert C. Martin (great book on good programming practices)

image text in transcribedimage text in transcribed
Basic simulation of the 2d Ising model with the Metropolis algorithm [1]: import numpy as np import matplotlib. pyplot as pit # define the system parameters = 20 # size of lattice in each direction J = 1 # interaction parameter h = 0 # magnetic field T = 0.1 # temperature beta = 1/T # set k B = 1 # define the state of the system: LXL grid with (initially) a random spin in each cell config = 2*np. random. randint(2, size=(L, L) )-1 # energy of a given state def energy ( ) : # elegant way of writing the sum over all nearest neighbors in the grid interaction = -J*( np. sum(config[0:L-1, : ]*config[1: L, : ]) + # contributions of top/bottom neighbors np . sum(config[ : , 0:L-1]*config[ : , 1: 4])) # contributions of Left/right neighbors magnetic = -h*np. sum(config) return interaction + magnetic current_energy = energy ( ) # magnetization of a given state def magnetization( ) : return np. sum(config)/L/LExercise 1 Monte Carlo integration [8 points) Estimate the volume of a hypersphere of unit radius in 10 dimensions using a Monte Carlo method and compare with the exact value (7/5!0). If we had to do a ten-dimensional integral the traditional way, it would take a very long time. Even with only 100 points along each axis (which wouldn't give a very accurate result) we'd still have 100'% = 10%\" points to sample, which is impossible on any computer. But using the Monte Carlo method we can get a pretty good result with a million points or so. Exercise 2 Importance sampling [12 points) The goal of this exercise is to calculate the integral gy f 3%e % dx 0 using Monte Carlo with importance sampling. For reference, the exact value of the integral is 3/ /4. (i) Use the exponential probability distribution p(z) = " to generate r-values for impor- tance sampling and calculate the integral using N = 10000 points. (ii) Repeat this calculation using any other suitable probability distribution p(z) of your choice. Explain why the chosen probability distribution is suitable (it does not have to be the most efficient, but it should produce the correct result). (iil) Extra credit [5 points|: Repeat the caleulation from (i) using Markov chain Monte Carlo. Exercise 3 Ising model [10 points] Study the 2d Ising model code from the lecture notes. (i) Use the provided code to calculate the average magnetization of the Ising model on a 5xd grid, for J = 1. h = 0 (no external magnetic field), and for two different temperature alues: T = 1 and T = 10. Perform 10 Monte Carlo steps, but only collect data for the magnetization during the last 10* steps. Explain the physical significance of your results. {i1) Extra credit [5 points|: Change the code so that the boundary conditions are periodic. This means that the spins on the boundary interact with the spins on the opposite side of the grid. Repeat your previous calculation of the magnetization with the modified code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Lectures On Quantum Mechanics

Authors: Steven Weinberg

2nd Edition

9781107111660

More Books

Students also viewed these Physics questions

Question

Explain the sources of recruitment.

Answered: 1 week ago

Question

Differentiate sin(5x+2)

Answered: 1 week ago

Question

Compute the derivative f(x)=1/ax+bx

Answered: 1 week ago

Question

What is job enlargement ?

Answered: 1 week ago