manoharan-lab / holopy

Hologram processing and light scattering in python
GNU General Public License v3.0
131 stars 50 forks source link

Complex refractive index for medium #383

Closed erikpoloni closed 3 years ago

erikpoloni commented 3 years ago

Hello, I'm a beginner and I'd like to calculate cross sections of air spheres embedded in carbon, my medium. I saw that medium_index can be complex, but every time I try it this error message shows up: "TypeError: Cannot handle complex arguments". However, I can define the sphere refractive index as complex without error messages, which is not really helpful in my case. Thank you!

barkls commented 3 years ago

Hi, thanks for the issue! Unfortunately HoloPy doesn't support a complex medium index. This would be tricky to handle for holograms because the intensity would depend on how far the light travels both inside and outside the medium. Where did you see that medium_index can be complex? If it's somewhere in our documentation, that's an error and should be corrected.

I understand you are trying to calculate scattering cross sections, which wouldn't pose as much of a problem as holograms. I think the underlying scattering theories used by HoloPy should be able to handle a complex medium index but I'm not 100% sure. @jeromefung would know better. If they can, you can probably write your own ScatteringTheory subclass to do get around the error - just make sure you fork from the develop and not master branch, since the ScatteringTheory class was recently refactored to facilitate just this type of modification (thanks @briandleahy!). It's hard to know exactly what changes you'd need to make without a full traceback of your error though.