pnps.bridge#

The bridge to solprop: this package’s instrument model on solprop’s free-space route.

solprop integrates the propagation; this package forms the input and reduces the output. The bridge is everything in between, built once per configuration and reused for every delay point of a scan:

  • grids – solprop.grid.EnvelopeGrid.from_limits(), with its temporal collar placed inside the requested window (collar_placement="inside": this package zeroes the collar’s rates, so outside would only widen the grid), and solprop.grid.FreeGrid with no room for a real-space collar reproduce this package’s pnps.grids.time_grid() and pnps.grids.space_grid() sample for sample; check_grid_rule() refuses to proceed if they ever stop doing so;

  • operator – the fused-silica index (optmat’s fit), a solprop.linear.Frame pinned to this package’s co-moving frame beta1_ref omega + beta0_ref, the envelope Kerr response, and this package’s spectral absorber as an solprop.boundaries.Absorber with zero temporal rates;

  • schedule – a solprop.stepper.schedule.FixedSchedule of equal steps of at most h_target with every save plane a schedule edge, replayed by solprop’s Runge-Kutta march (the low-storage RK4IP by default, or DOPRI5) so there is no dense output and no interpolation;

  • backend and reducer – the solprop backend holding the state, and the host Reducer that turns each saved plane into the measured spectra.

The transverse-wavevector ramp is solprop’s safety ramp, its solprop.boundaries.SpatialAbsorber without a real-space collar (Config.transverse_absorber). solprop’s 200 /m evanescent clamp is left at its default (no active pair is evanescent on the production grid, so it cannot act; docs/dev/numerics.md, “Evanescent census”).

All the numbers that justify these identities are in docs/dev/numerics.md.

Module Attributes

Reduction

Where a saved plane is reduced to the observables: "host" copies the field out of solprop and reduces it with Reducer; "solprop" keeps no field and reads solprop's far-field statistics (pnps.statistics).

ReductionChoice

The reduction a configuration asks for: one of Reduction, or "auto", which takes "solprop" whenever solprop accepts the windows without a caveat (pnps.statistics.statistics_unavailable()) and "host" otherwise.

TABLEAUS

The tableau each stepper's replayed Runge-Kutta march uses, recorded in every file.

BOUNDARY_CHECK

How solprop's boundary monitor watches a run.

ABSORBER_REFERENCE_LENGTH

Reference length of the spectral absorber, m: solprop caps a rate at 60 / reference_length, so 5 um admits 1.2e7 /m, above the 1e7 /m power rate of the default gamma_max.

Functions

bridge_tables(bridge)

Build the operator from the solprop objects a bridge configured.

build_bridge(setup, zsave, h_target, *[, ...])

Set a configuration up on solprop, once, for any number of delay points.

check_grid_rule(setup, grid, space)

Refuse grids that no longer reproduce this package's sampling.

peak_kerr_rate(setup)

Return the peak nonlinear wavenumber of a configuration's input.

Classes

Bridge(setup, zsave, h_target, chi3, ...[, ...])

One configuration set up on solprop, reusable across delay points.

pnps.bridge.ABSORBER_REFERENCE_LENGTH = 5e-06#

Reference length of the spectral absorber, m: solprop caps a rate at 60 / reference_length, so 5 um admits 1.2e7 /m, above the 1e7 /m power rate of the default gamma_max. It only sets that cap; the rate itself is given.

pnps.bridge.BOUNDARY_CHECK = BoundaryCheck(guard_fraction=0.05, budget=1.0, stop_factor=1.0, quiet_collar=False, transverse_budget=0.001, interval=None)#

How solprop’s boundary monitor watches a run. The time window is not watched: this package’s protection there is the lap budget (pnps.absorber.spectral_absorber()), which by design lets walked-off light fill the window, guards included, and removes only what would wrap onto the pulse; what it removes is reported (lap_lost). A guard check would warn about light the model means to carry, so its budget is the whole field (a guard occupancy cannot exceed one). The transverse edge is watched at solprop’s default budget: light reaching it in real space would wrap round the periodic grid, which nothing else here guards against.

