thin_film.optimization.needle
Needle Synthesis for thin film stack design.
Iterative layer insertion algorithm based on: Tikhonravov & Trubetskov, “Development of the needle optimization technique and new features of OptiLayer design software”, SPIE Vol. 2253, 1994.
This module uses a numerical approach: trial needles are inserted at sampled positions and the full merit function is evaluated, rather than computing analytical variational derivatives.
Classes
|
Result of a single needle insertion. |
|
Needle synthesis algorithm for discovering optimal thin film stack configurations by iteratively inserting thin layers at optimal positions. |
|
Overall result of needle synthesis. |
- class NeedleResult(iteration: int, layer_index: int, position_fraction: float, material_name: str, thickness_nm: float, merit_before: float, merit_after: float, improvement: float)[source]
Result of a single needle insertion.
- improvement: float
- iteration: int
- layer_index: int
- material_name: str
- merit_after: float
- merit_before: float
- position_fraction: float
- thickness_nm: float
- class NeedleSynthesis(stack: ThinFilmStack, candidate_materials: list[BaseMaterial], needle_thickness_nm: float = 1.0, min_thickness_nm: float = 1.0, max_iterations: int = 50, target_merit: float | None = None, num_positions_per_layer: int = 10, optimizer_method: OptimizerMethod = 'L-BFGS-B', optimizer_max_iter: int = 200)[source]
Needle synthesis algorithm for discovering optimal thin film stack configurations by iteratively inserting thin layers at optimal positions.
- Parameters:
stack – Starting thin film stack design.
candidate_materials – Materials to try inserting as needles.
needle_thickness_nm – Trial needle thickness in nm used for position screening. Smaller values (0.5–2 nm) give a better finite-difference approximation of the variational gradient.
min_thickness_nm – Layers thinner than this are removed during cleanup.
max_iterations – Maximum number of needle insertion iterations.
target_merit – Stop early if merit falls below this value.
num_positions_per_layer – Number of internal sampling points per layer.
optimizer_method – Scipy method for thickness re-optimization.
optimizer_max_iter – Max iterations for thickness re-optimization.
- add_spectral_target(property: Literal['R', 'T', 'A'], wavelengths_nm: list[float], target_type: Literal['equal', 'below', 'over'], value: float, weight: float = 1.0, aoi_deg: float = 0.0, polarization: str = 'u', tolerance: float = 1e-06) NeedleSynthesis[source]
Add a spectral target over multiple wavelengths.
- Parameters:
property – Optical property (‘R’, ‘T’, or ‘A’).
wavelengths_nm – List of wavelengths in nanometers.
target_type – Type of target (‘equal’, ‘below’, ‘over’).
value – Target value (single scalar applied at all wavelengths).
weight – Weight for this target.
aoi_deg – Angle of incidence in degrees.
polarization – Polarization state (‘s’, ‘p’, ‘u’).
tolerance – Tolerance for ‘equal’ targets.
- Returns:
self for method chaining.
- add_target(property: Literal['R', 'T', 'A'], wavelength_nm: float | list[float], target_type: Literal['equal', 'below', 'over'], value: float | list[float], weight: float = 1.0, aoi_deg: float | list[float] = 0.0, polarization: str = 'u', tolerance: float = 1e-06) NeedleSynthesis[source]
Add an optimization target.
- Parameters:
property – Optical property to target (‘R’, ‘T’, or ‘A’).
wavelength_nm – Wavelength(s) in nanometers.
target_type – Type of target (‘equal’, ‘below’, ‘over’).
value – Target value(s).
weight – Weight for this target.
aoi_deg – Angle(s) of incidence in degrees.
polarization – Polarization state (‘s’, ‘p’, ‘u’).
tolerance – Tolerance for ‘equal’ targets.
- Returns:
self for method chaining.
- run(verbose: bool = False) NeedleSynthesisResult[source]
Execute the needle synthesis algorithm.
- Parameters:
verbose – If True, print progress information.
- Returns:
NeedleSynthesisResult with the optimized stack and history.
- class NeedleSynthesisResult(success: bool, num_iterations: int, num_layers_added: int, initial_merit: float, final_merit: float, history: list[NeedleResult], stack: ThinFilmStack)[source]
Overall result of needle synthesis.
- final_merit: float
- history: list[NeedleResult]
- initial_merit: float
- num_iterations: int
- num_layers_added: int
- stack: ThinFilmStack
- success: bool