Beam groups
For convenience, the BeamletOptics.AbstractBeamGroup offers a container-like interface for groups of Beams as commonly used in other software packages. The following concrete implementations are currently provided:
julia> BeamletOptics.list_subtypes(BeamletOptics.AbstractBeamGroup);
└── BeamletOptics.AbstractBeamGroup
├── AstigmaticBeamGroup{T, R} where {T<:Real, R<:BeamletOptics.AbstractRay{T}}
├── CollimatedSource{T, R} where {T<:Real, R<:BeamletOptics.AbstractRay{T}}
└── PointSource{T, R} where {T<:Real, R<:BeamletOptics.AbstractRay{T}}
At least 3 types have been found.Refer to the following sections for convenience constructors to generate the sources listed above.
Moving a beam group
Every beam group has a source position (center) and an orientation matrix, whose second column is the central source direction and whose first column is the sampling reference vector (basis). Both are updated when the group is moved. Refer to BeamletOptics.AbstractBeamGroup for the convention and to Moving sources for the kinematic API.
Collimated beam source
The collimated beam source is ideal to model light coming from a focal plane at infinity. This is useful for simulating plane wavefronts. You can define a collimated monochromatic Beam source as follows:
BeamletOptics.CollimatedSource Method
CollimatedSource(pos, dir, diameter, λ; num_rings, num_rays, basis)Spawns a bundle of collimated Beams at the specified position and direction. The source is modelled as a ring of concentric beam rings around the center beam. The amount of beam rings between the center ray and outer diameter can be specified via num_rings.
Info
Note that for correct sampling, the number of rays should be atleast 20x the number of rings.
Arguments
The following inputs and arguments can be used to configure the CollimatedSource:
Inputs
pos: center beam starting positiondir: center beam starting directiondiameter: outer beam bundle diameter in [m]λ = 1e-6: wavelength in [m], default val. is 1000 nm
Keyword Arguments
num_rings: number of concentric beam rings, default is 10num_rays: total number of rays in the source, default is 100x num_ringsbasis: Optional reference vector (e.g.[1,0,0]) to define the starting azimuthal angle for the beam rings.
Reproducible sampling
If no basis is passed, the orthogonal basis vectors spanning the pupil plane are derived from dir deterministically, so two sources sharing the same dir, diameter, num_rings and num_rays sample exactly the same ray positions. Pass a basis to rotate the azimuthal sampling of a source about its own axis, e.g. to interleave several otherwise identical sources.

Already existing beams, e.g. Beams of PolarizedRays as in the Vectorial focusing at high NA example, can be wrapped into a group with CollimatedSource(beams, diameter, pos, dir). PointSource(beams, NA, pos, dir) and AstigmaticBeamGroup(beams, pos, dir) work analogously; instead of dir, a full orientation matrix can be passed.
A special constructor called UniformDiscSource is available, which offers an equal-area sampling (Fibonacci pattern) and is thus favorable in situations where the weighting of the individual beams becomes important, e.g. for calculating a point spread function using the intensity function.
BeamletOptics.UniformDiscSource Function
UniformDiscSource(pos, dir, diameter, λ; num_rays=1_000, basis)Generates a ray fan with equal area per ray across a circular pupil using the deterministic sunflower (Fibonacci) pattern.
The radius of the k-th ray (k = 0 … N-1) is ρₖ = diameter/2 ⋅ √((k + ½)/N), its azimuth is k times the golden angle π(3 - √5).
Note
This is merely a CollimatedSource constructor which uses Fibonacci sampling instead of concentric rings. Unlike CollimatedSource, there is no dedicated center beam at pos, i.e. all rays are equally weighted samples of the pupil.
Arguments
The following inputs and arguments can be used to configure the underlying CollimatedSource:
Inputs
pos: center of the pupil disc, i.e. the source positiondir: starting direction of all beamsdiameter: outer beam bundle diameter in [m]λ = 1e-6: wavelength in [m]
Keyword Arguments
num_rays=1000: total number of rays in the sourcebasis: Optional reference vector (e.g.[1,0,0]) to define the starting azimuthal angle of the sunflower pattern.
Reproducible sampling
If no basis is passed, the orthogonal basis vectors spanning the pupil plane are derived from dir deterministically, so two sources sharing the same dir, diameter and num_rays sample exactly the same ray positions. Pass a basis to rotate the sunflower pattern about its own axis, e.g. to interleave several otherwise identical sources.

