Skip to content
LupoLabPublic

About

Forward model of PNPS pulse-measurement traces in bulk media

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

pnps

CI Documentation codecov Ruff basedpyright PyPI Python 3.14 Licence: GPL-3.0-or-later REUSE

Status: experimental. pnps is young (0.x). Its model and validation are described in the manual, but the interface may still change between minor releases; pin the version you use and read the changelog before upgrading.

Simulated FROG traces of a real instrument, from first principles.

pnps is a forward model of PNPS (parametrized nonlinear process spectrum) pulse measurements in bulk media: transient-grating (TG) and self-diffraction (SD) FROG. It takes the instrument as it is built:

  • a beam is cut into beamlets by the chromatic holes of a mask;
  • they cross in a thin fused-silica slab, carried through it by the full 3-D envelope propagation equation;
  • the four-wave-mixing signal emerges in its own corner of momentum space;
  • chromatic collection windows reduce it to the spectra a spectrometer records.

Phase matching, walk-off, geometric delay smearing and the vignetting of every aperture come out of the propagation; none is a correction added afterwards. The traces are ground truth for developing and testing pulse-retrieval algorithms.

A TG-FROG and an SD-FROG trace of a 3 fs pulse at 260 nm

A 3 fs pulse at 260 nm through 10 µm of fused silica, measured by the transient-grating boxcar and by self-diffraction, each through a 1 mm collection window. docs/scripts/readme_figure.py makes the figure.

import numpy as np
from pnps import Config, HE11Beam, WindowSpec, signal_centre
from pnps.scan import run_scan

x, y = signal_centre("tg", mask_diam=1e-3, mask_spacing=1e-3)
cfg = Config(
    lam0=260e-9,
    tau_fwhm=1e-15,
    energy=0.1e-6,
    thickness=40e-6,
    mask_diam=1e-3,
    mask_spacing=1e-3,
    beam=HE11Beam(a=125e-6, f_coll=5.0, f_foc=0.1),  # a hollow-capillary beam
    windows=(WindowSpec(holex=x, holey=y, holediam=1e-3, zmask=0.1),),
    lam_lims=(143e-9, 600e-9),
    trange=250e-15,
    r_max=366e-6,
    n_transverse=192,
)
taus = np.linspace(-20e-15, 20e-15, 41)
path = run_scan(
    cfg, taus, "example", zsave=np.array([0.0, 20e-6, 40e-6]), h_target=0.5e-6
)

What it does

  • The instrument: the folded-boxcar TG geometry or the two-beam SD geometry; hollow-capillary (HE11), Gaussian or uniform illumination; chromatic input holes and collection windows, rendered exactly or with smooth edges; synthetic pulses with chirp, or a measured or simulated field injected from a file.
  • The physics: the 3-D envelope unidirectional propagation equation in fused silica, with dispersion, diffraction, the Kerr effect and, optionally, the delayed Raman response, from the silica model of optmat.
  • Verified numerics: a fixed step certified by Richardson extrapolation on the measured trace, absorbers inside the exact linear operator rather than windows in the loop, and a validation ladder against an exact linear propagator and a semi-analytic first-Born signal.
  • Scale: propagation by solprop on CPUs and NVIDIA and AMD GPUs; sharded, resumable scans; run files and a pnps command for Slurm clusters; a memory budget before launch.
  • Output: HDF5 scan files in the layout the Croak retrieval package reads, with the input pulse and the vignetted beamlet as ground truth.

Installation

pip install pnps   # with solprop and its compiled backend, solprop-native

GPUs need solprop's native backend built from source; see the manual's installation page. To work on pnps itself, clone the repository and run uv sync (CONTRIBUTING.md).

Running on CPUs

Set the thread budget with SOLPROP_THREADS (or let the allocation set it), and leave OpenMP's thread binding unset: no OMP_PROC_BIND or OMP_PLACES in the environment or the job script. Under binding, starting solprop's native backend pins the process's main thread to one CPU, and a run then uses about one core of its allocation: five times slower per step at the production shape on 16 cores. pnps restores the thread's CPUs when it finds it pinned, and warns (ThreadBindingWarning). Confining a process to a set of cores, with Slurm, taskset or numactl, is fine. The manual's clusters page has the measurements and an example Slurm script.

Documentation

The manual is at pnps.readthedocs.io: the model, how to simulate a trace, input pulses, masks and windows, accuracy and validation, the engine, clusters, performance, and the API.

Related projects

  • solprop integrates the propagation.
  • optmat provides the fused-silica model.
  • Croak retrieves pulses from measured and simulated traces, and reads pnps's scan files.

About

pnps was written by John Travers and Christian Brahms to model the transient-grating and self-diffraction FROG instruments used to measure few-femtosecond deep-ultraviolet pulses. Like solprop, it is developed almost entirely by AI coding agents under the lead developer's direction, within a strict harness of derivations, reference comparisons, convergence checks and complete test coverage. The code is free software under the GNU General Public License, version 3 or (at your option) any later version, and the documentation is under CC BY 4.0. Contributions are welcome: see CONTRIBUTING.md. If you use pnps in published work, please cite it as described in CITATION.cff, with the version you used.

About

Forward model of PNPS pulse-measurement traces in bulk media

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages