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 onpd, seesample_points. The window is the business of the sampling: it may look at the hits ofpd, e.g. asRegularGriddoes, or take a fixed one, asRectilinearGriddoes. All readouts then work for the new sampling.
Concrete subtypes include:
RegularGrid—num_points×num_pointspoints in a window around the hitsRectilinearGrid— the gridxs × zsof one's own, with any spacing
BeamletOptics.sample_points Function
sample_points(pd::Detector, sampling::AbstractDetectorSampling) -> DetectorSamplesThe 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.
BeamletOptics.DetectorSamples Type
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. aPoint2). The readouts return their values in the shape ofpoints.weights: the detector area in [m²] each point stands for, in the shape ofpoints, as an array or a lazy broadcast (Broadcast.broadcasted), which is only evaluated byoptical_power. It isΣ wᵢ Iᵢwith the irradianceIᵢ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).
OpticsBase extension internals
The diagram shows how the constructors share one sampling of the hits and how the return path leaves the PlaneField again.