pnps.bridge.TABLEAUS: dict[str, str] = {'dopri5': 'DOPRI5', 'rk4ip': 'RK4IP'}#

The tableau each stepper’s replayed Runge-Kutta march uses, recorded in every file.

class pnps.bridge.Bridge(setup, zsave, h_target, chi3, kerr_rate, grid, space, medium, frame, responses, absorber, schedule, settings, simulation, problem, runner, reducer, reduction, stats_spec, scale, metadata, identity, exact=None, tables=None)[source]#

Bases: object

One configuration set up on solprop, reusable across delay points.

Built by build_bridge(). Holds solprop’s runner and its backend, whose buffers persist until close() (or the end of a with block): build one bridge per scan, not one per delay point.

Attributes:
setupSetup

The configuration this bridge runs.

zsavenumpy.ndarray

Save positions in m, strictly increasing from >= 0; a position at 0 is the input itself.

h_targetfloat

Largest step of the replayed schedule, m.

chi3float

The total chi3 given to solprop, m^2/V^2 (setup.chi3). With Raman the Kerr response holds 1 - f_R of it and the Raman response f_R.

kerr_ratefloat

The peak nonlinear wavenumber k0 n2 I of this configuration’s input, which no delay or plane exceeds, 1/m (peak_kerr_rate()); zero for a linear bridge. It scales the march’s photon-number allowance (photon_allowance()).

gridsolprop.grid.EnvelopeGrid

The temporal grid.

spacesolprop.grid.FreeGrid

The transverse grid, no collar.

mediumsolprop.spatial.SpatialMedium

The slab.

framesolprop.linear.Frame

The co-moving frame (pinned unless built with pin_frame=False).

responsestuple

The nonlinear responses (the Kerr response, or empty for a linear run).

absorbersolprop.boundaries.Absorber

The spectral absorber, as solprop’s power rate.

schedulesolprop.stepper.schedule.FixedSchedule

The replayed step schedule.

settingssolprop.driver.simulation.SimulationSettings

The settings the problem was translated with.

simulationsolprop.driver.simulation.Simulation

The translated simulation.

problemsolprop.translate.problem.PropagationProblem

The kernel problem the backend steps.

runnersolprop.driver.simulation.SimulationRunner

solprop’s runner: the one backend every delay point runs on (backend).

reducerReducer

The host reduction of saved planes (with reduction = "solprop" it only computes the time-window edge diagnostic, when that is asked for).

reduction{“host”, “solprop”}

Where planes are reduced (Reduction).

stats_specsolprop.stats.StatsSpec or None

The statistics solprop evaluates at every plane with reduction = "solprop"; None for the host reduction.

scaleStatisticsScale or None

The constants turning those statistics into this package’s units.

metadatamapping

/grid provenance keys describing this engine (see pnps.io_h5.scan_grid_metadata()).

identitystr

A digest of the configuration, which with a delay names an input in solprop’s record in place of a SHA-256 of its bytes.

exactExactWindows or None

With Config.exact_windows and the host reduction, the windows’ exact hard-disc masks, which replace the rendered windows’ spectra on the band; None otherwise (through solprop the exact discs are its apertures).

tablesOperatorTables or None

With Config.exact_windows and the host reduction, the configured operator, which carries the input to each plane for the subtraction; None otherwise.

setup: Setup#
zsave: Float[ndarray, 'n_z']#
h_target: float#
chi3: float#
kerr_rate: float#
grid: EnvelopeGrid#
space: FreeGrid#
medium: SpatialMedium#
frame: Frame#
responses: tuple[object, ...]#
absorber: Absorber#
schedule: FixedSchedule#
settings: SimulationSettings#
simulation: Simulation#
problem: PropagationProblem#
runner: SimulationRunner#
reducer: Reducer#
reduction: Literal['host', 'solprop']#
stats_spec: StatsSpec | None#
scale: StatisticsScale | None#
metadata: Mapping[str, object]#
identity: str#
exact: ExactWindows | None = None#
tables: OperatorTables | None = None#
property backend: Backend[source]#

Return the solprop backend holding the state, the runner’s.

