Behind the simulation
The math
Why does a solar flare go off?
Surface flows twist the magnetic field above a spot group, storing energy like a wound spring. Past a threshold it snaps to a simpler shape and dumps the excess into the plasma as heat.
q = twist² + shear² + stress,flare at q > 0.8In the sim Each loop tracks its own q (loops.ts). A flare spends a share x of it, drawn from p(x) ∝ x⁻¹·⁸: mostly small flares, a few huge ones.
Why does flare plasma flash, then fade over minutes?
Heat races down the loop to the chromosphere, which boils up into it. The loop gets hot and dense, then radiates that energy away and drains.
dp/dt = ⅔ [ Q − (1 + c₁) n² Λ(T) ]In the sim Every loop is one EBTEL cell (Klimchuk 2008, plasma.ts). Its temperature and density set how bright it is in each AIA channel, through that channel's temperature response.
Why are sunspots dark?
A spot's 3,000 G field chokes the convection that carries heat up, so the surface there is about 2,000 K cooler. Planck's law turns that into a much dimmer patch.
I_spot / I = B_λ(T − ΔT) / B_λ(T)≈ 0.12 – 0.35 at 617 nmIn the sim Small umbrae sit at 35 % and big ones at 12 %, as SOHO/MDI measures (stars.ts). On a red dwarf ΔT is a few hundred K, so its spots are pale.
Why do sunspots march toward the equator?
Each 11-year cycle starts its spots near 28° latitude, and they emerge closer to the equator as it ages. Plotted over time, that's the butterfly diagram.
λ(t) = 28° · e^(−t / 0.68 P),tilt ≈ ½ λIn the sim New regions are born at λ(t), as often as Hathaway's cycle curve says (field.ts), tipped by Joy's law ±15°. Each cycle's tail overlaps the next.
Why does the Sun wind up its own field?
The Sun isn't solid. Its equator turns in 25 days and its poles in about 35, so field lines anchored across latitudes get stretched around the star.
Ω(φ) = 14.71 − 2.40 sin²φ − 1.79 sin⁴φ°/dayIn the sim Every spot and loop footpoint drifts at Ω for its latitude (Snodgrass's fit, field.ts). The shear is scaled for each star, so red dwarfs turn almost as solid bodies.
How does the corona store twist between flares?
The coronal field is pushed along its own magnetic force and slides toward a relaxed, force-free state. The surface keeps feeding it twist, so it never quite gets there.
∂A/∂t = v × B − ηJ,v = J × B / ν(B² + b₀²)In the sim A magnetofrictional grid runs on the GPU out to 2.5 star radii (frictional.ts). The energy it holds above the untwisted field is what the flares spend.
What slows a coronal mass ejection?
The solar wind. A CME faster than the wind around it is braked, and a slow one is towed, like a boat in a current.
dv/dt = −γ (v − w) |v − w|(+ gravity, magnetic push)In the sim Each CME integrates this against the local Parker wind (Vršnak 2013, cmes.ts), which is 750 km/s over coronal holes. A shock rides ahead of the fast ones.
Why can a coronagraph see the corona at all?
Free electrons scatter sunlight toward you. The corona is a million times fainter than the disc, so the disc is blocked out to see it.
I ∝ ∫ nₑ(r) · G(r, χ) ds(Thomson scattering)In the sim Each pixel sums electrons along its line of sight, with van de Hulst's weights for the limb-darkened Sun (shaders/cme.ts). CMEs show up as bright loops.
Coding decisions
Why WebGPU?
The surface flow, the field-line tracing and the twisted corona are compute work, thousands of small jobs every frame. WebGPU has compute shaders; WebGL2 doesn't.
const gpu = await startGpu(canvas);if (typeof gpu === 'string') await loadFallback();Trade-off Browsers without WebGPU get a lighter WebGL2 version: the same star and views, but no flowing surface, flares or CMEs. Its 38 KB only downloads when it's needed.
Why does the CPU keep the clocks?
GPU shaders work in 32-bit floats, which run out of precision as time grows: after an hour, orbits and rotations start to judder. The CPU wraps every phase in 64-bit first.
phase = (Ω · t) % (2π)// f64 on the CPU, f32 on the GPUTrade-off Every time-driven value goes through clock.ts, so a new effect has to be wired there too rather than reading the time in a shader.
Why doesn't a frame ever wait for the GPU?
Reading GPU results straight back stalls everything until the GPU catches up. The flow probes that heat the loops are read through a ring of buffers instead.
buffer.mapAsync(MAP_MODE.READ).then(read)Trade-off Those readings arrive a frame or two late. A loop heats a few hundredths of a second after the flow under it moves, which nobody can see.
How does it stay smooth on a weak GPU?
A 10 ms benchmark at start-up picks a quality tier: how many field lines and how fine a grid. Then the resolution follows the GPU's own frame time.
if (frameMs > budget × 1.15)scale −= 0.125Trade-off Each resolution step rebuilds the render targets, so steps are coarse and at most one every 0.6 s.
Why fade detail you can't see?
Surface noise finer than a few pixels doesn't add detail, it shimmers. Each octave fades to its average once its wavelength is under 3 pixels and is skipped under 1.5.
lod = smoothstep(1.5, 3, pxPerR · 2.94 / freq)Trade-off A small or foreshortened star does less work, but the fade distance is tuned by eye, not derived.
Why write GPU flags as numbers?
Browsers without WebGPU have no GPUBufferUsage at all, so code that read it at load crashed before the fallback could start. The spec's values are now plain numbers.
export const BUFFER = { MAP_READ: 0x1, COPY_SRC: 0x4, COPY_DST: 0x8, … }Trade-off The numbers are copied from the spec, so the type check guards against reintroducing the globals.
Fun facts
How old is the sunlight you see?
Light leaves the surface and reaches Earth in 8 minutes 20 seconds. But the energy it carries spent tens of thousands of years or more bouncing its way out from the core.
Why is the corona hotter than the surface?
The surface is about 5,800 K; the corona above it is 1–3 million K. Magnetic energy is the leading explanation, but how it's dumped as heat is still an open question.
On this page The twisted field the page simulates is one of those energy stores.
Is a sunspot actually dark?
Only next to the rest of the Sun. A big spot's umbra is still around 4,000 K, and on its own it would shine far brighter than the full Moon.
Does the Sun's magnetic field flip?
Yes, every 11 years or so, near solar maximum. So the full magnetic cycle, back to where it started, takes about 22 years.
On this page Leave the speed on 1 week/s and you can watch the cycle turn over.
How much does the Sun lose to the solar wind?
About 1.5 million tonnes every second. It sounds like a lot, but over the Sun's whole life so far it adds up to well under a thousandth of its mass.
What did the biggest storm on record do?
In 1859 the Carrington event lit auroras as far south as the Caribbean and made telegraph lines spark. A storm that size today would hit power grids and satellites.
Can a tiny star outflare the Sun?
Proxima Centauri, 7 times smaller than the Sun, brightened about 14,000 times in ultraviolet in seconds during a 2019 flare. Red dwarfs are small but magnetically fierce.
On this page Pick Proxima to see its big pale spots and frequent flares.
How small can a star be?
TRAPPIST-1 is barely bigger than Jupiter, at 12 % of the Sun's width, yet seven Earth-sized planets orbit it, three of them in the zone where water could stay liquid.