This is a web app that simulates the fluid flow around a falling sphere, taking into account the dynamic effects of fluid viscosity, sphere radius and density, along with static parameters such as gravity, buoyancy and drag.
The simulation measures the time taken for the sphere to travel 15cm at terminal velocity. It is meant as a lab auxiliary for the Chemical Engineering course at the University of Birmingham.
The simulation parameters can be changed from the menus at the top of the screen. The time can be altered from real time to 4 times slower or 4 times faster. The viscosity is measured in centistokes (cSt).
Any sphere can be selected by clicking on it. The radius is provided in imperial measurements, like the laboratory resources.
At the bottom of the screen is the table for physical, dynamic parameters. On the right is the data log that outputs the measurements.
The Jacobi iterations parameter represents the number of calculations for the fluid movement. A higher number of iterations provides higher fidelity in the fluid flow, but requires more power from the GPU.
More in-depth information is given in the next section.
The graphical fluid flow is modelled using the Navier-Stokes equations: $$\frac{\partial \vec{u}}{\partial t} = -\vec{u} \cdot \nabla \vec{u} - \frac{1}{\rho}\nabla \rho + \nu \nabla^2\vec{u} + \vec{F}$$ $$\nabla \cdot \vec{u} = 0$$ However, for purely graphical purposes, leaving the viscosity term out provides a very good trade-off in terms of computational efficiency and graphical fidelity. The equations are solved numerically for pressure using Jacobi iterations.
The graphical sphere movement is modelled using gravitational acceleration, drag force and buoyancy. The sphere moves in discrete time-steps of around 0.065ms. Therefore, at terminal velocity, the following is true: $$ m g = C_d A \frac {\rho u^2}{2} + \rho V g $$ The drag coefficient Cd is defined in terms of the Reynolds Number: $$ Re = \frac {\rho u d}{\mu} $$
The simulation screen is comprised of two superimposed HTML canvases:
The programming technicalities can be accessed in the well-commented javascript file fluid-sim.js. I have written it to be as modular and intuitive as possible. It is available in this website's sources in the developer menu, as well as on my github account
To make this, I had to draw from many different sources. The main ones are:
Acceleration (m / s2) | Velocity (m / s) | Position (m) | ||||
- | ||||||
x | y | x | y | x | y | |
accx | accy | velx | vely | posx | posy | |
Export to CSV |
Clear Log |