optimization.variable.element#

Element Variable Module

This module contains variables that move a group of consecutive surfaces (an element, or a group of elements) as one rigid body: a decenter, a tilt about a pivot point, and a roll about the element axis. Surfaces after the element do not move.

The axes are those of the element: the local x, y and z axes of its first surface. For an element on the optical axis these are the global axes.

Kramer Harrison, 2026

Classes

ElementDecenterVariable(optic, first, last, axis)

Decenter of an element along its local axis ("x" or "y"), in lens units.

ElementRollVariable(optic, first, last[, ...])

Roll of an element about its local z axis through the pivot, in radians.

ElementTiltVariable(optic, first, last, axis)

Tilt of an element about its local axis ("x" or "y") through the pivot, in radians.

ElementVariableBehavior(optic, first, last)

Variable that moves a group of surfaces as one rigid body.

RigidElement(optic, first, last[, pivot])

A group of consecutive surfaces moved as one rigid body.

class ElementDecenterVariable(optic, first, last, axis, scaler=None, **kwargs)[source]#

Decenter of an element along its local axis (“x” or “y”), in lens units.

Parameters:
  • optic – The optic that holds the surfaces.

  • first – The first surface of the element.

  • last – The last surface of the element (inclusive).

  • axis – "x" or "y".

  • scaler – The scaler for the variable. Defaults to IdentityScaler().

  • **kwargs – Additional keyword arguments.

get_value()#

Return the current move of the element.

inverse_scale(scaled_value)#

Inverse scale the value of the variable.

Parameters:

scaled_value – The scaled value to inverse scale

kind: str = 'decenter'#
release_graph() → None#

Drop the autograd graph of the last step from the element.

scale(value)#

Scale the value of the variable for improved optimization performance.

Parameters:

value – The value to scale

update_value(new_value) → None#

Move the element to new_value.

Parameters:

new_value – The new decenter (lens units) or angle (radians).

class ElementRollVariable(optic: Optic, first: int, last: int, scaler: Scaler = None, pivot: str | float = 'center', **kwargs)[source]#

Roll of an element about its local z axis through the pivot, in radians.

Parameters:
  • optic – The optic that holds the surfaces.

  • first – The first surface of the element.

  • last – The last surface of the element (inclusive).

  • scaler – The scaler for the variable. Defaults to IdentityScaler().

  • pivot – The pivot point; see RigidElement. Defaults to "center".

  • **kwargs – Additional keyword arguments.

get_value()#

Return the current move of the element.

inverse_scale(scaled_value)#

Inverse scale the value of the variable.

Parameters:

scaled_value – The scaled value to inverse scale

kind: str = 'roll'#
release_graph() → None#

Drop the autograd graph of the last step from the element.

scale(value)#

Scale the value of the variable for improved optimization performance.

Parameters:

value – The value to scale

update_value(new_value) → None#

Move the element to new_value.

Parameters:

new_value – The new decenter (lens units) or angle (radians).

class ElementTiltVariable(optic, first, last, axis, scaler=None, **kwargs)[source]#

Tilt of an element about its local axis (“x” or “y”) through the pivot, in radians.

Parameters:
  • optic – The optic that holds the surfaces.

  • first – The first surface of the element.

  • last – The last surface of the element (inclusive).

  • axis – "x" or "y".

  • scaler – The scaler for the variable. Defaults to IdentityScaler().

  • pivot – The pivot point; see RigidElement. Defaults to "center".

  • **kwargs – Additional keyword arguments.

get_value()#

Return the current move of the element.

inverse_scale(scaled_value)#

Inverse scale the value of the variable.

Parameters:

scaled_value – The scaled value to inverse scale

kind: str = 'tilt'#
release_graph() → None#

Drop the autograd graph of the last step from the element.

scale(value)#

Scale the value of the variable for improved optimization performance.

Parameters:

value – The value to scale

update_value(new_value) → None#

Move the element to new_value.

Parameters:

new_value – The new decenter (lens units) or angle (radians).

class ElementVariableBehavior(optic: Optic, first: int, last: int, scaler: Scaler = None, pivot: str | float = 'center', **kwargs)[source]#

Variable that moves a group of surfaces as one rigid body.

The value is the move from the state the variable was created in: zero at first. Each update applies the change from the previous value to the current surface positions, so other variables that act on the same surfaces (a thickness, for example) keep their effect.

Parameters:
  • optic – The optic that holds the surfaces.

  • first – The first surface of the element.

  • last – The last surface of the element (inclusive).

  • scaler – The scaler for the variable. Defaults to IdentityScaler().

  • pivot – The pivot of tilts and rolls; see RigidElement.

  • **kwargs – Additional keyword arguments.

get_value()[source]#

Return the current move of the element.

inverse_scale(scaled_value)#

Inverse scale the value of the variable.

Parameters:

scaled_value – The scaled value to inverse scale

kind: str = ''#
release_graph() → None[source]#

Drop the autograd graph of the last step from the element.

scale(value)#

Scale the value of the variable for improved optimization performance.

Parameters:

value – The value to scale

update_value(new_value) → None[source]#

Move the element to new_value.

Parameters:

new_value – The new decenter (lens units) or angle (radians).

class RigidElement(optic: Optic, first: int, last: int, pivot: str | float = 'center')[source]#

A group of consecutive surfaces moved as one rigid body.

Parameters:
  • optic – The optic that holds the surfaces.

  • first – The first surface of the element.

  • last – The last surface of the element (inclusive).

  • pivot – The point that tilts and rolls are about: "center" (default, midway between the first and last vertex), "first" or "last" (that vertex), or a number: the distance from the first vertex along the element axis, in lens units.

Raises:

ValueError – If the surface range or the pivot is invalid, or if a surface is placed relative to another coordinate system.

axis(name: str) → Vector[source]#

Return the element’s local "x", "y" or "z" axis in global coordinates.

coordinate_systems() → list[source]#

Return the coordinate systems of the element’s surfaces.

decenter(axis: str, distance) → None[source]#

Move the element along its local axis (“x” or “y”).

Parameters:
  • axis – The element axis to move along.

  • distance – The distance, in lens units.

move(kind: str, axis: str, amount) → None[source]#

Apply a decenter (kind="decenter") or a rotation (kind="tilt" or "roll") of amount.

pivot_point() → Vector[source]#

Return the pivot point in global coordinates.

release_graph() → None[source]#

Drop the autograd graph held by the surface positions.

restore(state: list[tuple]) → None[source]#

Restore a state returned by state.

rotate(axis: str, angle) → None[source]#

Rotate the element about its local axis through the pivot.

Parameters:
  • axis – "x" or "y" for a tilt, "z" for a roll.

  • angle – The rotation angle, in radians.

state() → list[tuple][source]#

Return (x, y, z, rx, ry, rz) of every surface, to restore later.