-
-
Save polyfractal/3b3ce7fa5f98119237ecbad10fd3cb78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = ro.system_from_yaml(""" | |
object: | |
pupil: | |
radius: 50 | |
elements: | |
- {} | |
- {distance: 1, material: 1.5, roc: 600, radius: 50} | |
- {distance: 10, material: Air, roc: -600, radius: 50} | |
- {distance: 5, material: 1.7, roc: -300, radius: 50} | |
- {distance: 10, material: Air, roc: -300, radius: 50} | |
- {distance: 500} | |
""") | |
s.update() | |
# load up PMMA and PC materials to use | |
lib = ro.Library.one() | |
s[1].material = lib.get("material", "poly(methyl_methacrylate)|Sultanova", source="rii") | |
s[3].material = lib.get("material", "polycarbonate|Sultanova", source="rii") | |
s.object = InfiniteConjugate(angle=np.deg2rad(3.5/2), pupil={"radius": 50}) | |
s.fields = 0, .7, 1. | |
s.update() | |
s.paraxial.focal_length_solve(500) | |
s.paraxial.update() | |
s.paraxial.refocus() | |
variables = [] | |
variables.extend(PathVariable(s, (i, "curvature"), (-1/10, 1/10)) | |
for i in (1, 2, 3, 4)) | |
def get(s): | |
s.update() | |
s.paraxial.focal_length_solve(500) | |
s.paraxial.propagate(start=-2) | |
s.paraxial.refocus() | |
s.paraxial.propagate(start=-1) | |
s.paraxial.resize() | |
s.paraxial.aberrations() | |
operands = [ | |
FuncOp(s, get), | |
#FuncOp(s, lambda s: s[-1].offset[2:], min=60), | |
#FuncOp(s, lambda s: s.edge_thickness()[1:], min=2), | |
#FuncOp(s, lambda s: np.diff(s.track), min=2), | |
FuncOp(s, lambda s: s.paraxial.transverse3[:, 5:].sum(0)/.5, min=-1, max=1), | |
FuncOp(s, lambda s: s.paraxial.transverse3[:, 3:5].sum(0)/1, min=-1, max=1), | |
FuncOp(s, lambda s: s.paraxial.transverse3[:, :3].sum(0)/.03, min=-1, max=1), | |
#FuncOp(s, lambda s: s.paraxial.transverse3[:, (0, 1, 2, 5, 6)].sum(0), weight=1), | |
GeomOp(s, rays=16, weight=1), | |
#PolyOp(s, weight=1), | |
] | |
r = optimize(variables, operands, trace=True, tol=1e-4, options=dict( \ | |
maxiter=100, disp=True, eps=1e-5, iprint=2)) | |
r.accept() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment