ricktu288 / ray-optics

A web app for creating and simulating 2D geometric optical scenes, with a gallery of (interactive) demos.
https://phydemo.app/ray-optics/
Apache License 2.0
1.23k stars 211 forks source link

Optical fiber with core and cladding refractive index #150

Closed josephernest closed 3 weeks ago

josephernest commented 1 month ago

Congratulations for this wonderful tool @ricktu288!

How can we simulate an optical fiber with:

Maybe you could add this new object in the common objects of the menus?

Goal:

Thanks a lot in advance!

ricktu288 commented 1 month ago

You can make a module with those parameters you mentioned (and submit it to the Other -> Import module list) See https://phydemo.app/ray-optics/modules/tutorial

josephernest commented 1 month ago

Hi @ricktu288! I have had a look at for example https://github.com/ricktu288/ray-optics/blob/master/modules/FresnelLens.json, but I currently can't see how I can model an optical fiber... How can I make the refractive index vary when we go out of the core to the cladding? Also, how to automatically add a "Blocker" on each parallel side of the fiber?

Thanks in advance if you can show me a starting point, and I'll modify it from there, and I'll make it publicly available when ready.

Thanks again @ricktu288!

ricktu288 commented 1 month ago

It depends on what the shape of the fiber you are making is. If it is linear, then maybe just one piece of rectangular glass for the core, two pieces of rectangular glass for the cladding on the two sides of the core, and two blockers for the two outer sides. So your module should possibly contain these 5 objects.

josephernest commented 1 month ago

Thank you @ricktu288. I would like the fiber to be a trapezoid polygon :

Is that possible with the setup you suggest?

Also when moving a point from the fiber polygon, I would like the cladding and blockers to follow the core, without having to move 5 objects manually each time I move the fiber core.

How would you do this?

Thanks again!

ricktu288 commented 1 month ago

So the first step is to determined what parameters (to be sliders and text boxes) and control points (draggable points) are.

And then write formulas of all the coordinates in terms of the parameters and control point coordinates. For each polygonal glass, we need the coordinates of each of its vertex. For each blocker, we need the coordinates of its endpoints. Note that ome of those coordinates may be the same (e.g. the core and cladding have common vertices.)

And then create a module to implements those coordinates. You may first create a model manually without using the modules, and then copy and paste the objs array to the module objs in the JSON editor, and then replace the numerical coordinates by the formulas.

josephernest commented 1 month ago

Thank you for your help. For now, I have simulated the fiber with 5 objects (1 core -> polygon glass, 2 cladding, 2 blockers), as I don't have enough experience to create a module.

If one day you have some time @ricktu288, I think it would be a great addition to have an optical fiber module, or an optical fiber example in the gallery https://phydemo.app/ray-optics/gallery/.

All the best!

ricktu288 commented 1 month ago

Maybe you can give me the non-module file and what parameters and draggable point you need.