optimization.variable.material#

Material Variable Module

This module contains the MaterialVariable class, which represents a variable for the material at a specific surface such as a glass. The variable can be used in optimization problems to optimize the material at a specific surface.

Classes

MaterialVariable(optic, surface_number, ...)

Represents a variable for the material at a specific surface.

class MaterialVariable(optic, surface_number: int, glass_selection: list[str], scaler: Scaler = None, **kwargs)[source]#

Represents a variable for the material at a specific surface.

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

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

  • **kwargs – Additional keyword arguments.

get_value() → str[source]#

Returns the name of the material at the specified surface.

Returns:

The material name.

Return type:

str

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: str) → None[source]#

Updates the material at the specified surface.

Parameters:

new_value (float) – The new material name.