Returns:
solprop.backends.protocol.Backend

The backend every delay point runs on.

visit(field0, visitor, *, tau=None, arms=None)[source]#

Propagate one input state and hand the field at every position to a callback.

The field is solprop’s own buffer, read-only and valid only while visitor runs, so one plane at a time is ever held: this is the streaming form of march(), for studies at the production shape.

Parameters:
field0numpy.ndarray

The input state (n, n, nt), complex128, C-contiguous, at z = 0.

visitorcallable

Called with the position in m and the field there, (n, n, nt), at every position of zsave, in order. Copy what must outlive the call.

taufloat or None, optional

The delay field0 was formed for, which names the input in solprop’s record instead of a digest of its bytes; None digests it.

armssequence of str or None, optional

The arms field0 was formed with (pnps.form_input.form_input()), when not all of them: they complete the input’s name, so that inputs of one delay with different arms are told apart in solprop’s record. Only used with tau.

Raises:
ConfigError

If field0 has the wrong shape, type or layout.

EngineError

If the bridge reduces with solprop’s statistics, whose planes carry no field.

march(field0, *, tau=None)[source]#

Propagate one input state and return a copy of the field at every position.

Every field is kept, so this is for tests and small grids: a run keeps only the reductions (observations()), and a study streams the planes (visit()).

Parameters:
field0numpy.ndarray

The input state (n, n, nt), complex128, C-contiguous, at z = 0.

taufloat or None, optional

The delay field0 was formed for, which names the input in solprop’s record instead of a digest of its bytes; None digests it.

Returns:
list of tuple of (float, numpy.ndarray)

The position in m and a copy of the field there, (n, n, nt).

Raises:
ConfigError

If field0 has the wrong shape, type or layout.

EngineError

If the bridge reduces with solprop’s statistics.

observations(field0, *, tau=None)[source]#

Propagate one input state and return the observables at every position.

With reduction = "host" each plane’s field, solprop’s own read-only observation, is reduced by reducer before the march goes on. With "solprop" no field leaves solprop (unless the time-window edge diagnostic, which solprop cannot form, is asked for): the observables are its statistics in this package’s units (pnps.statistics). The photon number sum eta |E|^2 / omega is checked at every plane: the envelope Kerr and Raman responses conserve it and every absorber removes it, so growth between two planes beyond the march’s allowance (photon_allowance()) stops the run. The energy is not checked: the Kerr response moves it physically, in proportion to the nonlinear phase.

Parameters:
field0numpy.ndarray

The input state (n, n, nt), complex128, C-contiguous, at z = 0. solprop lets it go once loaded, so a caller that passes it without keeping a reference (bridge.observations(form(...))) frees it before the first step.

taufloat or None, optional

The delay field0 was formed for, which names the input in solprop’s record instead of a SHA-256 of its bytes; None digests it.

Returns:
list of tuple of (float, Observation)

The position in m and the plane’s observables.

Raises:
ConfigError

If field0 has the wrong shape, type or layout.

EngineError

If the photon number grows between two planes by more than the march’s allowance.

photon_allowance(z_start, z_end)[source]#

Return how much the march may raise the photon number between two planes.

The relative growth of sum eta |E|^2 / omega that the fixed-step march and rounding can produce over the steps between two schedule edges; growth beyond it is a numerical instability (observations()).

Parameters:
z_start, z_endfloat

Two schedule edges, m, z_start < z_end (two save positions).

Returns:
float

The allowed relative growth, dimensionless, >= 0.

close()[source]#

Release the runner and its backend’s buffers. Idempotent.

pnps.bridge.Reduction#

Where a saved plane is reduced to the observables: "host" copies the field out of solprop and reduces it with Reducer; "solprop" keeps no field and reads solprop’s far-field statistics (pnps.statistics).

alias of Literal[‘host’, ‘solprop’]

pnps.bridge.ReductionChoice#

The reduction a configuration asks for: one of Reduction, or "auto", which takes "solprop" whenever solprop accepts the windows without a caveat (pnps.statistics.statistics_unavailable()) and "host" otherwise.

