コンテンツにスキップ

advection-diffusion2d

英語 | 日本語

« Home · « 移流拡散・反応・輻射

Advection-diffusion of a passive scalar (2D Gaussian pulse) -- exact-solution verification benchmark. A single D2Q5 advection-diffusion LBM for the scalar C, advected by a PRESCRIBED UNIFORM velocity u = (U, 0) on a doubly-periodic square. The scalar is passive: there is no momentum LBM, no buoyancy coupling -- u is imposed everywhere, so this isolates the D2Q5 collision/streaming as a pure advection-diffusion operator and checks it against the textbook Gaussian Green's function.

概要: 一様流に乗った受動スカラーのガウス分布。解析 Green 関数と比較でき、拡散係数の実効値と格子収束次数まで測れる数少ないケース。

Geometry

advection-diffusion2d geometry

Animation

Fields

この計算が最後の出力ステップで書き出した場をそのまま描いたもの。3D ケースは中央断面。

advection-diffusion2d C

Results

D2Q5 スカラー LBM を厳密解(2D ガウス核)で検証する純輸送ベンチマーク。 既定引数:N = 128、格子移流速度 U = 0.05、D_phys = 0.0064、T = 0.5、 σ0 = 0.08。写像は D_lat = 0.0064 × 0.05 × 128 = 0.040960、 τ = 3 × 0.04096 + 1/2 = 0.62288、steps = 0.5/(0.05/128) = 1280、 パルス幅基準の Pe = U σ0N/D_lat = 0.05 × 10.24/0.04096 = 12.5 — ログ 1 行目の数値がすべてこの算術で閉じる。Grace CPU 72 コアで壁時計 1.11 秒。

  • L2 誤差は 1.7820e-03(step 25)から一度下がり(最小 1.3132e-03、 step 325 付近)、最終 1.8139e-03。全経過で 1.3–1.8e-3 の帯に収まる。
  • 分散の成長:最終 σ² = 209.041 vs 厳密 209.715。厳密値は σ0² + 2 D_lat t = 104.8576 + 2 × 0.04096 × 1280 = 209.7152 — ちょうど初期分散が倍になる時刻で止めている。線形フィットの 拡散勾配は 8.162253e-02 で、理論値 2D = 2 × 0.04096 = 0.08192 に対し −0.36%。切片 104.5727 vs σ0² = 104.8576。
  • 移流速度:重心追跡で 5.000004e-02 vs U = 0.05(0.00%)。 格子上の平行移動は D2Q5 でほぼ厳密に再現される。
  • 保存:M/M0 = 1.000000 が全ステップで並ぶ。衝突・ストリーミングとも スカラー総量を機械精度で保存している証拠。

Governing equations

受動スカラー C の移流拡散方程式とその Green 関数:

\[
\partial_t C + U\,\partial_x C = D\,\nabla^2 C,\qquad
C=\frac{\sigma_0^2}{\sigma^2}\exp\!\Big(\!-\frac{(x-x_0-Ut)^2+(y-y_0)^2}{2\sigma^2}\Big),\;
\sigma^2=\sigma_0^2+2Dt
\]

これを D2Q5(静止 + 軸 4 方向、w0 = 1/3、w1..4 = 1/6、c_s² = 1/3)の BGK で解く。平衡分布と回復される拡散係数:

\[
g_i^{\rm eq}=w_i\,C\Big(1+\frac{\boldsymbol{c}_i\cdot\boldsymbol{u}}{c_s^2}\Big),
\qquad D=c_s^2\Big(\tau-\tfrac12\Big)\;\Rightarrow\;\tau=3D+\tfrac12
\]

速度場は u = (U, 0) を処方する(運動量 LBM なし)。つまりこのケースは D2Q5 衝突・ストリーミングを純粋な移流拡散演算子として単離し、教科書の Green 関数と突き合わせる。厳密解は周期像の格子和で評価するため、 比較側が L2 測定を律速しない。格子ごとに U を固定して N を上げると dx = 1/N、dt = U dx なので 2 次収束の格子細分試験が適定になる(ヘッダ参照)。

Code walkthrough

ソース(363 行)。

%%{init: {'themeVariables': {'fontSize': '11px'}}}%%
flowchart LR
    subgraph DOM["二重周期正方格子 128×128"]
      P(("ガウスパルス σ0=10.24 セル<br/>処方速度 u=(U,0) で並進<br/>σ²=σ0²+2Dt で自己相似拡散"))
    end
    DOM -->|周期ラップ x,y| DOM
  1. 写像 — (N, U, D_phys, T, σ0) から (D_lat, τ, steps) を導出して表示。
  2. collide/stream — D2Q5 BGK。境界処理は配列の周期インデックスのみ。
  3. 診断 — 25 ステップごとに L2(周期像和の厳密解に対する)、二次 モーメント σ²、総量 M/M0 を出力。
  4. 総括 — σ²(t) 直線フィットの勾配 vs 2D、重心速度 vs U、RESULT 行。

