mjhoptics / ray-optics

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

Possible issue #42

Closed dibyendumajumdar closed 2 years ago

dibyendumajumdar commented 3 years ago

Hi Mike,

An example that is giving me some errors:

https://github.com/mjhoptics/ray-optics-notebooks/pull/10

mjhoptics commented 3 years ago

Hi Dibyendu, I've found the source of the problem, although the downstream behavior could be made more robust as well. The main problem is that apply_paraxial_vignetting() didn't handle the wide angle field correctly. The vignetting factors for the field edge are outside of the range of reasonable values, and feeding them into an interpolation routine is a "garbage in, garbage out" situation. I have a revised version of apply_paraxial_vignetting() that at least generates values within expected ranges and the aberration plots work without problem (I think).

def apply_paraxial_vignetting(opt_model):
    fov = opt_model.optical_spec.field_of_view
    sm = opt_model.seq_model
    pm = opt_model.parax_model
    max_field, jth = fov.max_field()
    for j, fld in enumerate(fov.fields):
        rel_fov = math.sqrt(fld.x**2 + fld.y**2)/max_field
        min_vly = 1, None
        min_vuy = 1, None
        for i, ifc in enumerate(sm.ifcs[:-1]):
            if pm.ax[i][mc.ht] != 0:
                max_ap = ifc.surface_od()
                y = pm.ax[i][mc.ht]
                ybar = rel_fov * pm.pr[i][mc.ht]
                ratio = (max_ap - abs(ybar))/abs(y)
                if ratio > 0:
                    if ybar < 0:
                        if ratio < min_vly[0]:
                            min_vly = ratio, i
                    else:
                        if ratio < min_vuy[0]:
                            min_vuy = ratio, i

        if min_vly[1] is not None:
            fld.vly = 1 - min_vly[0]
        if min_vuy[1] is not None:
            fld.vuy = 1 - min_vuy[0]

I'm not sure how quickly I can get this into a release. I've been busy breaking things to make them better, and haven't got all of the pieces working just right yet.

dibyendumajumdar commented 3 years ago

Okay thank you - I will apply to my copy

dibyendumajumdar commented 3 years ago

I tried it. Although I don't get an error, it doesn't seem correct.

image

mjhoptics commented 3 years ago

The lower ray in the full field bundle looks correct; it is limited by the first surface. The upper ray is probably over-vignetted a little, it probably should be limited by the last lens surface. I've looked at intermediate fields and they look overvignetted by 2x, but I haven't found any issues yet.

It is possible that with a wide field lens like this that paraxial modeling of the extreme field isn't adequate for getting accurate vignetting values. Production programs use real rays to establish vignetting values accurately; vignetting only models vertical and horizontal clipping and so itself is a simplification to a full pupil map (sometimes called a cat's eye diagram or pupil footprint).

dibyendumajumdar commented 3 years ago

Yes I meant that the upper ray is over-vignetted.

I was worried if this also impacts other calculations or not - is it just the drawing that is impacted?

dibyendumajumdar commented 3 years ago

I checked this with latest - still over-vignetted.

mjhoptics commented 3 years ago

I have not worked on a real ray vignetting calculation yet and probably won't get to it before the IODC at the end of the month. Thank you for your patience. Mike

dibyendumajumdar commented 3 years ago

no rush - thanks!

mjhoptics commented 2 years ago

Fixed by commit https://github.com/mjhoptics/ray-optics/commit/10179b5168ef7fd96679796f79782327d1791566. Interestingly, the lens used requires overfilling the paraxial pupil to fill the real aperture stop. Updated the ray aberration plots to take this possibility into account.