mjhoptics / ray-optics

geometric ray tracing for optical systems
BSD 3-Clause "New" or "Revised" License
263 stars 54 forks source link

list SequentialModel with named glass #64

Closed asebian closed 2 years ago

asebian commented 2 years ago

Dear Mr. Hayford,

just minor issue.

>>> from rayoptics.environment import *
>>> opm = OpticalModel()
>>> sm  = opm['seq_model']
>>> opm.radius_mode = True
>>> sm.gaps[0].thi=1e10
>>> sm.add_surface([23.713, 4.831, 'N-LAK9', 'Schott'])
>>> sm.add_surface([7331.288, 5.86])
>>> sm.list_elements()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/rayoptics/seq/sequential.py", line 655, in list_elements
    if gp.medium.label.lower() != 'air':
AttributeError: 'SchottGlass' object has no attribute 'label'

create_surface_and_gap with string arguments returns an instance of Glass from opticalglass.glass otherwise an instance of Medium from rayoptics.seq.medium (which has a subtype Glass).

Cheers!

mjhoptics commented 2 years ago

Thank you for reporting these issues. Mike