Simulating fluid dripping on a chain

This is some little afternoon project I did today. It’s basically a chain moved by a rotating cylinder. The simulation really respects friction, forces and is pretty close to reality except that the “fluid” is not really fluid but are really really small particles. Everything’s written in Java using JBox2D and Processing (by utilising the testbed, actually modifying the chain example). What’s cool is that basically every parameter can be set. Those parameters are:

  • chain ball radius The radius of an element within the chain. This influences the speed of which a ball becomes fully colored.
  • amount of chain balls The amount of balls on the chain (this can be set to close or wide, which may cause the simulation to be unrealistic
  • bearing radius The size of the bearings
  • bearing distance The distance of both bearings. Together with amount of chain balls this modifies the distance between the balls
  • motor speed The speed of the motor. Basically one could also modify the motors tourge, but it’s set to 10kNm per default so that it doesn’t matter
  • injected particles per second
  • particle size This radius directly changes the speed in which the chain balls become “colored”. Actually the percentage (ranged from 0..1) is calculated using the following equation

        \[\frac{2}{4\pi\cdot r^2} \cdot \vert P_{recv}\vert \cdot \mbox{size}(p)\]



    is the radius of this chain ball,


    is the set of received particles for this chain ball and


    is the particle radius

  • particle velocity The norm of the velocity the injector produces. The velocity is then

        \[v\cdot \begin{pmatrix}0\\-1\end{pmatrix}\]

This was a nice little project and I’m looking forward to play around with this stuff a little more (once I’ve finished playing around with my graph theory studies). Below is a video of the simulation with the following values set:

Parameter Value
chain ball radius 0.5 cm
amount of chain balls 50
bearing radius 5.5 cm
bearing distance 20 cm
motor speed 1.5 cm/s
injected particles per second 50 particles/s
particle size 0.01 cm
particle velocity 1 cm/s

Fork me on GitHub