Energy

Energy of a Two-Gas System

Author: Michael Hoff
Date: October 21, 2014

Abstract:

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.

Introduction:

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.

Graph

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:

data

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.

Conclusion:

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.

News

UD Earns Recognition Among America's Best Liberal Arts Colleges

The University of Dallas has been recognized in the 2017-18 Colleges of Distinction Guidebook for the eighth consecutive year among nearly 400 of America's best liberal arts institutions. The annual college guidebook featured the university for having one of the nation's most vibrant college communities and named UD as one of three Catholic Colleges of Distinction in Texas.

+ Read More

Endowment Honors Father, Helps Students Go to Rome

Charles T. Uhl, who worked in UD's IT Department, sent four of his five children to UD and to Rome. When their father passed away, the Uhl children, along with their mother, Nancy, set up a scholarship fund in his name to enable more students to be able to afford Rome each semester.

+ Read More

Iraqi Couple Will Use UD Education to Enrich, Preserve Culture

They came here so that someday, they can go back with even more to offer. Sana Kandalan, MA '19, and Anmar Oghanna, MBA '19, a wife and husband, both received scholarships to pursue graduate education at UD; they hope to use their degrees and experiences here to better serve their community back home in Erbil.

+ Read More