This repository contains a numerical routine developed in Python and R for calculating and visualizing the Maxwell-Boltzmann velocity distribution of an ideal gas. The code generates the probability density function
Victor Moreira Acacio
Institute of Astronomy, Geophysics and Atmospheric Sciences of the University of São Paulo
GitHub: @OAkacio
ORCID: 0009-0007-4484-2129
Clone this repository and install the Python dependencies by running the following commands in your terminal. Ensure that an R environment is also installed on your system to execute the plotting routine.
git clone https://github.com/OAkacio/maxwell-boltzmann-distribution.git
cd maxwell-boltzmann-distribution
pip install -r requirements.txtThe workflow of this integrator is divided into two sequential steps: numerical data generation via Python and high-resolution visualization via R.
1. Generate the distribution data: Execute the main engine to calculate the probability density and characteristic velocities.
python main.py2. Plot the results:
Run the R script to process the generated .txt data and export the standardized scientific plot.
Rscript plot_main.RNote: To change the macroscopic variables such as Temperature (src/parameters.py before running the integration engine.
The mathematical foundation of this routine is based on the classical kinetic theory of gases. The code calculates the following physical quantities:
1. Probability Density Function ($f(v)$)
The probability of a particle having a velocity
2. Most Probable Velocity (
3. Mean Velocity (
4. Root-Mean-Square Velocity (
├── data/
│ ├── dados.txt # Distribution curve points (v, f(v))
│ └── dados_car.txt # Characteristic velocities (v_mp, v_avg, v_rms) # Generated data files (.txt)
├── figures/ # High-resolution distribution plots (.png)
├── src/ # Core modules (core.py, parameters.py, utils.py)
├── main.py # Python numerical integration engine
├── plot_main.R # R plotting and visualization script
└── requirements.txt
This repository was developed as an auxiliary computational tool for the study of Thermodynamics and Statistical Mechanics. The central objective is to provide a reproducible numerical routine to visualize how the statistical distribution of particle velocities shifts according to macroscopic thermodynamic variables, offering a clear analytical visualization of ideal gas behavior.
