Lava Lamp Model
Model
Overview
This project does not solve full fluid dynamics. The lava motion is modeled as a small set of blobs moving inside a bounded lamp volume under a simplified, physics-inspired update rule.
Each blob carries:
- position:
- velocity:
- temperature:
- mass:
The simulator then:
- updates blob temperatures
- computes forces on each blob
- integrates velocity and position with a fixed timestep
- rebuilds a scalar field for rendering
The main implementation files are:
PhysicsSimulator.tsphysicsSimulatorTimeStep.tsLavaLampRenderer.tslampRenderer.ts
State
For blob i, the state is:
The mean temperature is:
The normalized height of a blob inside the lamp bounds is:
Temperature Evolution
The temperature model is:
with:
Global Heating
where G = globalHeating.
Bottom Heating Bias
where B = bottomHeatingBias.
Top Cooling Bias
where:
h_cool = topCoolingThresholdC_t = topCoolingBias
Cooling Toward Ambient
where:
C = coolingRateT_a = ambientTemperature
Diffusion Toward Mean Temperature
where D = diffusionRate.
Stochastic Thermal Forcing
The stochastic term is deterministic per blob id but time-varying:
where:
A = stochasticAmplitudeS(i,t)is a weighted trigonometric mixture
The code uses:
where:
omega = stochasticFrequencyphi_iis a stable phase derived from the blob idP(i,t)is a plateau-shaped version of the primary sine wave
The explicit timestep update is:
This is implemented in updateBlobTemperature(...) in physicsSimulatorTimeStep.ts.
Forces
The total force on a blob is:
Buoyancy
Buoyancy is driven by temperature difference from ambient:
where:
beta = buoyancyBetag = gravity
Gravity
Drag
where c_d = dragCoefficient.
Boundary Force
Near the lamp wall, the model applies a spring-like restoring force plus damping:
where:
k = stiffnessc_b = dampingpis penetration into the boundary marginv_perpis the outward velocity component
This is applied axis-by-axis in computeBoundaryForce(...).
Motion Integration
Acceleration:
Velocity update:
Position update:
Then the blob is clamped back into the valid bounds:
and outward velocity is zeroed on collision.
This logic is implemented by advanceBlobs(...) in physicsSimulatorTimeStep.ts.
Time Stepping
The simulator uses a fixed timestep:
Real frame time is accumulated, and multiple internal substeps may run before rendering. This is handled in step(...) in PhysicsSimulator.ts.
Scalar Field for Rendering
The blobs are not the final visible lava surface. Instead they generate a scalar field:
where:
s_iis blob strengthr_iis blob influence radiusphiis the radial contribution kernel- some blobs are free interior blobs and some are anchored cap blobs that keep small persistent masses at the top and bottom extremes
That field is rebuilt in rebuildFieldSnapshot() and later rendered as a liquid surface.
Runtime Controls
The exposed controls do not change the structure of the model. They rescale parts of it:
temperaturescales global heating, bottom heating, top cooling, and stochastic amplitudebuoyancyscales buoyancy and slightly rebalances gravitydampingscales drag and boundary dampingdiffusionscales thermal diffusion and field softness
These mappings are implemented in setParameter(...) in PhysicsSimulator.ts.
Interpretation
The current simulation is best described as:
- a bounded particle system
- with temperature-driven buoyancy
- gravity
- linear drag
- soft wall response
- deterministic stochastic thermal forcing
It is intentionally a simplified, controllable demo model rather than a full physical fluid solver.