lshape#
- torchspin.lshape(x, x0=0.0, fwhm=1.0, diff=0, alpha=1.0, phase=0.0)[source]#
Combined Gaussian + Lorentzian absorption lineshape.
Port of EasySpin’s
lshape.m.- Parameters:
x (array_like) – Abscissa values (any units).
x0 (float) – Center of the lineshape. Default 0.
fwhm (float or [float, float]) –
Full width at half maximum (same units as x).
Scalar: the same FWHM is used for both Gaussian and Lorentzian components (the blend controlled by alpha).
Two-element list
[fwhm_G, fwhm_L]: Gaussian and Lorentzian each have their own width (independent of alpha).
diff (int) –
Derivative order.
0 — absorption (default)
1 — first derivative
2 — second derivative
-1 — integral (cumulative absorption from -∞)
alpha (float) – Gaussian fraction (0 ≤ alpha ≤ 1).
alpha=1→ pure Gaussian;alpha=0→ pure Lorentzian. Ignored when fwhm has two elements.phase (float) – Phase angle (radians) for mixing absorption and dispersion components. 0 → pure absorption; π/2 → pure dispersion.
- Returns:
y (ndarray) – Lineshape values. Area-normalized when
diff=0andphase=0.
Notes
Dispersion components are computed analytically:
Gaussian dispersion: Dawson integral
F(t) = e^{-t²} ∫₀ᵗ e^{s²} dsviascipy.special.dawsn.Lorentzian dispersion:
-(x-x0) / (π * ((x-x0)² + (Γ/2)²)).
Normalization: the absorption peak integrates to 1 (unit area).
Examples
>>> import numpy as np >>> x = np.linspace(-5, 5, 1000) >>> y = lshape(x, 0, 1.0) # Gaussian FWHM=1, pure absorption >>> print(np.trapezoid(y, x)) # ≈ 1.0 >>> y1 = lshape(x, 0, 1.0, diff=1) # first derivative