Solar Corona & Flare Prominence
Astrophysical simulation of the Sun's dynamic outer atmosphere. Models magnetic dipole coronal loops, convective thermonuclear core granulation, high-energy plasma prominences, and radial solar wind streamer rays.
60 FPS • Canvas 2D
Click + Drag to interact with field
</>
Full Executable Algorithm Code
139 lines
5716 chars
// 082 - Solar Corona & Flare Prominence (physics)
// 1:1 Original algorithm engine source
function createSolarCoronaFlare() {
const PROMINENCE_LOOPS = 28;
const loopPhases = [];
function initLoops() {
loopPhases.length = 0;
for (let i = 0; i < PROMINENCE_LOOPS; i++) {
loopPhases.push({
angle: (i / PROMINENCE_LOOPS) * Math.PI * 2 + (Math.random() - 0.5) * 0.2,
span: 0.15 + Math.random() * 0.35,
height: 25 + Math.random() * 65,
speed: 0.4 + Math.random() * 0.8,
phase: Math.random() * Math.PI * 2,
});
}
}
return {
setup() {
initLoops();
},
render(context, timeState, params) {
const { ctx, width, height } = context;
const speed = Number(params.speed ?? 1.0);
const solarActivity = Number(params.solarActivity ?? 1.2);
const loopDensity = Number(params.loopDensity ?? 1.0);
const coronaRadiusParam = Number(params.coronaRadius ?? 1.0);
const flareIntensity = Number(params.flareIntensity ?? 1.3);
const t = timeState.time * speed;
if (loopPhases.length === 0) initLoops();
const cx = width * 0.5;
const cy = height * 0.5;
const baseR = Math.min(width, height) * 0.19 * coronaRadiusParam;
ctx.fillStyle = '#050407';
ctx.fillRect(0, 0, width, height);
// Extended Outer Solar Corona Streamers
ctx.save();
ctx.globalCompositeOperation = 'screen';
const STREAMER_RAYS = 64;
const maxStreamerLen = Math.min(width, height) * 0.48;
for (let i = 0; i < STREAMER_RAYS; i++) {
const theta = (i / STREAMER_RAYS) * Math.PI * 2;
const rayAngle = theta + Math.sin(theta * 6.0 + t * 1.5) * 0.08 + Math.cos(theta * 14.0 - t * 2.2) * 0.04;
const pulse = 0.6 + 0.4 * Math.sin(i * 3.1 + t * 2.5 * solarActivity);
const rayLen = baseR + (maxStreamerLen - baseR) * (0.6 + 0.4 * Math.sin(theta * 3 + t));
const alpha = Math.min(0.55, 0.28 * pulse * flareIntensity);
const streamerGrad = ctx.createRadialGradient(cx, cy, baseR * 0.8, cx, cy, rayLen);
streamerGrad.addColorStop(0, `rgba(255, 235, 160, ${alpha * 1.3})`);
streamerGrad.addColorStop(0.25, `rgba(255, 140, 40, ${alpha})`);
streamerGrad.addColorStop(0.65, `rgba(210, 50, 15, ${alpha * 0.35})`);
streamerGrad.addColorStop(1.0, 'rgba(80, 10, 5, 0)');
ctx.beginPath();
ctx.moveTo(cx + Math.cos(rayAngle - 0.045) * baseR, cy + Math.sin(rayAngle - 0.045) * baseR);
ctx.lineTo(cx + Math.cos(rayAngle) * rayLen, cy + Math.sin(rayAngle) * rayLen);
ctx.lineTo(cx + Math.cos(rayAngle + 0.045) * baseR, cy + Math.sin(rayAngle + 0.045) * baseR);
ctx.closePath();
ctx.fillStyle = streamerGrad;
ctx.fill();
}
ctx.restore();
// Magnetic Coronal Plasma Loops
ctx.save();
ctx.globalCompositeOperation = 'screen';
const activeLoops = Math.floor(PROMINENCE_LOOPS * loopDensity);
for (let l = 0; l < activeLoops; l++) {
const loop = loopPhases[l];
const a1 = loop.angle - loop.span * 0.5;
const a2 = loop.angle + loop.span * 0.5;
const loopHeightDynamic = loop.height * (0.75 + 0.25 * Math.sin(t * loop.speed + loop.phase)) * solarActivity;
const p1x = cx + Math.cos(a1) * baseR;
const p1y = cy + Math.sin(a1) * baseR;
const p2x = cx + Math.cos(a2) * baseR;
const p2y = cy + Math.sin(a2) * baseR;
const apexR = baseR + loopHeightDynamic;
const cpx = cx + Math.cos(loop.angle) * (apexR * 1.25);
const cpy = cy + Math.sin(loop.angle) * (apexR * 1.25);
ctx.beginPath();
ctx.moveTo(p1x, p1y);
ctx.quadraticCurveTo(cpx, cpy, p2x, p2y);
ctx.strokeStyle = `hsla(${20 + Math.sin(t + l) * 15}, 95%, 60%, 0.75)`;
ctx.lineWidth = 1.8;
ctx.stroke();
}
ctx.restore();
// Photosphere Core
ctx.save();
const coreGrad = ctx.createRadialGradient(cx, cy, 0, cx, cy, baseR * 1.3);
coreGrad.addColorStop(0, '#ffffff');
coreGrad.addColorStop(0.35, '#fff0a0');
coreGrad.addColorStop(0.7, '#ff8010');
coreGrad.addColorStop(1.0, 'rgba(200, 30, 0, 0)');
ctx.fillStyle = coreGrad;
ctx.beginPath();
ctx.arc(cx, cy, baseR * 1.3, 0, Math.PI * 2);
ctx.fill();
ctx.restore();
}
};
}
const defaultParams = [
{ key: "speed", label: "Solar Dynamic Cadence", type: "range", min: 0.2, max: 2.5, step: 0.1, defaultValue: 1.0 },
{ key: "solarActivity", label: "MHD Prominence Activity", type: "range", min: 0.4, max: 2.2, step: 0.1, defaultValue: 1.2 },
{ key: "loopDensity", label: "Magnetic Arc Loop Count", type: "range", min: 0.3, max: 1.8, step: 0.1, defaultValue: 1.0 },
{ key: "coronaRadius", label: "Photosphere Core Scale", type: "range", min: 0.6, max: 1.5, step: 0.05, defaultValue: 1.0 },
{ key: "flareIntensity", label: "Streamer Glow Luminance", type: "range", min: 0.5, max: 2.5, step: 0.1, defaultValue: 1.3 }
];
if (!window.__art_instances) window.__art_instances = {};
if (!window.__art_instances['solar-corona-flare']) {
const inst = typeof createSolarCoronaFlare === 'function' ? createSolarCoronaFlare() : null;
if (inst && inst.setup) {
inst.setup({ ctx, width, height, dpr: 1, aspectRatio: width / height }, defaultParams);
}
window.__art_instances['solar-corona-flare'] = inst;
}
const instance = window.__art_instances['solar-corona-flare'];
if (instance && instance.render) {
instance.render(
{ ctx, width, height, dpr: 1, aspectRatio: width / height },
{ time, deltaTime: dt, frameCount: Math.floor(time * 60), fps: 60 },
defaultParams
);
} Edit in Interactive Playground
Zero Dependencies • Standalone Canvas 2D
ƒ
Mathematical Formulation
high
Analytical Equation
∇×B=μ0J,ρ(∂t∂v+v⋅∇v)=−∇p+J×B+ρg
Click to expand
∑
Solar Corona & Flare Prominence
Full Mathematical System • physics
100%
Complete System of Equations
[Governing Law][Discrete Progression]thetarhat+sinthetathetahat),Icorona(r)∝r(−2.5)⋅pulse(t)[Domain & Space][Parameter State]∇×B=μ0J,ρ(∂t∂v+v⋅∇v)=−∇p+J×B+ρgBdipole=μ0m/(4πr3)⋅(2cosx∈R2,t∈R+,ω∈[0,2π]λsolarActivity=1.2(Solar Flare Cycle),λloopDensity=1(Coronal Loops),λcoronaRadius=1(Photosphere Scale),λflareIntensity=1.3(Corona Streamers)
∇×B=μ0J,ρ(∂t∂v+v⋅∇v)=−∇p+J×B+ρg
Computational Implementation (JavaScript Engine Equivalent)
B_dipole = μ_0 m / (4π r³) · (2 cos θ r_hat + sin θ θ_hat), I_corona(r) ∝ r^(-2.5) · pulse(t) Compact Formula
B_dipole = μ_0 m / (4π r³) · (2 cos θ r_hat + sin θ θ_hat), I_corona(r) ∝ r^(-2.5) · pulse(t) Mathematical Tags
#astrophysics
#solar-flare
#corona
#plasma
#sunrays
#magnetic-loops
#space-physics
#solar-physics
Author: Solar Astrophysical Observatory Target: 60 FPS
Press ESC or F to exit