HelgeGehring / femwell

FEM mode solver for photonic waveguides
https://helgegehring.github.io/femwell/
GNU General Public License v3.0
104 stars 30 forks source link

Capillary waveguide help #116

Closed timothyara closed 6 months ago

timothyara commented 8 months ago

Hello, I'm new to femwell and I was wondering if there's a particular example that I could use to compute the supported modes in an air filled capillary waveguide with a fused silica cladding. The internal diameter of the capillary is 700 microns and outer diameter is 850 micron. I appreciate any help!

-Timothy

HelgeGehring commented 8 months ago

Hey Timothy,

it seems to me that you'd just need to adjust the geometry in https://helgegehring.github.io/femwell/photonics/examples/waveguide_modes.html you can define circles using

shapely.Point(0,0).buffer(1, resolution=6)

where you can adjust resultuion to have more/less points.

Would you have a paper we could reproduce in the docs?

timothyara commented 8 months ago

I'm sorry but I'm not sure I understand what you mean by 'paper'. Could you please clarify.

HelgeGehring commented 8 months ago

Some peer-reviewed publication in a journal which deals with a structure similar to the one you want to simulate.

timothyara commented 8 months ago

No, that's the issue. I can't find any scientific papers that use this precise fiber. I have included the data sheet for the glass tube. I am hoping that by modeling this in python I can learn the launch conditions of a He-Ne laser beam into the capillary in order to obtain a gaussian like mode.

1068150029.pdf

HelgeGehring commented 8 months ago

I didn't mean the exact fiber, but just a similar one as a starting point. https://doi.org/10.3390/s20041191 seems for example to be something similar like you're working on? Easiest is usually to start by reproducing something (even through it's a different geometry) and then adjust the numbers to your case.

I'd guess if you create three circles, the inner one, the outer one and an even larger one (to represent the air around the fiber) the geometry should be set up. You'll need to set the characteristic_lengthscale/resolutions larger for the meshing to not overshoot with elements (should be fine as the solution should vary quite slowly)

Maybe just start and if you run into problems you can post your code here? :)

timothyara commented 8 months ago

Thanks! I will work on it and let you know if I have questions.

timothyara commented 8 months ago

Here is a link to my code: https://github.com/timothyara/test_repo/blob/2c3fd3c20a49d231d4952b67a886c244abf3560b/Capillary_Fiber_calc.ipynb

I wasn't able to get the solution for the modes and I'm not sure why. When I ran compute_modes the computer was taking a really long and at some point I just interrupted the kernel. I made the buffer radius = 2 which represents the physical radius of the fiber of 350 microns. I then used this scaling and determined the wavelength to be .003617 for 633 nm. Not sure if this is the correct way of going about it so clarification on this would be nice. I appreciate your help.

simbilod commented 8 months ago

Hi @timothyara ,

I was able to get your geometry to work. I made a PR on your repo.

Couple things:

  1. You don't need to scale your dimensions and wavelength, you can use the numbers as they are and choose appropriate characteristic_lengths and resolutions
  2. I quickly found modes confined to the silica cladding with low resolution, meaning it works -- but to make sure the result is physical, you should increase the resolution until the result stabilizes. Higher resolution will mean longer computation times and memory errors if you go too high for your machine. ***
  3. (Bonus) For circular geometries, we can actually do slightly better than polygons by directly using GMSH disks

*** Note that here this might be tricky. Since your wavelength is so small and your guiding structure so large, there are a large number of modes with an effective index almost exactly equal to the cladding index. So we cannot just use the effective index as a measure of convergence, and the eigensolver may or may not reliably return the eigenvectors in the same order as we change the matrix (number of nodes in the geometry).

image

timothyara commented 8 months ago

Thank you @simbilod I ran the updated code after doing a 'pip install meshwell' to try to replicate your results but I'm getting thrown the following Type error in the Prism class:

File ~/opt/anaconda3/lib/python3.8/site-packages/meshwell/prism.py:24, in Prism() 22 model: Any 23 physical_name: Optional[str] = Field(None) ---> 24 mesh_order: float | None = None 25 mesh_bool: bool = Field(True) 26 buffered_polygons: List[Tuple[float, Polygon]] = []

TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

I didn't change anything with the code so I'm not sure why this is happening.

timothyara commented 7 months ago

Can anyone help me understand why I'm receiving the Type error in the Prism class. I'm just trying to produce the same results as @simbilod but this error is preventing me from doing so. Here is the link to the code in my repository that displays the error: https://github.com/timothyara/test_repo/blob/710035f82d68d62b73d59cf3af9361f47f11764a/Capillary_Fiber_calc_updated.ipynb

simbilod commented 7 months ago

what is your pydantic version? When you run pip show pydantic

simbilod commented 7 months ago

Ah nevermind this seems like it's a python version error. Can you use Python 3.10+?

https://github.com/tiangolo/typer/issues/371

timothyara commented 7 months ago

Thanks @simbilod. I got it to work after updating the interpreter in Jupyter notebooks to python 3.11.

simbilod commented 6 months ago

Great! Closing for now, feel free to reach out again if anything else comes up :)