Skip to main content

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.

  • 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.

Metadata

Release files for pnps 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pnps 0.2.0
File Size Uploaded Provenance Actions
pnps-0.2.0.tar.gz 1.1 MB With provenance Details for pnps-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pnps 0.2.0
File Interpreter ABI Platform Actions
pnps-0.2.0-py3-none-any.whl Python 3 none any Details for pnps-0.2.0-py3-none-any.whl

Total release size: 1.3 MB

Release files / pnps-0.2.0.tar.gz

Download URL pnps-0.2.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
72345a9038b53ab6a1727ce715451572325ecfc71c9ca455615d855ed11c4eb9
BLAKE2b-256 checksum
How to use checksums
4b8e997761d1d6fc7a031d64db240d1c4295615e51b0540032752ecf27bf2bb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / pnps-0.2.0-py3-none-any.whl

Download URL pnps-0.2.0-py3-none-any.whl
Size 158.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3dff7289acecfcc612184a55f675854bbdc09930fdbf85384ceeff32df0b13b5
BLAKE2b-256 checksum
How to use checksums
402d2ba68e0a61a63a10bc413d198a1719f5f5b49f5a2c047e3f0cbbd01f8956
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for pnps 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pnps-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page