Point beam source
The PointSource type is used to model emission from a spatially localized source that radiates Beams in a range of directions. This is commonly used to simulate conical emission patterns, such as light emerging from a fiber tip or a light source for a lens objective with a known focal distance. You can specify the origin and a propagation direction, which are then used to construct the monochromatic PointSource.
BeamletOptics.PointSource Method
PointSource(pos, dir, θ, λ; num_rings, num_rays, basis)Spawns a point source of Beams at the specified position and direction. The point source is modelled as a collection of concentric beam fans centered around the center beam. The amount of beam rings between the center ray and half-spread-angle θ can be specified via num_rings.
Info
Note that for correct sampling, the number of rays should be atleast 20x the number of rings.
Arguments
The following inputs and arguments can be used to configure the PointSource:
Inputs
pos: center beam starting positiondir: center beam starting directionθ: half spread angle in rad, must be< πλ = 1e-6: wavelength in [m], default val. is 1000 nm
Keyword Arguments
num_rings: number of concentric beam rings, default is 10num_rays: total number of rays in the source, default is 100x num_ringsbasis: Optional reference vector (e.g.[1,0,0]) to define the starting azimuthal angle for the source rings.
Reproducible sampling
If no basis is passed, the orthogonal basis vectors are derived from dir deterministically, so two sources sharing the same dir, θ, num_rings and num_rays sample exactly the same ray directions. Pass a basis to rotate the azimuthal sampling of a source about its own axis, e.g. to interleave several otherwise identical sources.
Below you can find an exemplary illustration of a PointSource.

Analogous to UniformDiscSource, a special constructor called UniformPointSource is available, which samples the spherical cap around dir with an equal solid angle per ray (Fibonacci/sunflower pattern), rather than in concentric rings. It returns a plain PointSource and, unlike the ring-based constructor, has no dedicated center beam along dir.
BeamletOptics.UniformPointSource Function
UniformPointSource(pos, dir, θ, λ; num_rays=1_000, basis)Generates a cone of Beams emitted from pos with equal solid angle per ray across the spherical cap 0 ≤ ϑ ≤ θ around dir, using the deterministic sunflower (Fibonacci) pattern. The polar angle ϑₖ of the k-th ray (k = 0 … N-1) follows from cos ϑₖ = 1 - (k + ½)/N ⋅ (1 - cos θ), its azimuth is k times the golden angle π(3 - √5).
Note
This is merely a PointSource constructor which uses Fibonacci sampling instead of concentric rings. Unlike PointSource, there is no dedicated center beam along dir, i.e. all rays are equally weighted samples of the cap.
Arguments
The following inputs and arguments can be used to configure the underlying PointSource:
Inputs
pos: starting position of all beamsdir: central source direction, i.e. the cone axisθ: half spread angle in rad, must be< πλ = 1e-6: wavelength in [m], default val. is 1000 nm
Keyword Arguments
num_rays=1000: total number of rays in the source, must be≥ 1basis: Optional reference vector (e.g.[1,0,0]) to define the starting azimuthal angle of the sunflower pattern. Must not be zero or parallel todir.
Reproducible sampling
If no basis is passed, the orthogonal basis vectors are derived from dir deterministically, so two sources sharing the same dir, θ and num_rays sample exactly the same ray directions. Pass a basis to rotate the sunflower pattern about its own axis, e.g. to interleave several otherwise identical sources.
Astigmatic Beam Groups
For complex sources, the package provides the AstigmaticBeamGroup container. Several constructors are available for different scenarios:
GaussianBeamletDecomposition: Tiling a large Gaussian beam into many small stable beamlets.WavefrontBeamletDecomposition: Importing an arbitrary complex field (e.g. from a phase screen or camera data).CollimatedGaussianBeamletSource: A square grid of parallel beamlets (ideal for aperture diffraction).SphericalGaussianBeamletSource: A point-like source emitting a cone of beamlets (ideal for focused/divergent beams).EllipticalGaussianBeamletSource: A point-like source emitting an elliptical cone of beamlets (ideal for sources with different fast/slow axis divergence).