Blog

A blog of Python-related topics and code.

A simple two-dimensional Brownian motion animation

This code continues the previous blog post on two-dimensional collisions to model Brownian motion. The code is on my GitHub page.

Two-dimensional collisions

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 circle with a fixed radius which undergoes elastic collisions with other particles.

Packing circles inside a shape

A previous blog post dealt with packing circles into a circle. To fill an arbitrary shape, a slightly different approach is needed. The code presented in my github repo.

Packing circles in a circle

The following code attempts to pack a predefined number of smaller circles (of random radii between two given limits) into a larger one.

The Morse oscillator

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 internuclear separation from equilibrium, $x = r - r_\mathrm{e}$ as: $$ V(x) = D_\mathrm{e}\left[ 1-e^{-ax} \right]^2, $$ where $D_\mathrm{e}$ is the dissociation energy, $a = \sqrt{k_\mathrm{r}/2D_\mathrm{e}}$, and $k_\mathrm{e} = (\mathrm{d}^2V/\mathrm{d}x^2)_\mathrm{e}$ is the bond force constant at the bottom of the potential well.