Energy of a Two-Gas System

Author: Michael Hoff
Date: October 21, 2014


This paper presents a computational program designed to simulate a two-gas system in Visual Python. Similar to the well-known "Particles in a Box", this simulation aims to illustrate the energies of two initially separated gases of different temperatures as they mix together and proceed toward equilibrium. The program uses Kinetic Gas Theory, the simple Euler method, and basic probability to calculate the energy of each gas based on the kinetic energies of its constituent particles, as well as the kinetic energy exchanges in collisions between individual particles. The results are qualitatively accurate, but precision could be improved with a smaller time-step, which was beyond the computing capabilities available in this experiment.


The goal of this project was to simulate the energy of a system composed of two gases of differing initial temperatures as they mix together and proceed toward equilibrium. To do this, the simple Euler method was used, treating each gas as a collection of individual particles with discrete velocities and confined to a box. This being achieved, the results were compared to the logical conclusion reached by applying the laws of thermodynamics.

Theoretical Background:

This project could be viewed as a specific instance of the classic "Particles in a Box" situation: within a box (i.e., a three-dimensional infinite potential well), two gases of different temperatures are initially separated, with the hot gas in one half of the box and the cold gas in the other half. As per Kinetic Gas Theory, the average speed of the particles of each gas are determined by the gas' temperature:

K = mv2 = 3/2 kT              v = (3kT/m)1/2

such that the particles composing the hot gas are moving substantially faster than those composing the cold gas. At t = 0, the barrier separating the two gases from each other is removed, allowing the gases to mix and their respective particles to collide. Through these collisions, energy and momentum are exchanged, with the overall trend being a transfer of energy from the fast-moving hot particles to the slow-moving cold particles. Over time, the energy difference between the two gases diminishes, until this difference finally disappears at equilibrium. The total energy of the two-gas system, however, ought to remain constant.

Computational Methods:

The program, written in Visual Python, simulates this scenario by treating each gas particle individually, and updating its position by the simple Euler method.

In order for both energy and momentum to be conserved, the following two equations must be simultaneously satisfied when a hot and a cold gas particle collide:

p: m1v1i + m2v2i = m1v1f + m2v2f
E: m1v1i2 + m2v2i2 = m1v1f2 + m2v2f2.

Since we are confining our attention to a system in which the hot and cold gas particles have the same mass, these equations simplify to:

p: v1i + v2i = v1f + v2f
E: v1i2 + v2i2 = v1f2 + v2f2

This is analogous to the following general system of two equations with four unknowns:

A + B = C + D
A2 + B2 = C2 + D2

Assuming all terms are non-zero, this system can only be satisfied if A = C and B = D, or if
A = D and B = C. That is to say, each collision between a pair of gas particles can only conserve both energy and momentum if each particle either maintains its initial velocity or swaps velocities with the other particle, with both of these possible outcomes being of statistically equal probability. Therefore, for each collision between a given pair of particles, the program chooses one of these two possible outcomes at random. In this way, the energy of the two systems will begin to equalize over time. Finally, the program continuously computes the total energies of each system based on the velocities of its constituent particles.

Results and Analysis:

In order to produce realistic results, the simulation should consider as many gas particles in the system as possible. This makes the program computationally intensive, and it is impossible to run for an extended period on a basic machine, unless the time-step is considerably larger than is optimal for the simple Euler method. Nevertheless, the program still yields good results, with the two gases approaching each other in temperature, and the total temperature of the system remaining nearly constant. The energy of each gas is very small (on the order of 10-20 Joules), but that is to be expected for a gas of less than one hundred particles.


Figure 1: Energy of the hot gas (red), energy of the cold gas (blue), and total energy of the
system (white), vs. time.

From a visual perspective, the program is also able to keep up with and accurately model the visual system itself, providing a useful illustration of and insight into its physical properties:


Figure 2: A three-dimensional visualization of the system, as it
approaches equilibrium; the particles of the hot gas (red)
are mixing with and subsequently colliding with the particles
of the cold gas (blue), thus imparting to them a portion of their
kinetic energy.


The primary issue with the program's performance was that the total energy of the system dipped initially. This was likely due to some lost energy when the particles were first beginning to interact and the gap between their respective energies was greatest. The culprit behind this problem is almost certainly the small time-step: if the system could be analyzed every milli- or even micro-second rather than every whole second there would be a substantially smaller window in which energy fragments could disappear. However, after this initial dip, the total energy does flat-line, and remains constant for the rest of the simulation even before the system reaches equilibrium. More importantly, the simulation shows the two gases approaching each other in energy, entering into a state with only a small energy difference between them, undergoing minor fluctuations, and ultimately seeing those fluctuations diminish asymptotically. The algorithm itself performed well; moving forward, perhaps more precise results could be obtained if the program were run on a more powerful machine, thus enabling a longer run-time and a smaller time-step.


UD in the Community: Lamberti's Carries On Tradition

Its connection to UD helps the alumnus-owned Lamberti's fulfill its three pillars: local, tradition and famiglia. Lamberti's was the vendor for this year's Groundhog "Party in the Park" celebration; additionally, Lamberti's is looking into carrying Due Santi Rosso wine from UD's own vineyard on the Eugene Constantin Campus.

+ Read More

University of Dallas Dedicates Cardinal Farrell Hall -- Its New 'Front Door'

The University of Dallas community gathered on Friday, Feb. 2, 2018, for the formal blessing and opening of Cardinal Farrell Hall, named after our former bishop of Dallas, previous chancellor and longtime friend of the university, Kevin Cardinal Farrell. The opening of the new student-focused building marks the completion of one of several capital projects, a part of a broader institutional effort to transform the university's Irving campus.

+ Read More

Textile and Ceramic Exhibition Arrives from North Carolina Mountain Range

The Beatrice M. Haggerty Gallery proudly announces the opening of a two-person exhibition, "What Remains," featuring artists Rachel Meginnes and Assistant Professor of Ceramics Kelly O'Briant. The exhibition is curated by Penland Gallery Director Kathryn Gremley of the Penland School of Craft in North Carolina. In 2001, O'Briant received a two-year Core Fellowship from the Penland School of Craft, where Meginnes recently completed a three-year residency.

+ Read More