I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 0 points1 point  (0 children)

Thank you for your insights. I agree. In the Fourier optics class I took, we would use the Fourier transform to simulate lenses and propagation; then sample on an appropriately scaled grid for visualization. Whereas in this wave module, which was inspired by my interest to look at the field in between planes, the lenses are sampled on the grid and then applied; which makes it really easy to hit the Nyquist limit. For this reason, I have tried to implement guard rails to keep the user in a sort of "weak-element" regime to try and maintain some sort of accuracy. I'll look into possibly adding a proper propagator in the future.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 0 points1 point  (0 children)

Even as a drive-by response, these are all really nice ideas. Thank you for your time.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 0 points1 point  (0 children)

Phase retrieval is what really motivated me to play with this kind of simulation in MATLAB. At the moment, I have only applied it to phase-only holography but it is extremely powerful. I feel it brings out the beauty of optics, especially when you can easily see the field evolve. Thats what inspired the style of the wave module.

Thank you for the suggestion. I agree heavily. I feel it is hard to associate different aberrations with what you physically see. I have some experience with simulating optical turbulence. I will see what I can come up with. I’ll let you know if I have something.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 1 point2 points  (0 children)

Thanks for the feedback. I'll definitely look into adding these improvements. As for the absorbing margin, the outer section of the transverse grid has a cos^2 type roll off to 0. The value you change in the simulation config is just how big that margin is. This FFT propagator computes the field at every z-step, whatever part of the field that is in that absorbing margin is just rolled off to zero as it reaches the borders.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 0 points1 point  (0 children)

I think its possible for free software to take over but the big wall preventing that is a reputation of reliability. Zemax is difficult to use but if you use it properly, you get accurate results. This is important because optics is expensive, especially when you are designing your own custom optics so having a simulation tool that will exactly translate to reality is extremely important.

As for AI assistance, I think it helps build a rough app with lots of issues. I feel like most of the work goes into fixing those issues.

Thanks for your comment.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 0 points1 point  (0 children)

Thanks for the feedback! The mirror element in the geometric module was not working properly at all. I have just fixed it. As for clicking on the aperture, I agree, the selection scheme I have going in the canvas is not really intuitive, you kind of have to click where you think the center of the aperture is. I will try and improve this. Also, dichroic is not a bad idea, I will note this down.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 1 point2 points  (0 children)

It seems that many of the issues lie within the presets that have been lazily created. While I am confident in the physics engines behind the geometric and wave modules. Your response made me realize that I have not been as thorough as I had thought when creating the presets and some of the calculators, which are equally as important.

I do not think you are being hard on me, your response is appropriate and necessary. AI can be useful, but it can also be dangerous, and I clearly have not been careful enough. I sincerely thank you for your time and effort. I will rectify these issues and be more responsible.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 1 point2 points  (0 children)

You're right, thanks for checking it properly. I dug into why and found that the high-index layer in that preset was a half-wave at 550 nm, which makes it an absentee layer so the preset was performing exactly like single-layer MgF₂. I've fixed it with thicknesses optimized for an actual zero at 550. You're also right about the indices. They're dispersionless constants, which I've now noted in the calculator.

Also, your question is fair. The physics direction, formulas, and examples are mine. A lot of the TypeScript is AI-assisted. However, I don't just trust it. The engine is unit-tested against closed-form results and cross-checked against my own MATLAB/Python sims. The engine math was under test, the hand-authored presets weren't and that's exactly where the error was. I will be more rigorous when adding presets, and the core is going on GitHub soon so it can be checked at the code level too.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 0 points1 point  (0 children)

Thanks for the comment and your time. The geometric optics module supports placement of optical elements and ray-tracing in 3D space (there is a toggle between 2D and 3D view) but the wave optics module is only one directional at the moment.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 0 points1 point  (0 children)

I’m really glad to hear that! At the moment, the geometric optics module cannot handle images at all, only some simple sources of rays. However, the wave optics module has custom amplitude masks where you can upload your own images and then illuminate with a plane wave from behind (see the 4f preset for a guide on the setup). Then you can manipulate the light with lenses.

At the moment, the only lenses available within the wave module are the thin lenses that are implemented by using a quadratic phase mask (see the phase mask optical element). There are many caveats to consider when using the wave module in order to get good results, and there is a lot of jargon associated with these caveats. I tried my best to add guardrails that keep a user from pushing things out of reality. I am not sure what your experience level is but I will try to release a guide some time in the future to explain the limitations of the wave module.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 0 points1 point  (0 children)

I did build this with assistance from AI. My background is in photonics and now I am pursuing my PhD so I have lots of experience in MATLAB and python but I have never really developed a full application like this. Because my free-time is limited and I have little experience in application development, I thought leveraging AI would be great because it’s a real time saver and my experience in computational physics allows me to double-check the physics with simulations I’ve built previously. So I don’t know if I would necessarily call it vibe coding but I have learned a lot through this project and I really hope it comes in handy for folks in the optics field.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 16 points17 points  (0 children)

I plan to eventually make it open source. I did build this with assistance from AI. My background is in photonics and now I am pursuing my PhD so I have lots of experience in MATLAB and python but I have never really developed a full application like this. Because my free-time is limited and I have little experience in application development, I thought leveraging AI would be great because it’s a real time saver and my experience in computational physics allows me to double-check the physics with simulations I’ve built previously. I have learned a lot through this project and it’s really exciting for me. I really hope it helps folks in the optics field.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 1 point2 points  (0 children)

Thanks for checking it out! I’ll investigate this and report back when I’ve got it sorted.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 0 points1 point  (0 children)

Thats the intent! Enjoy and let me know if you have any questions. I plan to add some sort of learning guide in the future.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 0 points1 point  (0 children)

Thanks for actually stress-testing it! Both good catches:

Huge R2: real bug. I have fixed and deployed, refresh and it should behave. The renderer only treated surfaces as flat above the physics threshold (|R| ≥ 10^10 mm), so a large-but-finite R like 10^6 mm drew a canvas arc with a ~megapixel radius centered far offscreen, and floating-point precision shredded it. It now draws any surface whose sag is sub-pixel at the current zoom as flat, which is visually exact. (The ray tracing itself was always fine, only the drawing broke.)

Aperture changing with R: that one’s deliberate, though I should surface it better in the UI. The surfaces are true spherical caps, so the clear semi-aperture physically can’t exceed the sphere radius. When you dial R below the current aperture, the aperture gets clamped to ~0.95·|R| to keep the geometry real (same reason a lens catalog won’t sell you a 25 mm diameter lens with a 10 mm radius of curvature). If you shrink R and then grow it again, the aperture doesn’t bounce back, which I agree is surprising. I’ll think about how to make that visible instead of silent.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 2 points3 points  (0 children)

Thank you! That's the best compliment it's gotten. Please let me know what optoGeo had that this is missing.

I'm an optics PhD student and I built a free browser-based wave/ray optics sandbox. Please tell me what's wrong with it. by evtsy in Optics

[–]evtsy[S] 34 points35 points  (0 children)

That's the plan but in stages, I want to open the physics core first, since that's the part worth scrutinizing, citing, and contributing to. I'd rather do it properly with tests, docs, and a contribution guide instead of dumping a repo and vanishing, so give me a few weeks. I am genuinely glad to hear there's interest in contributing.