pnps.exact_windows#
Exact hard-disc collection windows for the field the nonlinearity generated.
A collection window is a hard hole: in momentum, at each frequency, a disc of radius
R = (D/2) omega / (c z_mask) about k_c = (x_h, y_h) omega / (c z_mask). On the
momentum grid it has to be rendered, and every rendering
(pnps.beams.chromatic_mask()) carries a quadrature error that grows as the disc
spans fewer bins: a few 1e-4 of the trace’s peak for a 0.5 mm window on the production
grid (docs/windows.md). This module removes that error for a field whose real-space
support is compact.
The field a window sees is the nonlinear part N of the state
(pnps.simulate.visit_nonlinear()): behind compact input holes no linear light
reaches a signal window. N is driven by products of focal fields, so it is confined
near the focus, far inside the transverse box. A field of compact support on the grid’s
periodic real-space box has a spectrum that is a finite Fourier series in k,
N(k) = sum_l n_l exp(-i k x_l),
with n_l its real-space samples. Integrals of such a series over a disc are exact:
on-axis spectrum (linear in
N):int_disc N(k) exp(i k x_c) d^2k = sum_l n_l W(x_c - x_l), withx_cthe grid’s centre andW(r) = int_disc exp(-i k r) d^2k = exp(-i k_c r) 2 pi R J1(R |r|) / |r|the disc’s transform;collected energy (quadratic):
eta(k) |N(k)|^2is the series of the autocorrelationA = ifft2(eta |N|^2)over the lagsDelta x, exact when that autocorrelation does not wrap round the box, that is whenNoccupies less than half the box in each direction; thenint_disc eta |N|^2 d^2k = sum_Dx A(Dx) W(Dx).
Both sums are linear in the momentum-grid samples (of N, and of eta |N|^2), so
each is a fixed weight on the grid, one per window and frequency: the disc’s indicator
interpolated by the grid’s own kernel. ExactWindows builds these weights once
and applies them to any number of planes at the cost of a grid sum.
The admittance eta (pnps.flux) is smooth across a window, so multiplying by
it keeps the support compact. Both results are returned in the units of the grid sums of
pnps.extraction.extract_observables() (an integral over d^2k divided by the
pixel area dk^2), so the two are compared directly. wrap_share() reports the
share of |N|^2 in the outer part of the box, the measure of how well the support
condition holds.
Functions
|
Return the disc's transform, the integral of |
|
Integrate a compact field over each window's exact hard disc, once. |
|
Return how a window's disc reaches the grid's Nyquist limit, or None. |
|
Return the share of |
Classes
|
The exact hard-disc weights of a set of windows on the run's momentum grid. |
- class pnps.exact_windows.ExactWindows(sgrid, omega, k2, windows, bins=None)[source]#
Bases:
objectThe exact hard-disc weights of a set of windows on the run’s momentum grid.
Both sums of the module’s introduction are fixed linear functionals of the momentum-grid samples. Writing the lag sum of the energy back in momentum,
sum_Dx A(Dx) W(Dx) = sum_k eta |N(k)|^2 M(k)withM = ifft2(W)over the box’s lags: the weightMis the disc’s indicator interpolated by the grid’s own (Dirichlet) kernel, and the on-axis amplitude issum_k N(k) M(k)with the phase that centres it. So a window’s exact hard disc is a mask, one per window and frequency, built once and applied to every plane at the cost of a grid sum, like any other rendering. Unlike the others it is not compact: its tails reach every bin, which is why it is exact only for a field of compact real-space support, the nonlinear partNand not the whole state with its input arms.The masks take
n_bins * n_windows * n^2doubles: 6 GB for six windows over the 216 bins of 190 to 400 nm on the 768 x 768 production grid.- Parameters:
- sgridSpaceGrid
The transverse grid.
- omeganumpy.ndarray
Absolute angular frequency, FFT-ordered,
(nt,), rad/s.- k2numpy.ndarray
The material wavenumber squared,
(nt,), complex, rad^2/m^2, zero off the band (the admittance is zero there).- windowstuple of WindowSpec
The collection windows; only their position, diameter, mask distance and achromatic wavelength enter: each is its nominal hard hole.
- binsnumpy.ndarray or None, optional
The frequency bins to integrate; None takes every positive frequency on the band. The others are returned as zero.
- reduce(nonlinear)[source]#
Integrate one plane’s nonlinear field over each window’s hard disc.
- Parameters:
- nonlinearnumpy.ndarray
The nonlinear part of the state,
(n, n, nt): zero at the input arms, and of compact real-space support (wrap_share()).
- Returns:
- tuple of numpy.ndarray
(i_omega_win, i_omega_reimaged), each(n_windows, nt): the collected flux and the on-axis spectrum paired with its magnetic closure, aspnps.extraction.extract_observables()defines them, in its units.
- pnps.exact_windows.disc_transform(radius, centre, rx, ry)[source]#
Return the disc’s transform, the integral of
exp(-i k r)over the disc.- Parameters:
- radiusfloat
The disc’s radius in momentum, rad/m.
- centretuple of float
Its centre
(k_x, k_y), rad/m.- rx, rynumpy.ndarray
The displacement
r, m; the two broadcast together.
- Returns:
- numpy.ndarray
exp(-i k_c . r) 2 pi R J1(R |r|) / |r|, which ispi R^2atr = 0.
Examples
>>> import numpy as np >>> float(disc_transform(2.0, (0.0, 0.0), np.array(0.0), np.array(0.0)).real) 12.566370614359172
- pnps.exact_windows.exact_window_spectra(nonlinear, sgrid, omega, k2, windows, bins=None)[source]#
Integrate a compact field over each window’s exact hard disc, once.
The one-plane form of
ExactWindows, which builds the masks and applies them; build anExactWindowsto reduce several planes with one set.- Parameters:
- nonlinearnumpy.ndarray
The nonlinear part of the state,
(n, n, nt): zero at the input arms, and of compact real-space support (wrap_share()).- sgridSpaceGrid
The transverse grid.
- omeganumpy.ndarray
Absolute angular frequency, FFT-ordered,
(nt,), rad/s.- k2numpy.ndarray
The material wavenumber squared,
(nt,), complex, rad^2/m^2.- windowstuple of WindowSpec
The collection windows.
- binsnumpy.ndarray or None, optional
The frequency bins to integrate; None takes every positive frequency on the band.
- Returns:
- tuple of numpy.ndarray
(i_omega_win, i_omega_reimaged), each(n_windows, nt).
- pnps.exact_windows.nyquist_reach(sgrid, omega, windows)[source]#
Return how a window’s disc reaches the grid’s Nyquist limit, or None.
The disc’s transform takes the same value on every lag of the grid when its centre moves by
2 pi / dx, so a disc that reaches|k| = pi / dxalong either axis integrates part of a periodic copy of the spectrum instead of the light beyond the grid, which the grid cannot hold. solprop refuses such an exact aperture (SEP 53); this is the same test, made before anything is built.- Parameters:
- sgridSpaceGrid
The transverse grid.
- omeganumpy.ndarray
The frequencies the windows collect, rad/s.
- windowstuple of WindowSpec
The collection windows.
- Returns:
- str or None
The first window that reaches the limit and the wavelength from which it does, or None.
Return the share of
|N|^2beyondfractionof the box from its centre.The collected energy of
exact_window_spectra()is exact whenNoccupies less than half the box in each direction (its autocorrelation then does not wrap), so with the defaultfractionthis is the energy outside that region.- Parameters:
- nonlinearnumpy.ndarray
The nonlinear part of the state,
(n, n, nt).- fractionfloat, optional
The half-width of the central square, as a fraction of the box, in (0, 0.5).
- Returns:
- float
The share of
sum |N(x)|^2outside the central square, summed over frequency; zero for a zero field.