surfaces.surface_group

Surface Group

This module contains the SurfaceGroup class, which represents a group of surfaces in an optical system. The SurfaceGroup class provides methods for tracing rays through the surfaces, adding and removing surfaces, and converting the group to and from a dictionary for serialization.

Kramer Harrison, 2024

Classes

SurfaceGroup([surfaces])

Represents a group of surfaces in an optical system.

class SurfaceGroup(surfaces: list[Surface] | None = None)[source]

Represents a group of surfaces in an optical system.

surfaces

List of surfaces in the group.

Type:

list

_last_thickness

The thickness of the last surface added.

Type:

float

property L

x direction cosines on all surfaces

Type:

np.array

property M

y direction cosines on all surfaces

Type:

np.array

property N

z direction cosines on all surfaces

Type:

np.array

add(new_surface=None, surface_type: SurfaceType = 'standard', comment='', index=None, is_stop=False, material: str | BaseMaterial = 'air', **kwargs)[source]

Adds a new surface to the list of surfaces.

Parameters:
  • new_surface (Surface, optional) – The new surface to add. If not provided, a new surface will be created based on the other arguments.

  • surface_type (str, optional) – The type of surface to create.

  • comment (str, optional) – A comment for the surface. Defaults to ‘’.

  • index (int, optional) – The index at which to insert the new surface. If not provided, the surface will be appended to the end of the list.

  • is_stop (bool, optional) – Indicates if the surface is the aperture.

  • material (str, optional) – The material of the surface. Default is ‘air’.

  • **kwargs – Additional keyword arguments for surface-specific parameters such as radius, conic, dx, dy, rx, ry, rz, aperture, bsdf, x, y, z.

Raises:
  • ValueError – If a new surface is provided and no index is given.

  • IndexError – If the index is out of bounds for insertion, or negative.

clear()[source]

Clears the list of surfaces.

property conic

conic constant of all surfaces

Type:

be.array

flip(start_index: int = 0, end_index: int = 0)[source]

Flips a segment of the surfaces in the group.

The function will swap the materials on the Object and Image surface if both start_index and end_index are zero. Subgroups can be swapped by passing the index of the first surface and the index of the surface after the last surface of the group (standard Python slicing). Note that only “sensible” results are obtained when the material before and after the subgroup is the same (for example, air).

Parameters:
  • start_index (int, optional) – The starting index of the segment of surfaces to flip. Defaults to 0 (include object surface).

  • end_index (int, optional) – The ending index (exclusive for positive, inclusive for negative slice behavior) of the segment of surfaces to flip. Defaults to 0 (up to, and including, the image surface).

Raises:

RuntimeError – If either start_index or end_index is zero, but not both.

classmethod from_dict(data)[source]

Create a surface group from a dictionary.

Parameters:

data (dict) – The dictionary to create the surface group from.

Returns:

The surface group created from the dictionary.

Return type:

SurfaceGroup

get_thickness(surface_number)[source]

Calculate the thickness between two surfaces.

Parameters:

surface_number (int) – The index of the first surface.

Returns:

The thickness between the two surfaces.

Return type:

float

index(value)[source]

Return the first index of the specified surface.

property intensity

ray intensities on all surfaces

Type:

np.array

n(wavelength)[source]

Get the refractive indices of the surfaces.

Parameters:

wavelength (float or str, optional) – The wavelength for which to calculate the refractive indices.

Returns:

The refractive indices of the surfaces.

Return type:

numpy.ndarray

property num_surfaces

the number of surfaces

Type:

int

property opd

optical path difference recorded on all surfaces

Type:

np.array

property positions

z positions of surface vertices

Type:

np.array

property radii

radii of curvature of all surfaces

Type:

np.array

remove(index)[source]

Remove a surface from the list of surfaces.

Cannot remove the object surface (index 0). If relative coordinate positioning is active (use_absolute_cs=False), this may trigger an update of subsequent surface positions.

Parameters:

index (int) – The index of the surface to remove.

Raises:
  • ValueError – If attempting to remove the object surface (index 0).

  • IndexError – If the index is out of bounds for the current list of surfaces.

reset()[source]

Resets all the surfaces in the collection.

This method iterates over each surface in the collection and calls

its reset method.

set_fresnel_coatings()[source]

Set Fresnel coatings on all surfaces in the group.

property stop_index

the index of the aperture stop surface

Type:

int

property surfaces
to_dict()[source]

Convert the surface group to a dictionary.

Returns:

The surface group as a dictionary.

Return type:

dict

property total_track

the total track length of the system

Type:

float

trace(rays, skip=0)[source]

Trace the given rays through the surfaces.

Parameters:
  • rays (BaseRays) – List of rays to be traced.

  • skip (int, optional) – Number of surfaces to skip before tracing. Defaults to 0.

property u

paraxial ray angles on all surfaces

Type:

np.array

property uses_polarization

True if any surface uses polarization, False otherwise

Type:

bool

property x

x intersection points on all surfaces

Type:

np.array

property y

y intersection points on all surfaces

Type:

np.array

property z

z intersection points on all surfaces

Type:

np.array