pnps.grids#

Time/frequency and transverse grids for envelope propagation.

The temporal grid is the analytic-envelope grid: a complex field sampled on a centred time axis t = (n - N/2) * delta_t, whose discrete Fourier dual is the absolute angular frequency axis omega = omega0 + 2*pi*fftfreq(N, delta_t) — FFT-ordered, not monotonic. The sample spacing is fixed by the requested wavelength window (Nyquist for the envelope bandwidth), and the sample count by the requested time window, rounded up to an efficient FFT size.

The transverse grid is a square, centred real-space axis x = (n - N/2) * delta_x with FFT-ordered momentum axis kx = 2*pi*fftfreq(N, delta_x). Both x and y use the same axis. The physical half-width of the grid is r_max * (1 + window_factor): the caller-facing r_max is the radius meant to contain the field, and the extra margin is grid headroom.

Functions

fft_size(needed[, mode])

Round a required sample count up to an efficient FFT size.

optimal_spatial_grid(f_foc, mask_diam, ...)

Size the transverse grid for a beam layout.

space_grid(r_max, n[, window_factor])

Build the square transverse grid.

time_grid(lam0, lam_lims, trange[, fftsize])

Build the envelope time/frequency grid.

Classes

SpaceGrid(r_max, delta_x, x, kx)

Square transverse grid (same axis for x and y).

TimeGrid(lam0, omega0, delta_t, t, omega, ...)

Temporal/spectral grid for the analytic envelope.

class pnps.grids.SpaceGrid(r_max, delta_x, x, kx)[source]#

Bases: object

Square transverse grid (same axis for x and y).

Attributes:
r_maxfloat

Caller-facing containment radius in m (the physical half-width is r_max * (1 + window_factor)).

delta_xfloat

Real-space sample spacing in m.

xnumpy.ndarray

Centred real-space axis, shape (n,), in m. Used for both x and y.

kxnumpy.ndarray

FFT-ordered transverse momentum axis, shape (n,), in rad/m. Used for both kx and ky.

r_max: float#
delta_x: float#
x: Float[ndarray, 'n_x']#
kx: Float[ndarray, 'n_x']#
property n: int[source]#

Number of samples along each transverse axis.

Returns:
int

n, equal to n_y and n_x.

property k_nyquist: float[source]#

Transverse Nyquist momentum pi / delta_x in rad/m.

Returns:
float

The Nyquist momentum in rad/m.

class pnps.grids.TimeGrid(lam0, omega0, delta_t, t, omega, sidx, omega_min, omega_max)[source]#

Bases: object

Temporal/spectral grid for the analytic envelope.

Attributes:
lam0float

Reference (carrier) wavelength in m.

omega0float

Carrier angular frequency 2*pi*c/lam0 in rad/s.

delta_tfloat

Time sample spacing in s.

tnumpy.ndarray

Centred time axis, shape (nt,), in s.

omeganumpy.ndarray

Absolute angular frequency axis in rad/s, FFT-ordered (element 0 is the carrier), shape (nt,).

sidxnumpy.ndarray

Boolean mask of “real” frequencies for which the dispersion relation is evaluated: omega_min/2 < omega < 1.1*omega_max.

omega_min, omega_maxfloat

Angular-frequency limits of the physical band, 2*pi*c/lam at the long/short wavelength limits.

lam0: float#
omega0: float#
delta_t: float#
t: Float[ndarray, 'n_t']#
omega: Float[ndarray, 'n_omega']#
sidx: Bool[ndarray, 'n_omega']#
omega_min: float#
omega_max: float#
property nt: int[source]#

Number of temporal samples.

Returns:
int

n_t, equal to n_omega.

pnps.grids.fft_size(needed, mode='smooth')[source]#

Round a required sample count up to an efficient FFT size.

Parameters:
neededfloat

Minimum number of samples required.

modestr

"smooth" for the next even 2,3,5-smooth integer (tracks the requirement closely), "pow2" for the next power of two. Evenness is required by the centred grid layout t = (n - N/2) * delta_t.

Returns:
int

The rounded-up transform size.

Raises:
GridError

If mode is not "smooth" or "pow2".

pnps.grids.optimal_spatial_grid(f_foc, mask_diam, mask_spacing, lam_min, lam_max, n_airy=5, pts_per_lobe=10, safety=1.5, margin=1.1, geometry='tg')[source]#

Size the transverse grid for a beam layout.

Real-space containment requires n_airy Airy radii of the largest-hole focal spot at the longest wavelength; resolution requires pts_per_lobe samples per Airy lobe at the shortest; and the momentum span must hold the third-order mixing products with safety headroom. The returned sample count is the next even 2,3,5-smooth size above margin times the strictest requirement.

The mixing bound follows the layout (pnps.geometry). In the TG boxcar the outermost hole edge is mask_spacing/2 + mask_diam from the axis and the chi3 products are bounded by three times that. In self-diffraction the signal itself is the outermost thing, at 3s/2 (s = mask_spacing + mask_diam), so its edge, 3s/2 + mask_diam/2, is the bound, with no further factor.

Parameters:
f_focfloat

Focusing focal length in m.

mask_diam, mask_spacingfloat

Hole diameter and edge-to-edge hole spacing in m.

lam_min, lam_maxfloat

Wavelength limits of the simulation window in m.

n_airyint

Airy radii of real-space containment, see above.

pts_per_lobeint

Samples per Airy lobe at the shortest wavelength.

safetyfloat

Headroom factor on the momentum span of the mixing products.

marginfloat

Factor applied to the strictest sample-count requirement.

geometry{“tg”, “sd”}, optional

The beam layout.

Returns:
tuple of (float, int)

(r_max, n) for space_grid().

Raises:
ConfigError

For an unknown layout.

pnps.grids.space_grid(r_max, n, window_factor=0.1)[source]#

Build the square transverse grid.

Parameters:
r_maxfloat

Containment radius in m; the grid half-width is r_max * (1 + window_factor).

nint

Samples per axis; must be even (centred layout and the re-imaging identity in the extraction both require it).

window_factorfloat

Fractional half-width margin beyond r_max (inherited convention).

Returns:
SpaceGrid

The n by n transverse grid.

Raises:
GridError

If n is odd.

pnps.grids.time_grid(lam0, lam_lims, trange, fftsize='smooth')[source]#

Build the envelope time/frequency grid.

The sample spacing is the envelope Nyquist limit for the requested wavelength window (extended 10% on the blue side, headroom for the absorbing edge), and the sample count is trange / delta_t rounded up to an FFT size. The realised time window is therefore >= trange.

Parameters:
lam0float

Carrier wavelength in m.

lam_limstuple of float

(min, max) wavelength limits of the simulation window in m.

trangefloat

Requested extent of the time window in s.

fftsizestr

Sample-count rounding mode, see fft_size().

Returns:
TimeGrid

The envelope grid, with n_t samples.

Raises:
GridError

If the wavelength limits do not bracket lam0.