-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added surfaces not shown in plot #127
Comments
Hello @dominikonysz, The first is that add_surface inserts the surface after cur_surface. This is the convention, at least with CODE V. This is different than inserting an item into into a python list. So if you want to insert an element following lens 2, you would set_cur_surface to 4, the rear surface of lens 2. The workaround for the lens not drawing problem is to use a method in the opm, rebuild_from_seq(). This is my "force rebuild on the element model" hammer that rebuilds everything from the current sequential model.
Clearly, though, this is a bug and should be fixed. I haven't had a chance to test it on my dev version; if it works there, I'll report back. Let me know if you have any questions on this. Thanks for using ray-optics. |
Hey @mjhoptics, you're right about the modelling problem. That was a little oopsie in my example because I'm usually using a wrapper around the And I have tried out the Only thing I have noticed is that I need to call
I guess the cause is the same as for the other things so simply flipping the calls fixes that. Thank you for your help! |
Hello @dominikonysz, The first is that add_surface inserts the surface after cur_surface. This is the convention, at least with CODE V. This is different than inserting an item into into a python list. So if you want to insert an element following lens 2, you would set_cur_surface to 4, the rear surface of lens 2. The workaround for the lens not drawing problem is to use a method in the opm, rebuild_from_seq(). This is my "force rebuild on the element model" hammer that rebuilds everything from the current sequential model.
Clearly, though, this is a bug and should be fixed. I haven't had a chance to test it on my dev version; if it works there, I'll report back. Let me know if you have any questions on this. Thanks for using ray-optics. |
Hello @dominikonysz , |
Hey @mjhoptics, as far as I can tell your changes help with adding another lens into an "air gap" between two lenses. However, I'm still having a problem with introducing a new lens by splitting a lens in half and therefore first adding an air gap and then the first surface of the new lens. Here's another example to reproduce: from rayoptics.environment import *
from matplotlib import pyplot as plt
opm = OpticalModel()
sm = opm.seq_model
osp = opm.optical_spec
osp['pupil'] = PupilSpec(osp, key=['object', 'pupil'], value=12.5)
osp['wvls'] = WvlSpec([('F', 0.5), (587.5618, 1.0), ('C', 0.5)], ref_wl=1)
max_field = 20
FLD = [1e-10, 0.5 * max_field, 0.75 * max_field, max_field]
osp["fov"] = FieldSpec(osp, key=["object", "angle"], value=max(FLD), flds=FLD)
sm.gaps[0].thi=1e10
sm.add_surface([0, 10, 'N-BK7', 'Schott'])
sm.add_surface([0, 10])
sm.add_surface([0, 10, 'N-BK7', 'Schott'])
sm.set_stop()
sm.add_surface([0, 10])
sm.add_surface([0, 10, 'N-BK7', 'Schott'])
sm.add_surface([0, 10])
opm.update_model()
plt.figure(
100,
FigureClass=InteractiveLayout,
opt_model=opm,
is_dark=True,
).plot()
plt.show()
sm.set_cur_surface(3)
sm.gaps[3].thi = 5
sm.add_surface([0, 1, 'air'])
sm.add_surface([0, 5, 'N-BK7', 'Schott'])
opm.update_model()
plt.figure(
100,
FigureClass=InteractiveLayout,
opt_model=opm,
is_dark=True,
).plot()
plt.show() It's results in |
Hi @dominikonysz, |
Hey @mjhoptics, |
Hello Michael,
I'm currently having a problem with plotting an optical model after adding surfaces later on using
seq_model.add_surface(...)
. Here is an example using the Triplet example:So plotting the example optical model obviously works as expected:
but in the second plot the new lens (between the middle and last lens) is not shown although the rays are being traced correctly:
As far as I could see the new elements are not being added to the
part_tree
although the ids of the other elements are updated.I have also tried running
opm.update_model(build="rebuild")
but that didn't help unfortunately.Am I missing some step additional to the
opm.update_model()
or is there some other way to force the reload of thepart_tree
to correctly display the plot?The text was updated successfully, but these errors were encountered: