Tolerancing - Sensitivity Study
[1]:
from optiland.samples.objectives import CookeTriplet
from optiland.tolerancing import RangeSampler, SensitivityAnalysis, Tolerancing
[2]:
optic = CookeTriplet()
optic.draw()
[2]:
(<Figure size 1000x400 with 1 Axes>, <Axes: xlabel='Z [mm]', ylabel='Y [mm]'>)
[3]:
tolerancing = Tolerancing(optic)
[4]:
# radius scan
sampler = RangeSampler(start=15, end=30, steps=128)
tolerancing.add_perturbation("radius", sampler, surface_number=1)
# tilt scan
sampler = RangeSampler(start=-0.05, end=0.05, steps=128) # radians
tolerancing.add_perturbation("tilt", sampler, surface_number=1, axis="x")
# thickness scan
sampler = RangeSampler(start=2, end=5, steps=128)
tolerancing.add_perturbation("thickness", sampler, surface_number=1)
Define operands:
[5]:
input_data = {"optic": optic}
tolerancing.add_operand("f2", input_data)
# surface_number=-1 means the last surface
input_data = {
"optic": optic,
"surface_number": -1,
"Hx": 0,
"Hy": 0.0,
"wavelength": 0.55,
"num_rays": 5,
}
tolerancing.add_operand("rms_spot_size", input_data, target=0)
input_data = {"optic": optic, "Hx": 0, "Hy": 1, "wavelength": 0.55, "num_rays": 5}
tolerancing.add_operand("OPD_difference", input_data)
[6]:
sensitivity_analysis = SensitivityAnalysis(tolerancing)
[7]:
sensitivity_analysis.run()
[8]:
sensitivity_analysis.view()
[8]:
(<Figure size 990x750 with 9 Axes>,
[<Axes: ylabel='0: f2'>,
<Axes: >,
<Axes: >,
<Axes: ylabel='1: rms spot size'>,
<Axes: >,
<Axes: >,
<Axes: xlabel='Radius of Curvature, Surface 1', ylabel='2: OPD difference'>,
<Axes: xlabel='Tilt X, Surface 1'>,
<Axes: xlabel='Thickness, Surface 1'>])
Get pandas dataframe:
[9]:
df = sensitivity_analysis.get_results()
[10]:
df.head()
[10]:
| perturbation_type | perturbation_value | 0: f2 | 1: rms spot size | 2: OPD difference | |
|---|---|---|---|---|---|
| 0 | Radius of Curvature, Surface 1 | 15.000000 | 33.469945 | 2.701670 | 10.590084 |
| 1 | Radius of Curvature, Surface 1 | 15.118110 | 33.743491 | 2.634001 | 10.438667 |
| 2 | Radius of Curvature, Surface 1 | 15.236220 | 34.017200 | 2.567470 | 10.281144 |
| 3 | Radius of Curvature, Surface 1 | 15.354331 | 34.291071 | 2.502048 | 10.118328 |
| 4 | Radius of Curvature, Surface 1 | 15.472441 | 34.565104 | 2.437704 | 9.950932 |