optimization.variable.radius#

Radius of Curvature Variable Module

This module contains the RadiusVariable class, which represents a variable for the radius of a surface in an optic. The class inherits from the VariableBehavior class.

Kramer Harrison, 2024

Classes

RadiusVariable(optic, surface_number[, ...])

Represents a variable for the radius of a surface in an optic.

class RadiusVariable(optic, surface_number, axis=None, scaler=None, **kwargs)[source]#

Represents a variable for the radius of a surface in an optic.

Parameters:
  • optic (Optic) – The optic object that contains the surface.

  • surface_number (int) – The index of the surface in the optic.

  • axis (str, optional) – Radius axis for a toroidal surface. Must be "x" or "y" for toroidal geometry and omitted otherwise.

  • scaler (Scaler) – The scaler to use for the variable. Defaults to a linear scaler with factor=1/100 and offset=-1.0.

  • **kwargs – Additional keyword arguments.

Variables:
  • optic (Optic) – The optic object that contains the surface.

  • surface_number (int) – The index of the surface in the optic.

Methods:
  • get_value() – Returns the current value of the radius.

  • update_value (new_value) – Updates the value of the radius.

get_value()[source]#

Returns the current value of the radius.

Returns:

The current value of the radius.

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 radius.

Parameters:

new_value (float) – The new value of the radius.