thin_film.optimization.variable.layer_thickness#
Layer Thickness Variable Module
This module contains the LayerThicknessVariable class, which represents a variable for the thickness of a layer in a thin film stack. The class provides methods to get and update the layer thickness for optimization purposes.
Corentin Nannini, 2025
Classes
|
Represents a variable for a thin film layer thickness. |
- class LayerThicknessVariable(stack: ThinFilmStack, layer_index: int, apply_scaling=True, **kwargs)[source]#
Represents a variable for a thin film layer thickness.
This class inherits from VariableBehavior and provides specific functionality for optimizing the thickness of individual layers in a ThinFilmStack.
- Parameters:
stack (ThinFilmStack) – The thin film stack containing the layer.
layer_index (int) – The index of the layer in the stack (0-based).
apply_scaling (bool) – Whether to apply scaling for optimization. Defaults to True.
**kwargs – Additional keyword arguments passed to parent class.
- Variables:
stack (ThinFilmStack) – The thin film stack.
layer_index (int) – The index of the target layer.
- get_value() float[source]#
Returns the current thickness value of the layer in micrometers.
- Returns:
The current thickness value in μm.
- Return type:
- inverse_scale(scaled_value: float) float[source]#
Inverse scale the thickness value.
Converts from scaled representation back to micrometers.
- 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: float) float[source]#
Scale the thickness value for improved optimization performance.
Converts from micrometers to a scaled representation that’s better conditioned for numerical optimization.