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), andsolprop.grid.FreeGridwith no room for a real-space collar reproduce this package’spnps.grids.time_grid()andpnps.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.Framepinned to this package’s co-moving framebeta1_ref omega + beta0_ref, the envelope Kerr response, and this package’s spectral absorber as ansolprop.boundaries.Absorberwith zero temporal rates;schedule – a
solprop.stepper.schedule.FixedScheduleof equal steps of at mosth_targetwith 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
Reducerthat 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
Where a saved plane is reduced to the observables: |
|
The reduction a configuration asks for: one of |
|
The tableau each stepper's replayed Runge-Kutta march uses, recorded in every file. |
|
How solprop's boundary monitor watches a run. |
|
Reference length of the spectral absorber, m: solprop caps a rate at |
Functions
|
Build the operator from the solprop objects a bridge configured. |
|
Set a configuration up on solprop, once, for any number of delay points. |
|
Refuse grids that no longer reproduce this package's sampling. |
|
Return the peak nonlinear wavenumber of a configuration's input. |
Classes
|
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 defaultgamma_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:
objectOne configuration set up on solprop, reusable across delay points.
Built by
build_bridge(). Holds solprop’s runner and its backend, whose buffers persist untilclose()(or the end of awithblock): 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 holds1 - f_Rof it and the Raman responsef_R.- kerr_ratefloat
The peak nonlinear wavenumber
k0 n2 Iof 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
/gridprovenance keys describing this engine (seepnps.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_windowsand 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_windowsand the host reduction, the configured operator, which carries the input to each plane for the subtraction; None otherwise.
- zsave: Float[ndarray, 'n_z']#
- grid: EnvelopeGrid#
- medium: SpatialMedium#
- schedule: FixedSchedule#
- settings: SimulationSettings#
- simulation: Simulation#
- problem: PropagationProblem#
- runner: SimulationRunner#
- scale: StatisticsScale | None#
- 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
visitorruns, so one plane at a time is ever held: this is the streaming form ofmarch(), 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 ofzsave, in order. Copy what must outlive the call.- taufloat or None, optional
The delay
field0was 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
field0was 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 withtau.
- Raises:
- ConfigError
If
field0has 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
field0was 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
field0has 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 byreducerbefore 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 numbersum eta |E|^2 / omegais 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
field0was 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
field0has 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 / omegathat 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.
- pnps.bridge.Reduction#
Where a saved plane is reduced to the observables:
"host"copies the field out of solprop and reduces it withReducer;"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 takessetup.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()andpnps.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_peakat the carrier, withI_peak = n0 eps_0 c |e_peak|^2 / 2ande_peakthe 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|^2near 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’ admittancen cos(theta)asnleaves ittheta^2 / 2low, 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.