For my graduate graphics final project, I worked in a group of four to simulate the mesmerizing motion of a lava lamp using a method outlined in the paper Particle-Based Fluid-Fluid Interaction by Müller et al. The fluid simulation is based on Smoothed Particle Hydrodynamics (SPH) and enables the mutual interaction of different types of fluids.



Theory
Fluid simulation typically follows one of two paradigms: grid-based or particle-based.
- Grid-based methods divide space into small cells and compute whether each cell contains fluid at a given moment.
- Particle-based methods represent the fluid as discrete particles and track their positions over time.

Our implementation follows the particle-based paradigm. In SPH, each particle carries properties including position, velocity, density, and pressure. Simulation proceeds in the following loop:
- Internal forces (e.g., surface tension) are computed based on neighboring particles.
- Velocity and position are updated via numerical integration.
- Field functions are defined to estimate continuous properties (e.g., pressure at a point) based on nearby particles.
- These functions are used to update particle properties at their new positions.
External forces such as gravity and boundary collisions are also incorporated each step. This iterative process simulates fluid motion over time.
To model a lava lamp, we account for several additional effects:
- Buoyancy: Particles with lower density are pushed upward when surrounded by denser fluid, enabling hot wax to float.
- Immiscibility: The wax and liquid remain separate because particles of different fluids don’t mix.
- Temperature diffusion: Heating reduces a particle’s density, helping it rise; as it cools, it regains density and sinks.
These behaviors collectively produce the characteristic lava lamp cycle.
Implementation
The simulation was implemented in C++ using:
- Eigen for linear algebra
- Qt for the GUI
- OpenGL for real-time particle visualization during development

To render high-quality output, we exported particle data as Alembic files, which were then imported into Blender. Inside Blender:
- Geometry nodes mapped each particle to a sphere mesh.
- Remeshing created smooth fluid surfaces.
- Emissive, translucent materials were applied to simulate the wax and liquid.