Skip to content

Detector internals ​

This page explains how the Detector described in the basics is implemented internally, and what a developer has to provide so that a new hit type or sampling works with the readouts. What a readout computes is defined in Reading out a detector and Field distributions.

Hit recording ​

The following diagram shows how a solve records one hit type per beam model in a Detector and what empties it again. A new BeamletOptics.AbstractDetector implements interact3d and empty!.

Readout pipeline ​

The following diagram shows how a readout turns a sampling into points and evaluates the stored hits there. A new sampling type implements sample_points; a new hit type implements electric_field(hit, p), direction(hit), refractive_index(hit) and an intensity method for a vector of its hits. Only the RegularGrid calls calc_local_lims, to find its window around the hits; a new hit type therefore implements it for a vector of its hits with a crop_factor and for crop_factor = nothing. A new hit type must also be added to the hits field of Detector.

BeamletOptics.AbstractDetectorSampling Type

Abstract supertype of the samplings of a Detector: a sampling decides where on the detector the readouts electric_field, intensity and optical_power are evaluated, in which window, and with which weights the power is integrated.

Implementation reqs.

Functions

  • sample_points(pd::Detector, sampling::S) -> DetectorSamples: the points, weights and coordinates of the sampling on pd, see sample_points. The window is the business of the sampling: it may look at the hits of pd, e.g. as RegularGrid does, or take a fixed one, as RectilinearGrid does. All readouts then work for the new sampling.

Concrete subtypes include:

  • RegularGrid — num_points×num_points points in a window around the hits

  • RectilinearGrid — the grid xs × zs of one's own, with any spacing

source
BeamletOptics.sample_points Function

The points at which the readouts of the Detector pd are evaluated for the sampling sampling, with their weights and the coordinates that the readouts return, see DetectorSamples. Every AbstractDetectorSampling implements a method; the fallback throws an error.

source
BeamletOptics.DetectorSamples Type
julia
DetectorSamples(coordinates, points, weights)

The points at which the readouts of a Detector are evaluated, as returned by sample_points:

  • points: an array of local detector coordinates (x, z) in [m], each a vector (e.g. a Point2). The readouts return their values in the shape of points.

  • weights: the detector area in [m²] each point stands for, in the shape of points, as an array or a lazy broadcast (Broadcast.broadcasted), which is only evaluated by optical_power. It is Σ wᵢ Iᵢ with the irradiance Iᵢ at the points, so the weights are the quadrature rule of the sampling.

  • coordinates: a tuple that the readouts return in front of the values, e.g. (xs, zs) for a grid.

The local coordinates (x, z) form a left-handed system with the detector normal, see electric_field(pd, sampling).

source

OpticsBase extension internals ​

The diagram shows how the constructors share one sampling of the hits and how the return path leaves the PlaneField again.