solves
- class BaseSolve[source]
Applies a solve operation.
This method should be implemented by subclasses to define the specific behavior of the solve operation.
- Raises:
NotImplementedError – If the method is not implemented by the subclass.
- class ChiefRayAngleCurvatureSolve(optic, surface_idx: int, angle: float)[source]
Adjusts surface curvature to achieve a target chief ray exit angle.
- This solve uses the paraxial refraction equation:
n’u’ - nu = -y(n’ - n)c
- to solve for curvature c:
c = (nu - n’u’) / (y(n’ - n))
- surface_idx
The index of the surface.
- Type:
int
- angle
The target exit angle (u’) of the chief ray.
- Type:
float
- apply()[source]
Applies the chief ray angle solve.
Since changing the system affects the chief ray path (it must pass through the stop), this solve is iterative.
- classmethod from_dict(optic, data)
Creates a solve instance from a dictionary representation.
- ChiefRayAngleSolve
alias of
ChiefRayAngleCurvatureSolve
- ChiefRayHeightSolve
alias of
ChiefRayHeightThicknessSolve
- class ChiefRayHeightThicknessSolve(optic, surface_idx: int, height: float)[source]
Solves for a target chief ray height on a specific surface.
- apply()
Applies the thickness solve to the optic.
This method calculates the necessary shift in z-position for the target surface and all subsequent surfaces to achieve the desired ray height.
- classmethod from_dict(optic, data)
Creates a solve instance from a dictionary representation.
- to_dict()
Returns a dictionary representation of the solve.
- class CurvatureSolve(optic, surface_idx: int)[source]
Abstract base class for curvature solves.
This class provides the common structure for solves that aim to satisfy a condition by adjusting the curvature of a specific surface.
- surface_idx
The index of the surface where the curvature is to be controlled.
- Type:
int
- class MarginalRayAngleCurvatureSolve(optic, surface_idx: int, angle: float)[source]
Adjusts surface curvature to achieve a target marginal ray exit angle.
- This solve uses the paraxial refraction equation:
n’u’ - nu = -y(n’ - n)c
- to solve for curvature c:
c = (nu - n’u’) / (y(n’ - n))
- surface_idx
The index of the surface.
- Type:
int
- angle
The target exit angle (u’) of the marginal ray.
- Type:
float
- classmethod from_dict(optic, data)
Creates a solve instance from a dictionary representation.
- MarginalRayAngleSolve
alias of
MarginalRayAngleCurvatureSolve
- MarginalRayHeightSolve
alias of
MarginalRayHeightThicknessSolve
- class MarginalRayHeightThicknessSolve(optic, surface_idx: int, height: float)[source]
Solves for a target marginal ray height on a specific surface.
- apply()
Applies the thickness solve to the optic.
This method calculates the necessary shift in z-position for the target surface and all subsequent surfaces to achieve the desired ray height.
- classmethod from_dict(optic, data)
Creates a solve instance from a dictionary representation.
- to_dict()
Returns a dictionary representation of the solve.
- class QuickFocusSolve(optic, *args)[source]
Quick Focus :param optic: The optic object. :type optic: Optic
- Raises:
ValueError – If the optical system is not defined.
- apply()[source]
Applies the QuickFocusSolve to the optic.
This method calculates the optimal focus distance and sets the z-position of the last surface (image plane) accordingly.
- classmethod from_dict(optic, data)
Creates a solve from a dictionary representation.
- optimal_focus_distance(Hx=0, Hy=0, wavelength=0.55, num_rays=5, distribution='hexapolar')[source]
Compute the optimal location of the image plane where the RMS spot size is minimized. This is based on solving the quadratic equation that describes the RMS spot size as a function of the propagation distance.
- Parameters:
Hx (float) – The normalized x field.
Hy (float) – The normalized y field.
wavelength (float) – The wavelength of the light.
num_rays (int) – The number of rays to trace.
distribution (str) – The distribution of rays to trace.
- Returns:
- The optimal axial position (z-coordinate) of the image plane
that minimizes the RMS spot size.
- Return type:
float
- to_dict()
Returns a dictionary representation of the solve.
- Returns:
A dictionary representation of the solve.
- Return type:
dict
- RayHeightSolveBase
alias of
ThicknessSolve
- class SolveFactory[source]
Factory class for creating solves.
This factory uses a predefined map to find and instantiate the appropriate solve class based on the provided solve_type.
- static create_solve(optic, solve_type: str, surface_idx, *args, **kwargs)[source]
Creates a solve instance based on the given solve type.
- Parameters:
optic (Optic) – The optic object to which the solve will be applied.
solve_type (str) – The type of solve to create (e.g., ‘marginal_ray_height’, ‘quick_focus’, ‘chief_ray_height’).
surface_idx (int) – The index of the surface relevant to the solve. May not be used by all solve types (e.g., ‘quick_focus’).
*args – Variable length argument list. For height-based solves, the first argument (args[0]) is expected to be the height.
**kwargs – Arbitrary keyword arguments. (Currently unused in favor of positional arguments for height).
- Returns:
An instance of the solve class corresponding to the given solve type.
- Raises:
ValueError – If the solve type is invalid or if required arguments for a specific solve type are missing or invalid.
- class SolveManager(optic)[source]
Manages the application of solves to an optic.
- Parameters:
optic (Optic) – The optic object
- solves
A list of solve instances.
- Type:
list
- add(solve_type, surface_idx=None, *args, **kwargs)[source]
Adds a solve instance to the list of solves.
- Parameters:
solve_type (str) – The type of solve to create.
surface_idx (int) – The index of the surface.
*args – Variable length argument list.
**kwargs – Arbitrary keyword arguments.
- classmethod from_dict(optic, data)[source]
Creates a SolveManager from a dictionary representation.
- Parameters:
optic (Optic) – The optic object.
data (dict) – The dictionary representation of the solve manager.
- Returns:
The solve manager.
- Return type:
- class ThicknessSolve(optic, surface_idx: int, height: float)[source]
Abstract base class for thickness solves.
This class provides the common structure for solves that aim to achieve a specific ray height at a given surface by adjusting the z-position of that surface and subsequent surfaces.
- surface_idx
The index of the surface where the ray height is to be controlled.
- Type:
int
- height
The target height of the ray on the specified surface.
- Type:
float
- apply()[source]
Applies the thickness solve to the optic.
This method calculates the necessary shift in z-position for the target surface and all subsequent surfaces to achieve the desired ray height.