# 検証方針と結果

Cosmic Web Simulatorは教育用ソフトウェアですが、動画がもっともらしく見えることを「正しさ」の根拠にはしません。解析的極限、保存則、独立ソルバー間比較、seed固定の回帰値、全公開シナリオの有限性、公開サイトの静的契約を組み合わせて検証しています。

## 1. 最終検証コマンド

```bash
npm run verify
```

このコマンドは、次を順に実行します。

```text
TypeScript application strict check
TypeScript test strict check
38 deterministic numerical tests
clean production build
公開HTML・DOM ID・ES module graph・文書link・version contract検査
```

公開用buildでは、すべて成功しました。

依存関係については、runtime dependencyが存在しない状態で `npm audit --omit=dev` が `0 vulnerabilities` を返しました。開発依存を含む完全な `npm audit` も試行しましたが、検証時のregistry audit endpointがHTTP 503を返したため、開発依存全体について新しい「0件」の主張は行いません。`package-lock.json`はTypeScript 5.8.3を固定しています。

## 2. 自動数値試験 **38件**

### 宇宙論・kernel・FFT

1. Planck 2018代表パラメータ
2. WDM transferの低波数極限と高波数抑制
3. 2D／3D cubic-spline SPH kernelの数値規格化
4. Newtonian pair forceの作用反作用
5. 真の2D Poisson point forceの`1/r` scaling
6. radix-2 FFTのforward／inverse round trip
7. 2D／3D periodic CICの質量保存
8. 一様周期格子のPM重力が数値的にゼロ
9. 摂動周期格子の有限な力、density diagnostics、正味力ゼロ
10. 3D `n³` cosmology loadと互換性のあるperiodic PM mesh
11. 物理的意味を持つ連続したcomponent label
12. macro-particle質量が選択した平均物質密度を再現
13. seed固定PM計算が`z=0`までに非線形成長し、総質量を保存

### 重力多体系計算

14. galaxy-encounter presetが終了前に円盤の重なる近接通過へ到達
15. Barnes–HutとDirect summationの加速度比較
16. Direct pair-range分割とserial resultの一致
17. Barnes–Hut target-range分割とfull-tree resultの一致
18. SPH target-rangeとserial hydrodynamic kernelの一致
19. resource estimatorが粒子数、Worker複製、RAM比、安全停止を反映
20. collisional modeがDirect法を選び、adaptive global timestepが縮小
21. softened two-body leapfrogのenergy・mass・重心・運動量安定性
22. 2D／3D SPH初期状態の有限density、pressure、diagnostics
23. 任意整数`n`に対するSpeed／Balanced／Resolution PM policy
24. 全24公開シナリオの初期条件が有限で内部整合的

### SPH・compact remnant・ALE

25. 全公開SPHシナリオが低解像度で1 finite hydrodynamic step進む
26. Tait EOSが有限かつ正のweakly-compressible pressureを生成
27. compact-remnant explorerが有限で、islands modeでは非単調性を保持
28. 一様流と共移動するfaceに対するHLLC-ALE fluxのGalilean consistency
29. fixed／moving periodic contact testのmass・momentum・energy保存
30. LOW／HIGH／BLOCKEDのresource-panel path
31. 同じdtでForward Eulerのenergy driftがleapfrogより大きいこと
32. 全公開N-bodyシミュレーションが授業用低解像度で複数step進む
33. 全公開SPHシナリオの短時間multi-step stability sweep
34. 全moving-meshシナリオが正のcell幅を保ち、保存量を追跡して時間発展

### 公開UI・巨大設定・実行契約

35. 宇宙論粒子格子が任意整数`n`を2048まで保持し、auto PM meshをradix-2へ整合
36. `2048³`など単一TypedArrayで表現不能な条件をallocation前に解除不能BLOCKED
37. coordinator Worker protocolが重力多体系計算、SPH、ALEを初期化・step
38. 全24公開シナリオに重複のない解説があり、基礎知識・数値手法・観察点・解釈・適用限界を含む

## 3. 代表的な数値回帰値

以下は現在の実装に対する回帰値です。研究予測値やconvergence済みの物理結果ではありません。

### 16³ cosmology PM

```text
particle load: 16³ = 4,096
PM mesh:      32³
z:            49 → 0
initial RMS(delta): 0.0323388
final RMS(delta):   1.35346
final max(rho/rhobar): 29.0791
mass error:          0
steps:               49
```

この試験は、初期揺らぎがほぼ一様なまま停止せず、periodic PMで非線形density contrastへ成長することを確認します。finite box、seed、transfer approximation、mesh、stepに依存する実装回帰値です。

### Galaxy encounter

```text
initial nucleus separation: 6.000
minimum separation:         0.2394
end time:                   14.0
relative energy error:     -5.67e-3
relative mass error:        0
```

中心核particleの距離を追跡し、二つの円盤が単に並進・回転するだけでなく、終了前に重なる近点通過へ到達することを確認します。

### Euler／leapfrog comparison

