lsurf.sources.DivergingBeam

class lsurf.sources.DivergingBeam(origin, mean_direction, divergence_angle, num_rays, wavelength, power=1.0)[source]

Beam with angular divergence.

Generates rays from a single point with directions distributed within a cone around the mean direction. Suitable for modeling fiber optic outputs, LEDs, and similar diverging sources.

Parameters:
  • origin (tuple of float) – Source position (x, y, z) in meters.

  • mean_direction (tuple of float) – Mean beam direction (dx, dy, dz), will be normalized.

  • divergence_angle (float) – Half-angle divergence in radians (cone half-angle). Must be in range (0, π/2).

  • num_rays (int) – Number of rays to generate.

  • wavelength (float or tuple of float) – Single wavelength (m) or (min, max) range.

  • power (float, optional) – Total source power in watts. Default is 1.0.

origin

Source position.

Type:

ndarray, shape (3,)

mean_direction

Normalized mean beam direction.

Type:

ndarray, shape (3,)

divergence_angle

Cone half-angle in radians.

Type:

float

Notes

The angular distribution is uniform within the cone. For Lambertian sources (cosine distribution), a different implementation would be needed.

Examples

>>> # Fiber output with 0.1 rad NA
>>> source = DivergingBeam(
...     origin=(0, 0, 0),
...     mean_direction=(0, 0, 1),
...     divergence_angle=0.1,
...     num_rays=5000,
...     wavelength=1550e-9,
...     power=1e-3
... )
>>> # LED with wide angle
>>> source = DivergingBeam(
...     origin=(0, 0.1, 0),
...     mean_direction=(0, 0, 1),
...     divergence_angle=np.radians(30),  # 30 degrees
...     num_rays=10000,
...     wavelength=(400e-9, 700e-9),
...     power=0.5
... )
__init__(origin, mean_direction, divergence_angle, num_rays, wavelength, power=1.0)[source]

Initialize diverging beam.

Parameters:
  • origin (tuple of float) – Source position (x, y, z) in meters.

  • mean_direction (tuple of float) – Mean beam direction, will be normalized.

  • divergence_angle (float) – Cone half-angle in radians.

  • num_rays (int) – Number of rays to generate.

  • wavelength (float or tuple of float) – Wavelength in meters or (min, max) range.

  • power (float, optional) – Total source power in watts. Default is 1.0.

Raises:

ValueError – If divergence_angle not in (0, π/2).

Methods

__init__(origin, mean_direction, ...[, power])

Initialize diverging beam.

generate()

Generate diverging beam.

__init__(origin, mean_direction, divergence_angle, num_rays, wavelength, power=1.0)[source]

Initialize diverging beam.

Parameters:
  • origin (tuple of float) – Source position (x, y, z) in meters.

  • mean_direction (tuple of float) – Mean beam direction, will be normalized.

  • divergence_angle (float) – Cone half-angle in radians.

  • num_rays (int) – Number of rays to generate.

  • wavelength (float or tuple of float) – Wavelength in meters or (min, max) range.

  • power (float, optional) – Total source power in watts. Default is 1.0.

Raises:

ValueError – If divergence_angle not in (0, π/2).

generate()[source]

Generate diverging beam.

Creates rays from the origin with directions uniformly distributed within a cone around the mean direction.

Returns:

Ray batch with diverging direction distribution.

Return type:

RayBatch

Notes

Uses spherical coordinates relative to the mean direction to generate uniformly distributed directions within the cone.

__repr__()[source]

Return string representation.