fix: two-temperature model energy source and heat-diffusion stencil - #1250
fix: two-temperature model energy source and heat-diffusion stencil#1250MZKC wants to merge 1 commit into
Conversation
Three issues in the two-temperature model (TTM):
1. Energy source. fdtd_eh.f90 passed the time-accumulated absorbed energy
density (u_energy = -int divS dt) to ttm_main as the source S(r,t). But
ttm_main multiplies the source by dt, so S must be the instantaneous absorbed
power density -div(Poynting). With the accumulated energy, divS -> 0 after the
pulse but u_energy stays at its final value, so the electron temperature kept
rising even after the light had passed. Pass -divS instead.
2. Heat diffusion stencil. div(kappa grad Te) was computed by applying a central
first difference twice, giving [f(i+-2) - 2 f(i)]/(4 h^2): this skips the
midpoint, decouples the even/odd grid points and is blind to the checkerboard
mode. Replaced with the conservative half-grid (midpoint) flux form
[kappa_{i+1/2}(Te_{i+1}-Te_i) - kappa_{i-1/2}(Te_i-Te_{i-1})]/h^2.
3. init_ttm_alloc allocated rhs_l but re-initialised rhs_e (copy-paste); harmless
because ttm_main zeroes rhs_l each step, but corrected.
The now-unused calc_nabla helper and NABLA_* arrays are removed.
Verified with a standalone test: the old stencil returns 0 for a checkerboard
mode while the midpoint stencil gives 4*kappa/h^2; and with a square-pulse source
the accumulated-energy source keeps heating Te after the pulse whereas the
instantaneous-power source lets Te relax.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Can one of the admins verify this patch? |
MZKC
left a comment
There was a problem hiding this comment.
The core fixes are correct: instantaneous -divS as the TTM source (instead of the time-accumulated u_energy), the dt_em factor on the reported deposited energy, the conservative midpoint-flux Laplacian (replacing the even/odd-decoupled double-central-difference), and the rhs_l=0.0d0 alloc-zero typo. One boundary-handling caveat on the new stencil, inline.
| iy = ijk_media_myrnk(2,ii) | ||
| iz = ijk_media_myrnk(3,ii) | ||
| rhs_e(ix,iy,iz) = rhs_e(ix,iy,iz) & | ||
| + ( 0.5d0*(work(ix ,iy,iz)+work(ix+1,iy,iz))*(Te(ix+1,iy,iz)-Te(ix ,iy,iz)) & |
There was a problem hiding this comment.
+ ( 0.5d0*(work(ix ,iy,iz)+work(ix+1,iy,iz))*(Te(ix+1,iy,iz)-Te(ix ,iy,iz)) &
The conservative midpoint-flux form is the right fix for the decoupled stencil. Boundary caveat: this loop runs over media points (ijk_media_myrnk) but the face coefficient is 0.5*(kappa_i + kappa_{i±1}). At a media/non-media boundary the neighbor has work=0 (kappa via where(Tl/=0)) and Te≈0, so the face still carries ~kappa_i/2 * (0 - Te_i) ≠ 0 — heat conducts into the vacuum/non-media side, i.e. artificial surface cooling rather than the intended zero-flux boundary. Consider zeroing the face coefficient when the neighbor is not a media point (mask on Tl_{i±1}/=0 or kappa_{i±1}>0). The old central-difference path had a related leak so this isn't a regression, but the new stencil doesn't yet enforce the documented zero-flux boundary.
There was a problem hiding this comment.
Leaving this PR's stencil as-is: the media-boundary heat-flux handling is being addressed in the three-temperature-model work (#1268). As noted, this is not a regression versus the previous central-difference path.
Summary
Three issues in the two-temperature model (TTM), the most visible being that the
electron temperature kept rising even after the laser pulse had passed.
Energy source (the reported symptom).
fdtd_eh.f90passed thetime-accumulated absorbed energy density
u_energy = -∫ div(Poynting) dttottm_mainas the sourceS(r,t). Butttm_mainmultiplies the source bydt, soSmust be the instantaneousabsorbed power density
-div(Poynting). With the accumulated energy,div(Poynting) → 0after the pulse butu_energystays at its final value,so
Tekeeps being driven up every step. Pass-divSinstead.Heat-diffusion stencil.
div(kappa grad Te)was computed by applying acentral first difference twice, giving
[f(i±2) − 2 f(i)] / (4h²): this skipsthe midpoint, decouples the even/odd grid points and is blind to the
checkerboard mode. Replaced with the conservative half-grid (midpoint) flux
form
[kappa_{i+½}(Te_{i+1}−Te_i) − kappa_{i−½}(Te_i−Te_{i−1})] / h²,kappa_{i+½} = (kappa_i + kappa_{i+1})/2.Init typo.
init_ttm_allocallocatedrhs_lbut re-initialisedrhs_e(copy-paste). Harmless (
ttm_mainzeroesrhs_leach step) but corrected.The now-unused
calc_nablahelper andNABLA_*arrays are removed.Verification
Unit tests (standalone).
0(cannot damp it) while the midpoint stencil gives
4·kappa/h².heating
Teafter the pulse, while the instantaneous-power source letsTerelax once the pulse is over.
Integration (Wisteria-O, A64FX): FDTD + TTM.
theory='maxwell', an absorbing(Lorentz–Drude) sphere with the TTM enabled (
ttm.inp_ttm,Tini = 300 K), a5 fs pulse, total 20 fs. Both binaries absorb the same total energy (18.36, col 2):
TeTeat t = 20 fsTlat t = 20 fsPre-fix the electron temperature rises monotonically to ~3200 K and is still the
maximum at the end of the run — the reported runaway. After the fix
Tereachesits peak during the pulse and then decreases, i.e. it no longer keeps rising once
the light has passed.
🤖 Generated with Claude Code