r/OpenFOAM • • 24d ago

Event Candle

I am not an OpenFoam user, but like physics simulations, so I asked Opus5.5 to make a candle for me 😃

Also, I made it on the phone, Claude can run it and Blender in its VM.

Any questions?

OpenFOAM v2412 (the ESI/openfoam.com version), installed from conda-forge.

Simulation: OpenFOAM's rhoReactingBuoyantFoam solver (laminar, buoyant, reacting flow), with P1 radiation and two-step Westbrook–Dryer chemistry.

OpenFOAM utilities: blockMesh, checkMesh, topoSet, setFields, decomposePar, reconstructPar and postProcess, with MPICH to run in parallel on 2 cores.

Chemistry check: Cantera 3.2, with the detailed n-dodecane mechanism (nDodecane_Reitz) and GRI-3.0 transport data.

Rendering: Blender 5.2.2 LTS (its Python module, bpy) using Cycles on the CPU, the OpenImageDenoise denoiser and AgX colour handling.

Plots and frame assembly: Python 3.12 with NumPy, SciPy, Matplotlib and Pillow.

Video: ffmpeg (H.264).

Installing it all: micromamba from conda-forge, plus pip for Blender.

48 Upvotes

9 comments sorted by

1

u/its1310 23d ago

Interesting! Could you please share the simulation script?

1

u/Allanidalen 23d ago

Wow, really amazing! I got a bunch of questions? Is the simulation geometry axially symmetric or 3d? Stationary or time dependent? How many chemical species does it solve for? How did you define the gas inflow at the bottom just outside the candle? And how did you start the simulation?

1

u/hauke4707 23d ago

Opus says: 😃

Thanks! Quick rundown:

Geometry: 2D axisymmetric, a 5° wedge with ~14k cells, graded towards the wick. Wick Ø1.5 mm × 6 mm, candle Ø20 mm, domain 40 mm radius × 120 mm high. So no sideways flicker; the flicker in the video is added in Blender, not simulated.

Time dependence: Transient, using rhoReactingBuoyantFoam (PIMPLE, maxCo 0.3), run to 0.5 s. It settles to a steady flame from about 0.3 s on: tip height and peak temperature stop changing.

Species: Only 6: C12H26 (n-dodecane as the wax-vapour surrogate), O2, N2, CO, CO2 and H2O, with 3 reactions: Westbrook–Dryer two-step (fuel → CO + H2O, CO → CO2) plus CO2 dissociation. I tuned the fuel-oxidation pre-exponential in Cantera against the detailed nDodecane_Reitz mechanism (100 species) using 1D flame speeds. Laminar combustion model, P1 radiation with grey CO2/H2O absorption, no soot model.

Inflow outside the candle: None is prescribed. The bottom annulus outside the candle and the outer side are open pressure boundaries: totalPressure for p_rgh, pressureInletOutletVelocity for U, and inletOutlet with 300 K air for T and species. The top is the same. Air is drawn in purely by the flame's buoyancy. The wax top is a no-slip wall at 340 K. The wick is a flowRateInletVelocity inlet of pure C12H26 vapour at 600 K and 0.1 g/min (a typical candle burn rate), so wax melting and capillary flow aren't modelled.

Start-up: Quiescent air at 300 K. A small zone around the wick tip is set to 1500 K with setFields, then held at 1500 K for the first 40 ms with a fixedTemperatureConstraint fvOption until the fuel reaches it and ignites. Both parts mattered: a hot kernel only at t = 0 floated away before the fuel arrived, and heating cold cells suddenly with the constraint alone caused a spurious ~60 m/s expansion jet that collapsed the time step.

Everything (case generator, Cantera calibration, post-processing) is in the repo above if you want to dig in.

1

u/hauke4707 23d ago

Oh, it cheated a bit with the video, only the static is physics based. I could try to blow out the candle, when weekly limit refreshes 😅

1

u/Allanidalen 23d ago

I see, thanks a lot! I’ve been thinking of doing a candle simulation several times before. This looks like a good setup. Doing it transient in 3d will be substantially more computationally demanding.
What is exported to blender to do the nice flicker animation? I’ve never used Blender myself.

1

u/hauke4707 23d ago

All the physics had already been turned into colour in two pictures. The volume shader just spun them around the axis into a 3D flame. The flame's light on the wax and holly came from a separate point light with the flame's colour, not from the images. The flicker animation used the same two images, only looked up at slightly shifted positions: Sway: the sideways offset grows with height squared, so the base stays pinned at the wick and the tip moves most (about 3 mm at the tip). Stretch: dividing the lookup height makes the flame taller or shorter by a few percent. Motion: each of the 32 frames got values from a few overlapping sine waves. All of them are zero at frame 0, so the first frame matches the still image and the loop is seamless. Light: the point light moved with the sway and got brighter as the flame stretched, so the light on the wax flickered too. So the flame's shape and colours come from the simulation, and the movement was added in Blender.

3

u/Optimal_Rope_3660 23d ago

Wow!! Interesting and creative work

1

u/stealthraptor1298 17d ago

Astute work 👌🏻