This script demonstrates the relaxation of an ensemble of colliding particles towards the equilibrium, Maxwell-Boltzmann distribution of their speeds. Unlike this previous post, the collision detection and dynamics are handled using NumPy arrays without explicit python loops (except over collision pairs), which improves the performance …
Note: This post has been updated to use the new scipy.special.sph_harm_y function, which has a slightly different call signature to the deprecated scipy.special.sph_harm function (to be removed in SciPy version 1.17.0.) The spherical harmonics are a set of special functions defined on the surface of …
Following on from this post about the simple double pendulum, (two bobs connected by light, rigid rods), this post animates the double compound pendulum (also called a double complex or physical pendulum): two rods connected to each other, with their mass distributed along their length. …
The magnetic field due to a magnetic dipole moment, at a point relative to it may be written where is the vacuum permeability. In geomagnetism, it is usual to write the radial and angular components of as: where is polar (colatitude) angle (relative to the …
This code continues the previous blog post on two-dimensional collisions to model Brownian motion. The code is on my GitHub page. The core classes, PeriodicParticle and PeriodicSimulation are derived from the original Particle and Simulation classes to allow periodic boundary conditions: instead of bouncing off …
This small Python project is a physical simulation of two-dimensional physics. The animation is carried out using Matplotlib's FuncAnimation method and is implemented by the class Simulation. Each "particle" of the simulation is represented by an instance of the Particle class and depicted as a …
The Morse oscillator is a model for a vibrating diatomic molecule that improves on the simple harmonic oscillator model in that the vibrational levels converge with increasing energy and that at some finite energy the molecule dissociates. The potential energy varies with displacement of the …
The harmonic oscillator is often used as an approximate model for the behaviour of some quantum systems, for example the vibrations of a diatomic molecule. The Schrödinger equation for a particle of mass moving in one dimension in a potential is With the change of …
The following code simulates (very approximately) the growth of a polycrystal from a number of seeds. Atoms are added to the crystal lattice of each of the resulting grains until no more will fit, creating realistic-looking boundaries where two grains meet. Two sorts of lattice …
The most feasible nuclear reaction for a "first-generation" fusion reaction is the one involving deuterium (D) and tritium (T): Tritium is not a primary fuel and does not exist in significant quantities naturally since it decays with a half life of 12.3 years. It therefore …