Project 04 · Case study
Molecular thermodynamics

Methane NVT Monte Carlo

A custom Metropolis solver for estimating methane pressure and energy across liquid and gas states.

  • Python
  • Metropolis sampling
  • Lennard-Jones
  • Virial pressure
Monte Carlo pressure-temperature results for liquid and gas methane states Six state points
Project result Pressure response at 200, 300 and 400 K across two densities
System 362 methane molecules in the NVT ensemble
Force field TraPPE methane · σ = 3.73 Å · ε/kB = 148 K
State points 200, 300 and 400 K at two densities
Simulation method

From random moves to thermodynamic averages

Each cycle proposes one molecular translation, evaluates its energy change and accepts or rejects it using the Metropolis criterion.

01

Initialize

Generate a cubic periodic box from molecule count, density and methane molar mass.

02

Propose

Select one molecule and apply a uniformly distributed three-dimensional displacement.

03

Accept

Keep energy-lowering moves and probabilistically accept unfavourable moves.

04

Sample

Record virial pressure and total energy after decorrelated move intervals.

Lennard-Jones potential
Metropolis acceptance
Move tuning

One algorithm, different phase behaviour

Dense liquid configurations require short trial moves, while the dilute gas remains highly accepting even for much larger moves.

Liquid δ = 0.670 Å 358.4 kg/m³ · rcut = 14 Å
Gas δ = 100 Å 1.6 kg/m³ · rcut = 50 Å
Production length 500,000 moves Per tuning and production study
Statistical sampling

Equilibrated and decorrelated observables

Pressure and energy were sampled only after equilibration, with spacing and block averaging chosen from correlation behaviour.

Liquid methane pressure and energy equilibration with running averages
Running averages stabilise as the liquid simulation approaches equilibrium.
Equilibration 18,100 trial moves

Each production run begins after 50 moves per molecule.

Liquid sampling nSpacing = 1,549

Remaining dependence is handled with block averaging using blocks of ten samples.

Gas sampling nSpacing = 610

Pressure and energy correlations fall below 0.05 at the selected spacing.

Gas methane pressure and energy correlation and sample-count study
The first gas spacing satisfying the correlation threshold was selected for production sampling.
Pressure-temperature response

Six state points, two methane phases

Virial pressure, ideal-gas contribution and analytic tail corrections were evaluated at 200, 300 and 400 K.

Monte Carlo and equation-of-state pressure-temperature curves for liquid and gas methane
Monte Carlo pressure compared with CoolProp equation-of-state values at both densities.
200 K 441.58 bar Liquid · ±16.34 bar

Gas · 1.6430 ± 0.0019 bar

300 K 1,220.16 bar Liquid · ±20.99 bar

Gas · 2.4787 ± 0.0023 bar

400 K 1,918.27 bar Liquid · ±31.94 bar

Gas · 3.3121 ± 0.0025 bar

Engineering outcome

A reusable solver for molecular thermodynamics

The project produced a complete NVT Monte Carlo workflow from trial-move mechanics to uncertainty-aware pressure results.

It combined periodic molecular interactions, analytic tail corrections, virial pressure, equilibration checks, correlation analysis and block averaging in one reproducible model.

  • Metropolis algorithm
  • Virial pressure
  • Correlation analysis
  • Equation-of-state comparison