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
|
Round a required sample count up to an efficient FFT size. |
|
Size the transverse grid for a beam layout. |
|
Build the square transverse grid. |
|
Build the envelope time/frequency grid. |
Classes
|
Square transverse grid (same axis for x and y). |
|
Temporal/spectral grid for the analytic envelope. |
- class pnps.grids.SpaceGrid(r_max, delta_x, x, kx)[source]#
Bases:
objectSquare 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.
- x: Float[ndarray, 'n_x']#
- kx: Float[ndarray, 'n_x']#
- class pnps.grids.TimeGrid(lam0, omega0, delta_t, t, omega, sidx, omega_min, omega_max)[source]#
Bases:
objectTemporal/spectral grid for the analytic envelope.
- Attributes:
- lam0float
Reference (carrier) wavelength in m.
- omega0float
Carrier angular frequency
2*pi*c/lam0in 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/lamat the long/short wavelength limits.
- t: Float[ndarray, 'n_t']#
- omega: Float[ndarray, 'n_omega']#
- sidx: Bool[ndarray, '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 layoutt = (n - N/2) * delta_t.
- Returns:
- int
The rounded-up transform size.
- Raises:
- GridError
If
modeis 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_airyAiry radii of the largest-hole focal spot at the longest wavelength; resolution requirespts_per_lobesamples per Airy lobe at the shortest; and the momentum span must hold the third-order mixing products withsafetyheadroom. The returned sample count is the next even 2,3,5-smooth size abovemargintimes the strictest requirement.The mixing bound follows the layout (
pnps.geometry). In the TG boxcar the outermost hole edge ismask_spacing/2 + mask_diamfrom the axis and the chi3 products are bounded by three times that. In self-diffraction the signal itself is the outermost thing, at3s/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)forspace_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
nbyntransverse grid.
- Raises:
- GridError
If
nis 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_trounded 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_tsamples.
- Raises:
- GridError
If the wavelength limits do not bracket
lam0.