Skip to content

A simple model for free expansion of a gas using stochastic dynamics

License

Notifications You must be signed in to change notification settings

PabRod/SimpleExpansion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SimpleExpansion

A simple model for free expansion of a gas using stochastic dynamics

Background

The main purpose of this piece of code is simulating the free expansion of a gas (https://en.wikipedia.org/wiki/Free_expansion).

Here we use a minimal discrete time model. We initialize it with all the molecules in the left cavity. At each time step, one particle chosen randomly changes its position to the other cavity.Even with such a simple dynamics, several properties of free expansion can be derived.

The main purpose of this code is the generation of animated visualizations, useful for teaching basic statistical mechanics.

Where the value of the potential at x_0 is an arbitrary integration constant.

Examples of usage

Create and update the ExpansionSim object

%% Initialization
r = 10; % Number of rows
c = 10; % Number of columns

%% Create the object
obj = ExpansionSim(r, c);

%% Update N times
N = 100;
obj.Update(N);

Plot occupation diagram

obj.Plot(); % Plots current occupation diagram

obj.Plot(tStep); % Plots the occupation diagram at a given time step

Occupation_diagram

Plot a summary of the occupation as a bar plot

obj.PlotBar(); % Bar plot of the current occupation summary

obj.Plot(tStep); % Bar plot of the occupation summary at a given time step

Bar_diagram

Plot historic summary of occupation

obj.PlotHistoric();

Historic

Create an animated occupation diagram

obj.Animate();

Animation

By Pablo Rodríguez-Sánchez, November 2017.

About

A simple model for free expansion of a gas using stochastic dynamics

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages