Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Particle simulation

  1. May 12, 2009 #1
    I would like to simulate a gas--very approximately--in 2 dimensions. The container will be divided into a grid, and instead of keeping track of each molecule of gas individually, I want to let each cell in the grid have a value for the number of particles in that cell, and another couple of values for the average velocity within the cell. This will allow me to simulate a larger number of particles, without slowing down the simulation.

    The problem is then this: given that a cell has n molecules at time t=0, with average velocity v, how can one approximate the number and average velocity of molecules in the 4 adjacent cells at time t=1?

    I guess that I need to look at the number and velocity of molecules passing across the boundary between an adjacent pair of cells over that time unit. I'm sure this problem has been solved before, I just don't know where.
  2. jcsd
  3. May 12, 2009 #2


    User Avatar
    Science Advisor
    Gold Member

    What kind of numbers are we talking about?

    I don't think you could approximate the number and average velocity of molecules in the 4 adjacent cells at time t=1 without going through and calculating the forces on the molecules. Unless you have a very large number of molecules to work with you are not going to see a statistically averaged result (and really, with large numbers of gas particles situated haphazardly in a cell, the average net velocity would be zero and though the average speed would not be zero). There are ways to simulate large number of unknowns, like using fast multipole method. You can estimate the interaction of particles far away from your particle of interest by combining their potentials into the summation of pole moments (monopole, dipole, quadrapole, etc).

    Sometimes you can use monte carlo methods to achieve desired results as well. Monte carlo and similar methods (random walk, worm theory (I think that's the name), etc) generally iterate towards the final state, they aren't useful for observing the motion of the particles, but if you want to know the equilibrium state then these methods are a different way of achieving that.
  4. May 12, 2009 #3
    It doesn't have to be very accurate--this is for a cellular automaton (an ant colony--I want to give my ants velocities, instead of having them drift randomly). If the result looks qualitatively OK then it's good enough. Long-range effects aren't a concern, because velocities can be slow (1 cell/time step or less) and my ants don't have their own gravity :P

    For scale: presently I'm simulating a 640x480 grid, there could be 0-255 particles per pixel, and I want to have a high frame rate (30+ FPS). I want to be economical in how much computation I do per pixel.
  5. May 12, 2009 #4


    User Avatar
    Science Advisor
    Gold Member

    Well I'm just not sure how you would do this with a gas. The molecules of a gas have a potential profile, Van der Waals potential. The interaction between particles is a summation of the forces from all possible pairs according to the potential used. You can't just stick 10 gas molecules in a box and ask how will they come out and with what velocities without doing the calculations. Only if you have a very very large number would you be able to estimate this from statistical averages but that wouldn't be the case here.

    Take a look at Verlet integrators for an accurate and fast way to model molecular dynamics. If your "potential" has a sharp distance cutoff, then what you can do is ID each particle with the box they are in. You could keep a relationship for the neighboring boxes. For example, you have an array of box ids and each element points to a list of atoms that are in each box. Then you have a second list of box ids where each element points to a list of the neighboring boxes. Then you could just go through and only calculate the interactions from the atoms in the 9 boxes (1 self box, 8 neighbors).

    Another way is to have a list for each atom of the atoms that are within a cutoff distance of itself. Then you calculate the resulting interactions at that time step and integrate. The next time step, you would go through and update the list. You could speed this up by only looking at the atoms from the previous time step and the atoms in the list of these atoms (need to check for atoms that may come into your cutoff distance). This could work as long as the velocities are kept low enough.
  6. May 12, 2009 #5
    I think that to keep a separate ID and compute separate behavior for each particle would be too slow. That would amount to tens of millions of particles (the grid is not sparse).
  7. May 12, 2009 #6
    I believe you will need to know two things. 1) Divergence in two dimensions and 2) Diffusivity (diffusion coefficient). With this information, you can calculate a diffusion current from one cell to adjacent cells.
  8. May 12, 2009 #7
    I'm going to try Lattice Boltzmann methods.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook