optimization.variable.index#

Refractive Index Variable Module

This module contains the IndexVariable class, which represents a variable for the index of refraction at a specific surface and wavelength. The variable can be used in optimization problems to optimize the index of refraction at a specific surface.

Kramer Harrison, 2024

Classes

IndexVariable(optic, surface_number, wavelength)

Represents a variable for the index of refraction at a specific surface and wavelength.

class IndexVariable(optic, surface_number, wavelength, scaler=None, **kwargs)[source]#

Represents a variable for the index of refraction at a specific surface and wavelength.

Parameters:
  • optic (Optic) – The optic object associated with the variable.

  • surface_number (int) – The surface number where the variable is applied.

  • wavelength (float) – The wavelength at which the index of refraction is calculated.

  • scaler (Scaler) – The scaler to use for the variable. Defaults to a linear scaler with offset=-1.5.

  • **kwargs – Additional keyword arguments.

Variables:
  • optic (Optic) – The optic object to which the surface belongs.

  • surface_number (int) – The number of the surface.

  • wavelength (float) – The wavelength at which the index of refraction is calculated.

Methods:
  • get_value() – Returns the value of the index of refraction at the specified surface and wavelength.

  • update_value (new_value) – Updates the value of the index of refraction at the specified surface.

D_LINE = 0.5875618#
get_value()[source]#

Returns the value of the index of refraction at the specified surface and wavelength.

Returns:

The value of the index of refraction.

Return type:

float

inverse_scale(scaled_value)#

Inverse scale the value of the variable.

Parameters:

scaled_value – The scaled value to inverse scale

release_graph()#

Drop the autograd graph that the last update left in the optic.

A Torch optimizer calls this for all variables before it writes the values of a new step (VariableManager.release_graphs). A variable that writes one entry of an array, which other variables can share (a coefficient array), must start each step from plain values. Otherwise the array still holds the graph of the last step: the next backward pass then runs into that freed graph and fails, or the graph grows with each step.

The default does nothing: a variable that replaces a whole attribute leaves no old graph behind.

scale(value)#

Scale the value of the variable for improved optimization performance.

Parameters:

value – The value to scale

update_value(new_value)[source]#

Updates the value of the index of refraction at the specified surface.

Parameters:

new_value (float) – The new value of the index of refraction.