annaandherdad
Hazard to Others
Posts: 389
Registered: 17-9-2011
Member Is Offline
Mood: No Mood
|
|
Atoms in a Gas
Several years ago I made some movies to illustrate the dynamics of atoms in a gas. The purpose was educational. I never finished the project, but
I'm thinking about it again, and posting here a link to some of the results.
http://bohr.physics.berkeley.edu/lab/lab2.html
Any other SF Bay chemists?
|
|
phlogiston
International Hazard
Posts: 1379
Registered: 26-4-2008
Location: Neon Thorium Erbium Lanthanum Neodymium Sulphur
Member Is Offline
Mood: pyrophoric
|
|
Hypnotic.
The free expansion simulation made me wander if you could use it to demonstrate how/why a rocket nozzle works and the difference between a very
efficient nozzle vs. a poor nozzle.
-----
"If a rocket goes up, who cares where it comes down, that's not my concern said Wernher von Braun" - Tom Lehrer
|
|
annaandherdad
Hazard to Others
Posts: 389
Registered: 17-9-2011
Member Is Offline
Mood: No Mood
|
|
I don't know about rocket nozzles, but the simulation gives one all kinds of ideas. In the free expansion you can see the sound wave develop and
bounce back and forth. It's still visible when the simulation cuts off. Also, right after the membrane bursts, you can see the fast particles
moving into the vacuum first, as you'd expect. Then they bounce off the right wall, and create a counter stream that transfers momentum to the rest
of the (slower) gas, creating a pile-up of high density (and pressure) on the right, which is the beginning of the sound wave.
It is not an ideal gas, and it is not hard spheres, either. Hard spheres were too hard to simulate. Instead the particles have a repulsive Gaussian
potential (so it would be smooth but fall off rapidly with distance). The simulation proceeds by a symplectic integrator. Also, the walls are not
hard either, there's a smooth but rising potential at the walls. That's why you can see fast particles penetrating the wall for some distance.
I have other simulations I'll put up later. One is of a gas in a gravitational field, another has two different species of atoms that form
"molecules" and clusters. You can see the gas condensing to form droplets of liquid.
I made these about 5 years ago. At the time I did a search (youtube etc) for simulations like this, and couldn't find any. So I wrote my own. I
never finished the project, but I'm going back to it now. I want to add a gravitational field to the one with liquid droplets so the liquid will
condense at the bottom. I also want to simulate a wall held a fixed temperature, so I can heat or cool the gas. That's not as easy as it sounds.
Any other SF Bay chemists?
|
|
annaandherdad
Hazard to Others
Posts: 389
Registered: 17-9-2011
Member Is Offline
Mood: No Mood
|
|
I have added another movie, this one of a gas in a gravitational field. The format is .mp4 instead of .mpg, which on my Mac required me to download
the movie and play it with VLC. I am still experimenting with this, to find out what is most convenient, but I've found that .mp4, supposedly a
compressed version of .mpg, doesn't actually save much space on these movies, maybe because the entire picture is changing all the time.
Here is the link: http://bohr.physics.berkeley.edu/lab/lab2.html
Anyway, the gas in the gravitational field is supposed to be educational for children (age about 12) because it clearly shows that the air pressure at
the surface of the earth is due to the weight of the air, and because it shows why the air pressure decreases as the altitude increases.
The gas is in thermal equilibrium, which if it were ideal would mean that the distribution of velocities was the same at higher elevation as it is at
lower. This is a somewhat counter-intuitive aspect of ideal gases in a gravitational field.
I have been working on other movies, some with atoms that have a hard core at short range plus a weaker, attractive force at intermediate ranges.
This is more like real atoms. It leads to the formation of liquid droplets. When I get this one in condition to present, I'll put it up too.
Any other SF Bay chemists?
|
|
Fulmen
International Hazard
Posts: 1726
Registered: 24-9-2005
Member Is Offline
Mood: Bored
|
|
Quote: Originally posted by annaandherdad |
The gas is in thermal equilibrium, which if it were ideal would mean that the distribution of velocities was the same at higher elevation as it is at
lower. This is a somewhat counter-intuitive aspect of ideal gases in a gravitational field. |
Interesting, I've never thought about that. But it makes sense, I think. After all the higher energy particles would be more able to move against
gravity, but at the same time the kinetic energy would be converted to potential energy as they do.
Amazing how complex the physics in a simple gas can be.
We're not banging rocks together here. We know how to put a man back together.
|
|
smaerd
International Hazard
Posts: 1262
Registered: 23-1-2010
Member Is Offline
Mood: hmm...
|
|
Cool simulations. Your gas in a gravitational field isn't working for me it says file corrupt. It's likely due to my browser and operating selection
though.
How are you approaching these simulations? Big for-next loop and conditional movements?
What language are you writing them in?
I'm not sure if it would be interesting to do or not but what about Maxwells Demon?
|
|
annaandherdad
Hazard to Others
Posts: 389
Registered: 17-9-2011
Member Is Offline
Mood: No Mood
|
|
Quote: Originally posted by smaerd | Your gas in a gravitational field isn't working for me it says file corrupt. It's likely due to my browser and operating selection though.
How are you approaching these simulations? Big for-next loop and conditional movements?
What language are you writing them in?
I'm not sure if it would be interesting to do or not but what about Maxwells Demon? |
The gravitational field example is a file in mp4 format, which is a compressed version of mpg. It wouldn't work for me, either, if I just clicked on
it in my browser (Chrome under OS X). I had to download it first, then play it with VLC (the free movie player that plays almost anything). VLC is
available on all platforms (windows, mac linux). But I think mp4 is a fairly common format these days.
The simulations use Newton's laws for forces between the particles and with the walls. In the gravitational example, there is also the gravitational
force. The potentials are smooth functions. For example, the interparticle potential is a gaussian repulsive potential. I did not want to use hard
disks or hard walls because these are actually harder to simulate than smooth potentials. The potential at the walls are also smooth functions. The
interparticle potential is
V(r) = A * exp(-(r/a)^2),
where A and a are constants, and r is the distance between the particles. The wall potential is
V(x) = B ln [ 1+ exp(2x/b)],
where x is the distance from the wall (pos or neg) and B and b are constants. This potential -> 0 for large negative x, and -> (2B/b) x for
large pos x. You can see the fast particles penetrating the wall a short distance before getting repelled. I had to concoct more elaborate wall
functions to make the small hole in the effusion example, but the building block was this wall function (above).
I integrate Newton's laws with a leap-frog symplectic integrator, quite a simple integrator. I adjusted the time step until the total energy of the
system was conserved well. The energy drifts by less than 10^{-3} over the duration of the longest simulation. I wrote the program in C. It's not
very long and I'll send you (or anyone else) the code if you want to see it.
It takes quite a few hours to generate 2 minutes of movie, so the experiments take some time. I'm working on some simulations now where the hard,
repulsive potential used in the movies I've shown is modified so that there is a weaker, attractive well at intermediate distances. This is more like
real atoms and molecules, and it means that atoms can bind to each other. In these simulations I'm seeing the appearance of liquid droplets. I
working on one now where there is also a graviatational field, and I'm expecting or hoping the liquid droplets will "rain" down and form a layer of
liquid in the bottom. I've also got ideas of varying the temperature, to see phase transitions (crystal solids, liquids and gas).
I haven't thought about Maxwell's demon, but there are lots of variations on this. If I have enough time I may edit these with some voice over and
put them on youtube.
Any other SF Bay chemists?
|
|
annaandherdad
Hazard to Others
Posts: 389
Registered: 17-9-2011
Member Is Offline
Mood: No Mood
|
|
Quote: Originally posted by Fulmen |
Interesting, I've never thought about that. But it makes sense, I think. After all the higher energy particles would be more able to move against
gravity, but at the same time the kinetic energy would be converted to potential energy as they do.
Amazing how complex the physics in a simple gas can be. |
I've been thinking about this, because the gas I simulate is not ideal (there are repulsive forces between the particles in all the examples I've put
up so far). There are actually two miracles. The first is that an isothermal, ideal gas has the same velocity distribution at all altitudes,
namely, the Maxwellian distribution for the given temperature. The density of the gas falls off exponentially with altitude, ie it goes as
exp(-mgh/kT) where m is the mass of the particle and h is the height. But the velocity distribution is the same at all altitudes.
If you could turn off the interactions, so that each particle would just follow a parabola in the field, bouncing off the ground when it hit, then the
velocity distribution would remain Maxwellian at all altitudes. The fast particles near the ground could reach a high altitude before falling back,
but they would be moving slower by the time they got there. The slow particles near the ground never get to a high altitude. All of this conspires
to make the velocity distribution independent of altitude, which is amazing if you ask me.
The second miracle is that this fact about the velocity distribution remains true even if the gas is not ideal, that is, if there are interactions
between the particles (as in my simulations). The velocity distribution is still Maxwellian, and independent of altitude. The density no longer
decays exponentially, however.
Any other SF Bay chemists?
|
|
smaerd
International Hazard
Posts: 1262
Registered: 23-1-2010
Member Is Offline
Mood: hmm...
|
|
I got the gravitational sim. to work via your instructions. Quite nice!
I've tried learning some open source tools for simulating liquids and it is a bit of over my head. The tools are difficult to use without any
semblance of documentation or coherent implementation of multicomponent tools... Most simulation suites are based on finite element solutions, which
is fantastic for a numerical solution. However one of the problems I've been kicking around is more-so about 'what is happening' and not so much a
deterministic or numerical solution.
If you do venture into the liquid realm I may have a project for you. Or ask for your code and adapt it to serve something pretty involved. It's
probably too 'big' of an idea for a single computer or the method your using but it may provide some ideas.
I find it pretty beautiful to see the assumptions made in the statistical mechanics being used to drive a hoard of particles rather then leading to an
equation or numerical result. I'm excited to see more!
|
|
shadow
Hazard to Self
Posts: 52
Registered: 17-10-2007
Member Is Offline
Mood: No Mood
|
|
Neat stuff!!
I am curious if the relationship of the size of the atom(is this hydrogen?) to the average separation between atoms is consistent with the actual
ratio.
I remember seeing a simulation by Feynman years ago, I thinking the atoms were denser than your display but I'm not sure.
I found this 3d thing on you tube https://www.youtube.com/watch?v=ZN0Vqhbnass, that has huge gaps between molecules, must be in a low pressure area.
But then I realized that the 3rd dimension would be a terrific addition to your program, but probably horribly complex. (I'm no programmer anymore.)
How about one showing boiling water, turning to vapor, and spilling over the edge of a vessel, and then spinning about up into the air?
gc
|
|
annaandherdad
Hazard to Others
Posts: 389
Registered: 17-9-2011
Member Is Offline
Mood: No Mood
|
|
smaerd and shadow---thanks for your support! I'll post the source code as soon as I get a chance, pretty busy today. I'm currently working on a
simulation in which the gas condensed to a liquid. It forms droplets that gradually merge into bigger droplets, and when I put a gravitational field
on it, they "rain" down to the bottom. But I need to diddle with the parameters to make it look good, and it takes 30 hours of run time to generate 2
minutes of movie, so progress is slow.
Any other SF Bay chemists?
|
|
annaandherdad
Hazard to Others
Posts: 389
Registered: 17-9-2011
Member Is Offline
Mood: No Mood
|
|
Here is the source code for the atom movies. The code generates postscript files for each frame. These are later converted into jpg's, which are
then assembled into an mpeg. Development was all on a PC running Mint Linux, everything was compiled under gcc.
Attachment: atoms.tar (157kB) This file has been downloaded 679 times
Any other SF Bay chemists?
|
|
annaandherdad
Hazard to Others
Posts: 389
Registered: 17-9-2011
Member Is Offline
Mood: No Mood
|
|
I have added a new movie at http://bohr.physics.berkeley.edu/lab/lab2.html
It is Movie #5. It's nearly 300MB and takes several minutes to download, but I think it's very interesting. It shows a gas of atoms that are
cooled, so that they condense into a liquid and finally freeze into a solid. The system is in a gravitational field so the liquid "rains" to the
bottom and collects there, where it finally freezes. In the final stages, when vapor pressure is low and the gas is not as dense, you can see the
formation of diatomic and polyatomic molecules, complete with rotations and vibrations. You can see them break apart and reform during collisions.
The gas consists of red and blue "atoms". The red atoms repel the red ones, the blue atoms repel the blue ones, and the red and blue attract each
other at intermediate distances but repel at short distances. The attractive force is needed to form a liquid and a solid. It also causes a
considerable release of heat during the phase transition.
It took several days of run time to generate the movie, and several days of experimentation before that to find some parameters that gave an
interesting effect. I experimented for quite a while with a single species of atom, attractive at intermediate range and repulsive at short, but the
latent heat and surface tension were too great to make an interesting movie. I am continuing to generate frames for this movie, but it takes 10 hours
of computer time to generate 15 seconds of movie, so it's slow. I plan to add more to this movie as I continue the simulation.
I gained some intuition for the effects of molecular interactions in a non-ideal gas that I had never understood before, in the process of doing this.
I'll explain some of that later.
Any other SF Bay chemists?
|
|
smaerd
International Hazard
Posts: 1262
Registered: 23-1-2010
Member Is Offline
Mood: hmm...
|
|
I'm seriously impressed by your latest movie.
How hard would it be to add a constant external force on the 'box' or particles? Something like centrifugation or similar?
Is the computation slow due to the computer you are using or is the computer pretty high-end? It could be fun to try and optimize the process. Granted
it seems like you are handling thousands? of particles in an active fashion.
I'm finding this incredibly interesting from a chaos theory perspective. The old N-body problem.
|
|
annaandherdad
Hazard to Others
Posts: 389
Registered: 17-9-2011
Member Is Offline
Mood: No Mood
|
|
Quote: Originally posted by smaerd |
How hard would it be to add a constant external force on the 'box' or particles? Something like centrifugation or similar?
Is the computation slow due to the computer you are using or is the computer pretty high-end? It could be fun to try and optimize the process. Granted
it seems like you are handling thousands? of particles in an active fashion.
I'm finding this incredibly interesting from a chaos theory perspective. The old N-body problem. |
Thanks, smaerd. A centrifugal force would be easy to add, actually the gravitational force present in the last simulation is very similar.
If you have a real gas in a centrifuge, then the individual molecules feel not only a centrifugal force but also a Coriolis force. This means that
their orbits in between collisions are not straight lines. It would be easy to simulate this, but I haven't done it.
My computer isn't especially high end, it's a 5-year old PC. It has multiple cores and I could speed up the simulation by using all of them, but
that would be a significant complication in the program. For now it's easiest just to live with the slowness.
Yes, the simulation just integrates Newton's laws for 12,000 interacting particles, with the extra gravitational force and the forces at the walls.
Energy is conserved very well, which is a positive sign that the integration is accurate.
If you try to compute the force of every particle on every other then the calculation time for the forces on all the particles grows as N^2, where N
is the number of particles. This is impractical for so many particles. This is one reason why I chose short-range (Gaussian) potentials: I can
ignore the forces coming from any particles that are far away from a given particle. If the forces were more realistic (Coulomb or multipole) then
they would die off much more slowly with distance, and much more complicated programming is required.
Yes, it's the old N-body problem, and the motion is certainly chaotic.
I have gained quite a few insights from these simulations, and I'll write out more of them when I get time, but for now let me just mention this one,
regarding the measurement and meaning of temperature in the simulations.
Statistical mechanics of classical systems says that the temperature is directly proportional to the average kinetic energy of the particles, no
matter what the potential of interaction is. In 2d, such as in my simulation, the relation is <K.E.> = < 1/2 mv^2 > = kT. It 3d it
would be <K.E.> = (3/2)kT. This applies rigorously in thermal equilibrium, even in a liquid or solid.
It is also true independent of the masses of the particles. In my simulation the masses are all equal, but it would be easy to simulate particles of
different masses.
In particular, in thermal equilibrium a heavy particle has the same average kinetic energy as a light one, so its average velocity is smaller by the
square root of the mass ratio. An especially massive particle can be regarded as a particle in the Brownian motion. That is, there is no clear
distinction between the random motion of an individual atom and that of a Brownian particle; the only difference is the mass, which causes the average
velocity to be smaller for the Brownian particle. Einstein understood this very well, he used it in his 1905 paper on the Brownian motion, which is
often regarded as the first convincing proof that atoms exist (when his theory was confirmed experimentally).
In my simulation the liquid drops that form are effectively Brownian particles. They move downward in the gravitational field, collecting at the
bottom, but their motion is not a parabola in the field. Instead is is a Brownian motion superimposed on a downward drift.
My thermometer (in the movie) records the temperature by computing the average kinetic energy and using these formulas. The average kinetic energy
is the total kinetic energy divided by the number of atoms. The temperature fluctuates because energy is continuously being transferred from
kinetic to potential energy and back; the actual temperature becomes precisely defined only when the number of particles -> infinity. Since I
only have 12,000 particles, the temperature fluctuates with an rms of about 1% (since sqrt(12,000) approx = 1% of 12,000). On the other hand, the
total energy (kinetic plus potential) in the simulations holds constant to about 1 part in 10^6 (this is a measure of the accuracy of the
integration).
However, I cool the gas by periodically removing a small fraction of the kinetic energy at definite intervals. I do this by scaling downward the
magnitude of the velocities of each of the particles, without changing the position or direction of the velocity. This shifts the distribution out
of thermal equilibrium, but I rely on collisions and interactions to restore thermal equilibrium after some time.
I'll add more comments later.
Any other SF Bay chemists?
|
|
|