Spaces:
Running
Running
Demo v2: real 3-branch Maxwell viscoelasticity per edge, twin-history demo, shape-only surrogate toggle with live Pearson r
af3c355 verified Download index.html from zanesmit29/leia-explainer: direct link, hf CLI and curl.
- Browser
- Download file 36.4 kB
-
https://huggingface.co/spaces/zanesmit29/leia-explainer/resolve/main/index.html
- Command line
-
hf download hf://spaces/zanesmit29/leia-explainer/index.html
-
curl -L -o index.html https://huggingface.co/spaces/zanesmit29/leia-explainer/resolve/main/index.html
36.4 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>LEIA, explained — a world model for materials</title> | |
| <style> | |
| :root{ | |
| --ink:#1a2332; --muted:#5b6b7f; --bg:#f7f9fc; --card:#ffffff; --line:#e3e9f1; | |
| --accent:#c2410c; --accent2:#1d4ed8; --good:#15803d; --bad:#b91c1c; | |
| --chip:#eef2f7; | |
| } | |
| *{box-sizing:border-box} | |
| body{margin:0;font:16px/1.6 Georgia,'Times New Roman',serif;color:var(--ink);background:var(--bg)} | |
| .wrap{max-width:960px;margin:0 auto;padding:0 20px 80px} | |
| header.hero{background:linear-gradient(160deg,#12203a 0%,#1d3a63 55%,#7c3d1d 130%);color:#fff;padding:64px 0 56px} | |
| header.hero .wrap{padding-bottom:0} | |
| .kicker{font:600 12px/1 Helvetica,Arial,sans-serif;letter-spacing:.18em;text-transform:uppercase;color:#f0b28a;margin:0 0 14px} | |
| h1{font:700 44px/1.15 Georgia,serif;margin:0 0 16px} | |
| .sub{font-size:19px;color:#d8e2f0;max-width:640px} | |
| .stats{display:flex;gap:28px;margin-top:28px;flex-wrap:wrap} | |
| .stat b{display:block;font:700 30px Helvetica,Arial,sans-serif;color:#fff} | |
| .stat span{font:13px Helvetica,Arial,sans-serif;color:#b9c8dc} | |
| section{margin-top:64px} | |
| h2{font:700 28px Georgia,serif;margin:0 0 6px} | |
| h2 .no{color:var(--accent);margin-right:10px;font-family:Helvetica,Arial,sans-serif;font-size:20px;vertical-align:2px} | |
| .lede{color:var(--muted);font-size:17px;margin:0 0 24px;max-width:700px} | |
| .card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:24px 26px;box-shadow:0 1px 3px rgba(16,32,64,.05)} | |
| .cols{display:grid;grid-template-columns:1fr 1fr;gap:18px} | |
| @media (max-width:760px){.cols{grid-template-columns:1fr}} | |
| p{margin:.5em 0} | |
| .note{font-size:13.5px;color:var(--muted)} | |
| .fig-cap{font-size:13.5px;color:var(--muted);margin-top:10px} | |
| b.k{color:var(--accent)} | |
| /* demo */ | |
| button.act{font:700 14px Helvetica,Arial,sans-serif;border:1.5px solid var(--line);background:#fff;border-radius:10px;padding:10px 16px;cursor:pointer;color:var(--ink)} | |
| button.act:hover{border-color:var(--accent);color:var(--accent)} | |
| button.act.on{background:#12203a;color:#fff;border-color:#12203a} | |
| .action-row{display:flex;gap:14px;flex-wrap:wrap;background:var(--chip);border-radius:12px;padding:14px 16px;margin-top:14px;align-items:center} | |
| .action-row .grp{display:flex;align-items:center;gap:8px} | |
| .action-row .lbl{font:600 13px Helvetica,Arial,sans-serif;color:var(--muted);min-width:86px} | |
| .seg{display:flex;border:1.5px solid var(--line);border-radius:9px;overflow:hidden;background:#fff} | |
| .seg button{font:700 14px Helvetica,Arial,sans-serif;border:0;background:transparent;padding:7px 13px;cursor:pointer;color:var(--muted)} | |
| .seg button.on.p1{background:#1d4ed8;color:#fff} | |
| .seg button.on.m1{background:#c2410c;color:#fff} | |
| .seg button.on.z{background:#94a3b8;color:#fff} | |
| .readout{font:13px Helvetica,Arial,sans-serif;color:var(--muted);margin-top:10px} | |
| .readout b{color:var(--ink)} | |
| .readout .r-good{color:var(--good)} .readout .r-bad{color:var(--bad)} | |
| canvas.plate{width:100%;border:1px solid var(--line);border-radius:12px;background:#0d1526;display:block} | |
| .cap-under{font:600 13px Helvetica,Arial,sans-serif;color:var(--muted);margin:6px 2px 0} | |
| .twinbanner{display:none;background:#12203a;color:#f0b28a;font:700 14px Helvetica,Arial,sans-serif;border-radius:10px;padding:10px 16px;margin-top:10px} | |
| /* pipeline */ | |
| .pipe{display:flex;align-items:stretch;gap:0;flex-wrap:wrap;justify-content:center;margin:22px 0 6px} | |
| .stage{background:var(--card);border:1.5px solid var(--line);border-radius:12px;padding:12px 14px;width:158px;text-align:center;position:relative;margin:6px} | |
| .stage b{font:700 14px Helvetica,Arial,sans-serif;display:block} | |
| .stage span{font-size:12.5px;color:var(--muted);line-height:1.4;display:block;margin-top:4px} | |
| .arrow{align-self:center;color:#9aa9bd;font:700 22px Helvetica,sans-serif;margin:-6px 2px} | |
| .stage.hot{border-color:var(--accent)} | |
| /* charts */ | |
| .toggles{display:flex;gap:10px;flex-wrap:wrap;margin:16px 0} | |
| .toggles .seg{background:#fff} | |
| .bars .row{display:grid;grid-template-columns:120px 1fr;gap:12px;align-items:center;margin:10px 0} | |
| .bars .name{font:600 13.5px Helvetica,Arial,sans-serif;text-align:right} | |
| .bars .name small{display:block;font-weight:400;color:var(--muted)} | |
| .track{position:relative;height:26px;background:var(--chip);border-radius:6px} | |
| .bar{position:absolute;top:0;height:100%;border-radius:6px;min-width:2px} | |
| .bar.ind{left:0;background:#93a8c4} | |
| .bar.dir{top:0;background:var(--accent)} | |
| .bar.leia{background:#1d4ed8} | |
| .bar .v{position:absolute;right:6px;top:3px;font:600 11.5px Helvetica,Arial,sans-serif;color:#fff;white-space:nowrap} | |
| .legend{display:flex;gap:18px;font:12.5px Helvetica,Arial,sans-serif;color:var(--muted);margin:8px 0 4px;flex-wrap:wrap} | |
| .legend i{display:inline-block;width:12px;height:12px;border-radius:3px;margin-right:5px;vertical-align:-1px} | |
| table.t2{width:100%;border-collapse:collapse;font:13px Helvetica,Arial,sans-serif;margin-top:16px} | |
| table.t2 th,table.t2 td{border:1px solid var(--line);padding:6px 8px;text-align:center} | |
| table.t2 th{background:var(--chip);font-weight:600} | |
| table.t2 td.l{text-align:left} | |
| .callout{border-left:4px solid var(--accent);background:#fff7f2;padding:14px 18px;border-radius:0 10px 10px 0;margin:20px 0;font-size:15px} | |
| .claimbox{background:#12203a;color:#e8eef7;border-radius:14px;padding:22px 26px;margin:24px 0} | |
| .claimbox h3{font:700 17px Helvetica,Arial,sans-serif;margin:0 0 10px;color:#f0b28a} | |
| footer{margin-top:70px;padding-top:22px;border-top:1px solid var(--line);font-size:13.5px;color:var(--muted)} | |
| a{color:var(--accent2)} | |
| .tagline{display:inline-block;background:var(--chip);border-radius:20px;padding:4px 12px;font:600 12px Helvetica,Arial,sans-serif;color:var(--muted);margin:2px 4px 2px 0} | |
| </style> | |
| </head> | |
| <body> | |
| <header class="hero"> | |
| <div class="wrap"> | |
| <p class="kicker">Paper explainer · arXiv 2605.28368 · NeurIPS 2026</p> | |
| <h1>LEIA: a video-game-style world model,<br>for bending steel</h1> | |
| <p class="sub">Engineers design architected materials — lattice structures like the inside of bone — but every | |
| design idea must pass through a slow finite-element simulation. LEIA is a learned simulator you can | |
| <i>play</i>: pull, twist and shear a 3D material step by step, and watch its deformation and internal stress | |
| respond in real time.</p> | |
| <div class="stats"> | |
| <div class="stat"><b>~100–300×</b><span>faster than FEM per evaluation</span></div> | |
| <div class="stat"><b>442,000</b><span>mesh nodes handled autoregressively</span></div> | |
| <div class="stat"><b>30 FPS</b><span>interactive threshold LEIA clears</span></div> | |
| <div class="stat"><b>553 designs</b><span>searched in 30 minutes</span></div> | |
| </div> | |
| </div> | |
| </header> | |
| <div class="wrap"> | |
| <!-- ================= 1. THE PROBLEM ================= --> | |
| <section> | |
| <h2><span class="no">1</span>The bottleneck is the simulator</h2> | |
| <p class="lede">Nature builds strength from geometry — bone, nacre and wood get their properties from structure, | |
| not substance. Engineers copy the trick with <b>architected materials</b>: tiny engineered lattices repeated | |
| millions of times. But testing a new geometry the classical way is painfully slow.</p> | |
| <div class="cols"> | |
| <div class="card"> | |
| <h3 style="font:700 16px Helvetica,Arial,sans-serif;margin-top:0">How it works today</h3> | |
| <p>Each candidate geometry is meshed into up to <b class="k">442,000 tetrahedral elements</b> and solved with the | |
| finite element method (FEM) — a nonlinear Newton iteration at every one of hundreds of time steps. | |
| One evaluation can take minutes to hours, and a design campaign needs <i>thousands</i> of them.</p> | |
| <p class="note">FEM gives exact-ish answers, but it is a batch process: submit, wait, read a file.</p> | |
| </div> | |
| <div class="card"> | |
| <h3 style="font:700 16px Helvetica,Arial,sans-serif;margin-top:0">The world-model idea</h3> | |
| <p>Game engines replaced hand-written physics with <b class="k">learned world models</b> that respond to your | |
| controller in real time. LEIA applies the same idea to solids: an engineer "presses buttons" — stretch, twist, | |
| shear — and the model predicts the material's response <b class="k">autoregressively</b>, each step conditioned | |
| on the action you just chose.</p> | |
| <p class="note">The catch: it must be right about <i>stress</i>, not just shape — stress is what breaks things.</p> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- ================= 2. INTERACTIVE DEMO ================= --> | |
| <section> | |
| <h2><span class="no">2</span>Play with a material</h2> | |
| <p class="lede">This is the interaction model LEIA enables. The plate is clamped at the left; you drive the right | |
| grip with four controls. Blue = loading, gray = hold, orange = unloading — exactly the per-step actions in the | |
| paper's interface. The stress you see is <b>computed, not painted</b>: every edge carries a 3-branch Maxwell | |
| viscoelastic law (the paper's τ = 0.001 / 0.2 / 3.0 s structure, game-scaled), integrated live in your browser.</p> | |
| <div class="card"> | |
| <canvas id="plateA" class="plate" width="900" height="380" aria-label="Interactive plate: stretch, twist, shear; color shows von Mises stress"></canvas> | |
| <div class="cap-under" id="capA">History A — live</div> | |
| <canvas id="plateB" class="plate" width="900" height="380" style="display:none" aria-label="Second history panel"></canvas> | |
| <div class="cap-under" id="capB" style="display:none"></div> | |
| <div class="twinbanner" id="twinbanner"></div> | |
| <div class="action-row"> | |
| <div class="grp"><span class="lbl">S · stretch</span> | |
| <div class="seg" id="seg-S"><button data-v="1">+1</button><button data-v="0" class="on z">0</button><button data-v="-1">−1</button></div></div> | |
| <div class="grp"><span class="lbl">T · twist</span> | |
| <div class="seg" id="seg-T"><button data-v="1">+1</button><button data-v="0" class="on z">0</button><button data-v="-1">−1</button></div></div> | |
| <div class="grp"><span class="lbl">1 · shear-y</span> | |
| <div class="seg" id="seg-Y"><button data-v="1">+1</button><button data-v="0" class="on z">0</button><button data-v="-1">−1</button></div></div> | |
| <div class="grp"><span class="lbl">2 · shear-z</span> | |
| <div class="seg" id="seg-Z"><button data-v="1">+1</button><button data-v="0" class="on z">0</button><button data-v="-1">−1</button></div></div> | |
| <button class="act" id="btn-ghost" title="Render what a history-blind (shape-only) model would predict">👁 shape-only model</button> | |
| <button class="act" id="btn-twin">▶ twin-history demo</button> | |
| <button class="act" id="btn-hold">▶ demo: pull, then hold</button> | |
| <button class="act" id="btn-reset">↺ reset</button> | |
| </div> | |
| <div class="readout" id="readout"></div> | |
| <p class="fig-cap" id="democap"><b>What to watch.</b> (1) Color is von Mises stress, now computed per edge from its | |
| actual strain through a real three-branch relaxation law — during any hold, color genuinely decays as the | |
| non-equilibrium branches relax. (2) Press <b>👁 shape-only model</b> to see what a model that only knows the | |
| current <i>shape</i> would predict, with the live Pearson correlation <i>r</i> between it and the true field: | |
| it sags during holds, exactly the failure Table 2 quantifies. (3) Press <b>▶ twin-history demo</b> for two | |
| plates driven to the <i>same</i> final grip position by different paths — same shape, different stress.</p> | |
| <p class="note">Simplified but physically consistent: real edge strains and real relaxation dynamics, computed in | |
| your browser — it shows the physics intuition and the interface, not the trained LEIA model or FEM data.</p> | |
| </div> | |
| </section> | |
| <!-- ================= 3. ARCHITECTURE ================= --> | |
| <section> | |
| <h2><span class="no">3</span>How LEIA works</h2> | |
| <p class="lede">Three moving parts: a tokenizer that compresses any mesh into a fixed set of latent tokens, a | |
| transformer that rolls those latents forward under your commands, and a decoder that reads physical fields back out.</p> | |
| <div class="pipe"> | |
| <div class="stage"><b>Mesh state S<sub>t</sub></b><span>displacement field u on N nodes (N up to 442K, arbitrary tetrahedral mesh)</span></div> | |
| <div class="arrow">→</div> | |
| <div class="stage"><b>Tokenizer</b><span>Perceiver cross-attention squeezes N nodes into K fixed latent tokens (K=256–512)</span></div> | |
| <div class="arrow">→</div> | |
| <div class="stage hot"><b>Dynamics transformer</b><span>action-conditioned: each block is scaled/shifted by the boundary-condition action a<sub>t</sub> you pressed</span></div> | |
| <div class="arrow">→</div> | |
| <div class="stage"><b>Decoder</b><span>cross-attention reads latents back to every node</span></div> | |
| <div class="arrow">→</div> | |
| <div class="stage hot"><b>Stress head</b><span>a single Linear(H, 6) layer (<0.02% of parameters) emitting the six Cauchy stress components directly</span></div> | |
| </div> | |
| <div class="cols" style="margin-top:18px"> | |
| <div class="card"> | |
| <h3 style="font:700 15px Helvetica,Arial,sans-serif;margin-top:0">Why latents?</h3> | |
| <p>A mesh of 442K nodes is too big to process directly. The tokenizer compresses it to a fixed-size latent | |
| (like a video codec's keyframe codes), the dynamics transformer predicts the <i>next</i> latent from the | |
| current one plus your action, and the decoder renders any latent back onto the original mesh.</p> | |
| </div> | |
| <div class="card"> | |
| <h3 style="font:700 15px Helvetica,Arial,sans-serif;margin-top:0">Why a stress head?</h3> | |
| <p>You could compute stress <i>afterwards</i> from the predicted shape — differentiate the displacement, run the | |
| constitutive law. But for viscoelastic materials the stress also depends on <b class="k">internal state</b> | |
| (18 hidden variables in the paper's benchmark) that a shape-only model never sees. The stress head learns to | |
| emit stress directly, internal state included — at +6% training cost.</p> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- ================= 4. THE CLAIM ================= --> | |
| <section> | |
| <h2><span class="no">4</span>The claim under test</h2> | |
| <p class="lede">The paper's Table 2 (p. 7) says a tiny output layer fixes a universal stress-prediction failure across | |
| four very different architectures. This chart is built from the paper's reported numbers; toggle the view.</p> | |
| <div class="card"> | |
| <div class="toggles"> | |
| <div class="seg" id="met-seg"> | |
| <button data-m="vm" class="on p1">von Mises correlation ↑</button> | |
| <button data-m="disp">Displacement error ↓ (%)</button> | |
| </div> | |
| <div class="seg" id="mode-seg"> | |
| <button data-m="tf" class="on z">Teacher forcing</button> | |
| <button data-m="ar">100-step rollout</button> | |
| </div> | |
| </div> | |
| <div class="legend"> | |
| <span><i style="background:#93a8c4"></i>Indirect stress (recover via predicted internal variables)</span> | |
| <span><i style="background:#c2410c"></i>Direct stress head</span> | |
| <span><i style="background:#1d4ed0"></i>LEIA (reference, always direct)</span> | |
| </div> | |
| <div class="bars" id="bars"></div> | |
| <p class="fig-cap" id="barcap"></p> | |
| <div class="callout" id="callout"></div> | |
| <table class="t2"> | |
| <thead><tr><th rowspan="2" style="text-align:left">Model</th><th rowspan="2">Space</th> | |
| <th colspan="2">Teacher forcing</th><th colspan="2">AR rollout (100 steps)</th></tr> | |
| <tr><th>Disp. (%) ↓</th><th>VM corr. ↑</th><th>Disp. (%) ↓</th><th>VM corr. ↑</th></tr></thead> | |
| <tbody id="t2body"></tbody> | |
| <tfoot><tr><td class="l"><b>LEIA</b></td><td>latent</td><td>2.84</td><td>0.970</td><td>5.99</td><td><b>0.986</b></td></tr></tfoot> | |
| </table> | |
| <p class="note" style="margin-top:8px">Medians across 100 test trajectories; each cell is "without / with the stress head" | |
| where two values exist. Single training run per configuration — the paper reports no error bars. Source: Table 2, p. 7 | |
| of arXiv:2605.28368v2.</p> | |
| </div> | |
| <div class="claimbox"> | |
| <h3>The claim, precisely</h3> | |
| <p style="margin:0 0 8px">Under teacher forcing, replacing indirect stress recovery with a direct 6-component stress | |
| head raises median von Mises correlation from ≤0.26 to ≥0.94 for <b>all four</b> baselines: | |
| MGN −0.009→0.987 · UPT 0.257→0.951 · PointNet 0.091→0.943 · Transolver 0.108→0.941.</p> | |
| <p style="margin:0;color:#b9c8dc">How it could be <b>falsified</b> (with matched training on the same splits): any | |
| baseline <i>without</i> the stress head reaching correlation > ~0.6, or any baseline <i>with</i> it staying below | |
| ~0.8 — either breaks the ~0.7 gap. Under rollout, MGN is expected to collapse (0.987→0.225) while the per-frame | |
| models hold; that part is about rollout stability, not the head.</p> | |
| </div> | |
| </section> | |
| <!-- ================= 5. WHY IT MATTERS ================= --> | |
| <section> | |
| <h2><span class="no">5</span>What you can do with it</h2> | |
| <div class="cols"> | |
| <div class="card"> | |
| <h3 style="font:700 15px Helvetica,Arial,sans-serif;margin-top:0">Search 553 designs in half an hour</h3> | |
| <p>Because evaluation is 100–300× faster than FEM, a beam search over lattice mutations evaluated | |
| <b class="k">553 candidate designs in 30 minutes</b>, and FEM validation at every iteration confirmed the | |
| surrogate's ranking. It found a design 3.6× better on the search metric at 2.1% volume fraction.</p> | |
| </div> | |
| <div class="card"> | |
| <h3 style="font:700 15px Helvetica,Arial,sans-serif;margin-top:0">Know when to distrust it</h3> | |
| <p>Design searches wander off-distribution, where any surrogate can silently lie. LEIA learns a | |
| <b class="k">confidence head</b> that predicts its own von Mises accuracy without running FEM, flagging | |
| designs it should not be trusted on.</p> | |
| </div> | |
| </div> | |
| </section> | |
| <footer> | |
| <p><span class="tagline">Unofficial explainer</span><span class="tagline">Built from arXiv:2605.28368v2</span><span class="tagline">Figures recreated, not copied</span></p> | |
| <p>Paper: H. Yang, Y. Cao, M. J. Buehler, <i>LEIA: Learned Environment for Interactive Architected Materials</i>, | |
| NeurIPS 2026 — <a href="https://arxiv.org/abs/2605.28368">arxiv.org/abs/2605.28368</a> · | |
| Code: <a href="https://github.com/HaiqianYang-MechE/leia">github.com/HaiqianYang-MechE/leia</a> (pinned 173514a).</p> | |
| <p>The interactive plate in Section 2 uses real edge strains and a three-branch Maxwell relaxation law computed in | |
| the browser, but a simplified geometry and modulus — it demonstrates the physics intuition and the interface, not | |
| the trained model. All quantitative numbers are quoted verbatim from the paper. MicroPlate data is generated | |
| locally from the authors' FEM scripts; no bulk artifacts are hosted in their repository.</p> | |
| </footer> | |
| </div> | |
| <script> | |
| /* ================= interactive plate demo ================= */ | |
| /* Real-ish physics: per-edge strain -> 3-branch Maxwell viscoelastic law. | |
| Branch structure and tau ordering follow the paper (tau = 0.001 / 0.2 / 3.0 s, | |
| equal-weight branches); times are game-scaled into steps. */ | |
| (function(){ | |
| const NX=13, NY=6, NZ=4; | |
| const ref=[]; | |
| for(let i=0;i<NX;i++)for(let j=0;j<NY;j++)for(let k=0;k<NZ;k++) | |
| ref.push({x:i/(NX-1), y:j/(NY-1)*0.5, z:k/(NZ-1)*0.5}); | |
| const idx=(i,j,k)=>(i*NY+j)*NZ+k; | |
| const BR_W=[0.34,0.33,0.33], BR_TAU=[2,14,70]; // fast / mid / slow branches | |
| const MODULUS=3.6; // game-scaled, sets color range | |
| const STEP=0.055; | |
| function buildEdges(){ | |
| const edges=[]; | |
| for(let i=0;i<NX;i++)for(let j=0;j<NY;j++)for(let k=0;k<NZ;k++) | |
| for(const nb of [[i+1,j,k],[i,j+1,k],[i,j,k+1]]) | |
| if(nb[0]<NX&&nb[1]<NY&&nb[2]<NZ) | |
| edges.push([idx(i,j,k),idx(nb[0],nb[1],nb[2])]); | |
| return edges; | |
| } | |
| const EDGES=buildEdges(); | |
| const nodeEdges=ref.map(()=>[]); | |
| EDGES.forEach((e,ei)=>{nodeEdges[e[0]].push(ei);nodeEdges[e[1]].push(ei);}); | |
| // rest lengths at reference config (no grip displacement) | |
| function dist(p,q){return Math.hypot(p.px-q.px,p.py-q.py,p.pz-q.pz);} | |
| const ZERO={x:0,twist:0,sy:0,sz:0}; | |
| function deformRaw(r,g){ | |
| return { | |
| px: r.x*(1+0.28*g.x), | |
| py: r.y + 0.42*g.twist*r.x*r.z + 0.5*g.sy*r.x, | |
| pz: r.z - 0.42*g.twist*r.x*r.y + 0.5*g.sz*r.x | |
| }; | |
| } | |
| const REST=EDGES.map(e=>dist(deformRaw(ref[e[0]],ZERO),deformRaw(ref[e[1]],ZERO))); | |
| function colormap(v){ | |
| v=Math.max(0,Math.min(1,v/1.1)); | |
| if(v<0.5){const t=v/0.5;return `rgb(${Math.round(40+215*t)},${Math.round(110+120*t)},${Math.round(230-190*t)})`;} | |
| const t=(v-0.5)/0.5;return `rgb(255,${Math.round(230-160*t)},${Math.round(40-40*t)})`; | |
| } | |
| const W=900,H=380,S=180,OX=95,OY=250; | |
| function proj(px,py,pz){return [OX+px*S-pz*S*0.38, OY-py*S*1.15-pz*S*0.30];} | |
| class Plate{ | |
| constructor(canvas){ | |
| this.cv=canvas; this.ctx=canvas.getContext('2d'); | |
| this.g={x:0,twist:0,sy:0,sz:0}; | |
| this.act={S:'0',T:'0',Y:'0',Z:'0'}; | |
| this.eB=EDGES.map(()=>[0,0,0]); // per-edge branch stresses | |
| this.nodeS=ref.map(()=>0); // node von Mises (history-aware) | |
| this.nodeSsur=ref.map(()=>0); // node von Mises (shape-only surrogate) | |
| this.step=0; this.frozen=false; | |
| } | |
| deform(i){return deformRaw(ref[i],this.g);} | |
| edgeStrains(){ | |
| const pos=ref.map((_,i)=>this.deform(i)); | |
| return EDGES.map((e,ei)=>{ | |
| const eps=(dist(pos[e[0]],pos[e[1]])-REST[ei])/REST[ei]; | |
| return MODULUS*eps; | |
| }); | |
| } | |
| tick(){ | |
| if(!this.frozen){ | |
| const a=this.act; | |
| this.g.x=clamp(this.g.x+STEP*(a.S==='1'?1:a.S==='-1'?-1:0),0,0.85); | |
| this.g.twist=clamp(this.g.twist+STEP*0.85*(a.T==='1'?1:a.T==='-1'?-1:0),-0.6,0.6); | |
| this.g.sy=clamp(this.g.sy+STEP*(a.Y==='1'?1:a.Y==='-1'?-1:0),-0.6,0.6); | |
| this.g.sz=clamp(this.g.sz+STEP*(a.Z==='1'?1:a.Z==='-1'?-1:0),-0.6,0.6); | |
| const sigE=this.edgeStrains(); | |
| // Maxwell update per branch: s += (sigmaE - s)*(1-exp(-dt/tau)) | |
| for(let ei=0;ei<EDGES.length;ei++){ | |
| const b=this.eB[ei]; | |
| for(let br=0;br<3;br++) b[br]+=(sigE[ei]-b[br])*(1-Math.exp(-1/BR_TAU[br])); | |
| } | |
| for(let n=0;n<ref.length;n++){ | |
| let sg=0,ss=0,incident=nodeEdges[n]; | |
| for(const ei of incident){const b=this.eB[ei]; | |
| sg+=BR_W[0]*b[0]+BR_W[1]*b[1]+BR_W[2]*b[2]; | |
| ss+=sigE[ei]; | |
| } | |
| const m=incident.length||1; | |
| this.nodeS[n]=Math.abs(sg/m); | |
| this.nodeSsur[n]=Math.abs(ss/m); | |
| } | |
| this.step++; | |
| } | |
| } | |
| draw(highlightErr){ | |
| const c=this.ctx; c.clearRect(0,0,W,H); | |
| c.fillStyle='#233c66'; c.fillRect(40,48,10,290); | |
| c.fillStyle='#8fa8cf'; c.font='12px Helvetica,Arial'; | |
| c.fillText('clamped face (x = 0)',30,36); | |
| c.fillText('grip (x = 1) — your actions',640,36); | |
| // edges: color = GT stress; when highlightErr, color = surrogate and halo red where |s - ssur| large | |
| for(let ei=0;ei<EDGES.length;ei++){ | |
| const [a,b]=EDGES[ei]; | |
| const dA=this.deform(a), dB=this.deform(b); | |
| const A=proj(dA.px,dA.py,dA.pz), B=proj(dB.px,dB.py,dB.pz); | |
| const show=highlightErr?this.nodeSsur[a]*0.5+this.nodeSsur[b]*0.5 | |
| :this.nodeS[a]*0.5+this.nodeS[b]*0.5; | |
| const v=(show)/1.1; | |
| c.strokeStyle=colormap(show); | |
| c.globalAlpha=0.25+0.75*Math.min(1,v); | |
| c.lineWidth=1.2+1.6*Math.min(1,v); | |
| c.beginPath();c.moveTo(A[0],A[1]);c.lineTo(B[0],B[1]);c.stroke(); | |
| if(highlightErr){ | |
| const err=Math.abs(this.nodeS[a]-this.nodeSsur[a])+Math.abs(this.nodeS[b]-this.nodeSsur[b]); | |
| if(err>0.18){ // disagreeing region: outline in red | |
| c.globalAlpha=0.9;c.strokeStyle='#ff4d4d';c.lineWidth=1; | |
| c.beginPath();c.moveTo(A[0],A[1]);c.lineTo(B[0],B[1]);c.stroke(); | |
| } | |
| } | |
| } | |
| c.globalAlpha=1; | |
| for(let j=0;j<NY;j++)for(let k=0;k<NZ;k++){ | |
| const n=idx(NX-1,j,k),d=this.deform(n),P=proj(d.px,d.py,d.pz); | |
| c.fillStyle=colormap(highlightErr?this.nodeSsur[n]:this.nodeS[n]); | |
| c.beginPath();c.arc(P[0],P[1],2.4,0,7);c.fill(); | |
| } | |
| for(let x=0;x<120;x++){c.fillStyle=colormap(x/120*1.1);c.fillRect(690+x,H-24,1,10);} | |
| c.fillStyle='#7f93b3';c.font='11px Helvetica,Arial'; | |
| c.fillText('σvm low',688,H-2); c.fillText('high',822,H-2); | |
| } | |
| pearson(){ | |
| const x=this.nodeS,y=this.nodeSsur,N=x.length; | |
| let mx=0,my=0;for(let i=0;i<N;i++){mx+=x[i];my+=y[i];}mx/=N;my/=N; | |
| let sxy=0,sx=0,sy=0; | |
| for(let i=0;i<N;i++){const dx=x[i]-mx,dy=y[i]-my;sxy+=dx*dy;sx+=dx*dx;sy+=dy*dy;} | |
| return (sx&&sy)?sxy/Math.sqrt(sx*sy):1; | |
| } | |
| reset(){this.g={x:0,twist:0,sy:0,sz:0};this.eB=EDGES.map(()=>[0,0,0]);this.step=0;this.frozen=false;} | |
| } | |
| function clamp(v,a,b){return Math.max(a,Math.min(b,v));} | |
| const plateA=new Plate(document.getElementById('plateA')); | |
| const plateB=new Plate(document.getElementById('plateB')); | |
| const cvB=document.getElementById('plateB'), capB=document.getElementById('capB'); | |
| const banner=document.getElementById('twinbanner'); | |
| let mode='free'; // free | hold | twin | |
| let ghost=false; | |
| function readout(){ | |
| const el=document.getElementById('readout'); | |
| if(mode==='twin'){ | |
| const r=plateA.pearson(); | |
| el.innerHTML=`step <b>${plateA.step}</b>/20 · final grip stretch <b>${plateA.g.x.toFixed(2)}</b> on both plates · | |
| shape-only-model correlation <i>r</i> at this frozen frame: | |
| <b class="${r<0.6?'r-bad':'r-good'}">r = ${r.toFixed(2)}</b>`; | |
| } else if(ghost){ | |
| const r=plateA.pearson(); | |
| el.innerHTML=`step <b>${plateA.step}</b> · grip: stretch <b>${plateA.g.x.toFixed(2)}</b>, twist <b>${plateA.g.twist.toFixed(2)}</b>, | |
| shear-y <b>${plateA.g.sy.toFixed(2)}</b>, shear-z <b>${plateA.g.sz.toFixed(2)}</b> · | |
| shape-only vs true field: <b class="${r<0.6?'r-bad':'r-good'}">r = ${r.toFixed(2)}</b> ${r<0.6?'— sagging while stress relaxes':''}`; | |
| } else { | |
| el.innerHTML=`step <b>${plateA.step}</b> · grip: stretch <b>${plateA.g.x.toFixed(2)}</b>, twist <b>${plateA.g.twist.toFixed(2)}</b>, | |
| shear-y <b>${plateA.g.sy.toFixed(2)}</b>, shear-z <b>${plateA.g.sz.toFixed(2)}</b>`; | |
| } | |
| } | |
| function render(){ | |
| plateA.draw(false); | |
| if(mode==='twin'){plateB.draw(false);} | |
| else if(ghost){plateB.draw(true);} | |
| readout(); | |
| } | |
| function loop(){ | |
| if(mode==='twin'){ | |
| // scripted: A loads every step for 8, then holds; B loads every other step for 16, then holds | |
| if(!plateA.frozen){ | |
| plateA.act={S:plateA.step<8?'1':'0',T:'0',Y:'0',Z:'0'}; plateA.tick(); | |
| plateB.act={S:(plateB.step%2===0&&plateB.step<16)?'1':'0',T:'0',Y:'0',Z:'0'}; plateB.tick(); | |
| if(plateA.step>=20){ | |
| plateA.frozen=true;plateB.frozen=true; | |
| banner.style.display='block'; | |
| banner.textContent=`Same final shape (stretch ${plateA.g.x.toFixed(2)}), different stress — history A is hotter. A shape-only model cannot tell them apart.`; | |
| } | |
| } | |
| render(); return; | |
| } | |
| plateA.tick(); render(); | |
| } | |
| setInterval(loop,220); | |
| // segmented controls | |
| for(const key of ['S','T','Y','Z']){ | |
| const seg=document.getElementById('seg-'+key); | |
| seg.querySelectorAll('button').forEach(b=>b.addEventListener('click',()=>{ | |
| seg.querySelectorAll('button').forEach(x=>x.classList.remove('on','p1','m1','z')); | |
| b.classList.add('on', b.dataset.v==='1'?'p1':b.dataset.v==='-1'?'m1':'z'); | |
| plateA.act[key]=b.dataset.v; | |
| })); | |
| } | |
| function syncSegs(p){ | |
| for(const key of ['S','T','Y','Z']){ | |
| const seg=document.getElementById('seg-'+key); | |
| seg.querySelectorAll('button').forEach(x=>x.classList.remove('on','p1','m1','z')); | |
| const v=p.act[key]; | |
| [...seg.querySelectorAll('button')].find(x=>x.dataset.v===v) | |
| .classList.add('on', v==='1'?'p1':v==='-1'?'m1':'z'); | |
| } | |
| } | |
| function clearModes(){ | |
| clearInterval(holdTimer); holdTimer=null; | |
| plateA.reset(); plateB.reset(); | |
| banner.style.display='none'; capB.style.display='none'; cvB.style.display='none'; | |
| capA.textContent='History A — live'; | |
| document.getElementById('btn-ghost').classList.remove('on'); | |
| ghost=false; | |
| } | |
| document.getElementById('btn-reset').addEventListener('click',()=>{mode='free';clearModes();render();}); | |
| // ghost toggle (works in free mode) | |
| document.getElementById('btn-ghost').addEventListener('click',()=>{ | |
| if(mode==='twin')return; | |
| ghost=!ghost; | |
| document.getElementById('btn-ghost').classList.toggle('on',ghost); | |
| cvB.style.display=ghost?'block':'none'; capB.style.display=ghost?'block':'none'; | |
| capB.textContent='Shape-only model — instant elastic guess from the current shape, no history'; | |
| }); | |
| // pull-then-hold scenario | |
| let holdTimer=null; | |
| document.getElementById('btn-hold').addEventListener('click',()=>{ | |
| clearModes(); mode='hold'; ghost=true; | |
| document.getElementById('btn-ghost').classList.add('on'); | |
| cvB.style.display='block'; capB.style.display='block'; | |
| capB.textContent='Shape-only model — instant elastic guess from the current shape, no history'; | |
| plateA.reset();plateB.reset(); | |
| let t=0; | |
| holdTimer=setInterval(()=>{ | |
| if(t>=40){clearInterval(holdTimer);holdTimer=null;mode='free';return;} | |
| plateA.act={S:t<12?'1':'0',T:'0',Y:'0',Z:'0'}; syncSegs(plateA); | |
| plateA.tick(); plateB.frozen=false; render(); t++; | |
| },260); | |
| }); | |
| // twin-history demo | |
| document.getElementById('btn-twin').addEventListener('click',()=>{ | |
| clearModes(); mode='twin'; | |
| plateA.reset();plateB.reset(); | |
| cvB.style.display='block'; capB.style.display='block'; | |
| capA.textContent='History A — fast pull: +1 every step, then hold'; | |
| capB.textContent='History B — slow pull: +1 every other step, then hold'; | |
| banner.style.display='block'; | |
| banner.textContent='Driving both plates to the same final grip position…'; | |
| render(); | |
| }); | |
| render(); | |
| })(); | |
| /* ================= Table 2 chart ================= */ | |
| (function(){ | |
| const DATA = { | |
| MGN: {space:'phys.', tf:[3.88,3.52,-0.009,0.987], ar:[241,9.94,0.012,0.225]}, | |
| UPT: {space:'latent', tf:[13.0,6.09,0.257,0.951], ar:[80.8,31.8,0.197,0.882]}, | |
| PointNet: {space:'phys.', tf:[21.8,3.25,0.091,0.943], ar:[22.8,2.87,0.092,0.938]}, | |
| Transolver:{space:'phys.', tf:[33.0,2.84,0.108,0.941], ar:[40.3,2.42,0.109,0.947]} | |
| }; | |
| const LEIA={tf:{disp:2.84,vm:0.970}, ar:{disp:5.99,vm:0.986}}; | |
| let metric='vm', mode='tf'; | |
| const bars=document.getElementById('bars'), cap=document.getElementById('barcap'), co=document.getElementById('callout'); | |
| function fmt(v,vm){ return vm ? v.toFixed(3) : (v>=100?v.toFixed(0):v.toFixed(v<10?2:1)); } | |
| function render(){ | |
| const isVM = metric==='vm'; | |
| let rows=Object.entries(DATA).map(([name,d])=>{ | |
| const arr=d[mode]; | |
| const ind = isVM? arr[2] : arr[0], dir = isVM? arr[3] : arr[1]; | |
| return {name, space:d.space, ind, dir, leia: LEIA[mode][isVM?'vm':'disp']}; | |
| }); | |
| let html=''; | |
| for(const r of rows){ | |
| if(isVM){ | |
| const pw=v=>Math.max(0,Math.min(100,v*100)); | |
| html+=`<div class="row"><div class="name">${r.name}<small>${r.space}</small></div><div> | |
| <div class="track"> | |
| <div class="bar ind" style="width:${pw(r.ind)}%"><span class="v" style="color:#41506b;right:${100-pw(r.ind)>10?4+'px':'auto'};left:${pw(r.ind)>10?'auto':'6px'}">${fmt(r.ind,1)}</span></div> | |
| <div class="bar dir" style="width:${pw(r.dir)}%"><span class="v">${fmt(r.dir,1)}</span></div> | |
| </div></div></div>`; | |
| } else { | |
| const pw=v=>Math.max(1.2, Math.min(100, Math.log10(1+Math.max(0,v))/Math.log10(251)*100)); | |
| html+=`<div class="row"><div class="name">${r.name}<small>${r.space}</small></div><div> | |
| <div class="track"> | |
| <div class="bar ind" style="width:${pw(r.ind)}%"><span class="v" style="color:#41506b;left:6px;right:auto">${fmt(r.ind,0)}%</span></div> | |
| <div class="bar dir" style="width:${pw(r.dir)}%"><span class="v">${fmt(r.dir,0)}%</span></div> | |
| </div></div></div>`; | |
| } | |
| } | |
| const l=LEIA[mode][isVM?'vm':'disp']; | |
| const lw = isVM? Math.min(100,l*100) : Math.max(1.2,Math.min(100,Math.log10(1+l)/Math.log10(251)*100)); | |
| html+=`<div class="row"><div class="name">LEIA<small>latent · reference</small></div><div> | |
| <div class="track"><div class="bar leia" style="width:${lw}%"><span class="v">${isVM?fmt(l,1):fmt(l,1)+'%'}</span></div></div></div></div>`; | |
| bars.innerHTML=html; | |
| cap.textContent = isVM | |
| ? (mode==='tf' | |
| ? 'Median per-frame Pearson correlation between predicted and FEM von Mises stress, teacher forcing (ground-truth state fed at each step). Higher is better; chance is 0.' | |
| : 'Same metric under 100-step autoregressive rollout (initial state only). MGN collapses; per-frame models (PointNet, Transolver) re-see ground-truth actions each step, so they nearly match teacher forcing.') | |
| : (mode==='tf' | |
| ? 'Median per-frame relative L2 displacement error (%) under teacher forcing. Lower is better; scale is logarithmic.' | |
| : 'Displacement error (%) under 100-step autoregressive rollout; logarithmic scale. MGN\u2019s indirect variant collapses to 241%.'); | |
| co.innerHTML = isVM && mode==='tf' | |
| ? `<b>The headline gap.</b> Without the stress head, every architecture sits at ≤ 0.26 — barely better than chance. | |
| With a single Linear(H, 6) layer added, all four jump above 0.94. The failure is not architectural: message | |
| passing, transformers and set encoders all fail the same way, because recovering viscoelastic stress from a | |
| shape alone is underdetermined. This is the claim this page\u2019s companion reproduction tests.` | |
| : isVM | |
| ? `<b>Rollout separates the temporal models.</b> UPT and LEIA carry latent state; the per-frame models are re-fed | |
| the ground-truth state each step so they hold by construction. MGN degrades dramatically — its stress | |
| correlation falls 0.987 → 0.225 while displacement error explodes to 241%, the known fragility of | |
| autoregressive message-passing. The paper's LEIA holds the highest AR stress correlation (0.986).` | |
| : mode==='tf' | |
| ? `<b>Displacement improves too.</b> Adding the stress head cuts displacement error for every baseline — UPT | |
| 13.0→6.09%, PointNet 21.8→3.25%, Transolver 33.0→2.84% — multi-task supervision helps even the primary task.` | |
| : `<b>Displacement under rollout.</b> Same pattern: per-frame models stay near teacher forcing; UPT degrades | |
| moderately; MGN's indirect variant collapses entirely (241%). With the stress head it still fails, but less.`; | |
| } | |
| document.getElementById('met-seg').querySelectorAll('button').forEach(b=>b.addEventListener('click',()=>{ | |
| document.getElementById('met-seg').querySelectorAll('button').forEach(x=>x.classList.remove('on','p1')); | |
| b.classList.add('on', b.dataset.m==='vm'?'p1':'z'); metric=b.dataset.m; render(); | |
| })); | |
| document.getElementById('mode-seg').querySelectorAll('button').forEach(b=>b.addEventListener('click',()=>{ | |
| document.getElementById('mode-seg').querySelectorAll('button').forEach(x=>x.classList.remove('on','z')); | |
| b.classList.add('on','z'); mode=b.dataset.m; render(); | |
| })); | |
| const tb=document.getElementById('t2body'); | |
| tb.innerHTML = Object.entries(DATA).map(([n,d])=>{ | |
| const a=d.tf,b=d.ar; | |
| const vm=v=>v<0?`<span style="color:#b91c1c">${v.toFixed(3)}</span>`:v.toFixed(3); | |
| const dp=v=>v>=100?`<span style="color:#b91c1c">${v.toFixed(0)}</span>`:v.toFixed(v>=10?1:2); | |
| return `<tr><td class="l"><b>${n}</b></td><td>${d.space}</td> | |
| <td>${dp(a[0])} / <b>${dp(a[1])}</b></td><td>${vm(a[2])} / <b>${vm(a[3])}</b></td> | |
| <td>${dp(b[0])} / <b>${dp(b[1])}</b></td><td>${vm(b[2])} / <b>${vm(b[3])}</b></td></tr>`; | |
| }).join(''); | |
| render(); | |
| })(); | |
| </script> | |
| </body> | |
| </html> | |