adel-00

120 Reputation

9 Badges

11 years, 63 days

MaplePrimes Activity


These are replies submitted by adel-00

@Kitonum 

Thanks for ur clarifications

@Kitonum 

the warning is about the singularity,, how can we avoid if

@Carl Love 

Sorry If I do waste your time ...

many thanks

@Carl Love 

To calculate 

DeltaE:=2*(j*(spin*neighbours)+B*spin: p=exp(-DeltaE):

and 

calcultate the esponential 

p=exp(-DeltaE):

 

and decide which transition will occur

trans:=(rand(N)<trans)*(rand(N)<0.1)*-2+1:

perform the transition

spin:=spin*trans:

sum up our variables:

M:=sum(sum(spin)): E:=-sum(sum(DeltaE))/2:

 

display the current state of the system:

image((spin+1)*128);

 

@Carl Love @Doug Meade

I dont skip the line 

N:=3:B:=0:
j:=rand(0..1)()+10^(-10):
Spin := N -> (-1)^~(LinearAlgebra:-RandomMatrix( N, N, generator=rand(N) ));
spin := Spin(N):
N -> ~[^](-1, $,

LinearAlgebra:-RandomMatrix(N, N, generator = rand(N)))
for i from 1 to 2 do neighbours:=< spin[..,-1] | spin[..,1..-2] >+ < spin[..,2..-1] | spin[..,1] >+< spin[-1,..],spin[1..-2,..]>+ < spin[2..-1,..] , spin[1,..] >: DeltaE:=2*(j*(spin*neighbours)+B*spin: p=exp(-DeltaE): trans:=(rand(N)<trans)*(rand(N)<0.1)*-2+1: spin:=spin*trans: M:=sum(sum(spin)): E:=-sum(sum(DeltaE))/2: end do;

@Carl Love 

N:=3:B:=0:
j:=rand(0..1)()+10^(-10):
Spin := N -> (-1)^~(LinearAlgebra:-RandomMatrix( N, N, generator=rand(N) )); spin := Spin(N):
N -> ~[^](-1, $,

LinearAlgebra:-RandomMatrix(N, N, generator = rand(N)))
for i from 1 to 2 do neighbours:=< spin[..,-1] | spin[..,1..-2] >+ < spin[..,2..-1] | spin[..,1] >+< spin[-1,..],spin[1..-2,..]>+ < spin[2..-1,..] , spin[1,..] >: DeltaE:=2*(j*(spin*neighbours)+B*spin: p=exp(-DeltaE): trans:=(rand(N)<trans)*(rand(N)<0.1)*-2+1: spin:=spin*trans: M:=sum(sum(spin)): E:=-sum(sum(DeltaE))/2: end do;

Plz can u run the above and what is missing

@Doug Meade 

what in maple can I write this

image(C) displays the data in array C as an image. Each element of C specifies the color for 1 pixel of the image. The resulting image is an m-by-n grid of pixels where m is the number of columns and n is the number of rows in C. The row and column indices of the elements determine the centers of the corresponding pixels.

image((spin+1)*128);

@Doug Meade 

 

N:=3:B:=0:
j:=rand(0..1)()+10^(-10):
Spin := N -> (-1)^~(LinearAlgebra:-RandomMatrix( N, N, generator=rand(N) )); spin := Spin(N):
N -> ~[^](-1, $,

LinearAlgebra:-RandomMatrix(N, N, generator = rand(N)))
for i from 1 to 2 do neighbours:=< spin[..,-1] | spin[..,1..-2] >+ < spin[..,2..-1] | spin[..,1] >+< spin[-1,..],spin[1..-2,..]>+ < spin[2..-1,..] , spin[1,..] >: DeltaE:=2*(j*(spin*neighbours)+B*spin: p=exp(-DeltaE): trans:=(rand(N)<trans)*(rand(N)<0.1)*-2+1: spin:=spin*trans: M:=sum(sum(spin)): E:=-sum(sum(DeltaE))/2: end do;

@Doug Meade 

N:=1000:
Spin := N -> (-1)^~(LinearAlgebra:-RandomMatrix( N, N, generator=rand(N) ));
N -> ~[^](-1, $,

LinearAlgebra:-RandomMatrix(N, N, generator = rand(N)))
neighbours:=< spin[..,-1] | spin[..,1..-2] >+ < spin[..,2..-1] | spin[..,1] >+< spin[-1,..],spin[1..-2,..]>+ < spin[2..-1,..] , spin[1,..] >;

Error, (in rtable/Sum) invalid arguments

@Carl Love 

Thanks for ur fast reply..

so when we write

round(rand())

@Carl Love 

Thanks Carl

@YasH 

this is the matlab is it possible to rewrite it in simple maple code

function [M, num, E] = ising(N,J)

B = 0;

M = []; % The total magnetic field of the system

E = []; % The total energy of the system

randTol = 0.1; % The tolerance, dampens the spin flip process

% First we generate a random initial configuration

spin = (-1).^(round(rand(N)));

% Then we let the system evolve for a fixed number of steps

for i=1:1000,

% Calculating the total spin of neighbouring cells

neighbours = circshift(spin, [ 0 1]) + ...

circshift(spin, [ 0 -1]) + ...

circshift(spin, [ 1 0]) + ...

circshift(spin, [-1 0]);

% Calculate the change in energy of flipping a spin

DeltaE = 2 * (J*(spin .* neighbours) + B*spin);

% Calculate the transition probabilities

p_trans = exp(-DeltaE);

% Decide which transitions will occur

transitions = (rand(N) < p_trans ).*(rand(N) < randTol) * -2 + 1;

% Perform the transitions

spin = spin .* transitions;

% Sum up our variables of interest

M = sum(sum(spin));

E = -sum(sum(DeltaE))/2; % Divide by two because of double counting

% Display the current state of the system (optional)

image((spin+1)*128);

xlabel(sprintf('J = %0.2f, M = %0.2f, E = %0.2f', J, M/N^2, E/N^2));

set(gca,'YTickLabel',[],'XTickLabel',[]);

axis square; colormap bone; drawnow;

end

% Count the number of clusters of 'spin up' states

[L, num] = bwlabel(spin == 1, 4);

I have the same problem have u rewrite it in maple??

in terms of MC method

First: choose arbitrary configration of spoin (up or down)

how can I start with this line

@Carl Love 

is there in maple a build in packege of monte calro in statistical mechanics?

4 5 6 7 8 9 10 Page 6 of 11