Lens grating lens spectrometer #156
Replies: 3 comments 6 replies
-
Hi @chalongratken, Ray-optics follows the typical convention imaging optical software uses which is that light propagates in the negative Z direction after an odd number of reflections. In your model, you entered the doublet following the grating as if light was propagating in the +Z direction. If you look closely at the lens layout you can see the rays go through surface 6 to 8 "backwards", as seen in the image
You can fix this by scaling the relevant interfaces and gaps by -1. Since you entered the airspace thicknesses 5 and 8 as negative values, these don't need to be scaled.
I wrote a function that takes the surface range and does the scaling.
For this case, it would be invoked as: Hope this helps. Mike Hayford |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Thanks Michael! this is really wonderful. However, when I incorporated the code to visualize the spot diagram of the optical system, it gave me the following error: ValueError: zero-size array to reduction operation maximum which has no identity. My added code is: It seems that spot diagram fail to plot when using a grating. |
Beta Was this translation helpful? Give feedback.
-
Recently, I am trying to use the rayoptics to model a lens grating lens spectrometer which is basically consisted of a doublet collimator lens, a reflective grating, and a doublet focuser lenses. I followed the suggestion in #147 to create a ray trace with a collimator lens and a grating which is ok. However, when I tried to add the focuser lens after the grating, the rays seems to be discontinuous and they are diverged instead of focusing as seen in the attached image. Here is my code:
from rayoptics.environment import *
opm = OpticalModel()
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', 'epd'], value=25.4)
osp['fov'] = FieldSpec(osp, key=['object', 'height'], flds=[0.0], is_relative=False)
osp['wvls'] = WvlSpec([(400, 0.5), (600, 1.0), (800, 0.5)], ref_wl=1)
opm.radius_mode = True
sm.gaps[0].thi = 39
Add Collimator Lens
sm.add_surface([34.9, 9.0, 'N-BAF10','Schott'], aperture_type='circular', aperture_value=25.0)
sm.add_surface([-28.8, 3.5, 'N-SF6','Schott'])
sm.add_surface([-137.5, 0, 'air'])
sm.gaps[-1].thi = 70.0
Add grating
sm.add_surface([.0, -70., 'refl'])
grating_surface = sm.cur_surface
sm.ifcs[grating_surface].decenter = srf.DecenterData('bend', alpha=40)
grating600lp = DiffractionGrating('600L/mm grating', grating_lpmm=600, order=1)
sm.ifcs[grating_surface].phase_element = grating600lp
grating_tilt = 40
total_angle = 60
sm.cur_surface = grating_surface
sm.ifcs[sm.cur_surface].decenter = srf.DecenterData('dec and return', alpha=grating_tilt)
sm.gaps[sm.cur_surface].thi = .0
sm.add_surface([.0, -70.])
sm.ifcs[sm.cur_surface].interact_mode = 'dummy'
sm.ifcs[sm.cur_surface].decenter = srf.DecenterData('decenter', alpha=total_angle)
sm.gaps[-1].thi = -70
Add Focusor Lens
sm.set_stop()
sm.add_surface([34.9, 9.0, 'N-BAF10','Schott'], aperture_type='circular', aperture_value=25.0)
sm.add_surface([-28.8, 3.5, 'N-SF6','Schott'])
sm.add_surface([-137.5, 0, 'air'])
sm.gaps[-1].thi = -50
opm.update_model()
from rayoptics.elem.layout import RayFanBundle
def create_ray_fan_vs_wvl(fig, opt_model, num_rays=21):
ray_fan_bundles = []
system_length, start_offset = fig.sl_so
fov = opt_model['optical_spec']['fov']
fi = 0
fld = fov.fields[fi]
fld_label = fov.index_labels[fi]
wvls = opt_model['optical_spec']['wvls']
for wl, clr in zip(wvls.wavelengths, wvls.render_colors):
rayfan = RayFan(opt_model, f=fld, wl=wl, xyfan='y', num_rays=num_rays,
label=fld_label, color=clr)
rb = RayFanBundle(opt_model, rayfan, start_offset)
ray_fan_bundles.append(rb)
return ray_fan_bundles
entity_factory = create_ray_fan_vs_wvl, (opm,), {'num_rays': 3}
eflist = [entity_factory]
layout_plt3 = plt.figure(FigureClass=InteractiveLayout, opt_model=opm, do_draw_rays=False,
do_draw_beams=False, do_draw_edge_rays=False, entity_factory_list=eflist).plot()
I am still not very clear how to add the optical element after a grating after which the the system coordinate has rotated. Please help me on this issue. Thanks
Beta Was this translation helpful? Give feedback.
All reactions