This is wonderful simulation and it offers many possibilities. I tried to use it for a particular geometry and I think I have detected a small bug. Or it might be an opportunity for me to learn something new!
I am attaching an image of the setting I am using. This is the output of the lines generated:
The first bug seems to be related to the ray corresponding to j=5. Since this represents a beam going from n=1.5 to n=1, the refracted beam should be larger than what what is shown. The same problem happens to beam j=8 when it refracts into beam j=12. The problem does not happen for beam j=7!
The other item I don't understand is the fact that we have two beams reflected at x=4.221937396573228,y=-24.221937396573228 (j=7 and j=8)
Thanks for your help clarifying this and for all of your amazing work.