Build & run

cmake -S native -B native/build && cmake --build native/build -j
./native/build/orheo-advection-diffusion2d

advection_diffusion2d [N] [U] [D_phys] [T] [sigma0] [out_prefix]

このページの図を作った計算のコスト(Miyabi-G Grace CPU (72 cores, -stdpar=multicore)): 1.1 s wall。

Things to try

  • 格子細分:advection_diffusion2d 256 → 512。U 固定なので L2 が dx² で落ちるはず。減衰次数を自分で測る。
  • τ → 1/2 の危険域:D_phys を 1/10 にして τ = 0.512 付近での誤差の 振る舞いを見る(安定だが誤差構造が変わる)。
  • Ma を振る:U = 0.05 → 0.2。移流速度誤差(この実行では 0.00%)に 格子 Mach の 2 次の汚染が現れるかを確認。
  • σ0 を小さく:パルスをセル数本まで細くすると D2Q5 の数値分散が 見えてくる。L2 の初期値がどれだけ跳ねるか。

Validation

Tier T0 — 収束次数まで確認
QoI temperature-L2-error(abs)
Reference analytic Gaussian Green's function of the AD equation
Gate 🧩 モジュールゲート (advection_diffusion)
Measured 0.001813924 (rel. err +0.18%) — harvest N=128

Source & run details

View source

Item Value
Target orheo-advection-diffusion2d
Source native/benchmarks/advection_diffusion2d.cpp
Lattice D2Q5
GPU twin no
Gallery run 2026-07-27 @ 7628c0cf
Args ``
Wall time 1.11 s
CPU time 14.07 s
Device Miyabi-G Grace CPU (72 cores, -stdpar=multicore)

Computation log

この計算の実際の出力(先頭と末尾)。

advection_diffusion2d N=128 U=0.0500 D_phys=0.0064 T=0.500 sigma0=0.080 | D_lat=0.040960 tau=0.62288 steps=1280  Pe=12.5
  step 25/1280: L2=1.7820e-03 sigma2=106.623 (exact 106.906) M/M0=1.000000
  step 50/1280: L2=1.6671e-03 sigma2=108.664 (exact 108.954) M/M0=1.000000
  step 75/1280: L2=1.5866e-03 sigma2=110.704 (exact 111.002) M/M0=1.000000
  step 100/1280: L2=1.5245e-03 sigma2=112.744 (exact 113.050) M/M0=1.000000
  step 125/1280: L2=1.4748e-03 sigma2=114.785 (exact 115.098) M/M0=1.000000
  step 150/1280: L2=1.4344e-03 sigma2=116.825 (exact 117.146) M/M0=1.000000
  step 175/1280: L2=1.4016e-03 sigma2=118.865 (exact 119.194) M/M0=1.000000
  step 200/1280: L2=1.3751e-03 sigma2=120.906 (exact 121.242) M/M0=1.000000
  step 225/1280: L2=1.3542e-03 sigma2=122.946 (exact 123.290) M/M0=1.000000
  step 250/1280: L2=1.3380e-03 sigma2=124.986 (exact 125.338) M/M0=1.000000
  step 275/1280: L2=1.3261e-03 sigma2=127.026 (exact 127.386) M/M0=1.000000
  step 300/1280: L2=1.3180e-03 sigma2=129.067 (exact 129.434) M/M0=1.000000
  step 325/1280: L2=1.3132e-03 sigma2=131.107 (exact 131.482) M/M0=1.000000
...

  step 1250/1280: L2=1.7975e-03 sigma2=206.594 (exact 207.258) M/M0=1.000000
  step 1275/1280: L2=1.8112e-03 sigma2=208.633 (exact 209.306) M/M0=1.000000
  step 1280/1280: L2=1.8139e-03 sigma2=209.041 (exact 209.715) M/M0=1.000000
--- N=128 summary ---
  L2(final)          = 1.8139e-03
  diffusion slope    = 8.162253e-02  vs 2D = 8.192000e-02  (-0.36%)
  sigma^2 intercept  = 104.5727  vs sigma0^2 = 104.8576
  advection speed    = 5.000004e-02  vs U = 5.000000e-02  (0.00%)
RESULT N=128 L2=1.813924e-03 slope=8.162253e-02 twoD=8.192000e-02 speed=5.000004e-02 U=5.000000e-02 sig2fit0=104.572694 sig0sq=104.857600

References

  • R. G. M. van der Sman & M. H. Ernst, J. Comput. Phys. 160 (2000) 766 — D2Q5 拡散格子。
  • X. He, S. Chen & G. D. Doolen, J. Comput. Phys. 146 (1998) 282 — 移流拡散平衡分布。