tolerancing.core#
Core Tolerancing Module
This module contains the core classes for the tolerancing module. The Tolerancing class is the main class for defining a tolerancing problem. It allows the user to add operands, perturbations, and compensators to an optical system.
Kramer Harrison, 2024
Classes
|
Evaluates a set of named operands against an Optic instance. |
|
A class representing a tolerancing problem. |
- class OperandEvaluator(operands: list[Operand])[source]#
Evaluates a set of named operands against an Optic instance.
- Parameters:
operands – List of Operand objects to evaluate.
- class Tolerancing(optic, method='generic', tol=1e-05)[source]#
A class representing a tolerancing problem. This class is the core of the tolerancing module. It allows the user to define a tolerancing problem by adding operands (metrics), perturbations, and compensators to an optical system.
- Parameters:
optic – The optic object to be toleranced.
method – The method to use for optimization. Defaults to ‘generic’.
tol – The tolerance for the compensator optimizer. Defaults to 1e-5.
- Variables:
optic – The optic object to be toleranced.
method – The method to use for optimization. Defaults to ‘generic’.
tol – The tolerance for the compensator optimizer. Defaults to 1e-5.
_optic_nominal – A deep copy of the optic object representing its nominal state.
operands – A list of operands in the tolerancing problem.
perturbations – A list of perturbations applied to the optic.
compensator – An optimizer for compensating the perturbations.
- Methods:
__init__ (self, optic) – Initializes a Tolerancing object with the given optic.
add_operand (self, operand_type, input_data={}) – Adds an operand to the tolerancing problem.
add_perturbation (self, variable_type, perturbation, **kwargs) – Adds a perturbation to the optic.
add_compensator (self, variable_type, **kwargs) – Adds a compensator variable to the optimizer.
apply_compensators (self) – Applies compensators to the optic.
evaluate (self) – Evaluates the operands in the tolerancing problem.
reset (self) – Resets the optic to its nominal state.
- add_compensator(variable_type: str, **kwargs)[source]#
Add a compensator variable to the optimizer.
- Parameters:
variable_type – The type of the variable to be used for compensation, such as “thickness”, etc. See the variable module for more information.
**kwargs – Additional keyword arguments for the variable.
- add_operand(operand_type: str, input_data: dict = None, target: float = None, weight: float = 1.0, min_val: float = None, max_val: float = None)[source]#
Add an operand to the tolerancing problem.
- Parameters:
operand_type (str) – The type of the operand.
target (float) – The target value of the operand (equality operand). If target and both bounds are omitted, the current operand value is captured as the target. When bounds are provided, target remains None so compensation uses the allowed range.
min_val (float) – The operand should stay above this value (inequality operand).
max_val (float) – The operand should stay below this value (inequality operand).
weight (float) – The weight of the operand.
input_data (dict) – Additional input data for the operand.
- add_perturbation(variable_type: str, sampler: BaseSampler, **kwargs)[source]#
Add a perturbation to the optic.
- Parameters:
variable_type – The type of the variable to be perturbed, such as “radius”, “thickness”, etc. See the variable module for more information.
sampler – The sampler object used to generate perturbation values.
**kwargs – Additional keyword arguments for the variable.