alias of Literal[‘auto’, ‘host’, ‘solprop’]

pnps.bridge.bridge_tables(bridge)[source]#

Build the operator from the solprop objects a bridge configured.

The configured operator: solprop’s material wavenumber squares, its frame subtraction, its permeability 1/(eps_0 c^2), the bridge’s chi3, the absorber’s spectral rate, the hard band limit and the evanescent clamp.

Parameters:
bridgeBridge

The bridge whose operator to tabulate.

Returns:
OperatorTables

The configured operator tables.

pnps.bridge.build_bridge(setup, zsave, h_target, *, backend='auto', node_budget=None, nonlinear=True, pin_frame=True, reduction=None)[source]#

Set a configuration up on solprop, once, for any number of delay points.

Parameters:
setupSetup

The configuration (pnps.setup.build_setup()).

zsavearray_like

Save positions in m, strictly increasing from >= 0. Include 0.0 to record the input. Every positive position is an edge of the schedule.

h_targetfloat

Largest step in m. Each interval between save positions is covered by the fewest equal steps not longer than this. Choose it with pnps.calibrate.

backendstr

Backend registry name in solprop: "auto" (which is "native"), "native" or "numpy_ref".

node_budgetint or None

Per-chunk memory budget of solprop in bytes; None takes setup.cfg.node_budget.

nonlinearbool

Include the Kerr response. False builds the linear problem, for the exact linear-parity validation.

pin_framebool

Pin solprop’s co-moving frame to this package’s beta1_ref omega + beta0_ref (the default, and what every run uses). False leaves solprop to derive the frame from the medium – a validation control only: for a linear run the observables must not depend on it.

reduction{“auto”, “host”, “solprop”} or None

Where planes are reduced (ReductionChoice); None takes setup.cfg.reduction. "solprop" needs windows solprop can express (pnps.statistics.statistics_refusal()); "auto" resolves to "solprop" when solprop accepts them without a warning and to "host" otherwise, and the bridge records the resolved choice.

Returns:
Bridge

Close it (or use it as a context manager) to release the backend.

Raises:
ConfigError

For invalid save positions, a non-positive step, an unknown reduction, or windows solprop cannot express with reduction="solprop".

GridRuleError

If solprop’s grids do not reproduce this package’s (check_grid_rule()).

pnps.bridge.check_grid_rule(setup, grid, space)[source]#

Refuse grids that no longer reproduce this package’s sampling.

Everything this package hands solprop – the formed input, the absorber, the collection tables – is laid out on pnps.grids.time_grid() and pnps.grids.space_grid(), so solprop’s grids must be the same grids. Phase 0 measured them equal (docs/dev/numerics.md); this checks it on every build.

Parameters:
setupSetup

The configuration.

gridsolprop.grid.EnvelopeGrid

The temporal grid solprop built.

spacesolprop.grid.FreeGrid

The transverse grid solprop built.

Raises:
GridRuleError

Naming the first divergence: the sample count, the band mask, the frequency axis (relative 1e-12) or the momentum axis (relative 1e-12).

pnps.bridge.peak_kerr_rate(setup)[source]#

Return the peak nonlinear wavenumber of a configuration’s input.

k0 n2 I_peak at the carrier, with I_peak = n0 eps_0 c |e_peak|^2 / 2 and e_peak the coherent sum of the arms’ on-axis field at the focal centre: the arms’ on-axis spectral amplitudes |A(omega)|, each read from the beamlet’s on-axis spectrum (Setup.beamlets.i_omega_beamlet_reimaged, n(omega) |A|^2 near the axis), summed over frequency and arm (the triangle inequality). A transform-limited input at zero delay attains it; any other delay or spectral phase stays below it, and lossless linear propagation keeps every |E(k, omega)|, so no plane exceeds it until self-focusing does. Reading the arms’ admittance n cos(theta) as n leaves it theta^2 / 2 low, 1e-4 for the PNPS holes. Its product with a length bounds that length’s peak nonlinear phase (the B-integral).

Parameters:
setupSetup

The configuration (pnps.setup.build_setup()).

Returns:
float

The rate, 1/m.