同じsoftened two-body initial conditionとdtに対して、代表値は次のとおりです。

```text
Leapfrog KDK relative energy error: 1.36e-11
Forward Euler relative energy error: 3.05e-2
```

これは時間積分法の授業用比較であり、すべての問題で同じ誤差比になることを意味しません。

### Fixed／moving ALE contact advection

```text
128 cells, periodic, 250 steps
fixed mesh contact-width diagnostic:  0.1875
moving mesh contact-width diagnostic: 0.0000
mass error:   order 1e-16
energy error: order 1e-15
```

同じ流体速度にmesh faceを追随させる1D ALE testでは、contact discontinuityのgrid-crossing diffusionが大きく減ることを確認します。これは1D first-order HLLC-ALEの教材testであり、2D／3D Voronoi moving meshの性能保証ではありません。

## 4. Browser・public-site検査

### Static contract validator

clean build後の`dist/`に対して、次を自動検査します。

- UI versionとpackage versionが`1.0.1`
- 重力多体系／SPH／Moving meshの3 engine tab
- `main.ts`が参照するDOM IDの存在と重複なし
- compiled ES moduleの相対import解決
- source／built documentation link
- scientific warning、24件のscenario guide、export controls
- configuration JSON、diagnostics CSV、PNG、share URL
- moving-mesh tabがdisabled placeholderではないこと

### Headless Chromium checks

clean buildした`dist/`をHTTP配信し、公開UIと実際のWeb Worker coordinatorをheadless Chromiumから操作しました。

- Plummer星団512粒子を初期化し、重力多体系エンジンをstep `0 -> 2`
- Sod shock tubeを初期化し、SPHエンジンをstep `0 -> 1`
- 移流する接触不連続を初期化し、ALEエンジンをstep `0 -> 2`
- `n=2048`で`8,589,934,592`粒子が表示され、allocation前に解除不能BLOCKEDとなること
- 24件のscenario guideが選択中のsimulationへ追随すること
- desktopと430 px幅でのresponsive layout
- browser console/page error 0件、request failure 0件

検証画像:

- `docs/preview-ui.png`
- `docs/preview-mobile.png`
- `docs/preview-cosmology-resource-limit.png`
- `docs/preview-cosmology.png`
- `docs/preview-supernova.png`
- `docs/preview-moving-mesh.png`

GitHub Pagesへdeployした後は、実公開URLからもう一度、Worker起動、各engineの1 batch、download controls、share URL、mobile表示を確認してください。hosting headersやbrowser extensionまではrelease archive内で保証できないためです。

## 5. 診断量の解釈

### Cosmological density

PM meshへCICでmass assignmentし、configuration-space densityをparticle位置へ補間した`rho/rhobar`です。6次元phase-space densityではありません。`RMS(delta)`はmesh上の`delta = rho/rhobar - 1`のroot-mean-squareです。

### N-body energy

pair potential energyは非PMかつ診断上現実的な粒子数でのみ評価します。periodic PMに対して未整合なpair potentialを混ぜず、利用できないenergyは`N/A`にします。expanding cosmologyでは孤立Newton系の単純な`K+U`を保存量として扱いません。

### SPH densityとtemperature

2Dではsurface density、3Dではvolume densityです。temperatureはEOSに基づくcode-unit proxyであり、物理単位への校正をしていないscenarioではKelvinではありません。supernovaのcompact-remnant outcomeは教育用prescriptionであり、SPHがcore collapseを第一原理計算した結果ではありません。

### Memoryとruntime

preflightのmemoryはallocation estimateです。runtimeはsolver work modelとbrowser内batch実測を分けて表示します。Worker数はCPU coreの予約やaffinityではなく、browser schedulerへ許可するparallel task数です。

## 6. 未完了の研究精度検証

### Cosmology

- single-mode growth against independent linear theory
- time-step、particle、mesh、box、seed convergence
- initial／evolved power spectrum recovery
- independent periodic Green-function comparison
- CIC window、discrete gradient、Nyquist response
- CLASS／CAMB transfer table、BAO、2LPT

### N-body

- long-term Kepler phase／apsidal error
- force-error distribution versus Barnes–Hut opening angle
- Plummer density profile and relaxation convergence
- galaxy model convergence with live halo／bulge／gas

### SPH

- Sod profile against an exact Riemann solution
- sound-wave convergence order
- Sedov shock-radius scaling over a resolved dynamic range
- particle-by-particle adaptive smoothing with grad-h terms
- modern pressure-entropy SPH、conductivity、MHD、cooling／chemistry
- Jeans-resolution enforcement and sink particles

### Moving mesh

- high-order reconstruction and slope limiting
- multidimensional mesh connectivity and topology changes
- 2D／3D Voronoi geometry
- independent Riemann-solver comparison

したがって、本アプリは**大学の数値計算法教育、定性的比較、controlled numerical experiment**には利用できますが、precision cosmology、star-formation prediction、core-collapse outcome prediction、engineering liquid designには使用しないでください。
