surfaces.factories.surface_factory

Surface Factory

This module contains the SurfaceFactory class, which is used to create surface objects based on the given parameters. The SurfaceFactory class is used by the SurfaceGroup class to create surfaces for the optical system. The class abstracts the creation of surface objects and allows for easy configuration of the surface parameters.

Kramer Harrison, 2024

Classes

SurfaceFactory(surface_group)

A factory class for creating surface objects by delegating to sub-factories.

class SurfaceFactory(surface_group)[source]

A factory class for creating surface objects by delegating to sub-factories.

Parameters:

surface_group (SurfaceGroup) – The surface group to which the surfaces belong.

_surface_group

The surface group to which the surfaces belong.

Type:

SurfaceGroup

_coordinate_factory

Factory for coordinate systems.

Type:

CoordinateSystemFactory

_geometry_factory

Factory for surface geometries.

Type:

GeometryFactory

_material_factory

Factory for materials.

Type:

MaterialFactory

_coating_factory

Factory for coatings.

Type:

CoatingFactory

create_surface(surface_type: SurfaceType, comment: str, index: int | None, is_stop: bool, material: BaseMaterial | str, **kwargs: Unpack[SurfaceParameters])[source]

Creates a surface object based on the given parameters.

Parameters:
  • surface_type (str) – The type of surface to create.

  • comment (str) – A comment for the surface.

  • index (int) – The index of the surface.

  • is_stop (bool) – Indicates whether the surface is a stop surface.

  • material (str or tuple or BaseMaterial) – The material of the surface.

  • **kwargs – Additional keyword arguments for configuring the surface.

Returns:

The created surface object.

Return type:

Surface

Raises:

ValueError – If the index is greater than the number of surfaces.

classmethod register_surface_interaction(surface_type: str, interaction_type: str, *, overwrite: bool = False) None[source]

Register a mandatory interaction type for a given surface type.

When a surface of this type is created, the factory always uses the specified interaction_type regardless of any caller kwarg.

Parameters:
  • surface_type – The surface type string key (e.g. ‘paraxial’).

  • interaction_type – The interaction model string key to force.

  • overwrite – Allow replacing an existing mapping.

Raises:

ValueError – If surface_type already has a mapping and overwrite is False.