Entropy calculation atoms simulation

In summary, the conversation discussed a program that simulates a stochastic system of 400 particles and the need to separate the 200x200 grid into 2x2 smaller grids to calculate probabilities and determine entropy. The individual steps for implementing this were also mentioned, with the suggestion to start with a smaller matrix before applying it to the larger one.
  • #1
ChrisVer
Gold Member
3,378
464
I have the following program that simulates a stochastic system of 400 particles. What I want to do now is separate the 200x200 grid into 2x2 smaller grids, out of which I will calculate each probability:
[itex]P_i= \frac{\sum_{\text{atoms}}}{4}[/itex]
and from which in each step I'll be able to determine the entropy...
However I don't see how I can make the division to sub-grids... any help?
In the second part of code quote I show what I've tried to implement..but I don't think it works.

Python:
import sys
from pylab import *
from random import randintion() #allow animation
figure(figsize=(10,10)) #setup graph window

#Setup the problem
atoms = ones([400,2])*100                  #define all droplet coords to be at point 100,100
line, = plot(atoms[:,0], atoms[:,1], 'ro')
xlim(0,200)
ylim(0,200)
draw()
wait= raw_input("Press return to continue")

#time steps to take input
N= int(sys.argv[1])
#loop over steps
for i in range(N):

    #Go through all atoms
    for j in range(400):

         #move each atom
         atoms[j,0] += randint(-1,1)
         atoms[j,1] += randint(-1,1)
        #check boundary
         x,y = (atoms[j,0], atoms[j,1])
         if x==200: atoms[j,0] = 198
        elif x==0: atoms[j,0] = 2
         if y ==200: atoms[j,1] = 198
        elif y==0: atoms[j,1] =2

    #see how things look now
    line.set_xdata(atoms[:,0])
    line.set_ydata(atoms[:,1])
    draw()

wait= raw_input("Press Return to exit")
Python:
xs= atoms[:,0]
ys= atoms[:,1]
P=zeros([100,100])
for i in range(0,200,2):
    for j in range(0,200,2):
            P[i/2,j/2] = xs[i]+xs[i+1] +ys[j] + ys[j+1]
P=P/4.
Entropy=0.0
for i in range(100):
    for j in range(100):
        if P[i,j]!=0: Entropy+= P[i,j]*log(P[i,j])
        else: Entropy+=0.0
 
  • #3
What I would do is start with a smaller matrix, say 4 x 4, and see what needs to be done to split it up into four 2 x 2 matrices. The upper left submatrix with consist of P[0, 0], P[0, 1], P[1, 0], and P[1, 1]. See if you can figure out what the entries would be for the upper right. lower left, and lower right submatrices. You might be able to extend the idea to splitting your 200 x 200 matrix into 10,000 2x2 submatrices.
 

1. What is entropy and why is it important in atom simulations?

Entropy is a measure of the disorder or randomness of a system. In atom simulations, it is important because it helps to understand the behavior and interactions of atoms and molecules, which can be chaotic and unpredictable. Entropy also provides valuable information about the thermodynamic properties of a system.

2. How is entropy calculated in atom simulations?

Entropy can be calculated using statistical mechanics, which involves analyzing the positions and velocities of atoms in a system. This information is then used to calculate the probability of different states and the overall disorder of the system.

3. Can entropy be negative in atom simulations?

No, entropy cannot be negative in atom simulations. This is because entropy is a measure of disorder and randomness, and it is impossible for a system to have a negative amount of disorder.

4. How does increasing the number of atoms affect entropy in simulations?

In general, increasing the number of atoms in a system increases the overall entropy. This is because there are more possible configurations and interactions between the atoms, leading to a higher level of disorder.

5. How can entropy be used to analyze the stability of a system in atom simulations?

Entropy can be used to analyze the stability of a system by comparing the entropy values of different states. A system with a higher entropy is considered more stable, as it has a greater number of possible configurations and is less likely to collapse into a lower energy state.

Similar threads

Replies
1
Views
1K
  • Programming and Computer Science
Replies
2
Views
916
  • Programming and Computer Science
Replies
6
Views
5K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
4
Views
916
  • Programming and Computer Science
Replies
17
Views
2K
  • Programming and Computer Science
Replies
1
Views
944
Back
Top