Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Use Metropolis-Hastings Monte Carlo Method to Studv the Ising Model (70 point

ID: 3750582 • Letter: 2

Question

2. Use Metropolis-Hastings Monte Carlo Method to Studv the Ising Model (70 points every lattice site i, a spin variable ·= +1 or-1 i.j Write a code to predict the equilibrated average spin -N161of a two-dimensional 31 by 31 spin lattice (N-961 total electrons). In the Hamiltonian of the Ising model shown above, J- 0.5 kgTo (where To-300 K and k is the Boltzmann constant) and u 0 (no external fields here) (i) Show convergence of the Hamiltonian H as you increase the number of iterations under T- 100, 200, 250, 300, 350, 400, 500, and 600 K. (ii Predict and plot o) vs. the number of iterations under T- 100, 200, 250, 300, 350 (iii) (iv) 400, 500, and 600 K. Then summarize the results in a plot for (a) vs. T. Explain the trend you observed in the (o) vs. Tprofile and determine the phase transition temperature Tphase when (a) sharply drops to zero Plot the equilibrated two-dimensional spin lattice states under each temperature considered above. You can use the red grid to represent the spin up state ( 1) and blue grid to represent the spin down state (o,-1), as shown above on the right.

Explanation / Answer

% Generate a code to predict the equilibrated average spin of a 2D 31 by 31 spin lattice

initial 31 by 31, 2-dimensional lattice

[n1,n2] = meshgrid(0:31); //declaring 2D lattice

P = [ n1(:) n2(:) ].';

% Randomly assign initial node values

for i = 1:31

for j = 1:31

P(q,s) = randi(2); //declaring electrons

if P(q,s) == 1;

plot(P(q,:), P(s,:), 'bo', 'Hamiltonian Ising model', 'h');

else

plot(P(i,:), P(j,:), 'ro', 'Hamiltonian Ising model', 'h');

end

end

end

end

Answer no:1

//convergence of the hamiltonion to increase number of iterations

P = randi(2,31,31); % 0:31 -> 32 elements //to plot the number of elements

axes('NextPlot','add','ALimit',[0 size(T,1)-1],'YLim',[0 size(T,2)-1]); //to increase the number of iterations

axis square;

//in defining Boltzmann constant

T={100,200,250,300,350,400,500,600K)

[i1,j1] = ind2sub(size(P),find( isOne)); % ones

[i2,j2] = ind2sub(size(P),find(~isOne)); % twos //convergence of hamiltonion

plot(i1-1, j1-1, 'bo', 'Boltzmann constant', 'b');

plot(i2-1, j2-1, 'ro', 'Boltzmann constant', 'r');

K=randi(2,31,31);  

imagesc(P)

function [lattice] = getLattice(i, j, m, n) //increasing number of iterations

q = sort(mod(1:(n*m), m))';

b = bsxfun(@times, repmat(b, n*m, 1), q);

//when T=300k and Boltzmann constant

a = repmat(bsxfun(@times, a, (1:n-1)'), m, 1);

lattice = a + b;

%figure, plot(lattice(:, 1), lattice(:, 2), 'ok'),

T=100,200,300,400,500,600K

end

function [lattice] = getLattice(a, b, n, m, pts)

q = sort(mod(1:(n*m), m))';

b = bsxfun(@times, repmat(b, n*m, 1), q);

a = repmat(bsxfun(@times, a, (0:n-1)'), m, 1);

spinlattice = a + b;//while increasing number of iterations

spinlattice = bsxfun(@minus, lattice, max(lattice)./2);

figure, plot(lattice(:, 1), lattice(:, 2), 'ok'),

c = cell(n*m, 1);

for i = 1:n*m

c(i) = {bsxfun(@plus, spinlattice(i, :), pts)};

end

c = cell2mat(c);

hold on, plot(c(:, 1), c(:, 2), '.r'),

end

Answer no:2

function [out]=latticeplot(a,b,points,n) //predicting lattice points

%function will plot a lattice given an a and b vector and an array

%containing the points/plots in the lattice.

clf

axis square

hold on

%this section will make the lattice

T1x=a(1)*[1:n];

T1y=a(2)*[1:n];

T2x=b(1)*[1:n];

T2y=b(2)*[1:n];//plotting predictions

for i=2:n

for j=1:n

T1x(i,j)=K1x(1,j)+K2x(1,i-1); //defining number of iterations

T1y(i,j)=K1y(1,j)+K2y(1,i-1);

  

end

end

for i=2:n

plot(v1x(i,:),v1y(i,:),'bo-',v2x(i,:),v2y(i,:),'bo-')

end

Answer no:3

//Trend observed in

ratio=0.1;

%Td over T// delay spread relative to OFDM frame duration

c=2*pi*ratio;

for T=1:Nuser //Declaring T profile

temperature=[];

for n=1:Ncarrier //phase of transition temperature

nc=(n-1)*c;

entry=(1+i*nc)/(1+nc^2);

temperature=[temperature entry];

end

Rtemprature=drops(temperature);//temperature drops to zero

m=n+1;

for i=2:n

for j=1:n

end

m=m+1; //adding iterations

end

for i=2:m-1

plot(points1x(i,:),points1y(i,:),'.k',points2x(i,:),points2y(i,:),'.k',points3x(i,:),points3y(i,:),'.k',points4x(i,:),points4y(i,:),'.k')

end

end

Answer no:4

clear; clc

amaximumplot = 31;//plotting values in the grid

bmaximumplot = 31;

MaxAngle = 270;

//using redgrid for spinup

Radiusinternal = 2.; %radius internal circle

Radiusexternal = 5.; %radius external circle

Ax=zeros(imaximum,jmaximum); Xi=zeros(1,jmax); //defining blue grid

Ay=zeros(imaximum,jmaximum); Yi=zeros(1,jmax);

RI=zeros(imaximum,jmaximum); Xe=zeros(1,jmax);

Ye=zeros(1,jmax);

//using bluegrid for spindown

for j= 1:jmax

//plotting the equilibrated 2D spin lattice

sigma = MaximumAngle*(sigma/180.)*(j-1)/double(jmax-1); //declaring sigma values to plot   

Xi(j) = Radiusinternal(sigma+1); //defining spin up state

Yi(j) = Radiusinternal(sigma-1);

Xe(j) = Radiusexternal(sigma+1);

Ye(j) = Radiusexternal(sigma-1); //defining spin down state

for i = 1: imax

Px(i,j)(redgrid) = Xi(j) + (i-1)/double(imax - 1)* (Radiusexternal-Radiusinternal)*(sigma+1);

Py(i,j)(redgrid) = Yi(j) + (i-1)/double(imax - 1)* (Radiusexternal-Radusinternal)*sin(sigma+1);

RI(i,j)(bluegrid) = sqrt( Px(i,j)^2 +Py(i,j)^2); %Optionnel

end

end  

% RI=ones(imax,jmax);

map2 = [1 1 1 ];% map2 = [0 1 0; 0 0.8 0;1 1 1;0.6 0 0;1 0 0 ];

blue grid(map2)

redgrid(Px,Py,RI)

grid on

Hope you understand and this helps you.all the best

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote