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 GitHub page ‘https://github.com/xnx/collision’.

The core classes, PeriodicParticle and PeriodicSimulation are derived from the original Particle and Simulation classes to allow periodic boundary conditions: instead of bouncing off the walls, the particles move through them and reappear at the other side of the domain.

In the example given here, the mass of the large particle is set to be equal to that of the small ones, so that it gains enough momentum quickly to be seen to move in the animation. This can be altered by setting the mass property of the PeriodicParticle class.

A simple two-dimensional Brownian motion animation_第1张图片

你可能感兴趣的:(Python语言专栏,Brownian,Python,2维)