# Education app demonstrating 2nd law of thermodynamics

#### bcrowell

Staff Emeritus
Gold Member
I recently posted about a browser-based educational app that graphs the position, velocity, and acceleration of the mouse's vertical motion. In the same spirit, I've written an app that demonstrates the statistical basis of the second law of thermodynamics by simulating the free expansion of a gas: http://www.lightandmatter.com/entropy

Related Educators and Teaching News on Phys.org

#### Bystander

Homework Helper
Gold Member
Not unlike watching an aquarium --- almost hypnotic.

#### Andy Resnick

I recently posted about a browser-based educational app that graphs the position, velocity, and acceleration of the mouse's vertical motion. In the same spirit, I've written an app that demonstrates the statistical basis of the second law of thermodynamics by simulating the free expansion of a gas: http://www.lightandmatter.com/entropy
I understand this is an elementary presentation, but free expansion can be isentropic, isothermal, or somewhere in between:

http://www.engineeringtoolbox.com/compression-expansion-gases-d_605.html

It's not clear which you are trying to simulate.

Another point- while not stated, I suspect your 'atoms' are all indistinguishable; thus you can't easily resolve Gibbs' paradox:

#### bcrowell

Staff Emeritus
Gold Member
Thanks for your comments, Andy. If you watch the simulation, I think it should be clear that it's simulating what are essentially perfectly elastic billiard balls, so the expansion is isothermal. Although I hadn't stated it explicitly in the documentation, I think you can tell that it's simulating an ideal gas, and the free expansion of an ideal gas is isothermal.

Gibbs' paradox is interesting. However, I don't see its relevance here, since it deals with a different situation than the one I'm simulating.

#### Chestermiller

Mentor
Thanks for your comments, Andy. If you watch the simulation, I think it should be clear that it's simulating what are essentially perfectly elastic billiard balls, so the expansion is isothermal. Although I hadn't stated it explicitly in the documentation, I think you can tell that it's simulating an ideal gas, and the free expansion of an ideal gas is isothermal.

Gibbs' paradox is interesting. However, I don't see its relevance here, since it deals with a different situation than the one I'm simulating.
In the free adiabatic expansion of a gas, Q=W=0, so ΔU is zero. This also means that, if the gas is an ideal gas, ΔT is also zero. So, for an ideal gas, free expansion in a closed container is both adiabatic and isothermal. Of course, for a real gas, there will be a temperature change.

I regard free adiabatic expansion of a gas in a closed container as the closed-system analog of the Joule-Thompson effect for adiabatic flow of a gas through a valve or porous plug. In the case of free expansion in a closed container, one is interested in the effect of the pressure (or volume) change on temperature at constant internal energy. In Joule-Thompson, one is interested in the effect of the pressure change on the temperature at constant enthalpy.

Chet

#### bcrowell

Staff Emeritus
Gold Member
I've done some more work on the simulation and worked out several different demonstrations that I intend to use in lecture. I thought others might be interested to see them.

http://www.lightandmatter.com/entropy?wait

The basic demo of free expansion and the second law. Click the Start button to see the demonstration run. (This is the reason for the "wait" option in this url and the others below; in a lecture, it gives time to say something to the class before everything starts moving.) On the graphs you can see the system reaching equilibrium and fluctuating away from equilibrium. By increasing the number of particles you can see that the fluctuations get smaller in relative terms. If you hit the "Reverse velocities" button you can see the system move back to its initial state, violating the second law.

http://www.lightandmatter.com/entropy?flock,wait

The particles are all initially concentrated in one region of space and moving in the same direction. Because this particular version of the system is not ergodic, thermal equilibrium is never reached. Although the flock spreads out spatially due to collisions, it remains confined to a small portion of the phase space in terms of momentum. This doesn't violate the second law, since the second law doesn't demand that the entropy increase at any nonzero rate.

http://www.lightandmatter.com/entropy?gy=2,flock,wait

Adding gravity in the y direction breaks part of the system's unrealistically perfect symmetry and causes the y momentum to equilibrate.

http://www.lightandmatter.com/entropy?gx=3,gy=2,flock,wait

Adding an x component to gravity makes all the degrees of freedom equilibrate.

http://www.lightandmatter.com/entropy?island,flock,wait

Another way of getting rid of the non-ergodic behavior is to add a circular island in the middle of the box. This is known as Sinai's billiards. The island acts as a diverging lens.

http://www.lightandmatter.com/entropy?temps,n=300,wait

The whole box is uniformly filled with particles, but with unequal temperatures on the two sides

http://www.lightandmatter.com/entropy?temps,n=300,wait,mark

By adding ",mark" to any of these URLs, you can cause one of the particles to be marked in red. This allows you to look at ideas like diffusion and the mean free path.

Various other options are described in the documentation: https://github.com/bcrowell/entropy/blob/master/README.md

#### jasonRF

Gold Member
These are great simulations - certainly a lot of fun to watch and could be useful for students at many levels. I especially like the versions with the marked ball that let us see a random walk in action. The item on your to-do list would be fun to see; along the same lines, plots of mean velocity and temperature may be interesting for all the sims.

jason

#### Andy Resnick

<snip> If you hit the "Reverse velocities" button you can see the system move back to its initial state, violating the second law.

http://www.lightandmatter.com/entropy?flock,wait

<snip>
Like!

Just back from vacation, so I haven't fully explored these yet. But I do like the 'reverse velocities'- it is known that indeed, viscous flow can be reversible under certain circumstances- dye can be 'unwound', for example:

#### bcrowell

Staff Emeritus
Gold Member
Cool video, Andy! (I love how he obviously miscounts and asks his helpers to confirm his miscount, which they do -- and then at the end they tell him that he miscounted.)

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving