Open RadPlanets opened 4 months ago
I'm getting the same error message. It seems like the imaginary number caused the problem? I have the older version that does not get this error message, but I'm getting the error message "Opacity warning. The imaginary part of the refractive index is clamped to 35i for numerical stability." Any fix on this?
Hey, can you both try to run again with the develop branch checked out and see if it works? I think I worked on this bug a while ago but wasn't ready to merge this into main because of some other issue.
Hi, @Nerrror ,
I don't get the error AssertionError: It's not clear which beam is incoming vs outgoing. Weird index maybe?
in the develop branch, but I'm still getting the warnging "Opacity warning. The imaginary part of the refractive index is clamped to 35i for numerical stability.". Could you please evaluate the purpose of this warning?
The develop branch works for me as well. Thanks!
I get a similar warning (pasted below), but as I understand it, this does not affect the computations. Clamping the imaginary refractive index to a high value prevents divide by zero errors and other instabilities.
\\tmm_fast\vectorized_tmm_dispersive_multistack.py:153: UserWarning: Opacity warning. The imaginary part of the refractive index is clamped to 35i for numerical stability.
You might encounter problems with gradient computation...
warn('Opacity warning. The imaginary part of the refractive index is clamped to 35i for numerical stability.\n'+
\\tmm_fast\vectorized_incoherent_tmm.py:256: UserWarning: Casting complex values to real discards the imaginary part (Triggered internally at C:\cb\pytorch_1000000000000\work\aten\src\ATen\native\Copy.cpp:300.)
P_[..., 0, 0] = 1/P
Hi, @Nerrror , I don't get the error
AssertionError: It's not clear which beam is incoming vs outgoing. Weird index maybe?
in the develop branch, but I'm still getting the warnging "Opacity warning. The imaginary part of the refractive index is clamped to 35i for numerical stability.". Could you please evaluate the purpose of this warning?
@qizheng-1998 basically, exactly what @RadPlanets describes. The intensity in this layer becomes so low that it creates instabilities when you take this up to e to propagate the wave in the transfer matrix. Technically, what is clamped (ie. capped at the value of 35i) is the accrued phase k*T through an absorbing medium which is called delta in the code. We clamp delta because it's not a good idea to clamp the imaginary part of the material directly. What we want to avoid is to get numerically instable low intensity. You can achieve that by limiting the amount of power that is getting absorbed when a ray passes through the medium. This is achieved by clamping delta. However, this clampings effect on any results should be negligible and is just intendend to make you aware of this intervention
When running example_inc_tmm.py, I get an error
AssertionError: It's not clear which beam is incoming vs outgoing. Weird index maybe?
related to the forward angle check.The other example file (example_tmm) runs without any errors.
Full trace below: