xoppylib.sources.urgentpy_power_density_from_harmonics

Calculation of the power density for the individual harmonics.

Exact implementation like in the URGENT code: Walker & Diviacco, Rev. Sci. Instrum. 63, 392 (1992)

PLANE UNDULATOR (Kx=0), Section VI Power Density.

Amplitude (from paper, Kx=0):
A = xi * ( 2*alpha_x*S0 - Ky*(S1 + S_minus1),

2*alpha_y*S0, 0 )

S_q = sum_{p} J_p(Y) * J_{2p+q+n}(X) q = 0, +1, -1 xi = n / (1 + Ky^2/2 + alpha^2) X = 2 * xi * alpha_x * Ky (alpha_x = gamma * theta_x) Y = xi * Ky^2 / 4

Power density (Walker 1992, Section VI):
Integrate d²I/dw dΩ over frequency:

integral L(Δω/ω₁) dω = N · ω₁ [N in NUMERATOR] ω₁ = 4πcγ² / (λ₀ · denom)

=>

dI/dΩ = (e · γ⁴ · Ib · N) / (ε₀ · λ₀) · |An|² / denom [W/rad²]

p_max RULE (adaptive):

The Bessel sums converge once |J_p(Y)| and |J_{2p+n}(X)| are negligible. X is maximised at alpha = sqrt(1 + Ky²/2), giving X_max = n·Ky/sqrt(1+Ky²/2). Safe rule (error < 1e-12):

p_max(n, K) = ceil( n · (K/sqrt(1+K²/2) + 1) / 2 ) + 3

For K=1.358: p_max = 4, 5, 6, 7, 8 … for n = 1, 2, 3, 4, 5 … Using a fixed p_max=20 wastes ~40% CPU for typical K and low harmonics.

Functions

harmonic_energy(n, K, period_m, gamma)

Resonant photon energy [eV] for harmonic n on-axis.

power_density_all_harmonics(Ky, N_periods, ...)

Sum power density [W/rad²] over harmonics 1 … n_harmonics.

power_density_harmonic(n, Ky, N_periods, ...)

Power density [W/rad²] for harmonic n of a plane undulator.