Skip to content

FYS2160 · statistical physics in Python

A small engine. Physics you can see.

Build a system, let it evolve, and connect particle motion to temperature, pressure and heat capacity. A native C solver does the numerical work; a few Python lines define the experiment.

Install & run Explore a recorded notebook

Three steps to an experiment

from fys2160_md import FCC, MDSimulation

system = FCC(N=500, rho=0.1)
sim = MDSimulation(
    pair_potential="lj",
    epsilon=1,
    sigma=1,
    ensemble="nvt",
    temperature=2,
    timestep=0.005,
    cutoff=2.5,
)
result = sim.run(
    system,
    steps=10_000,
    thermo_every=100,
    trajectory_every=500,
    storage_name="gas",
)
result.view()

System holds the box and atoms: the state. MDSimulation(...) holds the interactions and controls; sim.run(state, ...) evolves a copy of the state, and run.state continues from where it ended. Run reads, plots and replays the recorded result—even in a later Python session.

  • Choose the geometry

    A periodic FCC crystal or self-avoiding random positions. Set density or box size.

    Build a system →

  • Ask a physics question

    Measure pressure, heat a gas, compare molecular degrees of freedom.

    Worked examples →

  • Watch a saved run

    Play, rotate, pan and zoom recorded particle trajectories. No Python kernel needed.

    Executed notebook →

  • Find an argument

    Defaults, units, saved quantities and the full public interface in one place.

    API reference →

Designed for the course

  • Atomic Lennard–Jones and flexible or rigid diatomic models.
  • Periodic 3D dynamics, thermostat and atomic pressure control.
  • Explicit heating for simple heat-capacity measurements.
  • Live notebook views and portable saved trajectories.

All numbers use LJ reduced reference units: σ_ref = ε_ref = mass_ref = kB = 1. Species may have different masses and interaction parameters in those shared units. The examples use ordinary NumPy, pandas and pyplot. Read the physics notes for the model conventions and limits.