Lattice-gas Monte Carlo Simulation

In summary, the conversation discusses the use of a Monte Carlo metropolis algorithm to model a lattice-gas system, specifically an Ising model. The code used to simulate particle exchange and maintain a constant number of particles was modified from a previous Ising model code. The conversation also mentions the use of a reduced temperature and chemical potential, as well as the Hamiltonian and energy for external magnetic field. The goal of the simulation is to observe a phase transition between two regions with different chemical potentials, but the results do not show the expected behavior. The question is whether the code is accurately modeling the system and if the observed phase transition is due to the boundary conditions used.
  • #1
gavincraig
3
0
Hi all...

Im trying to model a simple lattice-gas ( ising model ) system , using MC metropolis algorithm. I am having trouble with the code. I am trying to do it in matlab. My lattice gas does not show the characteristics it should. I used my old Ising Model code, which I modified to do particle exhange, to keep the number of particles constant, too see the effects in the canonical ensemble, not the grand canonical ensemble, as is the case with "normal" ising model spin-flip
metropolis algorith...

I need someone to spot the error, that for weeks I was unable to see. This is a little side project...

Code:
unction sorption7


L = 20;             %Lattice Size
N = 1000;           %MC steps

epsilon = 1;        %Interaction Term
J = epsilon;    

%k = 1;
k = 1.3806503 * 10^(-23);       %Boltzman constant
    
MU = linspace(5,7,100);         %chemical potential
mu2 = 7;                       %chemical potential in secondary region

T0 =0.5;                        %Temp
T_reduced = (k*T0)/epsilon;     %Reduced Temp
T = T_reduced;
    
beta = 1/(k*T);                 %beta 

%p = rand(L);
%p( find(p < 0.5) ) = -1;
%p( find(p > 0.5) ) = 1

p = zeros(L);

p(:,:) = -1;
p(1:8,1:8) = 1
QM = zeros(1,length(MU));

cnt = 1;
while cnt < length(MU)+1,

    mu  = MU(cnt);
    mecnt =  0;
    mctime = 0;
    aveMQ = 0;
    while( mctime < N ),
        mecnt = mecnt + 1;
        Q = length(find(p(:,L/2:L)==1));
        aveMQ = aveMQ + Q/(L*(L/2));
       
        
        gop =find(p==1);
        gop_L = length(gop);

        jut = round(1+ (gop_L-1)*rand(1));

        [i,j] = ind2sub(size(p),gop(jut));
        idx = move( i,j, p,L/2 );
        %current_index = sub2ind( size(p), i,j);
        current_index = gop(jut);
        if( idx ~= current_index && idx ~= 0 ),
            [de ep] = delta6( J, mu,mu2,idx,p,10);
            %[de ep] = delta6( J, mu,mu2, current_index,p );
            %de = de -1;
            %de = ((de2-1)-de1);
            %ep = (ep2-ep1);
            %aveEP = aveEP + ep;
            if de <= 0,
                p(idx) = 1;
                p(current_index) = -1;
            end;
            if de > 0,
                rr = rand(1);
                if rr < exp( -de*beta ),
                    p(idx) = 1;
                    p(current_index) = -1;

                end;

            end;

        end;


        if idx == 0,
            
        end;

        NN = length( find(p==1));
        ss = sprintf(' Number of Particles %d',NN);
        image(p+1);
        title(ss);
        colormap(hsv(4));
        drawnow;
        mctime = mctime + 1;
    end; %while MC LOOP

    QM(cnt) = aveMQ/mecnt;
    cnt = cnt + 1;
end;
figure;
plot(MU,QM,'.-m');
title('mu vs site density');
xlabel('mu');
ylabel('site density');
end

This is my hamiltonian, that I derived from the Ising Model hamiltonian/Energy for external magnetic field...

Code:
function E = Hamiltonian( mu, J, Ep, N_s,N_o )
mu0 = 4*J;
mu1 = 2*mu - 8*J;
term1 = N_s*(mu-2*J);

E = -mu0*Ep - mu1*N_s; + term1;
end


What I am trying to achieve is the simple phase transition. in my llittle model I have 2 regions. 1 region is kept at a constant chemical potential, while the other region I start from a low chemical potential moving up. I am expecting there to be some kind of phase transtion, where the particles will favour, mostly, but not all, 1 region above the other. What I see is in the graph attached. There is periodic BC in all directions.

My question is thus... is the code modelling it correctly? and is the phase transition I see due to the BC... I've altered my BC so that it has only say left/right periodicity, and not up/down, and it produces the same type of density plot...

thanks
 

Attachments

  • untitled.jpg
    untitled.jpg
    16.6 KB · Views: 445
Physics news on Phys.org
  • #2
new to the forum, but is this a school physics forum?
 
  • #3
lol nobody any ideas? hectic
 

FAQ: Lattice-gas Monte Carlo Simulation

What is a Lattice-gas Monte Carlo Simulation?

A Lattice-gas Monte Carlo Simulation is a computational method used in statistical physics to simulate the behavior of gases on a lattice. It is a type of Monte Carlo simulation that models the movement of particles on a lattice, taking into account interactions between neighboring particles.

How does a Lattice-gas Monte Carlo Simulation work?

In a Lattice-gas Monte Carlo Simulation, the particles are represented as discrete points on a lattice. The simulation works by randomly selecting a particle and proposing a move to a neighboring lattice site. The acceptance of this move is based on a probabilistic calculation that takes into account the energy of the system and the proposed move.

What is the purpose of using a Lattice-gas Monte Carlo Simulation?

A Lattice-gas Monte Carlo Simulation is used to study the behavior of gases at a microscopic level. By simulating the movement of individual particles, it allows for the investigation of thermodynamic properties, such as pressure and temperature, and the study of phase transitions in the system.

What are the advantages of using a Lattice-gas Monte Carlo Simulation?

One of the main advantages of a Lattice-gas Monte Carlo Simulation is its ability to model complex systems with a large number of particles. It is also relatively simple to implement, making it a popular choice for studying phase transitions and other phenomena in statistical physics.

What are some applications of Lattice-gas Monte Carlo Simulation?

Lattice-gas Monte Carlo Simulation has been used in a variety of fields, such as materials science, chemistry, and engineering. It has been used to study the properties of gases in confined environments, the behavior of fluids at interfaces, and the self-assembly of particles into ordered structures.

Similar threads

Replies
3
Views
2K
Replies
1
Views
1K
Replies
1
Views
1K
Replies
1
Views
1K
Replies
1
Views
3K
Replies
3
Views
1K
Replies
1
Views
4K
Replies
2
Views
1K
Replies
1
Views
3K
Back
Top