Adding a surface to an existing model #141
Replies: 5 comments 3 replies
-
Hello @joelmartis, Investigate issue #141from rayoptics.environment import *
opm, info = open_model(Path().parent / "PAF2-A4A-Zemax/TTN136376.ZMX", info=True)
sm = opm['seq_model']
osp = opm['optical_spec']
pm = opm['parax_model']
em = opm['ele_model']
pt = opm['part_tree']
ar = opm['analysis_results']
osp['pupil'] = PupilSpec(osp, key=['object', 'pupil'], value=1)
osp['fov'] = FieldSpec(osp, key=['object', 'height'], value=0, flds=[0]) #point source
sm.gaps[0].thi=3
opm.flip() #flipping the lenses
opm.update_model()
layout_plt = plt.figure(FigureClass=InteractiveLayout, do_draw_rays=True, do_paraxial_layout=False, opt_model=opm).plot()
#so far so good! We need to know the insertion point in the sequence that add_surface will use. sm.cur_surface
sm.list_model()
Surface 5 is the image surface. We want to insert after, say, the dummy plane - surface 4. sm.set_cur_surface(4) While adding the surfaces, set circular clear apertures to match the Thorlabs OD sm.add_surface([0.064499, 1.6, 'N-BK7', 'Schott'])
sm.ifcs[sm.cur_surface].clear_apertures.append(srf.Circular(1))
sm.add_surface([0.0, 30.0])
sm.ifcs[sm.cur_surface].clear_apertures.append(srf.Circular(1))
sm.list_model()
opm.update_model(src_model=sm) As identified in several other issues, a defect in ray-optics fails to recognize that adding surfaces should add lens elements in the new layout. You have to force ray-optics to rebuild the list of elements it uses for rendering by calling the opm method rebuild_from_seq(). opm.rebuild_from_seq() layout_plt1 = plt.figure(FigureClass=InteractiveLayout, do_draw_rays=True, do_paraxial_layout=False, opt_model=opm).plot() create a cemented doublet by inserting a surface between 5 and 6Insertion using add_surface() inserts the new surface after the cur_surface. This is different from Python list insertion but follows the practice of most image forming software. sm.set_cur_surface(5)
sm.add_surface([-0.64499,0.9,'N-SF6', 'Schott'], sd=1)
opm.update_model()
opm.rebuild_from_seq()
layout_plt2 = plt.figure(FigureClass=InteractiveLayout, do_draw_rays=True, do_paraxial_layout=False, opt_model=opm).plot() sm.list_model()
Editing the sequential modelThe individual attributes of the The Sequential Model is organized around lists of interfaces and gaps. Interfaces are commonly implemented as Surfaces; Surfaces support profile definitions and interface with the ray trace. Gaps consist of a thickness (the separation between adjacent interfaces) and an optical material specification. sm.gaps[5].medium = create_glass('N-SK16', 'Schott')
sm.gaps[5].thi = 1.2
sm.ifcs[7].profile.cv = -.12
opm.update_model()
opm.rebuild_from_seq()
sm.list_model()
layout_plt3 = plt.figure(FigureClass=InteractiveLayout, do_draw_rays=True, do_paraxial_layout=False, opt_model=opm).plot() |
Beta Was this translation helpful? Give feedback.
-
Thank you Michael! This is very helpful! I had another, not related to this particular issue. Can I export a ray trace as a wavefront? I want to do some diffraction limited spot size simulations, and exporting the ray trace as a wavefront (i.e. angle v/s phase or something equivalent) would be very helpful. Joel |
Beta Was this translation helpful? Give feedback.
-
Thank you so much Michael!
This is very helpful
…-Joel
On Tue, Mar 12, 2024 at 9:21 AM Michael Hayford ***@***.***> wrote:
Hi Joel,
I have a couple of jupyter notebooks that demonstrate wavefront
calculations. They are in my notebook repo.
https://github.com/mjhoptics/ray-optics-notebooks/focus%20tilt%20notebook.ipynb
https://github.com/mjhoptics/ray-optics-notebooks/wavefront%20notebook.ipynb
Both of these notebooks setup interactive widgets to change defocus and
image position to demonstrate their effect on the wavefront.
Hope these help.
Mike
—
Reply to this email directly, view it on GitHub
<#141 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACPSR4DGGZJOX7EKJDTNZATYX4TRXAVCNFSM6AAAAABEOK5VM2VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DONRSGMYDE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
yeah it is |
Beta Was this translation helpful? Give feedback.
-
This was very helpful because the existing documentation does not describe how to modify models after they have been created. However, when I followed the example above, I found that the layout plot was not rendering correctly until I moved the |
Beta Was this translation helpful? Give feedback.
-
I am trying to combine a few optical lenses from Thorlabs, Edmunds etc. I don't see an easy way to simply combine the surfaces in two models (i.e. the thorlabs lens followed by the edmunds lens), so I loaded the first model and decided to manually add the surfaces from the other model. However this turns out to not work:
My code:
Output:
c t medium mode zdr sd
Obj: 0.000000 3.00000 air 1 0.0000
1: 0.127065 1.30000 N-LASF9 1 1.0000
2: 0.458716 1.11000 N-SK16 1 1.0000
Stop: -0.420168 5.00000 air 1 1.0000
4: -0.000000 2.80100 air 1 0.90000
Img: 0.000000 1.60000 N-BK7 1 0.32818
6: 0.064499 30.0000 air 1 1.0000
7: 0.000000 0.00000 1 1.0000
Your help in correcting this is much appreciated!
Also, once a surface has been added, is there a way to quickly edit it? Such as changing the curvature, thickness or material? And how about being able to add a surface between two existing surfaces?
Thanks,
Joel
Beta Was this translation helpful? Give feedback.
All reactions