🧪 Gas Cylinder Simulator

Compress it. Release it. Watch temperature and pressure together.

A cylinder of gas is closed by a piston you control. When you push the piston down, you do work on the gas. In an insulated cylinder that work has nowhere to go, so the gas heats up and its pressure rises faster than volume alone would suggest. When you release the piston, the gas cools again.

The cylinder itself shows both quantities at once: colour = temperature (blue cold → red hot), brightness = pressure, with live numbers printed inside. Graphs of T(t), P(t), V(t) and a P–V diagram sit alongside.

 

Notes on the model

Each gas uses its real 3-D heat-capacity ratio γ (e.g., γ = 1.67 for He and Ar, 1.40 for N2, 1.31 for CH4, 1.29 for CO2) and molar mass M. Adiabatic compression follows T·V^(γ-1) = const and P·V^γ = const. In particle mode, molecules move in a 2-D cross-section of the cylinder with speeds proportional to √(T/M) while exchanging energy with an internal/out-of-plane degree-of-freedom reservoir so both models agree quantitatively. Real wall materials (finite heat capacity and conductivity) are planned as a future extension; the conductance control is the hook for that.

R = 8.3145 L·kPa/(mol·K) [= J/(mol·K)] M = 28.01 g/mol · γ = 1.40 · f = 5.0
Model:   Walls:

Validation against theory

These tests run the simulation headlessly (200 macro-particles, hard disks with internal degrees of freedom, fixed time step) and compare the results with textbook 3-D ideal-gas thermodynamics across monatomic (He, γ = 1.67), diatomic (N2, γ = 1.40), and polyatomic (CO2, γ = 1.29) gases. Tolerances allow for finite-size excluded-area effects, statistical noise, and finite piston speed.

TestTheoryMeasuredErrorToleranceResult

Equations used

Credits & AI Provenance

This project separates human authorship and legal ownership from AI tool and model provenance.

Human Author & Copyright Holder

James E. Mitchell — Concept, Domain Director

Project concept, thermodynamic direction, scope, review, and copyright stewardship.

AI Tool & Model Provenance

Google Antigravity (Claude Sonnet 5.5)

Physics engine (2-D hard-disk molecular dynamics and continuum ideal-gas model), overall layout, page design, visualization, automated validation suite, and coding.

Open-Source License & Copyright

Released under the MIT License — © 2026 James E. Mitchell. Source code is hosted on GitHub at github.com/Aengineerdu/Ideal-Gas-Simulator-2026-12.

Only the human author appears in the repository LICENSE file: AI systems are tools, not legal persons, and cannot hold copyright or act as legal licensors.

Third-Party Open-Source Libraries

None. This application has zero external libraries or CDN dependencies; it is built entirely with plain HTML, CSS, and JavaScript using the browser's built-in HTML5 Canvas 2D API.

Model Assumptions, Limits & Scientific References

This is an educational and exploratory proof-of-concept simulation of five ideal gases (He, Ar, N2, CH4, CO2) with real 3-D heat-capacity ratios (γ) and molar masses, adjustable gas amount n, and adjustable expanded cylinder volume Vmax. Conducting walls use a stochastic wall-thermalization fraction (α) as a stepping stone toward realistic finite-heat-capacity wall materials.

Physics references: kinetic theory of gases; hard-disk molecular dynamics; first law of thermodynamics for quasi-static and finite-rate piston processes. See the tab for the governing equations and live automated checks against theory.

Contact

Email: mitcheje@drexel.edu
GitHub: https://github.com/Aengineerdu/Ideal-Gas-Simulator-2026-12